Documentation ¶
Index ¶
- Constants
- Variables
- type DriftMA
- 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(time types.Time, profit types.Series, cumProfit types.Series)
- func (s *Strategy) DrawCumPNL(cumProfit types.Series) *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) InstanceID() string
- func (s *Strategy) ParamDump(f io.Writer, seriesLength ...int)
- 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) 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.StrategyController types.Market types.IntervalWindow bbgo.SourceSelector *bbgo.Environment *types.Position `persistence:"position"` *types.ProfitStats `persistence:"profit_stats"` *types.TradeStats `persistence:"trade_stats"` StopLoss fixedpoint.Value `json:"stoploss" modifiable:"true"` CanvasPath string `json:"canvasPath"` PredictOffset int `json:"predictOffset"` HighLowVarianceMultiplier float64 `json:"hlVarianceMultiplier" modifiable:"true"` NoTrailingStopLoss bool `json:"noTrailingStopLoss" modifiable:"true"` TrailingStopLossType string `json:"trailingStopLossType" modifiable:"true"` // trailing stop sources. Possible options are `kline` for 1m kline and `realtime` from order updates HLRangeWindow int `json:"hlRangeWindow"` Window1m int `json:"window1m"` FisherTransformWindow1m int `json:"fisherTransformWindow1m"` SmootherWindow1m int `json:"smootherWindow1m"` SmootherWindow int `json:"smootherWindow"` FisherTransformWindow int `json:"fisherTransformWindow"` ATRWindow int `json:"atrWindow"` PendingMinutes int `json:"pendingMinutes" modifiable:"true"` // if order not be traded for pendingMinutes 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"` DriftFilterNeg float64 `json:"driftFilterNeg" modifiable:"true"` DriftFilterPos float64 `json:"driftFilterPos" modifiable:"true"` DDriftFilterNeg float64 `json:"ddriftFilterNeg" modifiable:"true"` DDriftFilterPos float64 `json:"ddriftFilterPos" 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"` GraphPNLPath string `json:"graphPNLPath"` GraphCumPNLPath string `json:"graphCumPNLPath"` // Whether to generate graph when shutdown GenerateGraph bool `json:"generateGraph"` ExitMethods bbgo.ExitMethodSet `json:"exits"` Session *bbgo.ExchangeSession *bbgo.GeneralOrderExecutor // contains filtered or unexported fields }
func (*Strategy) CalcAssetValue ¶ added in v1.39.0
func (s *Strategy) CalcAssetValue(price fixedpoint.Value) fixedpoint.Value
func (*Strategy) ClosePosition ¶
func (*Strategy) CurrentPosition ¶
func (*Strategy) DrawCumPNL ¶ added in v1.39.0
func (*Strategy) DrawIndicators ¶ added in v1.39.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) Subscribe ¶
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession)
Click to show internal directories.
Click to hide internal directories.