Documentation
¶
Overview ¶
Package engine is the low-level backtest/live execution mechanism: the Trader type, which drives an execution.Broker and drains its event queue while tracking open lots. It is pure mechanism with no notion of a "run" — the higher-level backtest package orchestrates runs on top of it (backtest -> engine; engine never imports backtest).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CandleSource ¶
type CandleSource interface {
Candles(context.Context, datamanager.CandleRequest) (market.CandleIterator, error)
}
CandleSource provides candle iterators for backtest and replay execution. datamanager.DataManager satisfies this interface.
type Trader ¶
type Trader struct {
DataManager CandleSource
*execution.Broker
}
Trader couples a candle source with the broker/account it drives. It owns the broker event loop; backtest and live orchestration call its exported primitives to run a session.
func (*Trader) BrokerEventError ¶
BrokerEventError returns the first pending broker-event error without blocking, or nil if none is queued.
func (*Trader) StartBrokerEventHandler ¶
func (t *Trader) StartBrokerEventHandler(ctx context.Context, evtQ <-chan *execution.Event, processed *int64) (<-chan error, <-chan struct{})
StartBrokerEventHandler launches the goroutine that drains the broker event queue, processing each event and reporting the first error on the returned error channel. The done channel closes when the handler exits.