xmaker

package
v1.60.3 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: AGPL-3.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SignalNumberMaxLong  = 2.0
	SignalNumberMaxShort = -2.0
)
View Source
const ID = "xmaker"

Variables

This section is empty.

Functions

This section is empty.

Types

type BollingerBandTrendSignal added in v1.60.1

type BollingerBandTrendSignal struct {
	types.IntervalWindow
	MinBandWidth float64 `json:"minBandWidth"`
	MaxBandWidth float64 `json:"maxBandWidth"`
	// contains filtered or unexported fields
}

func (*BollingerBandTrendSignal) Bind added in v1.60.1

func (s *BollingerBandTrendSignal) Bind(ctx context.Context, session *bbgo.ExchangeSession, symbol string) error

func (*BollingerBandTrendSignal) CalculateSignal added in v1.60.1

func (s *BollingerBandTrendSignal) CalculateSignal(ctx context.Context) (float64, error)

type KLineShapeSignal added in v1.60.1

type KLineShapeSignal struct {
	FullBodyThreshold float64 `json:"fullBodyThreshold"`
}

type OrderBookBestPriceVolumeSignal added in v1.60.1

type OrderBookBestPriceVolumeSignal struct {
	RatioThreshold fixedpoint.Value `json:"ratioThreshold"`
	MinVolume      fixedpoint.Value `json:"minVolume"`
	// contains filtered or unexported fields
}

func (*OrderBookBestPriceVolumeSignal) Bind added in v1.60.1

func (*OrderBookBestPriceVolumeSignal) CalculateSignal added in v1.60.1

func (s *OrderBookBestPriceVolumeSignal) CalculateSignal(ctx context.Context) (float64, error)

type ProfitStats added in v1.17.0

type ProfitStats struct {
	*types.ProfitStats

	MakerExchange types.ExchangeName `json:"makerExchange"`

	AccumulatedMakerVolume    fixedpoint.Value `json:"accumulatedMakerVolume,omitempty"`
	AccumulatedMakerBidVolume fixedpoint.Value `json:"accumulatedMakerBidVolume,omitempty"`
	AccumulatedMakerAskVolume fixedpoint.Value `json:"accumulatedMakerAskVolume,omitempty"`

	TodayMakerVolume    fixedpoint.Value `json:"todayMakerVolume,omitempty"`
	TodayMakerBidVolume fixedpoint.Value `json:"todayMakerBidVolume,omitempty"`
	TodayMakerAskVolume fixedpoint.Value `json:"todayMakerAskVolume,omitempty"`
	// contains filtered or unexported fields
}

func (*ProfitStats) AddTrade added in v1.17.0

func (s *ProfitStats) AddTrade(trade types.Trade)

func (*ProfitStats) ResetToday added in v1.17.0

func (s *ProfitStats) ResetToday()

type Quote added in v1.60.1

type Quote struct {
	BestBidPrice, BestAskPrice fixedpoint.Value

	BidMargin, AskMargin fixedpoint.Value

	// BidLayerPips is the price pips between each layer
	BidLayerPips, AskLayerPips fixedpoint.Value
}

type SessionBinder added in v1.60.1

type SessionBinder interface {
	Bind(ctx context.Context, session *bbgo.ExchangeSession, symbol string) error
}

type SignalConfig added in v1.60.1

type SignalConfig struct {
	Weight                   float64                         `json:"weight"`
	BollingerBandTrendSignal *BollingerBandTrendSignal       `json:"bollingerBandTrend,omitempty"`
	OrderBookBestPriceSignal *OrderBookBestPriceVolumeSignal `json:"orderBookBestPrice,omitempty"`
	KLineShapeSignal         *KLineShapeSignal               `json:"klineShape,omitempty"`
	TradeVolumeWindowSignal  *TradeVolumeWindowSignal        `json:"tradeVolumeWindow,omitempty"`
}

type SignalNumber added in v1.60.1

type SignalNumber float64

type SignalProvider added in v1.60.1

type SignalProvider interface {
	CalculateSignal(ctx context.Context) (float64, error)
}

type State

type State struct {
	CoveredPosition fixedpoint.Value `json:"coveredPosition,omitempty"`

	// Deprecated:
	Position *types.Position `json:"position,omitempty"`

	// Deprecated:
	ProfitStats ProfitStats `json:"profitStats,omitempty"`
}

type Strategy

type Strategy struct {
	Environment *bbgo.Environment

	Symbol string `json:"symbol"`

	// SourceExchange session name
	SourceExchange string `json:"sourceExchange"`

	// MakerExchange session name
	MakerExchange string `json:"makerExchange"`

	UpdateInterval      types.Duration `json:"updateInterval"`
	HedgeInterval       types.Duration `json:"hedgeInterval"`
	OrderCancelWaitTime types.Duration `json:"orderCancelWaitTime"`

	EnableSignalMargin bool            `json:"enableSignalMargin"`
	SignalConfigList   []SignalConfig  `json:"signals"`
	SignalMarginScale  *bbgo.SlideRule `json:"signalMarginScale,omitempty"`

	Margin           fixedpoint.Value `json:"margin"`
	BidMargin        fixedpoint.Value `json:"bidMargin"`
	AskMargin        fixedpoint.Value `json:"askMargin"`
	UseDepthPrice    bool             `json:"useDepthPrice"`
	DepthQuantity    fixedpoint.Value `json:"depthQuantity"`
	SourceDepthLevel types.Depth      `json:"sourceDepthLevel"`

	EnableBollBandMargin bool             `json:"enableBollBandMargin"`
	BollBandInterval     types.Interval   `json:"bollBandInterval"`
	BollBandMargin       fixedpoint.Value `json:"bollBandMargin"`
	BollBandMarginFactor fixedpoint.Value `json:"bollBandMarginFactor"`

	// MinMarginLevel is the minimum margin level to trigger the hedge
	MinMarginLevel fixedpoint.Value `json:"minMarginLevel"`

	StopHedgeQuoteBalance fixedpoint.Value `json:"stopHedgeQuoteBalance"`
	StopHedgeBaseBalance  fixedpoint.Value `json:"stopHedgeBaseBalance"`

	// Quantity is used for fixed quantity of the first layer
	Quantity fixedpoint.Value `json:"quantity"`

	// QuantityMultiplier is the factor that multiplies the quantity of the previous layer
	QuantityMultiplier fixedpoint.Value `json:"quantityMultiplier"`

	// QuantityScale helps user to define the quantity by layer scale
	QuantityScale *bbgo.LayerScale `json:"quantityScale,omitempty"`

	// MaxExposurePosition defines the unhedged quantity of stop
	MaxExposurePosition fixedpoint.Value `json:"maxExposurePosition"`

	MaxHedgeAccountLeverage fixedpoint.Value `json:"maxHedgeAccountLeverage"`

	DisableHedge bool `json:"disableHedge"`

	NotifyTrade bool `json:"notifyTrade"`

	EnableArbitrage bool `json:"arbitrage"`

	// RecoverTrade tries to find the missing trades via the REStful API
	RecoverTrade bool `json:"recoverTrade"`

	RecoverTradeScanPeriod types.Duration `json:"recoverTradeScanPeriod"`

	NumLayers int `json:"numLayers"`

	// Pips is the pips of the layer prices
	Pips fixedpoint.Value `json:"pips"`

	// ProfitFixerConfig is the profit fixer configuration
	ProfitFixerConfig *common.ProfitFixerConfig `json:"profitFixer,omitempty"`

	CircuitBreaker *circuitbreaker.BasicCircuitBreaker `json:"circuitBreaker"`

	// persistence fields
	Position        *types.Position  `json:"position,omitempty" persistence:"position"`
	ProfitStats     *ProfitStats     `json:"profitStats,omitempty" persistence:"profit_stats"`
	CoveredPosition fixedpoint.Value `json:"coveredPosition,omitempty" persistence:"covered_position"`
	// contains filtered or unexported fields
}

func (*Strategy) CrossRun

func (s *Strategy) CrossRun(
	ctx context.Context, orderExecutionRouter bbgo.OrderExecutionRouter, sessions map[string]*bbgo.ExchangeSession,
) error

func (*Strategy) CrossSubscribe

func (s *Strategy) CrossSubscribe(sessions map[string]*bbgo.ExchangeSession)

func (*Strategy) Defaults added in v1.60.1

func (s *Strategy) Defaults() error

func (*Strategy) Hedge

func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value)

func (*Strategy) ID

func (s *Strategy) ID() string

func (*Strategy) Initialize added in v1.55.0

func (s *Strategy) Initialize() error

func (*Strategy) InstanceID added in v1.33.0

func (s *Strategy) InstanceID() string

func (*Strategy) Validate added in v1.16.0

func (s *Strategy) Validate() error

type TradeVolumeWindowSignal added in v1.60.2

type TradeVolumeWindowSignal struct {
	Threshold fixedpoint.Value `json:"threshold"`
	Window    types.Duration   `json:"window"`
	// contains filtered or unexported fields
}

func (*TradeVolumeWindowSignal) Bind added in v1.60.2

func (s *TradeVolumeWindowSignal) Bind(ctx context.Context, session *bbgo.ExchangeSession, symbol string) error

func (*TradeVolumeWindowSignal) CalculateSignal added in v1.60.2

func (s *TradeVolumeWindowSignal) CalculateSignal(_ context.Context) (float64, error)

Jump to

Keyboard shortcuts

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