Documentation ¶
Overview ¶
Package trader provides an API for building trading bots. A bot receives prices and execute orders with a broker. Child packages offer specific bot implementations.
Index ¶
- Variables
- type Bot
- type MakeFromConfig
- type Predicter
- type StubBot
- func (b *StubBot) Close(ctx context.Context) error
- func (b *StubBot) ReceivePrice(ctx context.Context, price market.Kline) error
- func (b *StubBot) SetAsset(asset market.Asset)
- func (b *StubBot) SetDealer(dealer broker.Dealer)
- func (b *StubBot) Warmup(ctx context.Context, prices []market.Kline) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidConfig = errors.New("invalid bot config")
ErrInvalidConfig is returned by MakeFromConfig.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot interface { // Warmup the indicators used by the bot with historical data prior to active trading. // The amount of price data required is typically equivalent to the longest lookback. Warmup(context.Context, []market.Kline) error // Sets the dealer to be used for order execution. SetDealer(broker.Dealer) // Sets the asset to trade. SetAsset(market.Asset) // Receive gives the bot the next market price and evaluates the algo, // potentially generating new broker orders. market.Receiver // Clean-up the bot before close down, e.g. close open positions. Close(context.Context) error }
Bot is the primary interface for a trading algo.
type MakeFromConfig ¶
MakeFromConfig is a factory for building a tailored bot from a given config. Used by the optimize package to mint new bots for backtesting.
type Predicter ¶
type Predicter interface { market.Receiver // Predict gives a confidence score between -1 (short) and +1 (long) that a // bot uses to generate buy and sell signals. Predict() float64 // Valid indicates readiness for prediction. Valid() bool }
Predicter is used by a bot to indicate price direction. Child packages provide specific prediction implementations.
Click to show internal directories.
Click to hide internal directories.