Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseSchedule ¶
ParseSchedule checks comma-separated numbers in a string format and returns the list of minutes that data feeding is executed. Examples: "0,15,30,45" -> [0,15,30,45] (the data feeding must be executed every 15 minutes) "50,10" -> [10, 50] " 20, 40 " -> [20, 40] (whitespaces are ignored) "20" -> [20] (00:10, 01:10, ..., 23:10) "100" -> error (minute must be between 0 and 59) "One" -> error (numbers must be used) "0-10" -> error (range is not supported).
Types ¶
type Backfill ¶
type Backfill struct {
// contains filtered or unexported fields
}
Backfill aggregates daily chart data using Alpava v2 API and store it to marketstore.
func NewBackfill ¶
func NewBackfill(symbolManager symbols.Manager, apiClient GetMultiBarsAPIClient, barWriter writer.BarWriter, since time.Time, maxBarsPerReq, maxSymbolsPerReq int, ) *Backfill
NewBackfill initializes the module to backfill the historical daily chart data to marketstore. Alpaca API spec: maxBarsPerRequest: 1000 bars per symbol per request at maximum Alpaca API spec: maxSymbolsPerRequest: 100 symbols per request at maximum.
func (*Backfill) UpdateSymbols ¶
func (b *Backfill) UpdateSymbols()
UpdateSymbols aggregates daily chart data since the specified date and store it to "{symbol}/{timeframe}/OHLCV" bucket in marketstore.
type DefaultMarketTimeChecker ¶
type DefaultMarketTimeChecker struct { // i.e. []string{"Saturday", "Sunday"} ClosedDaysOfTheWeek []time.Weekday ClosedDays []time.Time OpenTime time.Time CloseTime time.Time }
DefaultMarketTimeChecker is an implementation for MarketTimeChecker object. this checker checks the followings: - the market is open at this days of the week - the market is open at this time - the market is open today (= check if today is a holiday or not) all those settings should be defined in this object.
func NewDefaultMarketTimeChecker ¶
func NewDefaultMarketTimeChecker( closedDaysOfTheWeek []time.Weekday, closedDays []time.Time, openTime time.Time, closeTime time.Time, ) *DefaultMarketTimeChecker
NewDefaultMarketTimeChecker initializes the DefaultMarketTimeChecker object with the specifier parameters.s.
type GetMultiBarsAPIClient ¶ added in v4.1.16
type GetSnapShotsAPIClient ¶
type IntervalMarketTimeChecker ¶
type IntervalMarketTimeChecker struct { MarketTimeChecker // LastTime holds the last time that IntervalTimeChceker.IsOpen returned true. LastTime time.Time Interval time.Duration }
IntervalMarketTimeChecker is used where periodic processing is needed to run even when the market is closed.
func NewIntervalMarketTimeChecker ¶
func NewIntervalMarketTimeChecker( mtc MarketTimeChecker, interval time.Duration, ) *IntervalMarketTimeChecker
type MarketTimeChecker ¶
type MarketTimeChecker interface { IsOpen(t time.Time) bool // Sub returns a date after X business day (= day which market is open). businessDay can be a negative value. Sub(date time.Time, businessDay int) (time.Time, error) }
MarketTimeChecker is an interface to check if the market is open at the specified time or not.
type ScheduledMarketTimeChecker ¶
type ScheduledMarketTimeChecker struct { MarketTimeChecker // LastTime holds the last time that IntervalTimeChceker.IsOpen returned true. LastTime time.Time ScheduleMin []int }
ScheduledMarketTimeChecker is used where periodic processing is needed to run even when the market is closed.
func NewScheduledMarketTimeChecker ¶
func NewScheduledMarketTimeChecker( mtc MarketTimeChecker, scheduleMin []int, ) *ScheduledMarketTimeChecker
type Worker ¶
type Worker struct { MarketTimeChecker MarketTimeChecker APIClient GetSnapShotsAPIClient SymbolManager symbols.Manager SnapshotWriter writer.SnapshotWriter BarWriter writer.BarWriter Interval int }
Worker is the main worker instance. It implements bgworker.Run().