pivotshort

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: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ID = "pivotshort"

Variables

This section is empty.

Functions

This section is empty.

Types

type BreakLow

type BreakLow struct {
	Symbol string
	Market types.Market
	types.IntervalWindow

	// FastWindow is used for fast pivot (this is to filter the nearest high/low)
	FastWindow int `json:"fastWindow"`

	// Ratio is a number less than 1.0, price * ratio will be the price triggers the short order.
	Ratio fixedpoint.Value `json:"ratio"`

	bbgo.OpenPositionOptions

	// BounceRatio is a ratio used for placing the limit order sell price
	// limit sell price = breakLowPrice * (1 + BounceRatio)
	BounceRatio fixedpoint.Value `json:"bounceRatio"`

	StopEMA *bbgo.StopEMA `json:"stopEMA"`

	TrendEMA *bbgo.TrendEMA `json:"trendEMA"`

	FakeBreakStop *FakeBreakStop `json:"fakeBreakStop"`

	// StrategyController
	bbgo.StrategyController
	// contains filtered or unexported fields
}

BreakLow -- when price breaks the previous pivot low, we set a trade entry

func (*BreakLow) Bind

func (s *BreakLow) Bind(session *bbgo.ExchangeSession, orderExecutor *bbgo.GeneralOrderExecutor)

func (*BreakLow) Subscribe

func (s *BreakLow) Subscribe(session *bbgo.ExchangeSession)

type FailedBreakHigh

type FailedBreakHigh struct {
	Symbol string
	Market types.Market

	// IntervalWindow is used for finding the pivot high
	types.IntervalWindow

	FastWindow int

	bbgo.OpenPositionOptions

	// BreakInterval is used for checking failed break
	BreakInterval types.Interval `json:"breakInterval"`

	Enabled bool `json:"enabled"`

	// Ratio is a number less than 1.0, price * ratio will be the price triggers the short order.
	Ratio fixedpoint.Value `json:"ratio"`

	// EarlyStopRatio adjusts the break high price with the given ratio
	// this is for stop loss earlier if the price goes above the previous price
	EarlyStopRatio fixedpoint.Value `json:"earlyStopRatio"`

	VWMA *types.IntervalWindow `json:"vwma"`

	StopEMA *bbgo.StopEMA `json:"stopEMA"`

	TrendEMA *bbgo.TrendEMA `json:"trendEMA"`

	MACDDivergence *MACDDivergence `json:"macdDivergence"`

	// StrategyController
	bbgo.StrategyController
	// contains filtered or unexported fields
}

FailedBreakHigh -- when price breaks the previous pivot low, we set a trade entry

func (*FailedBreakHigh) Bind

func (s *FailedBreakHigh) Bind(session *bbgo.ExchangeSession, orderExecutor *bbgo.GeneralOrderExecutor)

func (*FailedBreakHigh) Subscribe

func (s *FailedBreakHigh) Subscribe(session *bbgo.ExchangeSession)

type FakeBreakStop

type FakeBreakStop struct {
	types.IntervalWindow
}

type MACDDivergence

type MACDDivergence struct {
	*indicator.MACDConfig
	PivotWindow int `json:"pivotWindow"`
}

type ResistanceShort

type ResistanceShort struct {
	Enabled bool         `json:"enabled"`
	Symbol  string       `json:"-"`
	Market  types.Market `json:"-"`

	types.IntervalWindow

	MinDistance   fixedpoint.Value `json:"minDistance"`
	GroupDistance fixedpoint.Value `json:"groupDistance"`
	NumLayers     int              `json:"numLayers"`
	LayerSpread   fixedpoint.Value `json:"layerSpread"`
	Quantity      fixedpoint.Value `json:"quantity"`
	Leverage      fixedpoint.Value `json:"leverage"`
	Ratio         fixedpoint.Value `json:"ratio"`

	TrendEMA *bbgo.TrendEMA `json:"trendEMA"`

	// StrategyController
	bbgo.StrategyController
	// contains filtered or unexported fields
}

func (*ResistanceShort) Bind

func (s *ResistanceShort) Bind(session *bbgo.ExchangeSession, orderExecutor *bbgo.GeneralOrderExecutor)

func (*ResistanceShort) Subscribe

func (s *ResistanceShort) Subscribe(session *bbgo.ExchangeSession)

type Strategy

type Strategy struct {
	Environment *bbgo.Environment
	Symbol      string `json:"symbol"`
	Market      types.Market

	// pivot interval and window
	types.IntervalWindow

	Leverage fixedpoint.Value `json:"leverage"`
	Quantity fixedpoint.Value `json:"quantity"`

	Position    *types.Position    `persistence:"position"`
	ProfitStats *types.ProfitStats `persistence:"profit_stats"`
	TradeStats  *types.TradeStats  `persistence:"trade_stats"`

	// BreakLow is one of the entry method
	BreakLow        *BreakLow        `json:"breakLow"`
	FailedBreakHigh *FailedBreakHigh `json:"failedBreakHigh"`

	// ResistanceShort is one of the entry method
	ResistanceShort *ResistanceShort `json:"resistanceShort"`

	ExitMethods bbgo.ExitMethodSet `json:"exits"`

	// StrategyController
	bbgo.StrategyController
	// contains filtered or unexported fields
}

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) ID

func (s *Strategy) ID() string

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)

Jump to

Keyboard shortcuts

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