feed

package
v4.1.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseSchedule added in v4.1.10

func ParseSchedule(s string) ([]int, error)

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 Xignite API and store it to.

func NewBackfill

func NewBackfill(symbolManager symbols.Manager, apiClient api.Client, quotesWriter writer.QuotesWriter,
	rangeWriter writer.QuotesRangeWriter, since time.Time,
) *Backfill

NewBackfill initializes the module to backfill the historical daily chart data to marketstore.

func (*Backfill) Update

func (b *Backfill) Update(ctx context.Context)

Update calls UpdateSymbols and UpdateIndexSymbols functions sequentially.

func (*Backfill) UpdateClosingPrice

func (b *Backfill) UpdateClosingPrice(ctx context.Context)

UpdateClosingPrice get real-time quotes data for the target symbols and store them into the local marketstore server.

func (*Backfill) UpdateIndexSymbols

func (b *Backfill) UpdateIndexSymbols(ctx context.Context)

UpdateIndexSymbols aggregates daily chart data of index symbols since the specified date and store it to "{symbol}/{timeframe}/OHLCV" bucket in marketstore. nolint: dupl // The impl of updateSymbols/updateIndexSymbols can change in the future, keep as it is for now

func (*Backfill) UpdateSymbols

func (b *Backfill) UpdateSymbols(ctx context.Context)

UpdateSymbols aggregates daily chart data since the specified date and store it to "{symbol}/{timeframe}/OHLCV" bucket in marketstore. nolint: dupl // The impl of updateSymbols/updateIndexSymbols can change in the future, keep as it is for now

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.

func (*DefaultMarketTimeChecker) IsOpen

func (m *DefaultMarketTimeChecker) IsOpen(t time.Time) bool

IsOpen returns true on weekdays from 08:55 to 15:10. if closedDates are defined, return false on those days.

func (*DefaultMarketTimeChecker) Sub

func (m *DefaultMarketTimeChecker) Sub(dateInJST time.Time, businessDay int) (time.Time, error)

Sub returns a date before X business days (= days which market is open). businessDay should be a positive value.

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 RecentBackfill

type RecentBackfill struct {
	// contains filtered or unexported fields
}

RecentBackfill aggregates daily chart data using Xignite API and store it to.

func NewRecentBackfill

func NewRecentBackfill(sm symbols.Manager, mtc MarketTimeChecker, ac api.Client, w writer.BarWriter, days int,
) *RecentBackfill

NewRecentBackfill initializes the module to backfill the historical 5-minute chart data to marketstore.

func (*RecentBackfill) Update

func (b *RecentBackfill) Update(ctx context.Context)

func (*RecentBackfill) UpdateIndexSymbols

func (b *RecentBackfill) UpdateIndexSymbols(ctx context.Context)

UpdateIndexSymbols aggregates recent chart data of index symbols for the past X business days and store it to "{symbol}/5Min/OHLCV" bucket in marketstore.

func (*RecentBackfill) UpdateSymbols

func (b *RecentBackfill) UpdateSymbols(ctx context.Context)

UpdateSymbols aggregates recent chart data for the past X business days and store it to "{symbol}/5Min/OHLCV" bucket in marketstore.

type ScheduledMarketTimeChecker added in v4.1.10

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 added in v4.1.10

func NewScheduledMarketTimeChecker(
	mtc MarketTimeChecker,
	scheduleMin []int,
) *ScheduledMarketTimeChecker

func (*ScheduledMarketTimeChecker) IsOpen added in v4.1.10

IsOpen returns true when the market is open or the interval elapsed since LastTime.

type Worker

type Worker struct {
	MarketTimeChecker MarketTimeChecker
	APIClient         api.Client
	SymbolManager     symbols.Manager
	QuotesWriter      writer.QuotesWriter
	Interval          int
}

Worker is the main worker instance. It implements bgworker.Run().

func (*Worker) Run

func (w *Worker) Run()

Run runs forever to get quotes data for each symbol in the target exchanges using Xignite API periodically, and writes the data to the local marketstore server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL