Documentation
¶
Index ¶
- Constants
- type Instrument
- func (i *Instrument) CreatedAt() string
- func (i *Instrument) DeletedAt() string
- func (instrument *Instrument) GetAssetClass() string
- func (instrument *Instrument) GetDescription() string
- func (instrument *Instrument) GetExchange() string
- func (instrument *Instrument) GetSymbol() string
- func (instrument *Instrument) ID() string
- func (instrument *Instrument) SetAssetClass(assetClass string) InstrumentInterface
- func (i *Instrument) SetCreatedAt(createdAt string) *Instrument
- func (i *Instrument) SetDeletedAt(deletedAt string) *Instrument
- func (instrument *Instrument) SetDescription(description string) InstrumentInterface
- func (instrument *Instrument) SetExchange(exchange string) InstrumentInterface
- func (instrument *Instrument) SetID(id string) InstrumentInterface
- func (instrument *Instrument) SetSymbol(symbol string) InstrumentInterface
- func (i *Instrument) SetUpdatedAt(updatedAt string) *Instrument
- func (i *Instrument) UpdatedAt() string
- type InstrumentInterface
- type InstrumentQuery
- func (iq *InstrumentQuery) AssetClass() string
- func (iq *InstrumentQuery) Columns() []string
- func (iq *InstrumentQuery) Exchange() string
- func (iq *InstrumentQuery) HasAssetClass() bool
- func (iq *InstrumentQuery) HasExchange() bool
- func (iq *InstrumentQuery) HasID() bool
- func (iq *InstrumentQuery) HasIDIn() bool
- func (iq *InstrumentQuery) HasLimit() bool
- func (iq *InstrumentQuery) HasOffset() bool
- func (iq *InstrumentQuery) HasOrderBy() bool
- func (iq *InstrumentQuery) HasSortDirection() bool
- func (iq *InstrumentQuery) HasSymbol() bool
- func (iq *InstrumentQuery) HasSymbolLike() bool
- func (iq *InstrumentQuery) ID() string
- func (iq *InstrumentQuery) IDIn() []string
- func (iq *InstrumentQuery) IsCountOnly() bool
- func (iq *InstrumentQuery) Limit() int
- func (iq *InstrumentQuery) Offset() int
- func (iq *InstrumentQuery) OrderBy() string
- func (iq *InstrumentQuery) SetAssetClass(assetClass string) InstrumentQueryInterface
- func (iq *InstrumentQuery) SetCountOnly(countOnly bool) InstrumentQueryInterface
- func (iq *InstrumentQuery) SetExchange(exchange string) InstrumentQueryInterface
- func (iq *InstrumentQuery) SetID(id string) InstrumentQueryInterface
- func (iq *InstrumentQuery) SetIDIn(ids []string) InstrumentQueryInterface
- func (iq *InstrumentQuery) SetLimit(limit int) InstrumentQueryInterface
- func (iq *InstrumentQuery) SetOffset(offset int) InstrumentQueryInterface
- func (iq *InstrumentQuery) SetOrderBy(orderBy string) InstrumentQueryInterface
- func (iq *InstrumentQuery) SetSortDirection(sortDirection string) InstrumentQueryInterface
- func (iq *InstrumentQuery) SetSymbol(symbol string) InstrumentQueryInterface
- func (iq *InstrumentQuery) SetSymbolLike(symbolLike string) InstrumentQueryInterface
- func (iq *InstrumentQuery) SortDirection() string
- func (iq *InstrumentQuery) Symbol() string
- func (iq *InstrumentQuery) SymbolLike() string
- func (iq *InstrumentQuery) Validate() error
- type InstrumentQueryInterface
- type NewStoreOptions
- type Price
- func (price *Price) GetClose() string
- func (price *Price) GetCloseFloat() float64
- func (price *Price) GetHigh() string
- func (price *Price) GetHighFloat() float64
- func (price *Price) GetLow() string
- func (price *Price) GetLowFloat() float64
- func (price *Price) GetOpen() string
- func (price *Price) GetOpenFloat() float64
- func (price *Price) GetTime() string
- func (price *Price) GetTimeCarbon() carbon.Carbon
- func (price *Price) GetVolume() string
- func (price *Price) GetVolumeFloat() float64
- func (price *Price) ID() string
- func (price *Price) SetClose(close string) PriceInterface
- func (price *Price) SetHigh(high string) PriceInterface
- func (price *Price) SetID(id string) PriceInterface
- func (price *Price) SetLow(low string) PriceInterface
- func (price *Price) SetOpen(open string) PriceInterface
- func (price *Price) SetTime(timeUtc string) PriceInterface
- func (price *Price) SetVolume(volume string) PriceInterface
- type PriceInterface
- type PriceQueryInterface
- type Store
- func (store *Store) AutoMigrate() error
- func (st *Store) DB() *sql.DB
- func (st *Store) EnableDebug(debug bool)
- func (store *Store) InstrumentCount(ctx context.Context, options InstrumentQueryInterface) (int64, error)
- func (store *Store) InstrumentCreate(ctx context.Context, instrument InstrumentInterface) error
- func (store *Store) InstrumentDelete(ctx context.Context, instrument InstrumentInterface) error
- func (store *Store) InstrumentDeleteByID(ctx context.Context, id string) error
- func (store *Store) InstrumentExists(ctx context.Context, options InstrumentQueryInterface) (bool, error)
- func (store *Store) InstrumentFindByID(ctx context.Context, id string) (InstrumentInterface, error)
- func (store *Store) InstrumentList(ctx context.Context, options InstrumentQueryInterface) ([]InstrumentInterface, error)
- func (store *Store) InstrumentUpdate(ctx context.Context, instrument InstrumentInterface) error
- func (store *Store) PriceCount(ctx context.Context, options PriceQueryInterface) (int64, error)
- func (store *Store) PriceCreate(ctx context.Context, price PriceInterface) error
- func (store *Store) PriceDelete(ctx context.Context, price PriceInterface) error
- func (store *Store) PriceDeleteByID(ctx context.Context, id string) error
- func (store *Store) PriceExists(ctx context.Context, options PriceQueryInterface) (bool, error)
- func (store *Store) PriceFindByID(ctx context.Context, id string) (PriceInterface, error)
- func (store *Store) PriceList(ctx context.Context, options PriceQueryInterface) ([]PriceInterface, error)
- func (store *Store) PriceUpdate(ctx context.Context, price PriceInterface) error
- type StoreInterface
Constants ¶
const ASSET_CLASS_CURRENCY = "CURRENCY"
const ASSET_CLASS_ETF = "ETF"
const ASSET_CLASS_INDEX = "INDEX"
const ASSET_CLASS_REIT = "REIT"
const ASSET_CLASS_STOCK = "STOCK"
const ASSET_CLASS_UNKNOWN = "UNKNOWN"
const COLUMN_ASSET_CLASS = "asset_class"
const COLUMN_CLOSE = "close"
const COLUMN_CREATED_AT = "created_at"
const COLUMN_DELETED_AT = "deleted_at"
const COLUMN_EXCHANGE = "exchange"
const COLUMN_HIGH = "high"
const COLUMN_ID = "id"
const COLUMN_LOW = "low"
const COLUMN_OPEN = "open"
const COLUMN_SYMBOL = "symbol"
const COLUMN_TIME = "time"
const COLUMN_UPDATED_AT = "updated_at"
const COLUMN_VOLUME = "volume"
const NIL_FLOAT = -0.0000000001
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Instrument ¶
type Instrument struct {
dataobject.DataObject
}
Instrument represents a trading instrument data object for storing in the database
func (*Instrument) CreatedAt ¶
func (i *Instrument) CreatedAt() string
func (*Instrument) DeletedAt ¶
func (i *Instrument) DeletedAt() string
func (*Instrument) GetAssetClass ¶
func (instrument *Instrument) GetAssetClass() string
func (*Instrument) GetDescription ¶
func (instrument *Instrument) GetDescription() string
func (*Instrument) GetExchange ¶
func (instrument *Instrument) GetExchange() string
func (*Instrument) GetSymbol ¶
func (instrument *Instrument) GetSymbol() string
func (*Instrument) ID ¶
func (instrument *Instrument) ID() string
func (*Instrument) SetAssetClass ¶
func (instrument *Instrument) SetAssetClass(assetClass string) InstrumentInterface
func (*Instrument) SetCreatedAt ¶
func (i *Instrument) SetCreatedAt(createdAt string) *Instrument
func (*Instrument) SetDeletedAt ¶
func (i *Instrument) SetDeletedAt(deletedAt string) *Instrument
func (*Instrument) SetDescription ¶
func (instrument *Instrument) SetDescription(description string) InstrumentInterface
func (*Instrument) SetExchange ¶
func (instrument *Instrument) SetExchange(exchange string) InstrumentInterface
func (*Instrument) SetID ¶
func (instrument *Instrument) SetID(id string) InstrumentInterface
func (*Instrument) SetSymbol ¶
func (instrument *Instrument) SetSymbol(symbol string) InstrumentInterface
func (*Instrument) SetUpdatedAt ¶
func (i *Instrument) SetUpdatedAt(updatedAt string) *Instrument
func (*Instrument) UpdatedAt ¶
func (i *Instrument) UpdatedAt() string
type InstrumentInterface ¶
type InstrumentInterface interface {
// from dataobject
Data() map[string]string
DataChanged() map[string]string
MarkAsNotDirty()
// setters and getters
ID() string
SetID(id string) InstrumentInterface
GetSymbol() string
SetSymbol(symbol string) InstrumentInterface
GetExchange() string
SetExchange(exchange string) InstrumentInterface
GetAssetClass() string
SetAssetClass(assetClass string) InstrumentInterface
GetDescription() string
SetDescription(description string) InstrumentInterface
}
func NewInstrument ¶
func NewInstrument() InstrumentInterface
func NewInstrumentFromExistingData ¶
func NewInstrumentFromExistingData(data map[string]string) InstrumentInterface
type InstrumentQuery ¶
type InstrumentQuery struct {
// contains filtered or unexported fields
}
InstrumentQuery implements the InstrumentQueryInterface
func (*InstrumentQuery) AssetClass ¶
func (iq *InstrumentQuery) AssetClass() string
AssetClass returns the asset class
func (*InstrumentQuery) Columns ¶
func (iq *InstrumentQuery) Columns() []string
Columns returns the columns to select
func (*InstrumentQuery) Exchange ¶
func (iq *InstrumentQuery) Exchange() string
Exchange returns the exchange
func (*InstrumentQuery) HasAssetClass ¶
func (iq *InstrumentQuery) HasAssetClass() bool
HasAssetClass returns true if the asset class is set
func (*InstrumentQuery) HasExchange ¶
func (iq *InstrumentQuery) HasExchange() bool
HasExchange returns true if the exchange is set
func (*InstrumentQuery) HasID ¶
func (iq *InstrumentQuery) HasID() bool
HasID returns true if the id is set
func (*InstrumentQuery) HasIDIn ¶
func (iq *InstrumentQuery) HasIDIn() bool
HasIDIn returns true if the id in is set
func (*InstrumentQuery) HasLimit ¶
func (iq *InstrumentQuery) HasLimit() bool
HasLimit returns true if the limit is set
func (*InstrumentQuery) HasOffset ¶
func (iq *InstrumentQuery) HasOffset() bool
HasOffset returns true if the offset is set
func (*InstrumentQuery) HasOrderBy ¶
func (iq *InstrumentQuery) HasOrderBy() bool
HasOrderBy returns true if the order by is set
func (*InstrumentQuery) HasSortDirection ¶
func (iq *InstrumentQuery) HasSortDirection() bool
HasSortDirection returns true if the sort direction is set
func (*InstrumentQuery) HasSymbol ¶
func (iq *InstrumentQuery) HasSymbol() bool
HasSymbol returns true if the symbol is set
func (*InstrumentQuery) HasSymbolLike ¶
func (iq *InstrumentQuery) HasSymbolLike() bool
HasSymbolLike returns true if the symbol like is set
func (*InstrumentQuery) IsCountOnly ¶
func (iq *InstrumentQuery) IsCountOnly() bool
IsCountOnly returns true if the count only option is set
func (*InstrumentQuery) OrderBy ¶
func (iq *InstrumentQuery) OrderBy() string
OrderBy returns the order by
func (*InstrumentQuery) SetAssetClass ¶
func (iq *InstrumentQuery) SetAssetClass(assetClass string) InstrumentQueryInterface
SetAssetClass sets the asset class
func (*InstrumentQuery) SetCountOnly ¶
func (iq *InstrumentQuery) SetCountOnly(countOnly bool) InstrumentQueryInterface
SetCountOnly sets the count only option
func (*InstrumentQuery) SetExchange ¶
func (iq *InstrumentQuery) SetExchange(exchange string) InstrumentQueryInterface
SetExchange sets the exchange
func (*InstrumentQuery) SetID ¶
func (iq *InstrumentQuery) SetID(id string) InstrumentQueryInterface
SetID sets the id
func (*InstrumentQuery) SetIDIn ¶
func (iq *InstrumentQuery) SetIDIn(ids []string) InstrumentQueryInterface
SetIDIn sets the id in
func (*InstrumentQuery) SetLimit ¶
func (iq *InstrumentQuery) SetLimit(limit int) InstrumentQueryInterface
SetLimit sets the limit
func (*InstrumentQuery) SetOffset ¶
func (iq *InstrumentQuery) SetOffset(offset int) InstrumentQueryInterface
SetOffset sets the offset
func (*InstrumentQuery) SetOrderBy ¶
func (iq *InstrumentQuery) SetOrderBy(orderBy string) InstrumentQueryInterface
SetOrderBy sets the order by
func (*InstrumentQuery) SetSortDirection ¶
func (iq *InstrumentQuery) SetSortDirection(sortDirection string) InstrumentQueryInterface
SetSortDirection sets the sort direction
func (*InstrumentQuery) SetSymbol ¶
func (iq *InstrumentQuery) SetSymbol(symbol string) InstrumentQueryInterface
SetSymbol sets the symbol
func (*InstrumentQuery) SetSymbolLike ¶
func (iq *InstrumentQuery) SetSymbolLike(symbolLike string) InstrumentQueryInterface
SetSymbolLike sets the symbol like
func (*InstrumentQuery) SortDirection ¶
func (iq *InstrumentQuery) SortDirection() string
SortDirection returns the sort direction
func (*InstrumentQuery) Symbol ¶
func (iq *InstrumentQuery) Symbol() string
Symbol returns the symbol
func (*InstrumentQuery) SymbolLike ¶
func (iq *InstrumentQuery) SymbolLike() string
SymbolLike returns the symbol like
func (*InstrumentQuery) Validate ¶
func (iq *InstrumentQuery) Validate() error
Validate validates the query options
type InstrumentQueryInterface ¶
type InstrumentQueryInterface interface {
// Validation
Validate() error
// Columns
Columns() []string
// Options
SetCountOnly(countOnly bool) InstrumentQueryInterface
IsCountOnly() bool
// Limit, Offset
SetLimit(limit int) InstrumentQueryInterface
HasLimit() bool
Limit() int
SetOffset(offset int) InstrumentQueryInterface
HasOffset() bool
Offset() int
// Order By
SetOrderBy(orderBy string) InstrumentQueryInterface
HasOrderBy() bool
OrderBy() string
SetSortDirection(sortDirection string) InstrumentQueryInterface
HasSortDirection() bool
SortDirection() string
// ID
SetID(id string) InstrumentQueryInterface
HasID() bool
ID() string
SetIDIn(ids []string) InstrumentQueryInterface
HasIDIn() bool
IDIn() []string
// Symbol
SetSymbol(symbol string) InstrumentQueryInterface
HasSymbol() bool
Symbol() string
SetSymbolLike(symbolLike string) InstrumentQueryInterface
HasSymbolLike() bool
SymbolLike() string
// Exchange
SetExchange(exchange string) InstrumentQueryInterface
HasExchange() bool
Exchange() string
// Asset Class
SetAssetClass(assetClass string) InstrumentQueryInterface
HasAssetClass() bool
AssetClass() string
}
func NewInstrumentQuery ¶
func NewInstrumentQuery() InstrumentQueryInterface
NewInstrumentQuery creates a new instrument query
type NewStoreOptions ¶
type NewStoreOptions struct {
PriceTableName string
InstrumentTableName string
DB *sql.DB
DbDriverName string
AutomigrateEnabled bool
DebugEnabled bool
}
NewStoreOptions define the options for creating a new tradingstore
type Price ¶
type Price struct {
dataobject.DataObject
}
Price represents an OHLCV data object, for storing the pricing data in the database
func (*Price) GetCloseFloat ¶
func (*Price) GetHighFloat ¶
func (*Price) GetLowFloat ¶
func (*Price) GetOpenFloat ¶
func (*Price) GetTime ¶
Time returns the time as a Iso8601 formatted string.
Parameters: - none
Returns: - string: the time in ISO8601 format
func (*Price) GetTimeCarbon ¶
func (*Price) GetVolumeFloat ¶
func (*Price) SetClose ¶
func (price *Price) SetClose(close string) PriceInterface
func (*Price) SetHigh ¶
func (price *Price) SetHigh(high string) PriceInterface
func (*Price) SetID ¶
func (price *Price) SetID(id string) PriceInterface
func (*Price) SetLow ¶
func (price *Price) SetLow(low string) PriceInterface
func (*Price) SetOpen ¶
func (price *Price) SetOpen(open string) PriceInterface
func (*Price) SetTime ¶
func (price *Price) SetTime(timeUtc string) PriceInterface
SetTime sets the time for a Price, must be in UTC. The time is stored as an ISO8601 formatted string.
Parameters: - timeUtc: time in UTC format
Returns: - *Price: the Price
func (*Price) SetVolume ¶
func (price *Price) SetVolume(volume string) PriceInterface
type PriceInterface ¶
type PriceInterface interface {
Data() map[string]string
DataChanged() map[string]string
MarkAsNotDirty()
// setters and getters
ID() string
SetID(id string) PriceInterface
GetClose() string
GetCloseFloat() float64
SetClose(close string) PriceInterface
GetHigh() string
GetHighFloat() float64
SetHigh(high string) PriceInterface
GetLow() string
GetLowFloat() float64
SetLow(low string) PriceInterface
GetOpen() string
GetOpenFloat() float64
SetOpen(open string) PriceInterface
GetTime() string
GetTimeCarbon() carbon.Carbon
SetTime(time string) PriceInterface
GetVolume() string
GetVolumeFloat() float64
SetVolume(volume string) PriceInterface
}
func NewPrice ¶
func NewPrice() PriceInterface
func NewPriceFromExistingData ¶
func NewPriceFromExistingData(data map[string]string) PriceInterface
type PriceQueryInterface ¶
type PriceQueryInterface interface {
Validate() error
Columns() []string
SetColumns(columns []string) PriceQueryInterface
HasCountOnly() bool
IsCountOnly() bool
SetCountOnly(countOnly bool) PriceQueryInterface
HasTime() bool
Time() string
SetTime(createdAt string) PriceQueryInterface
HasTimeGte() bool
TimeGte() string
SetTimeGte(createdAtGte string) PriceQueryInterface
HasTimeLte() bool
TimeLte() string
SetTimeLte(createdAtLte string) PriceQueryInterface
HasID() bool
ID() string
SetID(id string) PriceQueryInterface
HasIDIn() bool
IDIn() []string
SetIDIn(idIn []string) PriceQueryInterface
HasLimit() bool
Limit() int
SetLimit(limit int) PriceQueryInterface
HasOffset() bool
Offset() int
SetOffset(offset int) PriceQueryInterface
HasOrderBy() bool
OrderBy() string
SetOrderBy(orderBy string) PriceQueryInterface
HasSortDirection() bool
SortDirection() string
SetSortDirection(sortDirection string) PriceQueryInterface
// contains filtered or unexported methods
}
func NewPriceQuery ¶
func NewPriceQuery() PriceQueryInterface
NewPriceQuery creates a new price query
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) EnableDebug ¶
EnableDebug - enables the debug option
func (*Store) InstrumentCount ¶
func (store *Store) InstrumentCount(ctx context.Context, options InstrumentQueryInterface) (int64, error)
InstrumentCount returns the number of instruments based on the given query options
func (*Store) InstrumentCreate ¶
func (store *Store) InstrumentCreate(ctx context.Context, instrument InstrumentInterface) error
InstrumentCreate creates a new instrument
func (*Store) InstrumentDelete ¶
func (store *Store) InstrumentDelete(ctx context.Context, instrument InstrumentInterface) error
InstrumentDelete deletes an instrument
func (*Store) InstrumentDeleteByID ¶
InstrumentDeleteByID deletes an instrument by its ID
func (*Store) InstrumentExists ¶
func (store *Store) InstrumentExists(ctx context.Context, options InstrumentQueryInterface) (bool, error)
InstrumentExists returns true if an instrument exists based on the given query options
func (*Store) InstrumentFindByID ¶
InstrumentFindByID returns an instrument by its ID
func (*Store) InstrumentList ¶
func (store *Store) InstrumentList(ctx context.Context, options InstrumentQueryInterface) ([]InstrumentInterface, error)
InstrumentList returns a list of instruments based on the given query options
func (*Store) InstrumentUpdate ¶
func (store *Store) InstrumentUpdate(ctx context.Context, instrument InstrumentInterface) error
InstrumentUpdate updates an instrument
func (*Store) PriceCount ¶
PriceCount returns the number of prices based on the given query options
func (*Store) PriceCreate ¶
func (store *Store) PriceCreate(ctx context.Context, price PriceInterface) error
PriceCreate creates a new price
func (*Store) PriceDelete ¶
func (store *Store) PriceDelete(ctx context.Context, price PriceInterface) error
PriceDelete deletes a price
func (*Store) PriceDeleteByID ¶
PriceDeleteByID deletes a price by its ID
func (*Store) PriceExists ¶
PriceExists returns true if a price exists based on the given query options
func (*Store) PriceFindByID ¶
PriceFindByID returns a price by its ID
func (*Store) PriceList ¶
func (store *Store) PriceList(ctx context.Context, options PriceQueryInterface) ([]PriceInterface, error)
PriceList returns a list of prices based on the given query options
func (*Store) PriceUpdate ¶
func (store *Store) PriceUpdate(ctx context.Context, price PriceInterface) error
type StoreInterface ¶
type StoreInterface interface {
// AutoMigrate automatically creates the schema if it does not exist
AutoMigrate() error
// DB returns the underlying sql.DB connection
DB() *sql.DB
// EnableDebug enables debug mode
EnableDebug(bool)
// InstrumentCount returns the number of instruments that match the criteria
InstrumentCount(ctx context.Context, options InstrumentQueryInterface) (int64, error)
// InstrumentCreate creates a new instrument in the database
InstrumentCreate(ctx context.Context, instrument InstrumentInterface) error
// InstrumentDelete deletes an instrument
InstrumentDelete(ctx context.Context, instrument InstrumentInterface) error
// InstrumentDeleteByID deletes an instrument by ID
InstrumentDeleteByID(ctx context.Context, id string) error
// InstrumentExists checks if an instrument exists by checking a number of criteria
InstrumentExists(ctx context.Context, options InstrumentQueryInterface) (bool, error)
// InstrumentFindByID finds an instrument by its ID
InstrumentFindByID(ctx context.Context, id string) (InstrumentInterface, error)
// InstrumentList returns a list of instruments from the database based on criteria
InstrumentList(ctx context.Context, options InstrumentQueryInterface) ([]InstrumentInterface, error)
// InstrumentUpdate updates an instrument
InstrumentUpdate(ctx context.Context, instrument InstrumentInterface) error
// PriceCount returns the number of prices that match the criteria
PriceCount(ctx context.Context, options PriceQueryInterface) (int64, error)
// PriceCreate creates a new price in the database
PriceCreate(ctx context.Context, price PriceInterface) error
// PriceDelete deletes a price
PriceDelete(ctx context.Context, price PriceInterface) error
// PriceDeleteByID deletes a price by ID
PriceDeleteByID(ctx context.Context, id string) error
// PriceExists checks if a price exists by checking a number of criteria
PriceExists(ctx context.Context, options PriceQueryInterface) (bool, error)
// PriceFindByID finds a price by its ID
PriceFindByID(ctx context.Context, id string) (PriceInterface, error)
// PriceList returns a list of prices from the database based on criteria
PriceList(ctx context.Context, options PriceQueryInterface) ([]PriceInterface, error)
// PriceUpdate updates a price
PriceUpdate(ctx context.Context, price PriceInterface) error
}
StoreInterface defines the interface for a store
func NewStore ¶
func NewStore(opts NewStoreOptions) (StoreInterface, error)
NewStore creates a new trading store