Documentation ¶
Overview ¶
Package market provides an API to read and process market price data
Index ¶
Constants ¶
const MetaTraderTimeFormat = "02/01/2006 15:04"
MetaTraderTimeFormat is the time format expected by the MetaTrader decoder when cols [0] and [1] are used.
Variables ¶
var ( // ErrNotEnoughColumns is returned when the CSV price record does not have enough columns. ErrNotEnoughColumns = errors.New("not enough columns") // ErrInvalidTimeFormat is returned when the CSV price record does not have a valid time unix milli format. ErrInvalidTimeFormat = errors.New("cannot parse time string") // ErrInvalidPriceFormat is returned when the CSV price record does not prices in expected format. ErrInvalidPriceFormat = errors.New("OHLC prices must be in valid decimal format") // ErrInvalidVolumeFormat is returned when the CSV price record does not have a valid volume format. ErrInvalidVolumeFormat = errors.New("volume must be in valid float format") )
Functions ¶
This section is empty.
Types ¶
type Asset ¶
type Asset struct {
Symbol string `csv:"symbol"`
}
Asset represents a tradeable asset identified by its symbol, e.g. BTCUSD.
type CSVKlineDecoder ¶ added in v0.0.18
CSVKlineDecoder is an extension point for CSVKlineReader to support custom file formats.
type CSVKlineReader ¶
type CSVKlineReader struct {
// contains filtered or unexported fields
}
CSVKlineReader is a KlineReader that reads from a CSV file.
func NewBinanceCSVKlineReader ¶ added in v0.0.18
func NewBinanceCSVKlineReader(csv *csv.Reader) *CSVKlineReader
NewBinanceCSVKlineReader creates a new CSVKlineReader for Binance CSV files.
func NewCSVKlineReader ¶
func NewCSVKlineReader(csv *csv.Reader) *CSVKlineReader
NewCSVKlineReader creates a new CSVKlineReader with the default Binance decoder.
func NewCSVKlineReaderWithDecoder ¶ added in v0.0.18
func NewCSVKlineReaderWithDecoder(csv *csv.Reader, decoder CSVKlineDecoder) *CSVKlineReader
NewCSVKlineReaderWithDecoder creates a new CSVKlineReader with the given decoder.
func NewMetaTraderCSVKlineReader ¶ added in v0.0.18
func NewMetaTraderCSVKlineReader(csv *csv.Reader) *CSVKlineReader
NewMetaTraderCSVKlineReader creates a new CSVKlineReader for MetaTrader CSV files.
func (*CSVKlineReader) Read ¶
func (r *CSVKlineReader) Read() (Kline, error)
Read reads the next Kline from the underlying CSV data.
func (*CSVKlineReader) ReadAll ¶
func (r *CSVKlineReader) ReadAll() ([]Kline, error)
ReadAll reads all the Klines from the underlying CSV data.
type Kline ¶
type Kline struct { Start time.Time O decimal.Decimal H decimal.Decimal L decimal.Decimal C decimal.Decimal Volume float64 }
Kline represents a single candlestick.
func BinanceCSVKlineDecoder ¶ added in v0.0.18
BinanceCSVKlineDecoder decodes a CSV record from Binance into a Kline.
func MetaTraderCSVKlineDecoder ¶ added in v0.0.18
MetaTraderCSVKlineDecoder decodes a CSV record from MetaTrader into a Kline.
func ReadKlinesFromCSV ¶
ReadKlinesFromCSV reads all the .csv files in a given directory or a single file into a slice of Klines. Wraps a default CSVKlineReader with Binance decoder for convenience. For finer grained memory management use the base kline reader.
func ReadKlinesFromCSVWithDecoder ¶ added in v0.0.18
func ReadKlinesFromCSVWithDecoder(path string, maker MakeCSVKlineReader) ([]Kline, error)
ReadKlinesFromCSVWithDecoder permits using a custom CSVKlineReader.
type KlineReader ¶
KlineReader is an interface for reading candlesticks.
type MakeCSVKlineReader ¶ added in v0.0.18
type MakeCSVKlineReader func(csv *csv.Reader) *CSVKlineReader
MakeCSVKlineReader is a factory method type that creates a new CSVKlineReader.