Documentation
¶
Index ¶
- Constants
- func DrawCumPNL(instanceID string, cumProfit types.Series) *types.Canvas
- func DrawPNL(instanceID string, profit types.Series) *types.Canvas
- type DoubleDema
- type LinReg
- func (lr *LinReg) BindK(target indicator.KLineClosedEmitter, symbol string, interval types.Interval)
- func (lr *LinReg) GetSignal() types.Direction
- func (lr *LinReg) Index(i int) float64
- func (lr *LinReg) Last(i int) float64
- func (lr *LinReg) Length() int
- func (lr *LinReg) LoadK(allKLines []types.KLine)
- func (lr *LinReg) PushK(k types.KLine)
- func (lr *LinReg) Update(kline types.KLine)
- type Strategy
- func (s *Strategy) CalcAssetValue(price fixedpoint.Value) fixedpoint.Value
- func (s *Strategy) ClosePosition(ctx context.Context, percentage fixedpoint.Value) error
- func (s *Strategy) CurrentPosition() *types.Position
- func (s *Strategy) Draw(profit, cumProfit types.Series) error
- func (s *Strategy) ID() string
- func (s *Strategy) InitDrawCommands(profit, cumProfit types.Series)
- func (s *Strategy) InstanceID() string
- func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, ...) error
- func (s *Strategy) Subscribe(session *bbgo.ExchangeSession)
- func (s *Strategy) Validate() error
Constants ¶
View Source
const ID = "supertrend"
Variables ¶
This section is empty.
Functions ¶
func DrawCumPNL ¶ added in v1.40.3
Types ¶
type DoubleDema ¶ added in v1.36.0
type DoubleDema struct {
Interval types.Interval `json:"interval"`
// FastDEMAWindow DEMA window for checking breakout
FastDEMAWindow int `json:"fastDEMAWindow"`
// SlowDEMAWindow DEMA window for checking breakout
SlowDEMAWindow int `json:"slowDEMAWindow"`
// contains filtered or unexported fields
}
type LinReg ¶ added in v1.39.0
type LinReg struct {
types.SeriesBase
types.IntervalWindow
// Values are the slopes of linear regression baseline
Values floats.Slice
EndTime time.Time
// contains filtered or unexported fields
}
LinReg is Linear Regression baseline
type Strategy ¶
type Strategy struct {
Environment *bbgo.Environment
Market types.Market
// persistence fields
Position *types.Position `persistence:"position"`
ProfitStats *types.ProfitStats `persistence:"profit_stats"`
TradeStats *types.TradeStats `persistence:"trade_stats"`
// ProfitStatsTracker tracks profit related status and generates report
ProfitStatsTracker *report.ProfitStatsTracker `json:"profitStatsTracker"`
TrackParameters bool `json:"trackParameters"`
// Symbol is the market symbol you want to trade
Symbol string `json:"symbol"`
types.IntervalWindow
// FastDEMAWindow DEMA window for checking breakout
FastDEMAWindow int `json:"fastDEMAWindow"`
// SlowDEMAWindow DEMA window for checking breakout
SlowDEMAWindow int `json:"slowDEMAWindow"`
// SuperTrend indicator
Supertrend *indicator.Supertrend
// SupertrendMultiplier ATR multiplier for calculation of supertrend
SupertrendMultiplier float64 `json:"supertrendMultiplier"`
// LinearRegression Use linear regression as trend confirmation
LinearRegression *LinReg `json:"linearRegression,omitempty"`
// Leverage uses the account net value to calculate the order qty
Leverage fixedpoint.Value `json:"leverage"`
// Quantity sets the fixed order qty, takes precedence over Leverage
Quantity fixedpoint.Value `json:"quantity"`
AccountValueCalculator *bbgo.AccountValueCalculator
// TakeProfitAtrMultiplier TP according to ATR multiple, 0 to disable this
TakeProfitAtrMultiplier float64 `json:"takeProfitAtrMultiplier"`
// StopLossByTriggeringK Set SL price to the low/high of the triggering Kline
StopLossByTriggeringK bool `json:"stopLossByTriggeringK"`
// StopByReversedSupertrend TP/SL by reversed supertrend signal
StopByReversedSupertrend bool `json:"stopByReversedSupertrend"`
// StopByReversedDema TP/SL by reversed DEMA signal
StopByReversedDema bool `json:"stopByReversedDema"`
// StopByReversedLinGre TP/SL by reversed linear regression signal
StopByReversedLinGre bool `json:"stopByReversedLinGre"`
// ExitMethods Exit methods
ExitMethods bbgo.ExitMethodSet `json:"exits"`
// whether to draw graph or not by the end of backtest
DrawGraph bool `json:"drawGraph"`
GraphPNLPath string `json:"graphPNLPath"`
GraphCumPNLPath string `json:"graphCumPNLPath"`
// StrategyController
bbgo.StrategyController
// contains filtered or unexported fields
}
func (*Strategy) CalcAssetValue ¶ added in v1.40.3
func (s *Strategy) CalcAssetValue(price fixedpoint.Value) fixedpoint.Value
func (*Strategy) ClosePosition ¶
func (*Strategy) CurrentPosition ¶
func (*Strategy) InitDrawCommands ¶ added in v1.40.3
func (*Strategy) InstanceID ¶
func (*Strategy) Run ¶
func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error
func (*Strategy) Subscribe ¶
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession)
Click to show internal directories.
Click to hide internal directories.