support

package
v0.0.0-...-8d88297 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ID = "support"

Variables

This section is empty.

Functions

This section is empty.

Types

type PercentageTargetStop

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

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

func (*PercentageTargetStop) GenerateOrders

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

GenerateOrders generates the orders from the given targets

type State

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

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)

func (*Strategy) Validate

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

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

func (*TrailingStopControl) GenerateStopOrder

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

func (*TrailingStopControl) IsHigherThanMin

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

func (*TrailingStopControl) UpdateCurrentHighestPrice

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

type TrailingStopTarget

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