drift

package
v1.40.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2022 License: AGPL-3.0 Imports: 24 Imported by: 1

Documentation

Index

Constants

View Source
const ID = "drift"

Variables

View Source
var Fee = 0.0008 // taker fee % * 2, for upper bound

Functions

This section is empty.

Types

type DriftMA

type DriftMA struct {
	types.SeriesBase
	// contains filtered or unexported fields
}

func (*DriftMA) Clone

func (s *DriftMA) Clone() *DriftMA

func (*DriftMA) Index

func (s *DriftMA) Index(i int) float64

func (*DriftMA) Last

func (s *DriftMA) Last() float64

func (*DriftMA) Length

func (s *DriftMA) Length() int

func (*DriftMA) TestUpdate

func (s *DriftMA) TestUpdate(v, weight float64) *DriftMA

func (*DriftMA) Update

func (s *DriftMA) Update(value, weight float64)

func (*DriftMA) ZeroPoint

func (s *DriftMA) ZeroPoint() float64

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"`
	CanvasPath                string           `json:"canvasPath"`
	PredictOffset             int              `json:"predictOffset"`
	HighLowVarianceMultiplier float64          `json:"hlVarianceMultiplier"`
	NoTrailingStopLoss        bool             `json:"noTrailingStopLoss"`
	TrailingStopLossType      string           `json:"trailingStopLossType"` // 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"`  // if order not be traded for pendingMinutes of time, cancel it.
	NoRebalance               bool             `json:"noRebalance"`     // 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"` // beta filter on the Linear Regression of trendLine
	TrailingCallbackRate      []float64        `json:"trailingCallbackRate"`
	TrailingActivationRatio   []float64        `json:"trailingActivationRatio"`

	DriftFilterNeg  float64 `json:"driftFilterNeg"`
	DriftFilterPos  float64 `json:"driftFilterPos"`
	DDriftFilterNeg float64 `json:"ddriftFilterNeg"`
	DDriftFilterPos float64 `json:"ddriftFilterPos"`

	// 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 (s *Strategy) ClosePosition(ctx context.Context, percentage fixedpoint.Value) error

func (*Strategy) CurrentPosition

func (s *Strategy) CurrentPosition() *types.Position

func (*Strategy) Draw

func (s *Strategy) Draw(time types.Time, profit types.Series, cumProfit types.Series)

func (*Strategy) DrawCumPNL added in v1.39.0

func (s *Strategy) DrawCumPNL(cumProfit types.Series) *types.Canvas

func (*Strategy) DrawIndicators added in v1.39.0

func (s *Strategy) DrawIndicators(time types.Time) *types.Canvas

func (*Strategy) DrawPNL added in v1.39.0

func (s *Strategy) DrawPNL(profit types.Series) *types.Canvas

func (*Strategy) ID

func (s *Strategy) ID() string

func (*Strategy) InstanceID

func (s *Strategy) InstanceID() string

func (*Strategy) ParamDump added in v1.39.0

func (s *Strategy) ParamDump(f io.Writer, seriesLength ...int)

func (*Strategy) Print

func (s *Strategy) Print(f io.Writer, pretty bool, withColor ...bool)

func (*Strategy) Rebalance added in v1.39.0

func (s *Strategy) Rebalance(ctx context.Context)

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL