xpremium

package
v1.64.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const ID = "xpremium"

Variables

This section is empty.

Functions

This section is empty.

Types

type BacktestConfig

type BacktestConfig struct {
	BidAskPriceCsv  string         `json:"bidAskPriceCsv,omitempty"`
	TradingInterval types.Interval `json:"tradingInterval,omitempty"`
}

type EngulfingTakeProfitConfig

type EngulfingTakeProfitConfig struct {
	Enabled              bool             `json:"enabled"`
	Interval             types.Interval   `json:"interval"`
	BodyMultiple         fixedpoint.Value `json:"bodyMultiple"`
	BottomShadowMaxRatio fixedpoint.Value `json:"bottomShadowMaxRatio"`
}

type PivotStopConfig

type PivotStopConfig struct {
	Enabled  bool           `json:"enabled"`
	Interval types.Interval `json:"interval"`
	Left     int            `json:"left"`
	Right    int            `json:"right"`
}

type Signal

type Signal struct {
	Side       types.SideType
	Premium    fixedpoint.Value
	Discount   fixedpoint.Value
	MinSpread  fixedpoint.Value
	PremiumBid fixedpoint.Value
	PremiumAsk fixedpoint.Value
	BaseBid    fixedpoint.Value
	BaseAsk    fixedpoint.Value
	Symbol     string
}

func (*Signal) SlackAttachment

func (s *Signal) SlackAttachment() slack.Attachment

type Strategy

type Strategy struct {
	*common.Strategy

	Environment *bbgo.Environment

	// Symbol is the default trading pair for the trading session (fallback for TradingSymbol)
	Symbol string `json:"symbol"`

	// Premium session & symbol are the leading market to compare
	PremiumSession string `json:"premiumSession"`
	PremiumSymbol  string `json:"premiumSymbol"`

	// Base session & symbol are the lagging market to compare
	BaseSession string `json:"baseSession"`
	BaseSymbol  string `json:"baseSymbol"`

	// Trading session & symbol are where we open LONG/SHORT
	TradingSession string `json:"tradingSession"`
	TradingSymbol  string `json:"tradingSymbol"`

	// MinSpread is the minimum absolute price difference to trigger a signal (premium - base)
	MinSpread fixedpoint.Value `json:"minSpread"`

	// MinTriggers is the minimum number of consecutive premium/discount triggers required
	// before opening a position. A value of 0 opens immediately on first trigger. Default is 3.
	MinTriggers int `json:"minTriggers"`

	// Leverage to set on the trading session (futures)
	MaxLeverage int `json:"leverage"`

	// Quantity is the fixed order size to trade on signal. If zero, sizing will be computed.
	Quantity fixedpoint.Value `json:"quantity"`

	// MaxLossLimit is the maximum quote loss allowed per trade for sizing; if zero, falls back to Quantity/min.
	MaxLossLimit fixedpoint.Value `json:"maxLossLimit"`

	// PriceType selects which price from ticker to use for sizing/validation (maker/taker)
	PriceType types.PriceType `json:"priceType"`

	// TakeProfitROI is the ROI threshold to take profit (e.g., 0.03 for 3%).
	TakeProfitROI fixedpoint.Value `json:"takeProfitROI"`
	// StopLossSafetyRatio is the adjustment ratio applied to previous pivot for stop loss
	// For long: stop = prevLow * (1 - ratio); for short: stop = prevHigh * (1 + ratio)
	StopLossSafetyRatio fixedpoint.Value `json:"stopLossSafetyRatio"`

	// EngulfingTakeProfit is an optional take-profit rule triggered by 1h Engulfing pattern
	EngulfingTakeProfit *EngulfingTakeProfitConfig `json:"engulfingTakeProfit,omitempty"`

	ClosePositionOnStart bool `json:"closePositionOnStart"`

	PivotStop *PivotStopConfig `json:"pivotStop,omitempty"`

	BacktestConfig *BacktestConfig `json:"backtest,omitempty"`

	// SignalConfigList imports xmaker's signal configuration. All signals will be bound
	// to the PremiumSession as the data source by default unless the config explicitly
	// specifies otherwise. The aggregated signal value is used to gate entries:
	// we will only open a position if the aggregated signal side matches the intended side.
	SignalConfigList *xmakersignal.DynamicConfig `json:"signals,omitempty"`

	// QuoteDepth is the quoting depth in quote currency (e.g., USDT) when deriving bid/ask from depth books
	// Defaults to 300 USDT if not specified.
	QuoteDepth fixedpoint.Value `json:"quoteDepth"`
	// contains filtered or unexported fields
}

func (*Strategy) CrossRun

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

func (*Strategy) CrossSubscribe

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

func (*Strategy) Defaults

func (s *Strategy) Defaults() error

func (*Strategy) ID

func (s *Strategy) ID() string

func (*Strategy) Initialize

func (s *Strategy) Initialize() error

func (*Strategy) InstanceID

func (s *Strategy) InstanceID() string

func (*Strategy) Run

Run is only used for back-testing with single session

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