Documentation
¶
Index ¶
Constants ¶
const ASSET_CLASS_BOND = "BOND"
Asset Class (from https://en.wikipedia.org/wiki/Asset_classes)
const ASSET_CLASS_COMMODITY = "COMMODITY" // Commodities, such as gold, oil, and agricultural products
const ASSET_CLASS_CRYPTO = "CRYPTO" // Cryptocurrency
const ASSET_CLASS_CURRENCY = "CURRENCY" // Currencies
const ASSET_CLASS_DERIVATIVE = "DERIVATIVE" // Derivatives
const ASSET_CLASS_ETF = "ETF" // Exchange Traded Funds
const ASSET_CLASS_FOREX = "FOREX" // Foreign Exchange
const ASSET_CLASS_FUTURE = "FUTURE" // Futures
const ASSET_CLASS_INDEX = "INDEX" // Index
const ASSET_CLASS_OPTION = "OPTION" // Options
const ASSET_CLASS_REIT = "REIT" // Real Estate Investment Trust
const ASSET_CLASS_STOCK = "STOCK" // Stocks
const ASSET_CLASS_UNKNOWN = "UNKNOWN" // Unknown
const COLUMN_ASSET_CLASS = "asset_class"
Column names
const COLUMN_CLOSE = "close"
const COLUMN_CREATED_AT = "created_at"
const COLUMN_DESCRIPTION = "description"
const COLUMN_EXCHANGE = "exchange"
const COLUMN_HIGH = "high"
const COLUMN_ID = "id"
const COLUMN_LOW = "low"
const COLUMN_MEMO = "memo"
const COLUMN_METAS = "metas"
const COLUMN_NAME = "name"
const COLUMN_OPEN = "open"
const COLUMN_SOFT_DELETED_AT = "soft_deleted_at"
const COLUMN_STATUS = "status"
const COLUMN_SYMBOL = "symbol"
const COLUMN_TIME = "time"
const COLUMN_TIMEFRAMES = "timeframes"
const COLUMN_UPDATED_AT = "updated_at"
const COLUMN_VOLUME = "volume"
const INSTRUMENT_STATUS_ACTIVE = "active"
const INSTRUMENT_STATUS_DISABLED = "disabled"
const INSTRUMENT_STATUS_DRAFT = "draft"
Instrument Status
const INSTRUMENT_STATUS_INACTIVE = "inactive"
const MAX_DATETIME = "9999-12-31 23:59:59"
MAX_DATETIME is a far-future datetime used as the default soft-delete sentinel.
const NIL_FLOAT = -0.0000000001
Nil float
const TIMEFRAME_15_MINUTES = "15min"
const TIMEFRAME_1_DAY = "1day"
const TIMEFRAME_1_HOUR = "1hour"
const TIMEFRAME_1_MINUTE = "1min"
Timeframe
const TIMEFRAME_1_MONTH = "1month"
const TIMEFRAME_1_WEEK = "1week"
const TIMEFRAME_1_YEAR = "1year"
const TIMEFRAME_30_MINUTES = "30min"
const TIMEFRAME_4_HOURS = "4hour"
const TIMEFRAME_5_MINUTES = "5min"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InstrumentInterface ¶
type InstrumentInterface interface {
// setters and getters
AssetClass() string
SetAssetClass(assetClass string) InstrumentInterface
Exchange() string
SetExchange(exchange string) InstrumentInterface
Description() string
SetDescription(description string) InstrumentInterface
ID() string
SetID(id string) InstrumentInterface
Meta(key string) (string, error)
SetMeta(key string, value string) error
DeleteMeta(key string) error
Metas() (map[string]string, error)
SetMetas(metas map[string]string) error
Memo() string
SetMemo(memo string) InstrumentInterface
Name() string
SetName(name string) InstrumentInterface
Status() string
SetStatus(status string) InstrumentInterface
Symbol() string
SetSymbol(symbol string) InstrumentInterface
Timeframes() []string
SetTimeframes(timeframes []string) InstrumentInterface
CreatedAt() string
CreatedAtCarbon() *carbon.Carbon
SetCreatedAt(createdAt string) InstrumentInterface
UpdatedAt() string
UpdatedAtCarbon() *carbon.Carbon
SetUpdatedAt(updatedAt string) InstrumentInterface
SoftDeletedAt() string
SoftDeletedAtCarbon() *carbon.Carbon
SetSoftDeletedAt(softDeletedAt string) InstrumentInterface
IsSoftDeleted() bool
}
InstrumentInterface defines the interface for a financial instrument.
func NewInstrument ¶
func NewInstrument() InstrumentInterface
NewInstrument creates a new instrument with default values.
func NewInstrumentFromExistingData ¶
func NewInstrumentFromExistingData(data map[string]string) InstrumentInterface
NewInstrumentFromExistingData hydrates an instrument from a raw column map.
type InstrumentQueryInterface ¶
type InstrumentQueryInterface interface {
Validate() error
SetAssetClass(assetClass string) InstrumentQueryInterface
IsAssetClassSet() bool
AssetClass() string
IsExchangeSet() bool
Exchange() string
SetExchange(exchange string) InstrumentQueryInterface
IsColumnsSet() bool
Columns() []string
SetColumns(columns []string) InstrumentQueryInterface
SetCountOnly(countOnly bool) InstrumentQueryInterface
IsCountOnly() bool
SetID(id string) InstrumentQueryInterface
IsIDSet() bool
ID() string
SetIDIn(ids []string) InstrumentQueryInterface
IsIDInSet() bool
IDIn() []string
IsLimitSet() bool
Limit() int
SetLimit(limit int) InstrumentQueryInterface
IsOffsetSet() bool
Offset() int
SetOffset(offset int) InstrumentQueryInterface
IsOrderBySet() bool
OrderBy() string
SetOrderBy(orderBy string) InstrumentQueryInterface
IsOrderDirectionSet() bool
OrderDirection() string
SetOrderDirection(orderDirection string) InstrumentQueryInterface
SetStatus(status string) InstrumentQueryInterface
IsStatusSet() bool
Status() string
IsSymbolSet() bool
Symbol() string
SetSymbol(symbol string) InstrumentQueryInterface
IsSymbolLikeSet() bool
SymbolLike() string
SetSymbolLike(symbolLike string) InstrumentQueryInterface
IsSoftDeletedIncluded() bool
SoftDeletedIncluded() bool
SetSoftDeletedIncluded(softDeletedIncluded bool) InstrumentQueryInterface
}
InstrumentQueryInterface defines the interface for instrument query options.
func InstrumentQuery ¶
func InstrumentQuery() InstrumentQueryInterface
InstrumentQuery is a shortcut to create a new instrument query
func NewInstrumentQuery ¶
func NewInstrumentQuery() InstrumentQueryInterface
NewInstrumentQuery creates a new instrument query
type NewStoreOptions ¶
type NewStoreOptions struct {
PriceTableNamePrefix string
InstrumentTableName string
UseMultipleExchanges bool
DB *sql.DB
AutomigrateEnabled bool
DebugEnabled bool
}
NewStoreOptions define the options for creating a new tradingstore
type PriceInterface ¶
type PriceInterface interface {
ID() string
SetID(id string) PriceInterface
Close() string
CloseFloat() float64
SetClose(close string) PriceInterface
High() string
HighFloat() float64
SetHigh(high string) PriceInterface
Low() string
LowFloat() float64
SetLow(low string) PriceInterface
Open() string
OpenFloat() float64
SetOpen(open string) PriceInterface
Time() string
TimeCarbon() *carbon.Carbon
SetTime(time string) PriceInterface
Volume() string
VolumeFloat() float64
SetVolume(volume string) PriceInterface
}
PriceInterface defines the interface for an OHLCV price record.
func NewPriceFromExistingData ¶
func NewPriceFromExistingData(data map[string]string) PriceInterface
NewPriceFromExistingData hydrates a price from a raw column map.
type PriceQueryInterface ¶
type PriceQueryInterface interface {
Validate() error
IsColumnsSet() bool
Columns() []string
SetColumns(columns []string) PriceQueryInterface
IsCountOnlySet() bool
IsCountOnly() bool
SetCountOnly(countOnly bool) PriceQueryInterface
IsTimeSet() bool
Time() string
SetTime(createdAt string) PriceQueryInterface
IsTimeGteSet() bool
TimeGte() string
SetTimeGte(createdAtGte string) PriceQueryInterface
IsTimeLteSet() bool
TimeLte() string
SetTimeLte(createdAtLte string) PriceQueryInterface
IsIDSet() bool
ID() string
SetID(id string) PriceQueryInterface
IsIDInSet() bool
IDIn() []string
SetIDIn(idIn []string) PriceQueryInterface
IsLimitSet() bool
Limit() int
SetLimit(limit int) PriceQueryInterface
IsOffsetSet() bool
Offset() int
SetOffset(offset int) PriceQueryInterface
IsOrderBySet() bool
OrderBy() string
SetOrderBy(orderBy string) PriceQueryInterface
IsOrderDirectionSet() bool
OrderDirection() string
SetOrderDirection(orderDirection string) PriceQueryInterface
}
PriceQueryInterface defines the interface for price query options.
func NewPriceQuery ¶
func NewPriceQuery() PriceQueryInterface
NewPriceQuery creates a new price query
type StoreInterface ¶
type StoreInterface interface {
MigrateDown(ctx context.Context, tx ...*sql.Tx) error
MigrateUp(ctx context.Context, tx ...*sql.Tx) error
DB() *sql.DB
EnableDebug(bool)
InstrumentCount(ctx context.Context, options InstrumentQueryInterface) (int64, error)
InstrumentCreate(ctx context.Context, instrument InstrumentInterface) error
InstrumentDelete(ctx context.Context, instrument InstrumentInterface) error
InstrumentDeleteByID(ctx context.Context, id string) error
InstrumentExists(ctx context.Context, options InstrumentQueryInterface) (bool, error)
InstrumentFindByID(ctx context.Context, id string) (InstrumentInterface, error)
InstrumentList(ctx context.Context, options InstrumentQueryInterface) ([]InstrumentInterface, error)
InstrumentSoftDelete(ctx context.Context, instrument InstrumentInterface) error
InstrumentSoftDeleteByID(ctx context.Context, id string) error
InstrumentUpdate(ctx context.Context, instrument InstrumentInterface) error
PriceCount(ctx context.Context, symbol string, exchange string, timeframe string, options PriceQueryInterface) (int64, error)
PriceCreate(ctx context.Context, symbol string, exchange string, timeframe string, price PriceInterface) error
PriceDelete(ctx context.Context, symbol string, exchange string, timeframe string, price PriceInterface) error
PriceDeleteByID(ctx context.Context, symbol string, exchange string, timeframe string, priceID string) error
PriceExists(ctx context.Context, symbol string, exchange string, timeframe string, options PriceQueryInterface) (bool, error)
PriceFindByID(ctx context.Context, symbol string, exchange string, timeframe string, priceID string) (PriceInterface, error)
PriceList(ctx context.Context, symbol string, exchange string, timeframe string, options PriceQueryInterface) ([]PriceInterface, error)
PriceUpdate(ctx context.Context, symbol string, exchange string, timeframe string, price PriceInterface) error
}
StoreInterface defines the interface for a store
func NewStore ¶
func NewStore(opts NewStoreOptions) (StoreInterface, error)
NewStore creates a new trading store