From c952e19dcb61d148f6ecbd699123bbd56e79c197 Mon Sep 17 00:00:00 2001 From: cheatcountry Date: Sat, 19 Feb 2022 15:58:53 -0500 Subject: [PATCH] Ehlers (#15) * Added 38 new indicators Possible fix for issue #4 * Added 50 new indicators * Added 22 new indicators * Fixed build errors * Added 31 new indicators * Added 30 new indicators * Added 18 new indicators * Added 25 new indicators Added optional lengths to moving avg calculation for moving averages that need multiple lengths * Submitted again after initial failed * Added 25 new indicators * Added 13 new indicators * Added Dates to StockData interface and class Fixed up example code --- Interfaces/IStockData.cs | 1 + Models/StockData.cs | 4 +++- OoplesFinance.StockIndicators.csproj | 4 ++-- README.md | 19 +++++++++---------- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Interfaces/IStockData.cs b/Interfaces/IStockData.cs index 3b4464a..5204de9 100644 --- a/Interfaces/IStockData.cs +++ b/Interfaces/IStockData.cs @@ -10,6 +10,7 @@ public interface IStockData List LowPrices { get; } List ClosePrices { get; } List Volumes { get; } + List Dates { get; } List CustomValuesList { get; } Dictionary> OutputValues { get; } List SignalsList { get; } diff --git a/Models/StockData.cs b/Models/StockData.cs index 780fb77..ac64052 100644 --- a/Models/StockData.cs +++ b/Models/StockData.cs @@ -13,19 +13,21 @@ public class StockData : IStockData public List LowPrices { get; set; } public List ClosePrices { get; set; } public List Volumes { get; set; } + public List Dates { get; set; } public List CustomValuesList { get; set; } public Dictionary> OutputValues { get; set; } public List SignalsList { get; set; } public int Count { get; set; } public StockData(IEnumerable openPrices, IEnumerable highPrices, IEnumerable lowPrices, IEnumerable closePrices, - IEnumerable volumes) + IEnumerable volumes, IEnumerable dates) { OpenPrices = new List(openPrices); HighPrices = new List(highPrices); LowPrices = new List(lowPrices); ClosePrices = new List(closePrices); Volumes = new List(volumes); + Dates = new List(dates); InputValues = new List(closePrices); CustomValuesList = new List(); OutputValues = new Dictionary>(); diff --git a/OoplesFinance.StockIndicators.csproj b/OoplesFinance.StockIndicators.csproj index 46a8dd1..d33ee9b 100644 --- a/OoplesFinance.StockIndicators.csproj +++ b/OoplesFinance.StockIndicators.csproj @@ -7,8 +7,8 @@ enable True en-US - Largest C# library of stock indicators and easiest to use with abilities such as making an indicator out of any other indicator or using any moving average with any indicator. - 1.0.34 + Largest C# stock indicator library with over 750 to choose from and easiest to use with abilities such as making an indicator out of any other indicator or using any moving average with any indicator. + 1.0.35 ooples Ooples Finance https://github.com/ooples/OoplesFinance.StockIndicators diff --git a/README.md b/README.md index f4e995c..0fda163 100644 --- a/README.md +++ b/README.md @@ -21,19 +21,18 @@ using static OoplesFinance.StockIndicators.Calculations; const string paperApiKey = "REPLACEME"; const string paperApiSecret = "REPLACEME"; const string symbol = "AAPL"; -var secretKey = new SecretKey(paperApiKey, paperApiSecret); -var alpacaDataClient = Environments.Paper.GetAlpacaDataClient(secretKey); -var bars = (await alpacaDataClient.GetHistoricalBarsAsync(new HistoricalBarsRequest(symbol, new DateTime(2021, 1, 1), - new DateTime(2021, 12, 15), BarTimeFrame.Day)).ConfigureAwait(false)).Items.SelectMany(x => x.Value); +var startDate = new DateTime(2021, 01, 01); +var endDate = new DateTime(2021, 12, 31); -var closePrices = bars.Select(x => x.Close); -var openPrices = bars.Select(x => x.Open); -var highPrices = bars.Select(x => x.High); -var lowPrices = bars.Select(x => x.Low); -var volumes = bars.Select(x => x.Volume); +var client = Environments.Paper.GetAlpacaDataClient(new SecretKey(paperApiKey, paperApiSecret)); +var bars = (await client.ListHistoricalBarsAsync(new HistoricalBarsRequest(symbol, startDate, endDate, BarTimeFrame.Day)).ConfigureAwait(false)).Items; +var stockData = new StockData(bars.Select(x => x.Open), bars.Select(x => x.High), bars.Select(x => x.Low), bars.Select(x => x.Close), bars.Select(x => x.Volume), bars.Select(x => x.TimeUtc)); -var stockData = new StockData(openPrices, highPrices, lowPrices, closePrices, volumes); var results = stockData.CalculateBollingerBands(); +var upperBandList = results.OutputValues["UpperBand"]; +var middleBandList = results.OutputValues["MiddleBand"]; +var lowerBandList = results.OutputValues["LowerBand"]; + ``` ### Support This Project