DaveSkender / Stock.Indicators

Stock Indicators for .NET is a C# NuGet package that transforms raw equity, commodity, forex, or cryptocurrency financial market price quotes into technical indicators and trading insights. You'll need this essential data in the investment tools that you're building for algorithmic trading, technical analysis, machine learning, or visual charting.
https://dotnet.StockIndicators.dev
Apache License 2.0
970 stars 246 forks source link

quote-stream auto-aggregator #1093

Open DaveSkender opened 1 year ago

DaveSkender commented 1 year ago

That overload would be a good prototype to add to EMA if you’re interested. Sounds like a useful thing to open up different feed choices. I think a simple pre-processor Add(quote, outBarSize) to aggregate before calling Add(quote) would do it, keep some separation of concerns. This might be similar to or combined with #670

This is likely an adaptation of the quotes.Aggregate() utility.

Originally posted by @DaveSkender in https://github.com/DaveSkender/Stock.Indicators/discussions/1069#discussioncomment-6422153 discussion with @mihakralj

DaveSkender commented 11 months ago

One thing I'm noticing with Alpaca API for BTC quotes for "minutely" data is that it will regularly skip minutes. I can imagine many scenarios for why this would happen, like having no actual trade volume. I think this aggregator might need to fill in the gaps by carrying over the prior price in some cases. This could get messy, because some markets don't operate 24/7 and have intentional gaps with no new prices.

# note the missing 02:58 minute price

Date                     Price      SMA(3)      EMA(5)  EMA(7,HL2)
----------------------------------------------------------------------
2023-11-09 02:53    $36,299.93
2023-11-09 02:54    $36,348.60
2023-11-09 02:55    $36,341.55    36,330.0
2023-11-09 02:56    $36,356.48    36,348.9
2023-11-09 02:57    $36,348.91    36,349.0    36,339.1
2023-11-09 02:59    $36,375.22    36,360.2    36,351.1
2023-11-09 03:00    $36,352.32    36,358.8    36,351.5    36,345.8
2023-11-09 03:01    $36,341.65    36,356.4    36,348.2    36,348.3

You can observe this yourself from our ObserveStream sample project.