Versions in this module Expand all Collapse all v0 v0.1.2 Mar 10, 2021 Changes in this version + const Close + const Default + const High + const Low + const Open + const Volume + var AssetDoesNotExist = errors.New("Asset does not exist") + var EndOfBacktest = errors.New("End of backtest") + var EndOfData = errors.New("End of data") + var FFToStartDate = errors.New("Fast forwarding to start date") + var Initialization = errors.New("Initialization in Once() failed") + var UnknownDirection = errors.New("Unknown type of direction for order - should be Buy, Sell, Short or Cover") + var UnstablePeriod = errors.New("The stable period is not yet reached") + func MapRecordsInvesting(records ...string) (time.Time, []float64) + func ParseFloat(value string) float64 + func Run(ctx *Context, dm *DataManager) + func RunStrategyOnAssets(ctx *Context, dm *DataManager) + type Accepted struct + func (a Accepted) String() string + type Asset struct + func NewAsset(name string, ohlc *OHLC, length int) *Asset + func (a Asset) GetLength() int + type Broker struct + func (b *Broker) SendOrder(order Order, orderstatus OrderStatus) error + func (b *Broker) SetComission(comission Comission) + type Callback interface + Assets func() []string + IsOwning func(assetName string) (bool, error) + Owning func() bool + SendOrder func(direction Direction, orderType OrderType, qty int) error + SendOrderFor func(assetName string, direction Direction, orderType OrderType, qty int) error + type Comission interface + GetComisson func(price float64, qty int) float64 + type Context struct + K int + func NewContext() *Context + func (ctx *Context) AddAsset(asset *Asset) + func (ctx *Context) AddIndicator(indicator indicators.Indicator) + func (ctx *Context) AddIndicatorOnAsset(asset *Asset, indicator indicators.Indicator) + func (ctx *Context) AddIndicatorWithParams(indicator indicators.Indicator, param indicators.Param) + func (ctx *Context) GetAssetByName(name string) *Asset + func (ctx *Context) GetAssetIndicatorByName(name string) []indicators.Indicator + func (ctx *Context) GetAssets() []Asset + func (ctx *Context) GetDataPath() string + func (ctx *Context) GetEndDate() time.Time + func (ctx *Context) GetInitPeriod() int + func (ctx *Context) GetStartDate() time.Time + func (ctx *Context) GetStrategy() Strategy + func (ctx *Context) SetDataPath(path string) + func (ctx *Context) SetEndDate(endTime time.Time) + func (ctx *Context) SetInitPeriod(period int) + func (ctx *Context) SetStartDate(startTime time.Time) + func (ctx *Context) SetStrategy(strategy Strategy) + func (ctx *Context) Time() time.Time + type DataEvent struct + Name string + Ohlc OHLC + func (d DataEvent) String() string + type DataHandler interface + AddAsset func(asset *Asset) + type DataManager struct + Folder string + Headers bool + MappingFunc Maprecords + func NewCSVDataManager(folder string, headers bool, mapping Maprecords) *DataManager + func (d *DataManager) ReadCSVFile(file string) *Asset + type DataUpdate interface + Update func(ohlc OHLC) + type Direction int + const BuyOrder + const CoverOrder + const EMPTY + const Long + const SellOrder + const Short + const ShortOrder + const ZERO + type Directon int + type Event interface + String func() string + type Fill struct + AssetName string + Price float64 + Qty int + Time time.Time + func (f Fill) String() string + type FixedComission struct + func (f FixedComission) GetComisson(price float64, qty int) float64 + type GenerationK struct + func NewGenerationK() *GenerationK + func (k *GenerationK) AddAsset(asset *Asset) + func (k *GenerationK) AddStrategy(strat Strategy) + func (k *GenerationK) Assets() []string + func (k *GenerationK) GetAsset() Asset + func (k *GenerationK) GetAssetByName(name string) *Asset + func (k *GenerationK) GetAssets() []Asset + func (k *GenerationK) IsOwning(assetName string) (bool, error) + func (k *GenerationK) Owning() bool + func (k *GenerationK) Run() error + func (k *GenerationK) SendOrder(direction Direction, orderType OrderType, qty int) error + func (k *GenerationK) SendOrderFor(assetName string, direction Direction, orderType OrderType, qty int) error + func (k *GenerationK) SetBalance(balance float64) + func (k *GenerationK) SetComission(comission Comission) + func (k *GenerationK) SetDataManager() + func (k *GenerationK) SetEndDate(endDate time.Time) + func (k *GenerationK) SetPortfolio(portfolio *Portfolio) + func (k *GenerationK) SetStartDate(startDate time.Time) + type Holding struct + type IndicatorError struct + Err error + func (e IndicatorError) Error() string + type IndicatorNotReadyError struct + Len int + Msg string + func (e IndicatorNotReadyError) Error() string + type Job interface + GetFileName func() string + GetId func() int + GetParams func() []float64 + GetResult func() float64 + type JobStruct struct + FileName string + Id int + Params []Params + Result float64 + func (j *JobStruct) GetFileName() string + func (j *JobStruct) GetId() int + func (j *JobStruct) GetResult() float64 + func (j *JobStruct) SetParams(params ...Params) + type Maprecords func(...string) (time.Time, []float64) + type MultiStrategy interface + GetParams func() []*Params + Once func(ctx *Context, assets []*Asset) error + PerBar func(k int, callback Callback) error + Update func(k *int) error + type OHLC struct + Close []float64 + High []float64 + Low []float64 + Open []float64 + Time []time.Time + Volume []float64 + type OhlcConst int + type Order struct + Asset string + Price float64 + Qty int + Time time.Time + func (o Order) String() string + type OrderStatus interface + OrderEvent func(orderEvent Event) + type OrderType int + const LimitOrder + const MarketOrder + const StopLimitOrder + const StopOrder + type Params struct + High float64 + Low float64 + Value float64 + func (p *Params) NewParams(value, low, high float64) *Params + func (p Params) GetValue() float64 + type PartialFill struct + func (pf PartialFill) String() string + type PercentageComission struct + func (pc PercentageComission) GetComisson(price float64, qty int) float64 + type Portfolio struct + func NewPortfolio() *Portfolio + func (p *Portfolio) AddHolding(position Holding) + func (p *Portfolio) GetBalance() float64 + func (p *Portfolio) IsOwning(assetName string) bool + func (p *Portfolio) RemoveHolding(position Holding) + func (p *Portfolio) SetBalance(amount float64) + type Quit struct + func (q Quit) String() string + type RebalanceStrategy interface + GetInterval func() string + Rebalance func(k int, date time.Time, callback Callback) error + type Rejected struct + func (r Rejected) String() string + type Strategy interface + GetParams func() []*Params + Once func(ctx *Context, ohlc *OHLC) error + PerBar func(k int, callback Callback) error + Update func(k *int) error + type Submitted struct + func (s Submitted) String() string + type Tick struct + func (t Tick) String() string