Stock.Indicators icon indicating copy to clipboard operation
Stock.Indicators copied to clipboard

"Rolling" quote history resize

Open StevenFischerWI opened this issue 4 years ago • 3 comments

Hi, and thanks so much for your project.

I'm exploring the idea of "rolling" hourly candle periods that can be checked more frequently than waiting for the hourly candle to close. For example, a period from 1:23PM to 2:22PM could be a complete hourly candle, along with each hour preceding it (12:23PM to 1:22PM, 11:23-12:22PM, etc.). I'd aggregate quotes every minute as new data arrives.

Would it be possible to extend the quotes.Aggregate helper method to define a starting time that is not an even hour? Perhaps it could take the number of minutes offset from the start of the hour.

Thanks again

-Steven

StevenFischerWI avatar Dec 21 '21 04:12 StevenFischerWI

It currently aggregates to the base unit, so it’d have to be a different calculation entirely, but perhaps with a different parameter on the same interface. It would repaint, for sure. Interested in giving it a try with a contribution?

DaveSkender avatar Dec 21 '21 05:12 DaveSkender

Absolutely, I'll give it a shot.

StevenFischerWI avatar Dec 21 '21 12:12 StevenFischerWI

I think for this one, I'd recommend creating:

public enum AggType {
  Standard,
  Rolling
}

And then modify the existing method API with Standard as the default (to avoid breaking change), or maybe an overload in the general form of:

public class Aggregate (
  this IEnumerable<TQuote> quotes, 
  PeriodSize newSize,
  AggType aggType = AggType.Standard) { ... }

I just noticed there's also a TimeSpan overload that would need to be updated similarly. Might need some general refactoring to sort all these variants out cleanly.

DaveSkender avatar Jan 17 '22 06:01 DaveSkender