Documentation ¶
Index ¶
- Constants
- Variables
- type DriftMA
- type Strategy
- func (s *Strategy) CalcAssetValue(price fixedpoint.Value) fixedpoint.Value
- func (s *Strategy) CheckStopLoss() bool
- func (s *Strategy) ClosePosition(ctx context.Context, percentage fixedpoint.Value) error
- func (s *Strategy) CurrentPosition() *types.Position
- func (s *Strategy) Draw(time types.Time, profit types.Series, cumProfit types.Series)
- func (s *Strategy) DrawCumPNL(cumProfit types.Series) *types.Canvas
- func (s *Strategy) DrawElapsed() *types.Canvas
- func (s *Strategy) DrawIndicators(time types.Time) *types.Canvas
- func (s *Strategy) DrawPNL(profit types.Series) *types.Canvas
- func (s *Strategy) ID() string
- func (s *Strategy) InitDrawCommands(profit, cumProfit types.Series)
- func (s *Strategy) InstanceID() string
- func (s *Strategy) Print(f io.Writer, pretty bool, withColor ...bool)
- func (s *Strategy) Rebalance(ctx context.Context)
- func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, ...) error
- func (s *Strategy) SubmitOrder(ctx context.Context, submitOrder types.SubmitOrder) (*types.Order, error)
- func (s *Strategy) Subscribe(session *bbgo.ExchangeSession)
Constants ¶
View Source
const ID = "drift"
Variables ¶
View Source
var Delta fixedpoint.Value = fixedpoint.NewFromFloat(0.01)
View Source
var Fee = 0.0008 // taker fee % * 2, for upper bound
View Source
var Four fixedpoint.Value = fixedpoint.NewFromInt(4)
View Source
var Three fixedpoint.Value = fixedpoint.NewFromInt(3)
View Source
var Two fixedpoint.Value = fixedpoint.NewFromInt(2)
Functions ¶
This section is empty.
Types ¶
type DriftMA ¶
type DriftMA struct { types.SeriesBase // contains filtered or unexported fields }
func (*DriftMA) TestUpdate ¶
type Strategy ¶
type Strategy struct { Symbol string `json:"symbol"` bbgo.OpenPositionOptions bbgo.StrategyController types.Market types.IntervalWindow bbgo.SourceSelector *bbgo.Environment *types.Position `persistence:"position"` *types.ProfitStats `persistence:"profit_stats"` *types.TradeStats `persistence:"trade_stats"` MinInterval types.Interval `json:"MinInterval"` // minimum interval referred for doing stoploss/trailing exists and updating highest/lowest Debug bool `json:"debug" modifiable:"true"` // to print debug message or not UseStopLoss bool `json:"useStopLoss" modifiable:"true"` // whether to use stoploss rate to do stoploss UseAtr bool `json:"useAtr" modifiable:"true"` // use atr as stoploss StopLoss fixedpoint.Value `json:"stoploss" modifiable:"true"` // stoploss rate PredictOffset int `json:"predictOffset"` // the lookback length for the prediction using linear regression HighLowVarianceMultiplier float64 `json:"hlVarianceMultiplier" modifiable:"true"` // modifier to set the limit order price NoTrailingStopLoss bool `json:"noTrailingStopLoss" modifiable:"true"` // turn off the trailing exit and stoploss HLRangeWindow int `json:"hlRangeWindow"` // ma window for kline high/low changes SmootherWindow int `json:"smootherWindow"` // window that controls the smoothness of drift FisherTransformWindow int `json:"fisherTransformWindow"` // fisher transform window to filter drift's negative signals ATRWindow int `json:"atrWindow"` // window for atr indicator PendingMinInterval int `json:"pendingMinInterval" modifiable:"true"` // if order not be traded for pendingMinInterval of time, cancel it. NoRebalance bool `json:"noRebalance" modifiable:"true"` // disable rebalance TrendWindow int `json:"trendWindow"` // trendLine is used for rebalancing the position. When trendLine goes up, hold base, otherwise hold quote RebalanceFilter float64 `json:"rebalanceFilter" modifiable:"true"` // beta filter on the Linear Regression of trendLine TrailingCallbackRate []float64 `json:"trailingCallbackRate" modifiable:"true"` TrailingActivationRatio []float64 `json:"trailingActivationRatio" modifiable:"true"` // This is not related to trade but for statistics graph generation // Will deduct fee in percentage from every trade GraphPNLDeductFee bool `json:"graphPNLDeductFee"` CanvasPath string `json:"canvasPath"` // backtest related. the path to store the indicator graph GraphPNLPath string `json:"graphPNLPath"` // backtest related. the path to store the pnl % graph per trade graph. GraphCumPNLPath string `json:"graphCumPNLPath"` // backtest related. the path to store the asset changes in graph GraphElapsedPath string `json:"graphElapsedPath"` // the path to store the elapsed time in ms GenerateGraph bool `json:"generateGraph"` // whether to generate graph when shutdown ExitMethods bbgo.ExitMethodSet `json:"exits"` Session *bbgo.ExchangeSession *bbgo.FastOrderExecutor // contains filtered or unexported fields }
func (*Strategy) CalcAssetValue ¶ added in v1.39.0
func (s *Strategy) CalcAssetValue(price fixedpoint.Value) fixedpoint.Value
func (*Strategy) CheckStopLoss ¶ added in v1.42.0
func (*Strategy) ClosePosition ¶
func (*Strategy) CurrentPosition ¶
func (*Strategy) DrawCumPNL ¶ added in v1.39.0
func (*Strategy) DrawElapsed ¶ added in v1.43.0
func (*Strategy) DrawIndicators ¶ added in v1.39.0
func (*Strategy) InitDrawCommands ¶ added in v1.43.0
func (*Strategy) InstanceID ¶
func (*Strategy) Rebalance ¶ added in v1.39.0
Sending new rebalance orders cost too much. Modify the position instead to expect the strategy itself rebalance on Close
func (*Strategy) Run ¶
func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error
func (*Strategy) SubmitOrder ¶ added in v1.43.0
func (*Strategy) Subscribe ¶
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession)
Click to show internal directories.
Click to hide internal directories.