supertrend

package
v0.0.0-...-c0411a1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ID = "supertrend"

Variables

This section is empty.

Functions

func DrawCumPNL

func DrawCumPNL(instanceID string, cumProfit types.Series) *types.Canvas

func DrawPNL

func DrawPNL(instanceID string, profit types.Series) *types.Canvas

Types

type DoubleDema

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

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

func (*LinReg) BindK

func (lr *LinReg) BindK(target indicator.KLineClosedEmitter, symbol string, interval types.Interval)

func (*LinReg) GetSignal

func (lr *LinReg) GetSignal() types.Direction

GetSignal get linear regression signal

func (*LinReg) Index

func (lr *LinReg) Index(i int) float64

Index returns the slope of specified index

func (*LinReg) Last

func (lr *LinReg) Last(i int) float64

Last slope of linear regression baseline

func (*LinReg) Length

func (lr *LinReg) Length() int

Length of the slope values

func (*LinReg) LoadK

func (lr *LinReg) LoadK(allKLines []types.KLine)

func (*LinReg) PushK

func (lr *LinReg) PushK(k types.KLine)

func (*LinReg) Update

func (lr *LinReg) Update(kline types.KLine)

Update Linear Regression baseline slope

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

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(profit, cumProfit types.Series) error

func (*Strategy) ID

func (s *Strategy) ID() string

func (*Strategy) InitDrawCommands

func (s *Strategy) InitDrawCommands(profit, cumProfit types.Series)

func (*Strategy) InstanceID

func (s *Strategy) InstanceID() string

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)

func (*Strategy) Validate

func (s *Strategy) Validate() error

Jump to

Keyboard shortcuts

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