support

package
v1.61.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: AGPL-3.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const ID = "support"

Variables

This section is empty.

Functions

This section is empty.

Types

type PercentageTargetStop added in v1.18.0

type PercentageTargetStop struct {
	Targets []Target `json:"targets"`
}

PercentageTargetStop is a kind of stop order by setting fixed percentage target

func (*PercentageTargetStop) GenerateOrders added in v1.18.0

func (stop *PercentageTargetStop) GenerateOrders(market types.Market, pos *types.Position) []types.SubmitOrder

GenerateOrders generates the orders from the given targets

type State added in v1.17.0

type State struct {
	Position            *types.Position   `json:"position,omitempty"`
	CurrentHighestPrice *fixedpoint.Value `json:"currentHighestPrice,omitempty"`
}

type Strategy

type Strategy struct {
	*bbgo.Environment `json:"-"`

	Symbol string       `json:"symbol"`
	Market types.Market `json:"-"`

	// Interval for checking support
	Interval types.Interval `json:"interval"`

	// moving average window for checking support (support should be under the moving average line)
	TriggerMovingAverage types.IntervalWindow `json:"triggerMovingAverage"`

	// LongTermMovingAverage is the second moving average line for checking support position
	LongTermMovingAverage types.IntervalWindow `json:"longTermMovingAverage"`

	Quantity              fixedpoint.Value                `json:"quantity"`
	MinVolume             fixedpoint.Value                `json:"minVolume"`
	Sensitivity           fixedpoint.Value                `json:"sensitivity"`
	TakerBuyRatio         fixedpoint.Value                `json:"takerBuyRatio"`
	MarginOrderSideEffect types.MarginOrderSideEffectType `json:"marginOrderSideEffect"`
	Targets               []Target                        `json:"targets"`

	// Min BaseAsset balance to keep
	MinBaseAssetBalance fixedpoint.Value `json:"minBaseAssetBalance"`
	// Max BaseAsset balance to buy
	MaxBaseAssetBalance  fixedpoint.Value `json:"maxBaseAssetBalance"`
	MinQuoteAssetBalance fixedpoint.Value `json:"minQuoteAssetBalance"`

	ScaleQuantity *bbgo.PriceVolumeScale `json:"scaleQuantity"`

	Position            *types.Position    `persistence:"position"`
	ProfitStats         *types.ProfitStats `persistence:"profit_stats"`
	TradeStats          *types.TradeStats  `persistence:"trade_stats"`
	CurrentHighestPrice fixedpoint.Value   `persistence:"current_highest_price"`

	// Trailing stop
	TrailingStopTarget TrailingStopTarget `json:"trailingStopTarget"`

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

func (*Strategy) ClosePosition added in v1.29.0

func (s *Strategy) ClosePosition(ctx context.Context, percentage fixedpoint.Value) error

func (*Strategy) CurrentPosition added in v1.28.0

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

func (*Strategy) ID

func (s *Strategy) ID() string

func (*Strategy) InstanceID added in v1.33.0

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 added in v1.15.3

func (s *Strategy) Validate() error

type Target

type Target struct {
	ProfitPercentage      fixedpoint.Value                `json:"profitPercentage"`
	QuantityPercentage    fixedpoint.Value                `json:"quantityPercentage"`
	MarginOrderSideEffect types.MarginOrderSideEffectType `json:"marginOrderSideEffect"`
}

type TrailingStopControl added in v1.28.0

type TrailingStopControl struct {
	CurrentHighestPrice fixedpoint.Value
	StopOrder           *types.Order
	// contains filtered or unexported fields
}

func (*TrailingStopControl) GenerateStopOrder added in v1.28.0

func (control *TrailingStopControl) GenerateStopOrder(quantity fixedpoint.Value) types.SubmitOrder

func (*TrailingStopControl) IsHigherThanMin added in v1.28.0

func (control *TrailingStopControl) IsHigherThanMin(minTargetPrice fixedpoint.Value) bool

func (*TrailingStopControl) UpdateCurrentHighestPrice added in v1.36.0

func (control *TrailingStopControl) UpdateCurrentHighestPrice(p fixedpoint.Value) bool

type TrailingStopTarget added in v1.28.0

type TrailingStopTarget struct {
	TrailingStopCallbackRatio fixedpoint.Value `json:"callbackRatio"`
	MinimumProfitPercentage   fixedpoint.Value `json:"minimumProfitPercentage"`
}

Jump to

Keyboard shortcuts

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