Documentation
¶
Index ¶
Constants ¶
const ( StyleBar = "bar" StyleScatter = "scatter" StyleLine = "line" StyleHistogram = "histogram" StyleWaterfall = "waterfall" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChartIndicator ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller runs a strategy on the candles of a pair. A panic of the strategy, eg: an indicator failing on the data of the day, fails the candle it was called on only: recovered, logged with its stack, notified (see SetNotifier) and returned, for the bot to go on with the next candle live, or to stop, eg: in the warmup, where it would come back at every start.
func NewStrategyController ¶
func NewStrategyController(pair string, strategy Strategy, broker service.Broker) *Controller
func (*Controller) OnCandle ¶
func (s *Controller) OnCandle(candle model.Candle) error
OnCandle runs the strategy on candle, a closed one, its indicators only until Start, eg: the candles of the warmup; it returns its panic recovered, see Controller.
func (*Controller) OnPartialCandle ¶
func (s *Controller) OnPartialCandle(candle model.Candle) error
OnPartialCandle runs a high frequency strategy on candle, a candle in progress, returning its panic recovered, see Controller. The strategy is handed the candles kept (see trim), candle the last one.
func (*Controller) SetNotifier ¶
func (s *Controller) SetNotifier(notifier service.Notifier)
SetNotifier sets who is notified of the panics of the strategy, see Controller.
func (*Controller) Start ¶
func (s *Controller) Start()
type HighFrequencyStrategy ¶
type IndicatorMetric ¶
type LLMStrategy ¶
LLMStrategy is a strategy whose decisions a language model makes, an LLM: the application offers what goes with it, eg: the justifications of the decisions and their reanalysis on demand (see ui.DecisionSource and ui.Reanalyzer), which the other strategies go without. LLM names the model, eg: openai gpt-5-mini.
type MetricStyle ¶
type MetricStyle string
type Strategy ¶
type Strategy interface {
// Timeframe is the time interval in which the strategy will be executed. eg: 1h, 1d, 1w
Timeframe() string
// WarmupPeriod is the necessary time to wait before executing the strategy, to load data for indicators.
// This time is measured in the period specified in the `Timeframe` function.
WarmupPeriod() int
// Indicators will be executed for each new candle, in order to fill indicators before `OnCandle` function is called.
Indicators(df *model.Dataframe) []ChartIndicator
// OnCandle will be executed for each new candle, after indicators are filled, here you can do your trading logic.
// OnCandle is executed after the candle close.
OnCandle(df *model.Dataframe, broker service.Broker)
}