dotnet add package OoplesFinance.StockIndicators --version 1.0.53
NuGet\Install-Package OoplesFinance.StockIndicators -Version 1.0.53
<PackageReference Include="OoplesFinance.StockIndicators" Version="1.0.53" />
paket add OoplesFinance.StockIndicators --version 1.0.53
#r "nuget: OoplesFinance.StockIndicators, 1.0.53"
// Install OoplesFinance.StockIndicators as a Cake Addin #addin nuget:?package=OoplesFinance.StockIndicators&version=1.0.53 // Install OoplesFinance.StockIndicators as a Cake Tool #tool nuget:?package=OoplesFinance.StockIndicators&version=1.0.53
.Net Stock Indicator Library
This is a stock indicator library that is completely open source (Apache 2.0 license) and very easy to use. Current version contains 763 stock indicators and I will add more as I get requests for them!
How to use this library
Here is an example to show how easy it is to create indicators using other indicators
var stockData = new StockData(openPrices, highPrices, lowPrices, closePrices, volumes); var results = stockData.CalculateRelativeStrengthIndex().CalculateMovingAverageConvergenceDivergence();
Here is a simple example calculating default bollinger bands to get you started using the Alpaca C# Api
using Alpaca.Markets; using OoplesFinance.StockIndicators.Models; using static OoplesFinance.StockIndicators.Calculations; const string paperApiKey = "REPLACEME"; const string paperApiSecret = "REPLACEME"; const string symbol = "AAPL"; var startDate = new DateTime(2021, 01, 01); var endDate = new DateTime(2021, 12, 31); 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 results = stockData.CalculateBollingerBands(); var upperBandList = results.OutputValues["UpperBand"]; var middleBandList = results.OutputValues["MiddleBand"]; var lowerBandList = results.OutputValues["LowerBand"];
Here is a more advanced example showing how to calculate bollinger bands with full customization and using a custom input of high rather than the default close
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), InputName.High); var results = stockData.CalculateBollingerBands(MovingAvgType.EhlersMesaAdaptiveMovingAverage, 15, 2.5m); var upperBandList = results.OutputValues["UpperBand"]; var middleBandList = results.OutputValues["MiddleBand"]; var lowerBandList = results.OutputValues["LowerBand"];
It is extremely important to remember that if you use the same data source to calculate different indicators without using the chaining method then you need to clear the data in between each call. We have a great example for this below:
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), InputName.High); var sma = stockData.CalculateSimpleMovingAverage(14); // if you don't perform this clear method in between then your ema result will be calculated using the sma results stockData.Clear(); var ema = stockData.CalculateExponentialMovingAverage(14);
For more detailed Alpaca examples then check out my more advanced Alpaca example code
Support This Project
Support or Contact
Email me at email@example.com for any help or support or to let me know of ways to further improve this library.
|Product||Versions Compatible and additional computed target framework versions.|
|.NET||net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed.|
|.NET Core||netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible.|
|.NET Standard||netstandard2.0 is compatible. netstandard2.1 is compatible.|
|.NET Framework||net461 is compatible. net462 is compatible. net463 was computed. net47 is compatible. net471 is compatible. net472 is compatible. net48 is compatible. net481 was computed.|
|MonoAndroid||monoandroid was computed.|
|MonoMac||monomac was computed.|
|MonoTouch||monotouch was computed.|
|Tizen||tizen40 was computed. tizen60 was computed.|
|Xamarin.iOS||xamarinios was computed.|
|Xamarin.Mac||xamarinmac was computed.|
|Xamarin.TVOS||xamarintvos was computed.|
|Xamarin.WatchOS||xamarinwatchos was computed.|
This package is not used by any NuGet packages.
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on OoplesFinance.StockIndicators:
C# SDK for Alpaca Trade API https://docs.alpaca.markets/
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.