common

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SyncActiveOrder

func SyncActiveOrder(ctx context.Context, ex types.Exchange, orderQueryService types.ExchangeOrderQueryService, activeOrderBook *bbgo.ActiveOrderBook, orderID uint64, syncBefore time.Time) (isOrderUpdated bool, err error)

func SyncActiveOrders

func SyncActiveOrders(ctx context.Context, opts SyncActiveOrdersOpts) error

Types

type ProfitFixer

type ProfitFixer struct {
	// contains filtered or unexported fields
}

ProfitFixer implements a trade-history-based profit fixer

func NewProfitFixer

func NewProfitFixer() *ProfitFixer

func (*ProfitFixer) AddExchange

func (f *ProfitFixer) AddExchange(sessionName string, service types.ExchangeTradeHistoryService)

func (*ProfitFixer) Fix

func (f *ProfitFixer) Fix(
	ctx context.Context, symbol string, since, until time.Time, stats *types.ProfitStats, position *types.Position,
) error

func (*ProfitFixer) FixFromTrades

func (f *ProfitFixer) FixFromTrades(allTrades []types.Trade, stats *types.ProfitStats, position *types.Position) error

type ProfitFixerConfig

type ProfitFixerConfig struct {
	TradesSince types.Time `json:"tradesSince,omitempty"`
}

ProfitFixerConfig is used for fixing profitStats and position by re-playing the trade history

type RiskController

type RiskController struct {
	PositionHardLimit         fixedpoint.Value     `json:"positionHardLimit"`
	MaxPositionQuantity       fixedpoint.Value     `json:"maxPositionQuantity"`
	CircuitBreakLossThreshold fixedpoint.Value     `json:"circuitBreakLossThreshold"`
	CircuitBreakEMA           types.IntervalWindow `json:"circuitBreakEMA"`
	// contains filtered or unexported fields
}

type StatusCallbacks

type StatusCallbacks struct {
	// contains filtered or unexported fields
}

func (*StatusCallbacks) EmitClosed

func (c *StatusCallbacks) EmitClosed()

func (*StatusCallbacks) EmitError

func (c *StatusCallbacks) EmitError(err error)

func (*StatusCallbacks) EmitReady

func (c *StatusCallbacks) EmitReady()

func (*StatusCallbacks) OnClosed

func (c *StatusCallbacks) OnClosed(cb func())

func (*StatusCallbacks) OnError

func (c *StatusCallbacks) OnError(cb func(err error))

func (*StatusCallbacks) OnReady

func (c *StatusCallbacks) OnReady(cb func())

type Strategy

type Strategy struct {
	Position    *types.Position    `json:"position,omitempty" persistence:"position"`
	ProfitStats *types.ProfitStats `json:"profitStats,omitempty" persistence:"profit_stats"`

	Environ       *bbgo.Environment
	Session       *bbgo.ExchangeSession
	OrderExecutor *bbgo.GeneralOrderExecutor

	RiskController
	// contains filtered or unexported fields
}

Strategy provides the core functionality that is required by a long/short strategy.

func (*Strategy) Initialize

func (s *Strategy) Initialize(ctx context.Context, environ *bbgo.Environment, session *bbgo.ExchangeSession, market types.Market, strategyID, instanceID string)

func (*Strategy) IsHalted

func (s *Strategy) IsHalted(t time.Time) bool

type SyncActiveOrdersOpts

type SyncActiveOrdersOpts struct {
	Logger            *logrus.Entry
	Exchange          types.Exchange
	OrderQueryService types.ExchangeOrderQueryService
	ActiveOrderBook   *bbgo.ActiveOrderBook
	OpenOrders        []types.Order
}

Jump to

Keyboard shortcuts

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