Documentation ¶
Index ¶
- func MakeOrder(ctx *Context, ordertype OrderType, asset *Asset, time time.Time, ...)
- func Min(x, y int) int
- func RunEventBased(ctx *Context)
- type Accepted
- type Asset
- type Broker
- type CSVDataManager
- type Context
- func (ctx *Context) AddAsset(asset *Asset)
- func (ctx *Context) AddEndDate(endTime time.Time)
- func (ctx *Context) AddIndicator(indicator indicators.Indicator)
- func (ctx *Context) AddIndicatorOnAsset(asset *Asset, indicator *indicators.Indicator)
- func (ctx *Context) AddStartDate(startTime time.Time)
- func (ctx *Context) AddStrategy(strategy *Strategy)
- func (ctx *Context) AddUpdatable(indicators ...Updateable)
- func (ctx *Context) EventChannel() chan Event
- func (ctx Context) GetInitPeriod() int
- func (ctx *Context) OrderChannel() chan Event
- func (ctx *Context) Position(asset *Asset) bool
- func (ctx *Context) SetInitPeriod(period int)
- func (ctx *Context) Time() time.Time
- type Data
- type DataEvent
- type DataSource
- type DataUpdate
- type Direction
- type EndOfDataError
- type Event
- type Fill
- type Holding
- type IndicatorError
- type IndicatorNotReadyError
- type KlineExamples
- type OHLC
- type OhlcHeap
- type Order
- type OrderType
- type PartialFill
- type Portfolio
- type Quit
- type Rejected
- type Signal
- type Strategy
- type Submitted
- type Tick
- type Type
- type Updateable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunEventBased ¶
func RunEventBased(ctx *Context)
Types ¶
type Asset ¶
Asset data type
func (*Asset) CloseArray ¶
CloseArray is used to get the close series
func (*Asset) CloseAtBar ¶
CloseAtBar is used to get the close value
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker is used to send orders
func (*Broker) PlaceOrder ¶
PlaceOrder is used to place an order with the broker
type CSVDataManager ¶
type CSVDataManager struct {
// contains filtered or unexported fields
}
CSVDataManager type
func NewCSVDataManager ¶
func NewCSVDataManager(ctx *Context) CSVDataManager
NewCSVDataManager creates a new data manager object
func (CSVDataManager) ReadCSVFileAsync ¶
func (d CSVDataManager) ReadCSVFileAsync(file string)
ReadCSVFileAsync is used to start a go thread
func (CSVDataManager) ReadFolderWithCSVFilesAsync ¶
func (d CSVDataManager) ReadFolderWithCSVFilesAsync(folder string)
ReadFolderWithCSVFilesAsync is used to read a folder of files and put them on the queue to the strategy
type Context ¶
type Context struct { //Updateable []Updateable Strategy []Strategy Asset []Asset AssetMap map[string]*Asset AssetIndicatorMap map[string][]*indicators.Indicator StartDate time.Time EndDate time.Time Portfolio Portfolio Broker Broker K int // contains filtered or unexported fields }
Context for this backtester
func (*Context) AddEndDate ¶
AddEndDate is used to set the strategy that will be run
func (*Context) AddIndicator ¶
func (ctx *Context) AddIndicator(indicator indicators.Indicator)
AddIndicator will add it to all assets
func (*Context) AddIndicatorOnAsset ¶
func (ctx *Context) AddIndicatorOnAsset(asset *Asset, indicator *indicators.Indicator)
AddIndicatorOnAsset will add an indicator on the asset
func (*Context) AddStartDate ¶
AddStartDate is used to set the strategy that will be run
func (*Context) AddStrategy ¶
AddStrategy is used to set the strategy that will be run
func (*Context) AddUpdatable ¶
func (ctx *Context) AddUpdatable(indicators ...Updateable)
AddUpdatable add an updatable interface
func (*Context) EventChannel ¶
EventChannel return the channel for events
func (Context) GetInitPeriod ¶
GetInitPeriod returns the period
func (*Context) OrderChannel ¶
OrderChannel returns the channel for orders
func (*Context) SetInitPeriod ¶
SetInitPeriod is used to set the priod for which
type DataSource ¶
type DataSource interface { GetData(period int) GetLatestData() }
DataSource interface for getting data
type DataUpdate ¶
type DataUpdate interface {
Update(ohlc OHLC)
}
DataUpdate is used to update the data in the assets
type EndOfDataError ¶
type EndOfDataError struct {
Description string
}
func (*EndOfDataError) Error ¶
func (e *EndOfDataError) Error() string
type IndicatorError ¶
type IndicatorError struct { Err error // contains filtered or unexported fields }
IndicatorError Used to signal an error with an indicator
func (IndicatorError) Error ¶
func (e IndicatorError) Error() string
type IndicatorNotReadyError ¶
type IndicatorNotReadyError struct { Msg string //description of error Len int //the length needed before trying again }
IndicatorNotReadyError is an error thrown when an indicator needs more data to be used
func (IndicatorNotReadyError) Error ¶
func (e IndicatorNotReadyError) Error() string
type OhlcHeap ¶
type OhlcHeap []OHLC
An OhlcHeap is a min-heap of ints.
func (*OhlcHeap) Pop ¶
func (h *OhlcHeap) Pop() interface{}
Pop is used to remove items from the heap
type PartialFill ¶
type PartialFill struct { }
func (PartialFill) String ¶
func (pf PartialFill) String() string
type Portfolio ¶
type Portfolio struct { Holdings []Holding // contains filtered or unexported fields }
func (*Portfolio) AddHolding ¶
func (Portfolio) IsOwning ¶
IsOwning is used to find out if a position is already owned in this asset
func (*Portfolio) SellHolding ¶
type Strategy ¶
type Strategy interface { Setup(ctx *Context) error Tick(ctx *Context) OrderEvent(orderEvent Event) }
Strategy needs to implement Orders in order to generate them
type Updateable ¶
type Updateable interface {
Update([]float64)
}
Updateable takes new data into account