Documentation ¶
Overview ¶
Package gobacktest is a simple placeholder to root all gobacktest documentation
Index ¶
- Constants
- type Algo
- type AlgoHandler
- type AlgoStack
- type Asset
- type Backtest
- func (t *Backtest) Reset() error
- func (t *Backtest) Run() error
- func (t *Backtest) SetData(data DataHandler)
- func (t *Backtest) SetExchange(exchange ExecutionHandler)
- func (t *Backtest) SetPortfolio(portfolio PortfolioHandler)
- func (t *Backtest) SetStatistic(statistic StatisticHandler)
- func (t *Backtest) SetStrategy(strategy StrategyHandler)
- func (t *Backtest) SetSymbols(symbols []string)
- func (t *Backtest) Stats() StatisticHandler
- type Bar
- type BarEvent
- type Booker
- type Casher
- type CommissionHandler
- type Data
- func (d *Data) History() []DataEvent
- func (d *Data) Latest(symbol string) DataEvent
- func (d *Data) List(symbol string) []DataEvent
- func (d *Data) Load(s []string) error
- func (d *Data) Next() (dh DataEvent, ok bool)
- func (d *Data) Reset() error
- func (d *Data) SetStream(stream []DataEvent)
- func (d *Data) SortStream()
- func (d *Data) Stream() []DataEvent
- type DataEvent
- type DataHandler
- type DataLoader
- type DataStreamer
- type Direction
- type Directioner
- type Event
- type EventHandler
- type EventTracker
- type Exchange
- type ExchangeFeeHandler
- type ExecutionHandler
- type Fill
- func (f Fill) Commission() float64
- func (f Fill) Cost() float64
- func (f Fill) Direction() Direction
- func (f Fill) ExchangeFee() float64
- func (f Fill) NetValue() float64
- func (f Fill) Price() float64
- func (f Fill) Qty() int64
- func (f *Fill) SetDirection(dir Direction)
- func (f *Fill) SetQty(i int64)
- func (f Fill) Value() float64
- type FillEvent
- type FixedCommission
- type FixedExchangeFee
- type IDer
- type Investor
- type Metric
- type MetricHandler
- type Node
- func (n Node) Children() ([]NodeHandler, bool)
- func (n Node) Name() string
- func (n Node) Root() bool
- func (n *Node) SetChildren(children ...NodeHandler) NodeHandler
- func (n *Node) SetName(s string) NodeHandler
- func (n *Node) SetRoot(b bool)
- func (n *Node) SetTolerance(t float64)
- func (n *Node) SetWeight(w float64)
- func (n Node) Tolerance() float64
- func (n Node) Weight() float64
- type NodeHandler
- type OnFiller
- type OnSignaler
- type Order
- func (o *Order) Cancel()
- func (o Order) Direction() Direction
- func (o Order) ID() int
- func (o Order) Limit() float64
- func (o Order) Qty() int64
- func (o *Order) SetDirection(dir Direction)
- func (o *Order) SetID(id int)
- func (o *Order) SetQty(i int64)
- func (o Order) Status() OrderStatus
- func (o Order) Stop() float64
- func (o *Order) Update(fill FillEvent)
- type OrderBook
- func (ob *OrderBook) Add(order OrderEvent) error
- func (ob OrderBook) OrderBy(fn func(order OrderEvent) bool) ([]OrderEvent, bool)
- func (ob OrderBook) Orders() ([]OrderEvent, bool)
- func (ob OrderBook) OrdersAskBySymbol(symbol string) ([]OrderEvent, bool)
- func (ob OrderBook) OrdersBidBySymbol(symbol string) ([]OrderEvent, bool)
- func (ob OrderBook) OrdersBySymbol(symbol string) ([]OrderEvent, bool)
- func (ob OrderBook) OrdersCanceled() ([]OrderEvent, bool)
- func (ob OrderBook) OrdersOpen() ([]OrderEvent, bool)
- func (ob *OrderBook) Remove(id int) error
- type OrderEvent
- type OrderStatus
- type OrderType
- type PercentageCommission
- type Portfolio
- func (p Portfolio) Cash() float64
- func (p Portfolio) Holdings() map[string]Position
- func (p Portfolio) InitialCash() float64
- func (p Portfolio) IsInvested(symbol string) (pos Position, ok bool)
- func (p Portfolio) IsLong(symbol string) (pos Position, ok bool)
- func (p Portfolio) IsShort(symbol string) (pos Position, ok bool)
- func (p *Portfolio) OnFill(fill FillEvent, data DataHandler) (*Fill, error)
- func (p *Portfolio) OnSignal(signal SignalEvent, data DataHandler) (*Order, error)
- func (p Portfolio) OrderBook() ([]OrderEvent, bool)
- func (p Portfolio) OrdersBySymbol(symbol string) ([]OrderEvent, bool)
- func (p *Portfolio) Reset() error
- func (p Portfolio) RiskManager() RiskHandler
- func (p *Portfolio) SetCash(cash float64)
- func (p *Portfolio) SetInitialCash(initial float64)
- func (p *Portfolio) SetRiskManager(risk RiskHandler)
- func (p *Portfolio) SetSizeManager(size SizeHandler)
- func (p Portfolio) SizeManager() SizeHandler
- func (p *Portfolio) Update(d DataEvent)
- func (p Portfolio) Value() float64
- type PortfolioHandler
- type Position
- type Pricer
- type Quantifier
- type Reseter
- type Resulter
- type Risk
- type RiskHandler
- type Signal
- type SignalEvent
- type Size
- type SizeHandler
- type Spreader
- type Statistic
- func (s Statistic) Events() []EventHandler
- func (s Statistic) MaxDrawdown() float64
- func (s Statistic) MaxDrawdownDuration() (d time.Duration)
- func (s Statistic) MaxDrawdownTime() time.Time
- func (s Statistic) PrintResult()
- func (s *Statistic) Reset() error
- func (s *Statistic) SharpRatio(riskfree float64) float64
- func (s *Statistic) SortinoRatio(riskfree float64) float64
- func (s Statistic) TotalEquityReturn() (r float64, err error)
- func (s *Statistic) TrackEvent(e EventHandler)
- func (s *Statistic) TrackTransaction(f FillEvent)
- func (s Statistic) Transactions() []FillEvent
- func (s *Statistic) Update(d DataEvent, p PortfolioHandler)
- type StatisticHandler
- type StatisticPrinter
- type StatisticUpdater
- type Strategy
- func (s *Strategy) AddSignal(signals ...SignalEvent) error
- func (s *Strategy) Assets() ([]*Asset, bool)
- func (s *Strategy) Data() (DataHandler, bool)
- func (s *Strategy) Event() (DataEvent, bool)
- func (s *Strategy) OnData(event DataEvent) (signals []SignalEvent, err error)
- func (s *Strategy) Portfolio() (PortfolioHandler, bool)
- func (s *Strategy) SetAlgo(algos ...AlgoHandler) *Strategy
- func (s *Strategy) SetData(data DataHandler) error
- func (s *Strategy) SetEvent(event DataEvent) error
- func (s *Strategy) SetPortfolio(portfolio PortfolioHandler) error
- func (s *Strategy) Signals() ([]SignalEvent, bool)
- func (s *Strategy) Strategies() ([]StrategyHandler, bool)
- type StrategyHandler
- type Symboler
- type Tick
- type TickEvent
- type Timer
- type TransactionTracker
- type TresholdFixedCommission
- type Updater
- type ValueCommission
- type Valuer
- type WeightHandler
Constants ¶
const DP = 4 // DP
DP sets the the precision of rounded floating numbers used after calculations to format
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Algo ¶
type Algo struct {
// contains filtered or unexported fields
}
Algo is a base algo structure, implements AlgoHandler
type AlgoHandler ¶
type AlgoHandler interface { Run(StrategyHandler) (bool, error) Always() bool SetAlways() Value() float64 }
AlgoHandler defines the base algorythm functionality.
func RunAlways ¶
func RunAlways(a AlgoHandler) AlgoHandler
RunAlways set the runAlways property on the AlgoHandler
type AlgoStack ¶
type AlgoStack struct { Algo // contains filtered or unexported fields }
AlgoStack represents a single stack of algos.
type Asset ¶
type Asset struct {
Node
}
Asset is a data building block for the tree structure, eg. Stock, Option, Cash etc. It implements the NodeHandler interface via the promoted Node field.
func (Asset) Children ¶
func (a Asset) Children() ([]NodeHandler, bool)
Children returns an empty slice and false, an Asset is not allowed to have children.
func (*Asset) SetChildren ¶
func (a *Asset) SetChildren(c ...NodeHandler) NodeHandler
SetChildren return itself without change, as an Asset ist not allowed to have children.
type Backtest ¶
type Backtest struct {
// contains filtered or unexported fields
}
Backtest is the main struct which holds all elements.
func New ¶
func New() *Backtest
New creates a default backtest with sensible defaults ready for use.
func (*Backtest) SetData ¶
func (t *Backtest) SetData(data DataHandler)
SetData sets the data provider to be used within the backtest.
func (*Backtest) SetExchange ¶
func (t *Backtest) SetExchange(exchange ExecutionHandler)
SetExchange sets the execution provider to be used within the backtest.
func (*Backtest) SetPortfolio ¶
func (t *Backtest) SetPortfolio(portfolio PortfolioHandler)
SetPortfolio sets the portfolio provider to be used within the backtest.
func (*Backtest) SetStatistic ¶
func (t *Backtest) SetStatistic(statistic StatisticHandler)
SetStatistic sets the statistic provider to be used within the backtest.
func (*Backtest) SetStrategy ¶
func (t *Backtest) SetStrategy(strategy StrategyHandler)
SetStrategy sets the strategy provider to be used within the backtest.
func (*Backtest) SetSymbols ¶
SetSymbols sets the symbols to include into the backtest.
func (*Backtest) Stats ¶
func (t *Backtest) Stats() StatisticHandler
Stats returns the statistic handler of the backtest.
type Bar ¶
type Bar struct { Event Metric Open float64 High float64 Low float64 Close float64 AdjClose float64 Volume int64 }
Bar declares a data event for an OHLCV bar.
type Booker ¶
type Booker interface { OrderBook() ([]OrderEvent, bool) OrdersBySymbol(symbol string) ([]OrderEvent, bool) }
Booker defines methods for handling the order book of the portfolio
type Casher ¶
type Casher interface { InitialCash() float64 SetInitialCash(float64) Cash() float64 SetCash(float64) }
Casher handles basic portolio info
type CommissionHandler ¶
CommissionHandler is the basic interface for executing orders
type Data ¶
type Data struct {
// contains filtered or unexported fields
}
Data is a basic data provider struct.
func (*Data) Load ¶
Load data events into a stream. This method satisfies the DataLoader interface, but should be overwritten by the specific data loading implementation.
func (*Data) Next ¶
Next returns the first element of the data stream, deletes it from the data stream and appends it to the historic data stream.
func (*Data) Reset ¶
Reset implements Reseter to reset the data struct to a clean state with loaded data events.
func (*Data) SortStream ¶
func (d *Data) SortStream()
SortStream sorts the data stream in ascending order.
type DataEvent ¶
type DataEvent interface { EventHandler MetricHandler Pricer }
DataEvent declares a data event interface
type DataHandler ¶
type DataHandler interface { DataLoader DataStreamer Reseter }
DataHandler is the combined data interface.
type DataLoader ¶
DataLoader defines how to load data into the data stream.
type DataStreamer ¶
type DataStreamer interface { Next() (DataEvent, bool) Stream() []DataEvent History() []DataEvent Latest(string) DataEvent List(string) []DataEvent }
DataStreamer defines data stream functionality.
type Directioner ¶
Directioner defines a direction interface
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event is the implementation of the basic event interface.
type EventHandler ¶
EventHandler declares the basic event interface
type EventTracker ¶
type EventTracker interface { TrackEvent(EventHandler) Events() []EventHandler }
EventTracker is responsible for all event tracking during a backtest
type Exchange ¶
type Exchange struct { Symbol string Commission CommissionHandler ExchangeFee ExchangeFeeHandler }
Exchange is a basic execution handler implementation
func NewExchange ¶
func NewExchange() *Exchange
NewExchange creates a default exchange with sensible defaults ready for use.
func (*Exchange) OnOrder ¶
func (e *Exchange) OnOrder(order OrderEvent, data DataHandler) (*Fill, error)
OnOrder executes an order event
type ExchangeFeeHandler ¶
ExchangeFeeHandler is the basic interface for managing the exchange fee
type ExecutionHandler ¶
type ExecutionHandler interface { OnData(DataEvent) (*Fill, error) OnOrder(OrderEvent, DataHandler) (*Fill, error) }
ExecutionHandler is the basic interface for executing orders
type Fill ¶
type Fill struct { Event Exchange string // exchange symbol // contains filtered or unexported fields }
Fill declares a basic fill event
func (Fill) Commission ¶
Commission returns the Commission field of a fill.
func (Fill) ExchangeFee ¶
ExchangeFee returns the ExchangeFee Field of a fill
func (*Fill) SetDirection ¶
SetDirection sets the Directions field of a Fill
type FillEvent ¶
type FillEvent interface { EventHandler Directioner Quantifier Price() float64 Commission() float64 ExchangeFee() float64 Cost() float64 Value() float64 NetValue() float64 }
FillEvent declares fill event functionality.
type FixedCommission ¶
type FixedCommission struct {
Commission float64
}
FixedCommission is a commission handler implementation which returns a fixed price commission
type FixedExchangeFee ¶
type FixedExchangeFee struct {
ExchangeFee float64
}
FixedExchangeFee returns a fixed exchange fee
func (*FixedExchangeFee) Fee ¶
func (e *FixedExchangeFee) Fee() (float64, error)
Fee returns the set exchange fee of the trade
type Investor ¶
type Investor interface { IsInvested(string) (Position, bool) IsLong(string) (Position, bool) IsShort(string) (Position, bool) }
Investor is an interface to check if a portfolio has a position of a symbol
type Metric ¶
Metric holds metric propertys to a data point.
type MetricHandler ¶
MetricHandler defines the handling of metrics to a data event
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node implements NodeHandler. It represents the base information of each tree node. This is the main building block of the tree.
func (Node) Children ¶
func (n Node) Children() ([]NodeHandler, bool)
Children returns the children of this Node.
func (*Node) SetChildren ¶
func (n *Node) SetChildren(children ...NodeHandler) NodeHandler
SetChildren sets the Children of this Node.
type NodeHandler ¶
type NodeHandler interface { WeightHandler Name() string SetName(string) NodeHandler Root() bool SetRoot(bool) Children() ([]NodeHandler, bool) SetChildren(...NodeHandler) NodeHandler }
NodeHandler defines the basic node functionality.
type OnFiller ¶
type OnFiller interface {
OnFill(FillEvent, DataHandler) (*Fill, error)
}
OnFiller is an interface for the OnFill method
type OnSignaler ¶
type OnSignaler interface {
OnSignal(SignalEvent, DataHandler) (*Order, error)
}
OnSignaler is an interface for the OnSignal method
type Order ¶
type Order struct { Event // contains filtered or unexported fields }
Order declares a basic order event.
func (*Order) SetDirection ¶
SetDirection sets the Directions field of an Order
type OrderBook ¶
type OrderBook struct {
// contains filtered or unexported fields
}
OrderBook represents an order book.
func (*OrderBook) Add ¶
func (ob *OrderBook) Add(order OrderEvent) error
Add an order to the order book.
func (OrderBook) OrderBy ¶
func (ob OrderBook) OrderBy(fn func(order OrderEvent) bool) ([]OrderEvent, bool)
OrderBy returns the order by a select function from the order book.
func (OrderBook) Orders ¶
func (ob OrderBook) Orders() ([]OrderEvent, bool)
Orders returns all Orders from the order book
func (OrderBook) OrdersAskBySymbol ¶
func (ob OrderBook) OrdersAskBySymbol(symbol string) ([]OrderEvent, bool)
OrdersAskBySymbol returns all bid orders of a specific symbol from the order book.
func (OrderBook) OrdersBidBySymbol ¶
func (ob OrderBook) OrdersBidBySymbol(symbol string) ([]OrderEvent, bool)
OrdersBidBySymbol returns all bid orders of a specific symbol from the order book.
func (OrderBook) OrdersBySymbol ¶
func (ob OrderBook) OrdersBySymbol(symbol string) ([]OrderEvent, bool)
OrdersBySymbol returns the order of a specific symbol from the order book.
func (OrderBook) OrdersCanceled ¶
func (ob OrderBook) OrdersCanceled() ([]OrderEvent, bool)
OrdersCanceled returns all orders which are canceled from the order book.
func (OrderBook) OrdersOpen ¶
func (ob OrderBook) OrdersOpen() ([]OrderEvent, bool)
OrdersOpen returns all orders which are open from the order book.
type OrderEvent ¶
type OrderEvent interface { EventHandler Directioner Quantifier IDer Status() OrderStatus Limit() float64 Stop() float64 }
OrderEvent declares the order event interface.
type OrderStatus ¶
type OrderStatus int
OrderStatus defines an order status
const ( OrderNone OrderStatus = iota // 0 OrderNew OrderSubmitted OrderPartiallyFilled OrderFilled OrderCanceled OrderCancelPending OrderInvalid )
different types of order status
type PercentageCommission ¶
type PercentageCommission struct {
Commission float64
}
PercentageCommission is a commission handler implementation which returns a percentage price commission calculated of the value of the trade
type Portfolio ¶
type Portfolio struct {
// contains filtered or unexported fields
}
Portfolio represent a simple portfolio struct.
func NewPortfolio ¶
func NewPortfolio() *Portfolio
NewPortfolio creates a default portfolio with sensible defaults ready for use.
func (Portfolio) InitialCash ¶
InitialCash returns the initial cash value of the portfolio
func (Portfolio) IsInvested ¶
IsInvested checks if the portfolio has an open position on the given symbol
func (Portfolio) IsLong ¶
IsLong checks if the portfolio has an open long position on the given symbol
func (Portfolio) IsShort ¶
IsShort checks if the portfolio has an open short position on the given symbol
func (*Portfolio) OnFill ¶
func (p *Portfolio) OnFill(fill FillEvent, data DataHandler) (*Fill, error)
OnFill handles an incomming fill event
func (*Portfolio) OnSignal ¶
func (p *Portfolio) OnSignal(signal SignalEvent, data DataHandler) (*Order, error)
OnSignal handles an incomming signal event
func (Portfolio) OrderBook ¶
func (p Portfolio) OrderBook() ([]OrderEvent, bool)
OrderBook returns the order book of the portfolio
func (Portfolio) OrdersBySymbol ¶
func (p Portfolio) OrdersBySymbol(symbol string) ([]OrderEvent, bool)
OrdersBySymbol returns the order of a specific symbol from the order book.
func (Portfolio) RiskManager ¶
func (p Portfolio) RiskManager() RiskHandler
RiskManager returns the risk manager of the portfolio.
func (*Portfolio) SetInitialCash ¶
SetInitialCash sets the initial cash value of the portfolio
func (*Portfolio) SetRiskManager ¶
func (p *Portfolio) SetRiskManager(risk RiskHandler)
SetRiskManager sets the risk manager to be used with the portfolio.
func (*Portfolio) SetSizeManager ¶
func (p *Portfolio) SetSizeManager(size SizeHandler)
SetSizeManager sets the size manager to be used with the portfolio.
func (Portfolio) SizeManager ¶
func (p Portfolio) SizeManager() SizeHandler
SizeManager return the size manager of the portfolio.
type PortfolioHandler ¶
PortfolioHandler is the combined interface building block for a portfolio.
type Position ¶
type Position struct {
// contains filtered or unexported fields
}
Position represents the holdings position
func (*Position) UpdateValue ¶
UpdateValue updates the current market value of a position
type Pricer ¶
type Pricer interface {
Price() float64
}
Pricer defines the handling otf the latest Price Information
type Quantifier ¶
Quantifier defines a qty interface.
type Resulter ¶
type Resulter interface { TotalEquityReturn() (float64, error) MaxDrawdown() float64 MaxDrawdownTime() time.Time MaxDrawdownDuration() time.Duration SharpRatio(float64) float64 SortinoRatio(float64) float64 }
Resulter bundles all methods which return the results of the backtest
type Risk ¶
type Risk struct { }
Risk is a basic risk handler implementation
func (*Risk) EvaluateOrder ¶
func (r *Risk) EvaluateOrder(order OrderEvent, data DataEvent, positions map[string]Position) (*Order, error)
EvaluateOrder handles the risk of an order, refines or cancel it
type RiskHandler ¶
type RiskHandler interface {
EvaluateOrder(OrderEvent, DataEvent, map[string]Position) (*Order, error)
}
RiskHandler is the basic interface for accessing risks of a portfolio
type Signal ¶
type Signal struct { Event // contains filtered or unexported fields }
Signal declares a basic signal event
func (*Signal) SetDirection ¶
SetDirection sets the Directions field of a Signal
type SignalEvent ¶
type SignalEvent interface { EventHandler Directioner }
SignalEvent declares the signal event interface.
type Size ¶
Size is a basic size handler implementation
func (*Size) SizeOrder ¶
func (s *Size) SizeOrder(order OrderEvent, data DataEvent, pf PortfolioHandler) (*Order, error)
SizeOrder adjusts the size of an order
type SizeHandler ¶
type SizeHandler interface {
SizeOrder(OrderEvent, DataEvent, PortfolioHandler) (*Order, error)
}
SizeHandler is the basic interface for setting the size of an order
type Spreader ¶
type Spreader interface {
Spread() float64
}
Spreader declares functionality to get spre spread of a tick.
type Statistic ¶
type Statistic struct {
// contains filtered or unexported fields
}
Statistic is a basic test statistic, which holds simple lists of historic events
func (Statistic) Events ¶
func (s Statistic) Events() []EventHandler
Events returns the complete events history
func (Statistic) MaxDrawdown ¶
MaxDrawdown returns the maximum draw down value in percent.
func (Statistic) MaxDrawdownDuration ¶
MaxDrawdownDuration returns the maximum draw down value in percent
func (Statistic) MaxDrawdownTime ¶
MaxDrawdownTime returns the time of the maximum draw down value.
func (Statistic) PrintResult ¶
func (s Statistic) PrintResult()
PrintResult prints the backtest statistics to the screen
func (*Statistic) SharpRatio ¶
SharpRatio returns the Sharp ratio compared to a risk free benchmark return.
func (*Statistic) SortinoRatio ¶
SortinoRatio returns the Sortino ratio compared to a risk free benchmark return.
func (Statistic) TotalEquityReturn ¶
TotalEquityReturn calculates the the total return on the first and last equity point
func (*Statistic) TrackEvent ¶
func (s *Statistic) TrackEvent(e EventHandler)
TrackEvent tracks an event
func (*Statistic) TrackTransaction ¶
TrackTransaction tracks a transaction aka a fill event
func (Statistic) Transactions ¶
Transactions returns the complete events history
func (*Statistic) Update ¶
func (s *Statistic) Update(d DataEvent, p PortfolioHandler)
Update the complete statistics to a given data event.
type StatisticHandler ¶
type StatisticHandler interface { EventTracker TransactionTracker StatisticPrinter Reseter StatisticUpdater Resulter }
StatisticHandler is a basic statistic interface
type StatisticPrinter ¶
type StatisticPrinter interface {
PrintResult()
}
StatisticPrinter handles printing of the statistics to screen
type StatisticUpdater ¶
type StatisticUpdater interface {
Update(DataEvent, PortfolioHandler)
}
StatisticUpdater handles the updateing of the statistics
type Strategy ¶
type Strategy struct { Node // contains filtered or unexported fields }
Strategy implements NodeHandler via Node, used as a strategy building block.
func NewStrategy ¶
NewStrategy return a new strategy node ready to use.
func (*Strategy) AddSignal ¶
func (s *Strategy) AddSignal(signals ...SignalEvent) error
AddSignal sets the data property.
func (*Strategy) Data ¶
func (s *Strategy) Data() (DataHandler, bool)
Data returns the underlying data property.
func (*Strategy) OnData ¶
func (s *Strategy) OnData(event DataEvent) (signals []SignalEvent, err error)
OnData handles an incoming data event. It runs the algo stack on this data.
func (*Strategy) Portfolio ¶
func (s *Strategy) Portfolio() (PortfolioHandler, bool)
Portfolio returns the underlying portfolio property.
func (*Strategy) SetAlgo ¶
func (s *Strategy) SetAlgo(algos ...AlgoHandler) *Strategy
SetAlgo sets the algo stack for the Strategy
func (*Strategy) SetData ¶
func (s *Strategy) SetData(data DataHandler) error
SetData sets the data property.
func (*Strategy) SetPortfolio ¶
func (s *Strategy) SetPortfolio(portfolio PortfolioHandler) error
SetPortfolio sets the portfolio property.
func (*Strategy) Signals ¶
func (s *Strategy) Signals() ([]SignalEvent, bool)
Signals returns a slice of all from th ealgo loop created signals.
func (*Strategy) Strategies ¶
func (s *Strategy) Strategies() ([]StrategyHandler, bool)
Strategies return all children which are a strategy.
type StrategyHandler ¶
type StrategyHandler interface { Data() (DataHandler, bool) SetData(d DataHandler) error Portfolio() (PortfolioHandler, bool) SetPortfolio(p PortfolioHandler) error Event() (DataEvent, bool) SetEvent(DataEvent) error Signals() ([]SignalEvent, bool) AddSignal(...SignalEvent) error Strategies() ([]StrategyHandler, bool) Assets() ([]*Asset, bool) OnData(DataEvent) ([]SignalEvent, error) }
StrategyHandler is a basic strategy interface.
type TransactionTracker ¶
TransactionTracker is responsible for all transaction tracking during a backtest
type TresholdFixedCommission ¶
TresholdFixedCommission is a commission handler implementation which returns a fixed price commission if the value of the trade is above a set treshold
type Updater ¶
type Updater interface {
Update(DataEvent)
}
Updater handles the updating of the portfolio on data events
type ValueCommission ¶
ValueCommission is a commission handler implementation which returns a percentage price commission calculated of the value of the trade, if the value of the trade is within a given commission span