Skip to content

Commit

Permalink
Ehlers (#15)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ooples authored Feb 19, 2022
1 parent f1a7dc9 commit c952e19
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions Interfaces/IStockData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public interface IStockData
List<decimal> LowPrices { get; }
List<decimal> ClosePrices { get; }
List<decimal> Volumes { get; }
List<DateTime> Dates { get; }
List<decimal> CustomValuesList { get; }
Dictionary<string, List<decimal>> OutputValues { get; }
List<Signal> SignalsList { get; }
Expand Down
4 changes: 3 additions & 1 deletion Models/StockData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ public class StockData : IStockData
public List<decimal> LowPrices { get; set; }
public List<decimal> ClosePrices { get; set; }
public List<decimal> Volumes { get; set; }
public List<DateTime> Dates { get; set; }
public List<decimal> CustomValuesList { get; set; }
public Dictionary<string, List<decimal>> OutputValues { get; set; }
public List<Signal> SignalsList { get; set; }
public int Count { get; set; }

public StockData(IEnumerable<decimal> openPrices, IEnumerable<decimal> highPrices, IEnumerable<decimal> lowPrices, IEnumerable<decimal> closePrices,
IEnumerable<decimal> volumes)
IEnumerable<decimal> volumes, IEnumerable<DateTime> dates)
{
OpenPrices = new List<decimal>(openPrices);
HighPrices = new List<decimal>(highPrices);
LowPrices = new List<decimal>(lowPrices);
ClosePrices = new List<decimal>(closePrices);
Volumes = new List<decimal>(volumes);
Dates = new List<DateTime>(dates);
InputValues = new List<decimal>(closePrices);
CustomValuesList = new List<decimal>();
OutputValues = new Dictionary<string, List<decimal>>();
Expand Down
4 changes: 2 additions & 2 deletions OoplesFinance.StockIndicators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<NeutralLanguage>en-US</NeutralLanguage>
<Description>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. </Description>
<Version>1.0.34</Version>
<Description>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. </Description>
<Version>1.0.35</Version>
<Authors>ooples</Authors>
<Company>Ooples Finance</Company>
<RepositoryUrl>https://github.com/ooples/OoplesFinance.StockIndicators</RepositoryUrl>
Expand Down
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c952e19

Please sign in to comment.