Documentation ¶
Index ¶
- Constants
- Variables
- func AdjustFloatQuantityByMaxAmount(quantity fixedpoint.Value, price fixedpoint.Value, maxAmount fixedpoint.Value) fixedpoint.Value
- func AdjustFloatQuantityByMinAmount(quantity, currentPrice, minAmount fixedpoint.Value) fixedpoint.Value
- func AdjustQuantityByMaxAmount(quantity, currentPrice, maxAmount fixedpoint.Value) fixedpoint.Value
- func AdjustQuantityByMinAmount(quantity, currentPrice, minAmount fixedpoint.Value) fixedpoint.Value
- func Build(ctx context.Context, userConfig *Config, targetConfig BuildTargetConfig) (string, error)
- func BuildTarget(ctx context.Context, userConfig *Config, target BuildTargetConfig) (string, error)
- func RegisterStrategy(key string, s interface{})
- func SetWrapperBinary()
- type ActiveOrderBook
- func (b *ActiveOrderBook) Add(orders ...types.Order)
- func (b *ActiveOrderBook) Backup() []types.SubmitOrder
- func (b *ActiveOrderBook) BindStream(stream types.Stream)
- func (b *ActiveOrderBook) EmitFilled(o types.Order)
- func (b *ActiveOrderBook) Exists(order types.Order) bool
- func (b *ActiveOrderBook) GracefulCancel(ctx context.Context, ex types.Exchange) error
- func (b *ActiveOrderBook) MarshalJSON() ([]byte, error)
- func (b *ActiveOrderBook) NumOfOrders() int
- func (b *ActiveOrderBook) OnFilled(cb func(o types.Order))
- func (b *ActiveOrderBook) Orders() types.OrderSlice
- func (b *ActiveOrderBook) Print()
- func (b *ActiveOrderBook) Remove(order types.Order) bool
- func (b *ActiveOrderBook) Update(orders ...types.Order)
- type AverageCostPnLReporter
- type BA
- type Backtest
- type BacktestAccount
- type BacktestAccountBalanceMap
- type BasicRiskController
- type BuildConfig
- type BuildTargetConfig
- type Config
- type Context
- type CoreInteraction
- type CrossExchangeSessionSubscriber
- type CrossExchangeStrategy
- type EmergencyStopper
- type Environment
- func (environ *Environment) AddExchange(name string, exchange types.Exchange) (session *ExchangeSession)
- func (environ *Environment) AddExchangeSession(name string, session *ExchangeSession) *ExchangeSession
- func (environ *Environment) AddExchangesByViperKeys() error
- func (environ *Environment) AddExchangesFromSessionConfig(sessions map[string]*ExchangeSession) error
- func (environ *Environment) BindSync(config *SyncConfig)
- func (environ *Environment) ConfigureDatabase(ctx context.Context) error
- func (environ *Environment) ConfigureDatabaseDriver(ctx context.Context, driver string, dsn string) error
- func (environ *Environment) ConfigureExchangeSessions(userConfig *Config) error
- func (environ *Environment) ConfigureNotificationRouting(conf *NotificationConfig) error
- func (environ *Environment) ConfigureNotificationSystem(userConfig *Config) error
- func (environ *Environment) ConfigurePersistence(conf *PersistenceConfig) error
- func (environ *Environment) Connect(ctx context.Context) error
- func (environ *Environment) Init(ctx context.Context) (err error)
- func (environ *Environment) IsBackTesting() bool
- func (environ *Environment) IsSyncing() (status SyncStatus)
- func (environ *Environment) RecordAsset(t time.Time, session *ExchangeSession, assets types.AssetMap)
- func (environ *Environment) RecordPosition(position *types.Position, trade types.Trade, profit *types.Profit)
- func (environ *Environment) RecordProfit(profit types.Profit)
- func (environ *Environment) SelectSessions(names ...string) map[string]*ExchangeSession
- func (environ *Environment) Session(name string) (*ExchangeSession, bool)
- func (environ *Environment) Sessions() map[string]*ExchangeSession
- func (environ *Environment) SetStartTime(t time.Time) *Environment
- func (environ *Environment) SetSyncStartTime(t time.Time) *Environment
- func (environ *Environment) Start(ctx context.Context) (err error)
- func (environ *Environment) Sync(ctx context.Context, userConfig ...*Config) error
- func (environ *Environment) SyncSession(ctx context.Context, session *ExchangeSession, defaultSymbols ...string) error
- type ExchangeOrderExecutionRouter
- type ExchangeOrderExecutor
- func (e *ExchangeOrderExecutor) CancelOrders(ctx context.Context, orders ...types.Order) error
- func (e *ExchangeOrderExecutor) EmitOrderUpdate(order types.Order)
- func (e *ExchangeOrderExecutor) EmitTradeUpdate(trade types.Trade)
- func (e *ExchangeOrderExecutor) OnOrderUpdate(cb func(order types.Order))
- func (e *ExchangeOrderExecutor) OnTradeUpdate(cb func(trade types.Trade))
- func (e *ExchangeOrderExecutor) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder) (types.OrderSlice, error)
- type ExchangeSession
- func (session *ExchangeSession) AllLastPrices() map[string]fixedpoint.Value
- func (session *ExchangeSession) FindPossibleSymbols() (symbols []string, err error)
- func (session *ExchangeSession) FormatOrder(order types.SubmitOrder) (types.SubmitOrder, error)
- func (session *ExchangeSession) GetAccount() (a *types.Account)
- func (session *ExchangeSession) Init(ctx context.Context, environ *Environment) error
- func (session *ExchangeSession) InitExchange(name string, ex types.Exchange) error
- func (session *ExchangeSession) InitSymbols(ctx context.Context, environ *Environment) error
- func (session *ExchangeSession) LastPrice(symbol string) (price fixedpoint.Value, ok bool)
- func (session *ExchangeSession) LastPrices() map[string]fixedpoint.Value
- func (session *ExchangeSession) MarginType() string
- func (session *ExchangeSession) Market(symbol string) (market types.Market, ok bool)
- func (session *ExchangeSession) MarketDataStore(symbol string) (s *MarketDataStore, ok bool)
- func (session *ExchangeSession) Markets() map[string]types.Market
- func (session *ExchangeSession) OrderBook(symbol string) (s *types.StreamOrderBook, ok bool)
- func (session *ExchangeSession) OrderStore(symbol string) (store *OrderStore, ok bool)
- func (session *ExchangeSession) OrderStores() map[string]*OrderStore
- func (session *ExchangeSession) Position(symbol string) (pos *types.Position, ok bool)
- func (session *ExchangeSession) Positions() map[string]*types.Position
- func (session *ExchangeSession) SlackAttachment() slack.Attachment
- func (session *ExchangeSession) StandardIndicatorSet(symbol string) (*StandardIndicatorSet, bool)
- func (session *ExchangeSession) StartPrice(symbol string) (price fixedpoint.Value, ok bool)
- func (session *ExchangeSession) Subscribe(channel types.Channel, symbol string, options types.SubscribeOptions) *ExchangeSession
- func (session *ExchangeSession) UpdateAccount(ctx context.Context) (*types.Account, error)
- func (session *ExchangeSession) UpdatePrices(ctx context.Context, currencies []string, fiat string) (err error)
- type ExchangeSessionSubscriber
- type ExchangeStrategyMount
- type ExponentialScale
- type FixedStop
- type Graceful
- type InstanceIDProvider
- type LayerScale
- type LinearScale
- type LogarithmicScale
- type Logger
- type Logging
- type MarketDataStore
- func (store *MarketDataStore) AddKLine(kline types.KLine)
- func (store *MarketDataStore) BindStream(stream types.Stream)
- func (store *MarketDataStore) EmitKLineWindowUpdate(interval types.Interval, klines types.KLineWindow)
- func (store *MarketDataStore) KLinesOfInterval(interval types.Interval) (kLines *types.KLineWindow, ok bool)
- func (store *MarketDataStore) OnKLineWindowUpdate(cb func(interval types.Interval, klines types.KLineWindow))
- func (store *MarketDataStore) SetKLineWindows(windows map[types.Interval]*types.KLineWindow)
- type MovingAverageSettings
- type Notifiability
- func (m *Notifiability) AddNotifier(notifier Notifier)
- func (m *Notifiability) Notify(obj interface{}, args ...interface{})
- func (m *Notifiability) NotifyTo(channel string, obj interface{}, args ...interface{})
- func (m *Notifiability) RouteObject(obj interface{}) (channel string, ok bool)
- func (m *Notifiability) RouteSession(session string) (channel string, ok bool)
- func (m *Notifiability) RouteSymbol(symbol string) (channel string, ok bool)
- type NotificationConfig
- type Notifier
- type NullNotifier
- type ObjectChannelHandler
- type ObjectChannelRouter
- type OrderExecutionRouter
- type OrderExecutor
- type OrderStore
- func (s *OrderStore) Add(orders ...types.Order)
- func (s *OrderStore) AllFilled() bool
- func (s *OrderStore) BindStream(stream types.Stream)
- func (s *OrderStore) Exists(oID uint64) (ok bool)
- func (s *OrderStore) Get(oID uint64) (order types.Order, ok bool)
- func (s *OrderStore) NumOfOrders() (num int)
- func (s *OrderStore) Orders() (orders []types.Order)
- func (s *OrderStore) Remove(o types.Order)
- func (s *OrderStore) Update(o types.Order) bool
- type PatternChannelRouter
- type PercentageScale
- type Persistence
- type PersistenceConfig
- type PersistenceSelector
- type PnLReporter
- type PnLReporterConfig
- type PnLReporterManager
- type PositionCloser
- type PositionReader
- type PriceVolumeScale
- type QuadraticScale
- type QuantityOrAmount
- type Quota
- type QuotaTransaction
- type RiskControlOrderExecutor
- type RiskControls
- type Scale
- type Session
- type SessionBasedRiskControl
- type SilentLogger
- type SingleExchangeStrategy
- type SlackNotification
- type SlackNotificationRouting
- type SlideRule
- type SmartStops
- type StandardIndicatorSet
- func (set *StandardIndicatorSet) BOLL(iw types.IntervalWindow, bandWidth float64) *indicator.BOLL
- func (set *StandardIndicatorSet) EWMA(iw types.IntervalWindow) *indicator.EWMA
- func (set *StandardIndicatorSet) SMA(iw types.IntervalWindow) *indicator.SMA
- func (set *StandardIndicatorSet) STOCH(iw types.IntervalWindow) *indicator.STOCH
- func (set *StandardIndicatorSet) VOLATILITY(iw types.IntervalWindow) *indicator.VOLATILITY
- type Stash
- type Stop
- type StopController
- type StrategyController
- func (s *StrategyController) EmergencyStop() error
- func (s *StrategyController) EmitEmergencyStop()
- func (s *StrategyController) EmitResume()
- func (s *StrategyController) EmitSuspend()
- func (s *StrategyController) GetStatus() types.StrategyStatus
- func (s *StrategyController) OnEmergencyStop(cb func())
- func (s *StrategyController) OnResume(cb func())
- func (s *StrategyController) OnSuspend(cb func())
- func (s *StrategyController) Resume() error
- func (s *StrategyController) Suspend() error
- type StrategyID
- type StrategyInitializer
- type StrategyStatusReader
- type StrategyToggler
- type StructFieldIterator
- type SymbolBasedRiskController
- type SyncConfig
- type SyncStatus
- type TelegramNotification
- type TradeCollector
- func (c *TradeCollector) BindStream(stream types.Stream)
- func (c *TradeCollector) BindStreamForBackground(stream types.Stream)
- func (c *TradeCollector) Emit()
- func (c *TradeCollector) EmitPositionUpdate(position *types.Position)
- func (c *TradeCollector) EmitProfit(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value)
- func (c *TradeCollector) EmitRecover(trade types.Trade)
- func (c *TradeCollector) EmitTrade(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value)
- func (c *TradeCollector) OnPositionUpdate(cb func(position *types.Position))
- func (c *TradeCollector) OnProfit(...)
- func (c *TradeCollector) OnRecover(cb func(trade types.Trade))
- func (c *TradeCollector) OnTrade(...)
- func (c *TradeCollector) OrderStore() *OrderStore
- func (c *TradeCollector) Position() *types.Position
- func (c *TradeCollector) Process() bool
- func (c *TradeCollector) ProcessTrade(trade types.Trade) bool
- func (c *TradeCollector) QueueTrade(trade types.Trade)
- func (c *TradeCollector) Recover(ctx context.Context, ex types.ExchangeTradeHistoryService, symbol string, ...) error
- func (c *TradeCollector) Run(ctx context.Context)
- type TradeFilter
- type TradeReporter
- type TradeStore
- func (s *TradeStore) Add(trades ...types.Trade)
- func (s *TradeStore) Clear()
- func (s *TradeStore) Exists(oID uint64) (ok bool)
- func (s *TradeStore) Filter(filter TradeFilter)
- func (s *TradeStore) GetAndClear() (trades []types.Trade)
- func (s *TradeStore) Num() (num int)
- func (s *TradeStore) Trades() (trades []types.Trade)
- type Trader
- func (trader *Trader) AttachCrossExchangeStrategy(strategy CrossExchangeStrategy) *Trader
- func (trader *Trader) AttachStrategyOn(session string, strategies ...SingleExchangeStrategy) error
- func (trader *Trader) Configure(userConfig *Config) error
- func (trader *Trader) DisableLogging()
- func (trader *Trader) EnableLogging()
- func (trader *Trader) IterateStrategies(f func(st StrategyID) error) error
- func (trader *Trader) LoadState() error
- func (trader *Trader) ReportPnL() *PnLReporterManager
- func (trader *Trader) Run(ctx context.Context) error
- func (trader *Trader) RunAllSingleExchangeStrategy(ctx context.Context) error
- func (trader *Trader) RunSingleExchangeStrategy(ctx context.Context, strategy SingleExchangeStrategy, session *ExchangeSession, ...) error
- func (trader *Trader) SaveState() error
- func (trader *Trader) SetRiskControls(riskControls *RiskControls)
- func (trader *Trader) Subscribe()
- type TrailingStop
- type TrailingStopController
- type TwapExecution
- type Validator
Constants ¶
const CancelOrderWaitTime = 20 * time.Millisecond
const MaxNumOfKLines = 5_000
const MaxNumOfKLinesTruncate = 100
const TemplateOrderReport = `:handshake: {{ .Symbol }} {{ .Side }} Order Update @ {{ .Price }}`
Variables ¶
var ( ErrQuoteBalanceLevelTooLow = errors.New("quote balance level is too low") ErrInsufficientQuoteBalance = errors.New("insufficient quote balance") ErrAssetBalanceLevelTooLow = errors.New("asset balance level too low") ErrInsufficientAssetBalance = errors.New("insufficient asset balance") ErrAssetBalanceLevelTooHigh = errors.New("asset balance level too high") )
var DefaultBacktestAccount = BacktestAccount{ MakerFeeRate: fixedpoint.MustNewFromString("0.050%"), TakerFeeRate: fixedpoint.MustNewFromString("0.075%"), Balances: BacktestAccountBalanceMap{ "USDT": fixedpoint.NewFromFloat(10000), }, }
var DefaultFeeRate = fixedpoint.NewFromFloat(0.075 * 0.01)
DefaultFeeRate set the fee rate for most cases BINANCE uses 0.1% for both maker and taker
for BNB holders, it's 0.075% for both maker and taker
MAX uses 0.050% for maker and 0.15% for taker
var ErrSessionAlreadyInitialized = errors.New("session is already initialized")
var IsWrapperBinary = false
var LoadedCrossExchangeStrategies = make(map[string]CrossExchangeStrategy)
var LoadedExchangeStrategies = make(map[string]SingleExchangeStrategy)
var LocalTimeZone *time.Location
Functions ¶
func AdjustFloatQuantityByMaxAmount ¶ added in v1.17.0
func AdjustFloatQuantityByMaxAmount(quantity fixedpoint.Value, price fixedpoint.Value, maxAmount fixedpoint.Value) fixedpoint.Value
func AdjustFloatQuantityByMinAmount ¶ added in v1.17.0
func AdjustFloatQuantityByMinAmount(quantity, currentPrice, minAmount fixedpoint.Value) fixedpoint.Value
AdjustFloatQuantityByMinAmount adjusts the quantity to make the amount greater than the given minAmount
func AdjustQuantityByMaxAmount ¶ added in v1.16.0
func AdjustQuantityByMaxAmount(quantity, currentPrice, maxAmount fixedpoint.Value) fixedpoint.Value
AdjustQuantityByMaxAmount adjusts the quantity to make the amount greater than the given minAmount
func AdjustQuantityByMinAmount ¶ added in v1.16.0
func AdjustQuantityByMinAmount(quantity, currentPrice, minAmount fixedpoint.Value) fixedpoint.Value
AdjustQuantityByMinAmount adjusts the quantity to make the amount greater than the given minAmount
func BuildTarget ¶ added in v1.9.0
func RegisterStrategy ¶
func RegisterStrategy(key string, s interface{})
func SetWrapperBinary ¶ added in v1.9.0
func SetWrapperBinary()
Types ¶
type ActiveOrderBook ¶ added in v1.33.0
type ActiveOrderBook struct { Symbol string // contains filtered or unexported fields }
ActiveOrderBook manages the local active order books.
func NewActiveOrderBook ¶ added in v1.33.0
func NewActiveOrderBook(symbol string) *ActiveOrderBook
func (*ActiveOrderBook) Add ¶ added in v1.33.0
func (b *ActiveOrderBook) Add(orders ...types.Order)
func (*ActiveOrderBook) Backup ¶ added in v1.33.0
func (b *ActiveOrderBook) Backup() []types.SubmitOrder
func (*ActiveOrderBook) BindStream ¶ added in v1.33.0
func (b *ActiveOrderBook) BindStream(stream types.Stream)
func (*ActiveOrderBook) EmitFilled ¶ added in v1.33.0
func (b *ActiveOrderBook) EmitFilled(o types.Order)
func (*ActiveOrderBook) Exists ¶ added in v1.33.0
func (b *ActiveOrderBook) Exists(order types.Order) bool
func (*ActiveOrderBook) GracefulCancel ¶ added in v1.33.0
GracefulCancel cancels the active orders gracefully
func (*ActiveOrderBook) MarshalJSON ¶ added in v1.33.0
func (b *ActiveOrderBook) MarshalJSON() ([]byte, error)
func (*ActiveOrderBook) NumOfOrders ¶ added in v1.33.0
func (b *ActiveOrderBook) NumOfOrders() int
func (*ActiveOrderBook) OnFilled ¶ added in v1.33.0
func (b *ActiveOrderBook) OnFilled(cb func(o types.Order))
func (*ActiveOrderBook) Orders ¶ added in v1.33.0
func (b *ActiveOrderBook) Orders() types.OrderSlice
func (*ActiveOrderBook) Print ¶ added in v1.33.0
func (b *ActiveOrderBook) Print()
func (*ActiveOrderBook) Remove ¶ added in v1.33.0
func (b *ActiveOrderBook) Remove(order types.Order) bool
func (*ActiveOrderBook) Update ¶ added in v1.33.0
func (b *ActiveOrderBook) Update(orders ...types.Order)
type AverageCostPnLReporter ¶
type AverageCostPnLReporter struct { Sessions []string Symbols []string // contains filtered or unexported fields }
func (*AverageCostPnLReporter) Of ¶
func (reporter *AverageCostPnLReporter) Of(sessions ...string) *AverageCostPnLReporter
func (*AverageCostPnLReporter) Run ¶
func (reporter *AverageCostPnLReporter) Run()
func (*AverageCostPnLReporter) When ¶
func (reporter *AverageCostPnLReporter) When(specs ...string) *AverageCostPnLReporter
type BA ¶ added in v1.30.3
type BA BacktestAccount
type Backtest ¶
type Backtest struct { StartTime types.LooseFormatTime `json:"startTime,omitempty" yaml:"startTime,omitempty"` EndTime *types.LooseFormatTime `json:"endTime,omitempty" yaml:"endTime,omitempty"` // RecordTrades is an option, if set to true, back-testing should record the trades into database RecordTrades bool `json:"recordTrades,omitempty" yaml:"recordTrades,omitempty"` // Deprecated: // Account is deprecated, use Accounts instead Account map[string]BacktestAccount `json:"account" yaml:"account"` Accounts map[string]BacktestAccount `json:"accounts" yaml:"accounts"` Symbols []string `json:"symbols" yaml:"symbols"` Sessions []string `json:"sessions" yaml:"sessions"` }
func (*Backtest) GetAccount ¶ added in v1.33.0
func (b *Backtest) GetAccount(n string) BacktestAccount
type BacktestAccount ¶
type BacktestAccount struct { // TODO: MakerFeeRate should replace the commission fields MakerFeeRate fixedpoint.Value `json:"makerFeeRate,omitempty" yaml:"makerFeeRate,omitempty"` TakerFeeRate fixedpoint.Value `json:"takerFeeRate,omitempty" yaml:"takerFeeRate,omitempty"` Balances BacktestAccountBalanceMap `json:"balances" yaml:"balances"` }
func (*BacktestAccount) UnmarshalJSON ¶ added in v1.30.3
func (b *BacktestAccount) UnmarshalJSON(input []byte) error
func (*BacktestAccount) UnmarshalYAML ¶ added in v1.30.3
func (b *BacktestAccount) UnmarshalYAML(value *yaml.Node) error
type BacktestAccountBalanceMap ¶
type BacktestAccountBalanceMap map[string]fixedpoint.Value
func (BacktestAccountBalanceMap) BalanceMap ¶
func (m BacktestAccountBalanceMap) BalanceMap() types.BalanceMap
type BasicRiskController ¶
type BasicRiskController struct { Logger *log.Logger MaxOrderAmount fixedpoint.Value `json:"maxOrderAmount,omitempty" yaml:"maxOrderAmount,omitempty"` MinQuoteBalance fixedpoint.Value `json:"minQuoteBalance,omitempty" yaml:"minQuoteBalance,omitempty"` MaxBaseAssetBalance fixedpoint.Value `json:"maxBaseAssetBalance,omitempty" yaml:"maxBaseAssetBalance,omitempty"` MinBaseAssetBalance fixedpoint.Value `json:"minBaseAssetBalance,omitempty" yaml:"minBaseAssetBalance,omitempty"` }
func (*BasicRiskController) ProcessOrders ¶
func (c *BasicRiskController) ProcessOrders(session *ExchangeSession, orders ...types.SubmitOrder) (outOrders []types.SubmitOrder, errs []error)
ProcessOrders filters and modifies the submit order objects by: 1. Increase the quantity by the minimal requirement 2. Decrease the quantity by risk controls 3. If the quantity does not meet minimal requirement, we should ignore the submit order.
type BuildConfig ¶ added in v1.9.0
type BuildConfig struct { BuildDir string `json:"buildDir,omitempty" yaml:"buildDir,omitempty"` Imports []string `json:"imports,omitempty" yaml:"imports,omitempty"` Targets []BuildTargetConfig `json:"targets,omitempty" yaml:"targets,omitempty"` }
type BuildTargetConfig ¶ added in v1.9.0
type BuildTargetConfig struct { Name string `json:"name" yaml:"name"` Arch string `json:"arch" yaml:"arch"` OS string `json:"os" yaml:"os"` LDFlags datatype.StringSlice `json:"ldflags,omitempty" yaml:"ldflags,omitempty"` GCFlags datatype.StringSlice `json:"gcflags,omitempty" yaml:"gcflags,omitempty"` Imports []string `json:"imports,omitempty" yaml:"imports,omitempty"` }
func GetNativeBuildTargetConfig ¶ added in v1.9.0
func GetNativeBuildTargetConfig() BuildTargetConfig
type Config ¶
type Config struct { Build *BuildConfig `json:"build,omitempty" yaml:"build,omitempty"` // Imports is deprecated // Deprecated: use BuildConfig instead Imports []string `json:"imports,omitempty" yaml:"imports,omitempty"` Backtest *Backtest `json:"backtest,omitempty" yaml:"backtest,omitempty"` Sync *SyncConfig `json:"sync,omitempty" yaml:"sync,omitempty"` Notifications *NotificationConfig `json:"notifications,omitempty" yaml:"notifications,omitempty"` Persistence *PersistenceConfig `json:"persistence,omitempty" yaml:"persistence,omitempty"` Sessions map[string]*ExchangeSession `json:"sessions,omitempty" yaml:"sessions,omitempty"` RiskControls *RiskControls `json:"riskControls,omitempty" yaml:"riskControls,omitempty"` ExchangeStrategies []ExchangeStrategyMount `json:"-" yaml:"-"` CrossExchangeStrategies []CrossExchangeStrategy `json:"-" yaml:"-"` PnLReporters []PnLReporterConfig `json:"reportPnL,omitempty" yaml:"reportPnL,omitempty"` }
func LoadBuildConfig ¶ added in v1.3.1
func (*Config) GetSignature ¶ added in v1.33.0
type CoreInteraction ¶ added in v1.26.0
type CoreInteraction struct {
// contains filtered or unexported fields
}
func NewCoreInteraction ¶ added in v1.26.0
func NewCoreInteraction(environment *Environment, trader *Trader) *CoreInteraction
func (*CoreInteraction) Commands ¶ added in v1.26.0
func (it *CoreInteraction) Commands(i *interact.Interact)
func (*CoreInteraction) Initialize ¶ added in v1.26.0
func (it *CoreInteraction) Initialize() error
type CrossExchangeSessionSubscriber ¶ added in v1.2.0
type CrossExchangeSessionSubscriber interface {
CrossSubscribe(sessions map[string]*ExchangeSession)
}
type CrossExchangeStrategy ¶
type CrossExchangeStrategy interface { StrategyID CrossRun(ctx context.Context, orderExecutionRouter OrderExecutionRouter, sessions map[string]*ExchangeSession) error }
type EmergencyStopper ¶ added in v1.29.0
type EmergencyStopper interface {
EmergencyStop() error
}
type Environment ¶
type Environment struct { // Notifiability here for environment is for the streaming data notification // note that, for back tests, we don't need notification. Notifiability PersistenceServiceFacade *service.PersistenceServiceFacade DatabaseService *service.DatabaseService OrderService *service.OrderService TradeService *service.TradeService ProfitService *service.ProfitService PositionService *service.PositionService BacktestService *service.BacktestService RewardService *service.RewardService MarginService *service.MarginService SyncService *service.SyncService AccountService *service.AccountService WithdrawService *service.WithdrawService DepositService *service.DepositService // contains filtered or unexported fields }
Environment presents the real exchange data layer
func NewEnvironment ¶
func NewEnvironment() *Environment
func (*Environment) AddExchange ¶
func (environ *Environment) AddExchange(name string, exchange types.Exchange) (session *ExchangeSession)
AddExchange adds the given exchange with the session name, this is the default
func (*Environment) AddExchangeSession ¶ added in v1.8.0
func (environ *Environment) AddExchangeSession(name string, session *ExchangeSession) *ExchangeSession
AddExchangeSession adds the existing exchange session or pre-created exchange session
func (*Environment) AddExchangesByViperKeys ¶ added in v1.5.0
func (environ *Environment) AddExchangesByViperKeys() error
func (*Environment) AddExchangesFromSessionConfig ¶ added in v1.5.0
func (environ *Environment) AddExchangesFromSessionConfig(sessions map[string]*ExchangeSession) error
func (*Environment) BindSync ¶ added in v1.28.0
func (environ *Environment) BindSync(config *SyncConfig)
func (*Environment) ConfigureDatabase ¶ added in v1.7.0
func (environ *Environment) ConfigureDatabase(ctx context.Context) error
func (*Environment) ConfigureDatabaseDriver ¶ added in v1.12.0
func (*Environment) ConfigureExchangeSessions ¶ added in v1.12.0
func (environ *Environment) ConfigureExchangeSessions(userConfig *Config) error
func (*Environment) ConfigureNotificationRouting ¶ added in v1.12.0
func (environ *Environment) ConfigureNotificationRouting(conf *NotificationConfig) error
ConfigureNotificationRouting configures the notification rules for symbol-based routes, we should register the same symbol rules for each session. for session-based routes, we should set the fixed callbacks for each session
func (*Environment) ConfigureNotificationSystem ¶ added in v1.12.0
func (environ *Environment) ConfigureNotificationSystem(userConfig *Config) error
func (*Environment) ConfigurePersistence ¶ added in v1.3.1
func (environ *Environment) ConfigurePersistence(conf *PersistenceConfig) error
func (*Environment) Init ¶
func (environ *Environment) Init(ctx context.Context) (err error)
Init prepares the data that will be used by the strategies
func (*Environment) IsBackTesting ¶ added in v1.33.0
func (environ *Environment) IsBackTesting() bool
func (*Environment) IsSyncing ¶ added in v1.12.0
func (environ *Environment) IsSyncing() (status SyncStatus)
func (*Environment) RecordAsset ¶ added in v1.32.0
func (environ *Environment) RecordAsset(t time.Time, session *ExchangeSession, assets types.AssetMap)
func (*Environment) RecordPosition ¶ added in v1.28.0
func (*Environment) RecordProfit ¶ added in v1.28.0
func (environ *Environment) RecordProfit(profit types.Profit)
func (*Environment) SelectSessions ¶ added in v1.11.1
func (environ *Environment) SelectSessions(names ...string) map[string]*ExchangeSession
func (*Environment) Session ¶ added in v1.8.0
func (environ *Environment) Session(name string) (*ExchangeSession, bool)
func (*Environment) Sessions ¶
func (environ *Environment) Sessions() map[string]*ExchangeSession
func (*Environment) SetStartTime ¶
func (environ *Environment) SetStartTime(t time.Time) *Environment
func (*Environment) SetSyncStartTime ¶ added in v1.12.0
func (environ *Environment) SetSyncStartTime(t time.Time) *Environment
SetSyncStartTime overrides the default trade scan time (-7 days)
func (*Environment) Start ¶ added in v1.15.5
func (environ *Environment) Start(ctx context.Context) (err error)
Start initializes the symbols data streams
func (*Environment) Sync ¶ added in v1.12.0
func (environ *Environment) Sync(ctx context.Context, userConfig ...*Config) error
Sync syncs all registered exchange sessions
func (*Environment) SyncSession ¶ added in v1.11.1
func (environ *Environment) SyncSession(ctx context.Context, session *ExchangeSession, defaultSymbols ...string) error
type ExchangeOrderExecutionRouter ¶
type ExchangeOrderExecutionRouter struct { Notifiability // contains filtered or unexported fields }
func (*ExchangeOrderExecutionRouter) CancelOrdersTo ¶ added in v1.29.0
func (*ExchangeOrderExecutionRouter) SubmitOrdersTo ¶
func (e *ExchangeOrderExecutionRouter) SubmitOrdersTo(ctx context.Context, session string, orders ...types.SubmitOrder) (types.OrderSlice, error)
type ExchangeOrderExecutor ¶
type ExchangeOrderExecutor struct { Notifiability `json:"-" yaml:"-"` Session *ExchangeSession `json:"-" yaml:"-"` // contains filtered or unexported fields }
ExchangeOrderExecutor is an order executor wrapper for single exchange instance.
func (*ExchangeOrderExecutor) CancelOrders ¶ added in v1.29.0
func (*ExchangeOrderExecutor) EmitOrderUpdate ¶ added in v1.5.0
func (e *ExchangeOrderExecutor) EmitOrderUpdate(order types.Order)
func (*ExchangeOrderExecutor) EmitTradeUpdate ¶ added in v1.5.0
func (e *ExchangeOrderExecutor) EmitTradeUpdate(trade types.Trade)
func (*ExchangeOrderExecutor) OnOrderUpdate ¶ added in v1.5.0
func (e *ExchangeOrderExecutor) OnOrderUpdate(cb func(order types.Order))
func (*ExchangeOrderExecutor) OnTradeUpdate ¶ added in v1.5.0
func (e *ExchangeOrderExecutor) OnTradeUpdate(cb func(trade types.Trade))
func (*ExchangeOrderExecutor) SubmitOrders ¶
func (e *ExchangeOrderExecutor) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder) (types.OrderSlice, error)
type ExchangeSession ¶
type ExchangeSession struct { // exchange Session based notification system // we make it as a value field so that we can configure it separately Notifiability `json:"-" yaml:"-"` // Exchange Session name Name string `json:"name,omitempty" yaml:"name,omitempty"` ExchangeName types.ExchangeName `json:"exchange" yaml:"exchange"` EnvVarPrefix string `json:"envVarPrefix" yaml:"envVarPrefix"` Key string `json:"key,omitempty" yaml:"key,omitempty"` Secret string `json:"secret,omitempty" yaml:"secret,omitempty"` Passphrase string `json:"passphrase,omitempty" yaml:"passphrase,omitempty"` SubAccount string `json:"subAccount,omitempty" yaml:"subAccount,omitempty"` // Withdrawal is used for enabling withdrawal functions Withdrawal bool `json:"withdrawal,omitempty" yaml:"withdrawal,omitempty"` MakerFeeRate fixedpoint.Value `json:"makerFeeRate" yaml:"makerFeeRate"` TakerFeeRate fixedpoint.Value `json:"takerFeeRate" yaml:"takerFeeRate"` PublicOnly bool `json:"publicOnly,omitempty" yaml:"publicOnly"` Margin bool `json:"margin,omitempty" yaml:"margin"` IsolatedMargin bool `json:"isolatedMargin,omitempty" yaml:"isolatedMargin,omitempty"` IsolatedMarginSymbol string `json:"isolatedMarginSymbol,omitempty" yaml:"isolatedMarginSymbol,omitempty"` Futures bool `json:"futures,omitempty" yaml:"futures"` IsolatedFutures bool `json:"isolatedFutures,omitempty" yaml:"isolatedFutures,omitempty"` IsolatedFuturesSymbol string `json:"isolatedFuturesSymbol,omitempty" yaml:"isolatedFuturesSymbol,omitempty"` // The exchange account states Account *types.Account `json:"-" yaml:"-"` IsInitialized bool `json:"-" yaml:"-"` OrderExecutor *ExchangeOrderExecutor `json:"orderExecutor,omitempty" yaml:"orderExecutor,omitempty"` // UserDataStream is the connection stream of the exchange UserDataStream types.Stream `json:"-" yaml:"-"` MarketDataStream types.Stream `json:"-" yaml:"-"` // Subscriptions // this is a read-only field when running strategy Subscriptions map[types.Subscription]types.Subscription `json:"-" yaml:"-"` Exchange types.Exchange `json:"-" yaml:"-"` // Trades collects the executed trades from the exchange // map: symbol -> []trade Trades map[string]*types.TradeSlice `json:"-" yaml:"-"` // contains filtered or unexported fields }
ExchangeSession presents the exchange connection Session It also maintains and collects the data returned from the stream.
func NewExchangeSession ¶
func NewExchangeSession(name string, exchange types.Exchange) *ExchangeSession
func (*ExchangeSession) AllLastPrices ¶ added in v1.33.0
func (session *ExchangeSession) AllLastPrices() map[string]fixedpoint.Value
func (*ExchangeSession) FindPossibleSymbols ¶ added in v1.11.1
func (session *ExchangeSession) FindPossibleSymbols() (symbols []string, err error)
func (*ExchangeSession) FormatOrder ¶ added in v1.5.0
func (session *ExchangeSession) FormatOrder(order types.SubmitOrder) (types.SubmitOrder, error)
func (*ExchangeSession) GetAccount ¶ added in v1.31.0
func (session *ExchangeSession) GetAccount() (a *types.Account)
func (*ExchangeSession) Init ¶ added in v1.11.0
func (session *ExchangeSession) Init(ctx context.Context, environ *Environment) error
Init initializes the basic data structure and market information by its exchange. Note that the subscribed symbols are not loaded in this stage.
func (*ExchangeSession) InitExchange ¶ added in v1.21.0
func (session *ExchangeSession) InitExchange(name string, ex types.Exchange) error
InitExchange initialize the exchange instance and allocate memory for fields In this stage, the session var could be loaded from the JSON config, so the pointer fields are still nil The Init method will be called after this stage, environment.Init will call the session.Init method later.
func (*ExchangeSession) InitSymbols ¶ added in v1.11.0
func (session *ExchangeSession) InitSymbols(ctx context.Context, environ *Environment) error
func (*ExchangeSession) LastPrice ¶
func (session *ExchangeSession) LastPrice(symbol string) (price fixedpoint.Value, ok bool)
func (*ExchangeSession) LastPrices ¶ added in v1.11.0
func (session *ExchangeSession) LastPrices() map[string]fixedpoint.Value
func (*ExchangeSession) MarginType ¶ added in v1.21.0
func (session *ExchangeSession) MarginType() string
func (*ExchangeSession) Market ¶
func (session *ExchangeSession) Market(symbol string) (market types.Market, ok bool)
func (*ExchangeSession) MarketDataStore ¶
func (session *ExchangeSession) MarketDataStore(symbol string) (s *MarketDataStore, ok bool)
MarketDataStore returns the market data store of a symbol
func (*ExchangeSession) Markets ¶ added in v1.11.0
func (session *ExchangeSession) Markets() map[string]types.Market
func (*ExchangeSession) OrderBook ¶ added in v1.17.0
func (session *ExchangeSession) OrderBook(symbol string) (s *types.StreamOrderBook, ok bool)
OrderBook returns the personal orderbook of a symbol
func (*ExchangeSession) OrderStore ¶ added in v1.11.0
func (session *ExchangeSession) OrderStore(symbol string) (store *OrderStore, ok bool)
func (*ExchangeSession) OrderStores ¶ added in v1.11.0
func (session *ExchangeSession) OrderStores() map[string]*OrderStore
func (*ExchangeSession) Position ¶ added in v1.9.0
func (session *ExchangeSession) Position(symbol string) (pos *types.Position, ok bool)
func (*ExchangeSession) Positions ¶ added in v1.11.0
func (session *ExchangeSession) Positions() map[string]*types.Position
func (*ExchangeSession) SlackAttachment ¶ added in v1.32.0
func (session *ExchangeSession) SlackAttachment() slack.Attachment
func (*ExchangeSession) StandardIndicatorSet ¶
func (session *ExchangeSession) StandardIndicatorSet(symbol string) (*StandardIndicatorSet, bool)
func (*ExchangeSession) StartPrice ¶
func (session *ExchangeSession) StartPrice(symbol string) (price fixedpoint.Value, ok bool)
func (*ExchangeSession) Subscribe ¶
func (session *ExchangeSession) Subscribe(channel types.Channel, symbol string, options types.SubscribeOptions) *ExchangeSession
Subscribe save the subscription info, later it will be assigned to the stream
func (*ExchangeSession) UpdateAccount ¶ added in v1.31.0
UpdateAccount locks the account mutex and update the account object
func (*ExchangeSession) UpdatePrices ¶ added in v1.11.0
type ExchangeSessionSubscriber ¶
type ExchangeSessionSubscriber interface {
Subscribe(session *ExchangeSession)
}
ExchangeSessionSubscriber provides an interface for collecting subscriptions from different strategies Subscribe method will be called before the user data stream connection is created.
type ExchangeStrategyMount ¶
type ExchangeStrategyMount struct { // Mounts contains the ExchangeSession name to mount Mounts []string `json:"mounts"` // Strategy is the strategy we loaded from config Strategy SingleExchangeStrategy `json:"strategy"` }
ExchangeStrategyMount wraps the SingleExchangeStrategy with the ExchangeSession name for mounting
func (*ExchangeStrategyMount) Map ¶ added in v1.11.0
func (m *ExchangeStrategyMount) Map() (map[string]interface{}, error)
type ExponentialScale ¶ added in v1.13.0
type ExponentialScale struct { Domain [2]float64 `json:"domain"` Range [2]float64 `json:"range"` // contains filtered or unexported fields }
y := ab^x shift xs[0] to 0 (x - h) a = y1
y := ab^(x-h) y2/a = b^(x2-h) y2/y1 = b^(x2-h)
also posted at https://play.golang.org/p/JlWlwZjoebE
func (*ExponentialScale) Call ¶ added in v1.13.0
func (s *ExponentialScale) Call(x float64) (y float64)
func (*ExponentialScale) Formula ¶ added in v1.13.0
func (s *ExponentialScale) Formula() string
func (*ExponentialScale) FormulaOf ¶ added in v1.13.0
func (s *ExponentialScale) FormulaOf(x float64) string
func (*ExponentialScale) Solve ¶ added in v1.13.0
func (s *ExponentialScale) Solve() error
func (*ExponentialScale) String ¶ added in v1.13.0
func (s *ExponentialScale) String() string
type Graceful ¶ added in v1.1.0
type Graceful struct {
// contains filtered or unexported fields
}
func (*Graceful) EmitShutdown ¶ added in v1.1.0
func (*Graceful) OnShutdown ¶ added in v1.1.0
type InstanceIDProvider ¶ added in v1.33.0
type InstanceIDProvider interface {
InstanceID() string
}
type LayerScale ¶ added in v1.16.0
type LayerScale struct {
LayerRule *SlideRule `json:"byLayer"`
}
LayerScale defines the scale DSL for maker layers, e.g.,
quantityScale:
byLayer: exp: domain: [1, 5] range: [0.01, 1.0]
and
quantityScale:
byLayer: linear: domain: [1, 3] range: [0.01, 1.0]
type LinearScale ¶ added in v1.13.0
type LinearScale struct { Domain [2]float64 `json:"domain"` Range [2]float64 `json:"range"` // contains filtered or unexported fields }
func (*LinearScale) Call ¶ added in v1.13.0
func (s *LinearScale) Call(x float64) (y float64)
func (*LinearScale) Formula ¶ added in v1.13.0
func (s *LinearScale) Formula() string
func (*LinearScale) FormulaOf ¶ added in v1.13.0
func (s *LinearScale) FormulaOf(x float64) string
func (*LinearScale) Solve ¶ added in v1.13.0
func (s *LinearScale) Solve() error
func (*LinearScale) String ¶ added in v1.13.0
func (s *LinearScale) String() string
type LogarithmicScale ¶ added in v1.13.0
type LogarithmicScale struct { Domain [2]float64 `json:"domain"` Range [2]float64 `json:"range"` // contains filtered or unexported fields }
func (*LogarithmicScale) Call ¶ added in v1.13.0
func (s *LogarithmicScale) Call(x float64) (y float64)
func (*LogarithmicScale) Formula ¶ added in v1.13.0
func (s *LogarithmicScale) Formula() string
func (*LogarithmicScale) FormulaOf ¶ added in v1.13.0
func (s *LogarithmicScale) FormulaOf(x float64) string
func (*LogarithmicScale) Solve ¶ added in v1.13.0
func (s *LogarithmicScale) Solve() error
func (*LogarithmicScale) String ¶ added in v1.13.0
func (s *LogarithmicScale) String() string
type MarketDataStore ¶
type MarketDataStore struct { Symbol string // KLineWindows stores all loaded klines per interval KLineWindows map[types.Interval]*types.KLineWindow `json:"-"` // contains filtered or unexported fields }
MarketDataStore receives and maintain the public market data
func NewMarketDataStore ¶
func NewMarketDataStore(symbol string) *MarketDataStore
func (*MarketDataStore) AddKLine ¶
func (store *MarketDataStore) AddKLine(kline types.KLine)
func (*MarketDataStore) BindStream ¶
func (store *MarketDataStore) BindStream(stream types.Stream)
func (*MarketDataStore) EmitKLineWindowUpdate ¶
func (store *MarketDataStore) EmitKLineWindowUpdate(interval types.Interval, klines types.KLineWindow)
func (*MarketDataStore) KLinesOfInterval ¶
func (store *MarketDataStore) KLinesOfInterval(interval types.Interval) (kLines *types.KLineWindow, ok bool)
KLinesOfInterval returns the kline window of the given interval
func (*MarketDataStore) OnKLineWindowUpdate ¶
func (store *MarketDataStore) OnKLineWindowUpdate(cb func(interval types.Interval, klines types.KLineWindow))
func (*MarketDataStore) SetKLineWindows ¶
func (store *MarketDataStore) SetKLineWindows(windows map[types.Interval]*types.KLineWindow)
type MovingAverageSettings ¶ added in v1.17.1
type MovingAverageSettings struct { Type string `json:"type"` Interval types.Interval `json:"interval"` Window int `json:"window"` Side *types.SideType `json:"side"` QuantityOrAmount }
func (*MovingAverageSettings) Indicator ¶ added in v1.17.1
func (settings *MovingAverageSettings) Indicator(indicatorSet *StandardIndicatorSet) (inc types.Float64Indicator, err error)
func (MovingAverageSettings) IntervalWindow ¶ added in v1.17.1
func (settings MovingAverageSettings) IntervalWindow() types.IntervalWindow
type Notifiability ¶
type Notifiability struct { SessionChannelRouter *PatternChannelRouter `json:"-"` SymbolChannelRouter *PatternChannelRouter `json:"-"` ObjectChannelRouter *ObjectChannelRouter `json:"-"` // contains filtered or unexported fields }
func (*Notifiability) AddNotifier ¶
func (m *Notifiability) AddNotifier(notifier Notifier)
AddNotifier adds the notifier that implements the Notifier interface.
func (*Notifiability) Notify ¶
func (m *Notifiability) Notify(obj interface{}, args ...interface{})
func (*Notifiability) NotifyTo ¶
func (m *Notifiability) NotifyTo(channel string, obj interface{}, args ...interface{})
func (*Notifiability) RouteObject ¶
func (m *Notifiability) RouteObject(obj interface{}) (channel string, ok bool)
RouteObject routes object to channel
func (*Notifiability) RouteSession ¶
func (m *Notifiability) RouteSession(session string) (channel string, ok bool)
RouteSession routes Session name to channel
func (*Notifiability) RouteSymbol ¶
func (m *Notifiability) RouteSymbol(symbol string) (channel string, ok bool)
RouteSymbol routes symbol name to channel
type NotificationConfig ¶
type NotificationConfig struct { Slack *SlackNotification `json:"slack,omitempty" yaml:"slack,omitempty"` Telegram *TelegramNotification `json:"telegram,omitempty" yaml:"telegram,omitempty"` SymbolChannels map[string]string `json:"symbolChannels,omitempty" yaml:"symbolChannels,omitempty"` SessionChannels map[string]string `json:"sessionChannels,omitempty" yaml:"sessionChannels,omitempty"` Routing *SlackNotificationRouting `json:"routing,omitempty" yaml:"routing,omitempty"` }
type Notifier ¶
type Notifier interface { NotifyTo(channel string, obj interface{}, args ...interface{}) Notify(obj interface{}, args ...interface{}) }
type NullNotifier ¶
type NullNotifier struct{}
func (*NullNotifier) Notify ¶
func (n *NullNotifier) Notify(obj interface{}, args ...interface{})
func (*NullNotifier) NotifyTo ¶
func (n *NullNotifier) NotifyTo(channel string, obj interface{}, args ...interface{})
type ObjectChannelHandler ¶
type ObjectChannelRouter ¶
type ObjectChannelRouter struct {
// contains filtered or unexported fields
}
func NewObjectChannelRouter ¶
func NewObjectChannelRouter() *ObjectChannelRouter
func (*ObjectChannelRouter) AddRoute ¶
func (router *ObjectChannelRouter) AddRoute(f ObjectChannelHandler)
func (*ObjectChannelRouter) Route ¶
func (router *ObjectChannelRouter) Route(obj interface{}) (channel string, ok bool)
type OrderExecutionRouter ¶
type OrderExecutionRouter interface { // SubmitOrdersTo submit order to a specific exchange Session SubmitOrdersTo(ctx context.Context, session string, orders ...types.SubmitOrder) (createdOrders types.OrderSlice, err error) CancelOrdersTo(ctx context.Context, session string, orders ...types.Order) error }
type OrderExecutor ¶
type OrderExecutor interface { SubmitOrders(ctx context.Context, orders ...types.SubmitOrder) (createdOrders types.OrderSlice, err error) CancelOrders(ctx context.Context, orders ...types.Order) error OnTradeUpdate(cb func(trade types.Trade)) OnOrderUpdate(cb func(order types.Order)) EmitTradeUpdate(trade types.Trade) EmitOrderUpdate(order types.Order) }
type OrderStore ¶ added in v1.1.0
type OrderStore struct { Symbol string RemoveCancelled bool RemoveFilled bool AddOrderUpdate bool // contains filtered or unexported fields }
func NewOrderStore ¶ added in v1.1.0
func NewOrderStore(symbol string) *OrderStore
func (*OrderStore) Add ¶ added in v1.1.0
func (s *OrderStore) Add(orders ...types.Order)
func (*OrderStore) AllFilled ¶ added in v1.18.0
func (s *OrderStore) AllFilled() bool
func (*OrderStore) BindStream ¶ added in v1.1.0
func (s *OrderStore) BindStream(stream types.Stream)
func (*OrderStore) Exists ¶ added in v1.1.0
func (s *OrderStore) Exists(oID uint64) (ok bool)
func (*OrderStore) Get ¶ added in v1.28.0
func (s *OrderStore) Get(oID uint64) (order types.Order, ok bool)
Get a single order from the order store by order ID Should check ok to make sure the order is returned successfully
func (*OrderStore) NumOfOrders ¶ added in v1.17.0
func (s *OrderStore) NumOfOrders() (num int)
func (*OrderStore) Orders ¶ added in v1.11.0
func (s *OrderStore) Orders() (orders []types.Order)
func (*OrderStore) Remove ¶ added in v1.1.0
func (s *OrderStore) Remove(o types.Order)
type PatternChannelRouter ¶
type PatternChannelRouter struct {
// contains filtered or unexported fields
}
func NewPatternChannelRouter ¶
func NewPatternChannelRouter(routes map[string]string) *PatternChannelRouter
func (*PatternChannelRouter) AddRoute ¶
func (router *PatternChannelRouter) AddRoute(routes map[string]string)
type PercentageScale ¶ added in v1.28.0
type PercentageScale struct {
ByPercentage *SlideRule `json:"byPercentage"`
}
type Persistence ¶ added in v1.3.1
type Persistence struct { PersistenceSelector *PersistenceSelector `json:"persistence,omitempty" yaml:"persistence,omitempty"` Facade *service.PersistenceServiceFacade `json:"-" yaml:"-"` }
Persistence is used for strategy to inject the persistence.
func (*Persistence) Load ¶ added in v1.3.1
func (p *Persistence) Load(val interface{}, subIDs ...string) error
func (*Persistence) Save ¶ added in v1.3.1
func (p *Persistence) Save(val interface{}, subIDs ...string) error
func (*Persistence) Sync ¶ added in v1.33.0
func (p *Persistence) Sync(obj interface{}) error
type PersistenceConfig ¶ added in v1.3.1
type PersistenceConfig struct { Redis *service.RedisPersistenceConfig `json:"redis,omitempty" yaml:"redis,omitempty"` Json *service.JsonPersistenceConfig `json:"json,omitempty" yaml:"json,omitempty"` }
type PersistenceSelector ¶ added in v1.3.1
type PnLReporter ¶
type PnLReporter interface {
Run()
}
type PnLReporterConfig ¶
type PnLReporterConfig struct { AverageCostBySymbols datatype.StringSlice `json:"averageCostBySymbols" yaml:"averageCostBySymbols"` Of datatype.StringSlice `json:"of" yaml:"of"` When datatype.StringSlice `json:"when" yaml:"when"` }
type PnLReporterManager ¶
type PnLReporterManager struct {
// contains filtered or unexported fields
}
func NewPnLReporter ¶
func NewPnLReporter(notifier Notifier) *PnLReporterManager
func (*PnLReporterManager) AverageCostBySymbols ¶
func (manager *PnLReporterManager) AverageCostBySymbols(symbols ...string) *AverageCostPnLReporter
type PositionCloser ¶ added in v1.26.0
type PositionCloser interface {
ClosePosition(ctx context.Context, percentage fixedpoint.Value) error
}
type PositionReader ¶ added in v1.26.0
type PriceVolumeScale ¶ added in v1.13.0
type PriceVolumeScale struct { ByPriceRule *SlideRule `json:"byPrice"` ByVolumeRule *SlideRule `json:"byVolume"` }
PriceVolumeScale defines the scale DSL for strategy, e.g.,
quantityScale:
byPrice: exp: domain: [10_000, 50_000] range: [0.01, 1.0]
and
quantityScale:
byVolume: linear: domain: [10_000, 50_000] range: [0.01, 1.0]
func (*PriceVolumeScale) Scale ¶ added in v1.13.0
func (s *PriceVolumeScale) Scale(price float64, volume float64) (quantity float64, err error)
func (*PriceVolumeScale) ScaleByPrice ¶ added in v1.13.0
func (s *PriceVolumeScale) ScaleByPrice(price float64) (float64, error)
ScaleByPrice scale quantity by the given price
func (*PriceVolumeScale) ScaleByVolume ¶ added in v1.13.0
func (s *PriceVolumeScale) ScaleByVolume(volume float64) (float64, error)
ScaleByVolume scale quantity by the given volume
type QuadraticScale ¶ added in v1.13.0
type QuadraticScale struct { Domain [3]float64 `json:"domain"` Range [3]float64 `json:"range"` // contains filtered or unexported fields }
see also: http://www.vb-helper.com/howto_find_quadratic_curve.html
func (*QuadraticScale) Call ¶ added in v1.13.0
func (s *QuadraticScale) Call(x float64) (y float64)
func (*QuadraticScale) Formula ¶ added in v1.13.0
func (s *QuadraticScale) Formula() string
func (*QuadraticScale) FormulaOf ¶ added in v1.13.0
func (s *QuadraticScale) FormulaOf(x float64) string
func (*QuadraticScale) Solve ¶ added in v1.13.0
func (s *QuadraticScale) Solve() error
func (*QuadraticScale) String ¶ added in v1.13.0
func (s *QuadraticScale) String() string
type QuantityOrAmount ¶ added in v1.28.0
type QuantityOrAmount struct { // Quantity is the base order quantity for your buy/sell order. // when quantity is set, the amount option will be not used. Quantity fixedpoint.Value `json:"quantity"` // Amount is the order quote amount for your buy/sell order. Amount fixedpoint.Value `json:"amount,omitempty"` }
QuantityOrAmount is a setting structure used for quantity/amount settings You can embed this struct into your strategy to share the setting methods
func (*QuantityOrAmount) CalculateQuantity ¶ added in v1.28.0
func (qa *QuantityOrAmount) CalculateQuantity(currentPrice fixedpoint.Value) fixedpoint.Value
CalculateQuantity calculates the equivalent quantity of the given price when amount is set it returns the quantity if the quantity is set
func (*QuantityOrAmount) IsSet ¶ added in v1.28.0
func (qa *QuantityOrAmount) IsSet() bool
func (*QuantityOrAmount) Validate ¶ added in v1.28.0
func (qa *QuantityOrAmount) Validate() error
type Quota ¶ added in v1.2.0
type Quota struct { Available fixedpoint.Value Locked fixedpoint.Value // contains filtered or unexported fields }
func (*Quota) Add ¶ added in v1.2.0
func (q *Quota) Add(fund fixedpoint.Value)
type QuotaTransaction ¶ added in v1.2.0
type QuotaTransaction struct { BaseAsset Quota QuoteAsset Quota // contains filtered or unexported fields }
func (*QuotaTransaction) Commit ¶ added in v1.2.0
func (m *QuotaTransaction) Commit() bool
func (*QuotaTransaction) Rollback ¶ added in v1.2.0
func (m *QuotaTransaction) Rollback() bool
type RiskControlOrderExecutor ¶
type RiskControlOrderExecutor struct { *ExchangeOrderExecutor // Symbol => Executor config BySymbol map[string]*SymbolBasedRiskController `json:"bySymbol,omitempty" yaml:"bySymbol,omitempty"` }
func (*RiskControlOrderExecutor) SubmitOrders ¶
func (e *RiskControlOrderExecutor) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder) (retOrders types.OrderSlice, err error)
type RiskControls ¶
type RiskControls struct {
SessionBasedRiskControl map[string]*SessionBasedRiskControl `json:"sessionBased,omitempty" yaml:"sessionBased,omitempty"`
}
type Session ¶
type Session struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` ExchangeName string `json:"exchange" yaml:"exchange"` EnvVarPrefix string `json:"envVarPrefix" yaml:"envVarPrefix"` Key string `json:"key,omitempty" yaml:"key,omitempty"` Secret string `json:"secret,omitempty" yaml:"secret,omitempty"` PublicOnly bool `json:"publicOnly,omitempty" yaml:"publicOnly"` Margin bool `json:"margin,omitempty" yaml:"margin,omitempty"` IsolatedMargin bool `json:"isolatedMargin,omitempty" yaml:"isolatedMargin,omitempty"` IsolatedMarginSymbol string `json:"isolatedMarginSymbol,omitempty" yaml:"isolatedMarginSymbol,omitempty"` }
type SessionBasedRiskControl ¶
type SessionBasedRiskControl struct {
OrderExecutor *RiskControlOrderExecutor `json:"orderExecutor,omitempty" yaml:"orderExecutor"`
}
func (*SessionBasedRiskControl) SetBaseOrderExecutor ¶
func (control *SessionBasedRiskControl) SetBaseOrderExecutor(executor *ExchangeOrderExecutor)
type SilentLogger ¶
type SilentLogger struct{}
func (*SilentLogger) Errorf ¶
func (logger *SilentLogger) Errorf(string, ...interface{})
func (*SilentLogger) Infof ¶
func (logger *SilentLogger) Infof(string, ...interface{})
func (*SilentLogger) Warnf ¶
func (logger *SilentLogger) Warnf(string, ...interface{})
type SingleExchangeStrategy ¶
type SingleExchangeStrategy interface { StrategyID Run(ctx context.Context, orderExecutor OrderExecutor, session *ExchangeSession) error }
SingleExchangeStrategy represents the single Exchange strategy
func NewStrategyFromMap ¶ added in v1.11.0
func NewStrategyFromMap(id string, conf interface{}) (SingleExchangeStrategy, error)
type SlackNotification ¶
type SlackNotificationRouting ¶ added in v1.12.0
type SlideRule ¶ added in v1.13.0
type SlideRule struct { // Scale type could be one of "log", "exp", "linear", "quadratic" // this is similar to the d3.scale LinearScale *LinearScale `json:"linear"` LogScale *LogarithmicScale `json:"log"` ExpScale *ExponentialScale `json:"exp"` QuadraticScale *QuadraticScale `json:"quadratic"` }
type SmartStops ¶ added in v1.28.0
type SmartStops struct { // Stops is the slice of the stop order config Stops []Stop `json:"stops,omitempty"` // StopControllers are constructed from the stop config StopControllers []StopController `json:"-"` }
SmartStops shares the stop order logics between different strategies
See also: - Stop-Loss order: https://www.investopedia.com/terms/s/stop-lossorder.asp - Trailing Stop-loss order: https://www.investopedia.com/articles/trading/08/trailing-stop-loss.asp
How to integrate this into your strategy?
To use the stop controllers, you can embed this struct into your Strategy struct ¶
func (s *Strategy) Initialize() error { return s.SmartStops.InitializeStopControllers(s.Symbol) }
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) { s.SmartStops.Subscribe(session) }
func (s *Strategy) Run() { s.SmartStops.RunStopControllers(ctx, session, s.tradeCollector) }
func (*SmartStops) InitializeStopControllers ¶ added in v1.28.0
func (s *SmartStops) InitializeStopControllers(symbol string) error
func (*SmartStops) RunStopControllers ¶ added in v1.28.0
func (s *SmartStops) RunStopControllers(ctx context.Context, session *ExchangeSession, tradeCollector *TradeCollector)
func (*SmartStops) Subscribe ¶ added in v1.28.0
func (s *SmartStops) Subscribe(session *ExchangeSession)
type StandardIndicatorSet ¶
type StandardIndicatorSet struct { Symbol string // contains filtered or unexported fields }
func NewStandardIndicatorSet ¶
func NewStandardIndicatorSet(symbol string, store *MarketDataStore) *StandardIndicatorSet
func (*StandardIndicatorSet) BOLL ¶
func (set *StandardIndicatorSet) BOLL(iw types.IntervalWindow, bandWidth float64) *indicator.BOLL
BOLL returns the bollinger band indicator of the given interval, the window and bandwidth
func (*StandardIndicatorSet) EWMA ¶
func (set *StandardIndicatorSet) EWMA(iw types.IntervalWindow) *indicator.EWMA
EWMA returns the exponential weighed moving average indicator of the given interval and the window size.
func (*StandardIndicatorSet) SMA ¶
func (set *StandardIndicatorSet) SMA(iw types.IntervalWindow) *indicator.SMA
SMA returns the simple moving average indicator of the given interval and the window size.
func (*StandardIndicatorSet) STOCH ¶ added in v1.17.0
func (set *StandardIndicatorSet) STOCH(iw types.IntervalWindow) *indicator.STOCH
func (*StandardIndicatorSet) VOLATILITY ¶ added in v1.21.0
func (set *StandardIndicatorSet) VOLATILITY(iw types.IntervalWindow) *indicator.VOLATILITY
VOLATILITY returns the volatility(stddev) indicator of the given interval and the window size.
type Stop ¶ added in v1.28.0
type Stop struct { TrailingStop *TrailingStop `json:"trailingStop,omitempty"` FixedStop *FixedStop `json:"fixedStop,omitempty"` }
type StopController ¶ added in v1.28.0
type StopController interface { Subscribe(session *ExchangeSession) Run(ctx context.Context, session *ExchangeSession, tradeCollector *TradeCollector) }
type StrategyController ¶ added in v1.29.0
type StrategyController struct { Status types.StrategyStatus // contains filtered or unexported fields }
func (*StrategyController) EmergencyStop ¶ added in v1.31.0
func (s *StrategyController) EmergencyStop() error
func (*StrategyController) EmitEmergencyStop ¶ added in v1.31.0
func (s *StrategyController) EmitEmergencyStop()
func (*StrategyController) EmitResume ¶ added in v1.31.0
func (s *StrategyController) EmitResume()
func (*StrategyController) EmitSuspend ¶ added in v1.31.0
func (s *StrategyController) EmitSuspend()
func (*StrategyController) GetStatus ¶ added in v1.31.0
func (s *StrategyController) GetStatus() types.StrategyStatus
func (*StrategyController) OnEmergencyStop ¶ added in v1.31.0
func (s *StrategyController) OnEmergencyStop(cb func())
func (*StrategyController) OnResume ¶ added in v1.31.0
func (s *StrategyController) OnResume(cb func())
func (*StrategyController) OnSuspend ¶ added in v1.31.0
func (s *StrategyController) OnSuspend(cb func())
func (*StrategyController) Resume ¶ added in v1.31.0
func (s *StrategyController) Resume() error
func (*StrategyController) Suspend ¶ added in v1.31.0
func (s *StrategyController) Suspend() error
type StrategyID ¶ added in v1.33.0
type StrategyID interface {
ID() string
}
type StrategyInitializer ¶ added in v1.28.0
type StrategyInitializer interface {
Initialize() error
}
type StrategyStatusReader ¶ added in v1.31.0
type StrategyStatusReader interface {
GetStatus() types.StrategyStatus
}
type StrategyToggler ¶ added in v1.31.0
type StrategyToggler interface { StrategyStatusReader Suspend() error Resume() error }
type StructFieldIterator ¶ added in v1.33.0
type SymbolBasedRiskController ¶
type SymbolBasedRiskController struct {
BasicRiskController *BasicRiskController `json:"basic,omitempty" yaml:"basic,omitempty"`
}
type SyncConfig ¶ added in v1.27.0
type SyncConfig struct { // Sessions to sync, if ignored, all defined sessions will sync Sessions []string `json:"sessions,omitempty" yaml:"sessions,omitempty"` // Symbols is the list of symbol to sync, if ignored, symbols wlll be discovered by your existing crypto balances Symbols []string `json:"symbols,omitempty" yaml:"symbols,omitempty"` // DepositHistory is for syncing deposit history DepositHistory bool `json:"depositHistory" yaml:"depositHistory"` // WithdrawHistory is for syncing withdraw history WithdrawHistory bool `json:"withdrawHistory" yaml:"withdrawHistory"` // RewardHistory is for syncing reward history RewardHistory bool `json:"rewardHistory" yaml:"rewardHistory"` // MarginHistory is for syncing margin related history: loans, repays, interests and liquidations MarginHistory bool `json:"marginHistory" yaml:"marginHistory"` MarginAssets []string `json:"marginAssets" yaml:"marginAssets"` // Since is the date where you want to start syncing data Since *types.LooseFormatTime `json:"since,omitempty"` // UserDataStream is for real-time sync with websocket user data stream UserDataStream *struct { Trades bool `json:"trades,omitempty" yaml:"trades,omitempty"` FilledOrders bool `json:"filledOrders,omitempty" yaml:"filledOrders,omitempty"` } `json:"userDataStream,omitempty" yaml:"userDataStream,omitempty"` }
type SyncStatus ¶ added in v1.12.0
type SyncStatus int
const ( SyncNotStarted SyncStatus = iota Syncing SyncDone )
type TelegramNotification ¶ added in v1.18.0
type TelegramNotification struct {
Broadcast bool `json:"broadcast" yaml:"broadcast"`
}
type TradeCollector ¶ added in v1.17.0
type TradeCollector struct { Symbol string // contains filtered or unexported fields }
func NewTradeCollector ¶ added in v1.17.0
func NewTradeCollector(symbol string, position *types.Position, orderStore *OrderStore) *TradeCollector
func (*TradeCollector) BindStream ¶ added in v1.17.0
func (c *TradeCollector) BindStream(stream types.Stream)
func (*TradeCollector) BindStreamForBackground ¶ added in v1.18.0
func (c *TradeCollector) BindStreamForBackground(stream types.Stream)
BindStreamForBackground bind the stream callback for background processing
func (*TradeCollector) Emit ¶ added in v1.17.0
func (c *TradeCollector) Emit()
Emit triggers the trade processing (position update) If you sent order, and the order store is updated, you can call this method so that trades will be processed in the next round of the goroutine loop
func (*TradeCollector) EmitPositionUpdate ¶ added in v1.17.0
func (c *TradeCollector) EmitPositionUpdate(position *types.Position)
func (*TradeCollector) EmitProfit ¶ added in v1.17.0
func (c *TradeCollector) EmitProfit(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value)
func (*TradeCollector) EmitRecover ¶ added in v1.25.0
func (c *TradeCollector) EmitRecover(trade types.Trade)
func (*TradeCollector) EmitTrade ¶ added in v1.17.0
func (c *TradeCollector) EmitTrade(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value)
func (*TradeCollector) OnPositionUpdate ¶ added in v1.17.0
func (c *TradeCollector) OnPositionUpdate(cb func(position *types.Position))
func (*TradeCollector) OnProfit ¶ added in v1.17.0
func (c *TradeCollector) OnProfit(cb func(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value))
func (*TradeCollector) OnRecover ¶ added in v1.25.0
func (c *TradeCollector) OnRecover(cb func(trade types.Trade))
func (*TradeCollector) OnTrade ¶ added in v1.17.0
func (c *TradeCollector) OnTrade(cb func(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value))
func (*TradeCollector) OrderStore ¶ added in v1.28.0
func (c *TradeCollector) OrderStore() *OrderStore
OrderStore returns the order store used by the trade collector
func (*TradeCollector) Position ¶ added in v1.28.0
func (c *TradeCollector) Position() *types.Position
Position returns the position used by the trade collector
func (*TradeCollector) Process ¶ added in v1.18.0
func (c *TradeCollector) Process() bool
Process filters the received trades and see if there are orders matching the trades if we have the order in the order store, then the trade will be considered for the position. profit will also be calculated.
func (*TradeCollector) ProcessTrade ¶ added in v1.23.0
func (c *TradeCollector) ProcessTrade(trade types.Trade) bool
return true when the given trade is added return false when the given trade is not added
func (*TradeCollector) QueueTrade ¶ added in v1.23.0
func (c *TradeCollector) QueueTrade(trade types.Trade)
QueueTrade sends the trade object to the trade channel, so that the goroutine can receive the trade and process in the background.
func (*TradeCollector) Recover ¶ added in v1.25.0
func (c *TradeCollector) Recover(ctx context.Context, ex types.ExchangeTradeHistoryService, symbol string, from time.Time) error
func (*TradeCollector) Run ¶ added in v1.17.0
func (c *TradeCollector) Run(ctx context.Context)
Run is a goroutine executed in the background Do not use this function if you need back-testing
type TradeFilter ¶ added in v1.17.0
type TradeReporter ¶
type TradeReporter struct {
*Notifiability
}
type TradeStore ¶ added in v1.17.0
type TradeStore struct { // any created trades for tracking trades sync.Mutex Symbol string RemoveCancelled bool RemoveFilled bool AddOrderUpdate bool // contains filtered or unexported fields }
func NewTradeStore ¶ added in v1.17.0
func NewTradeStore(symbol string) *TradeStore
func (*TradeStore) Add ¶ added in v1.17.0
func (s *TradeStore) Add(trades ...types.Trade)
func (*TradeStore) Clear ¶ added in v1.17.0
func (s *TradeStore) Clear()
func (*TradeStore) Exists ¶ added in v1.17.0
func (s *TradeStore) Exists(oID uint64) (ok bool)
func (*TradeStore) Filter ¶ added in v1.17.0
func (s *TradeStore) Filter(filter TradeFilter)
func (*TradeStore) GetAndClear ¶ added in v1.17.0
func (s *TradeStore) GetAndClear() (trades []types.Trade)
func (*TradeStore) Num ¶ added in v1.17.0
func (s *TradeStore) Num() (num int)
func (*TradeStore) Trades ¶ added in v1.17.0
func (s *TradeStore) Trades() (trades []types.Trade)
type Trader ¶
type Trader struct { Graceful Graceful // contains filtered or unexported fields }
func NewTrader ¶
func NewTrader(environ *Environment) *Trader
func (*Trader) AttachCrossExchangeStrategy ¶
func (trader *Trader) AttachCrossExchangeStrategy(strategy CrossExchangeStrategy) *Trader
AttachCrossExchangeStrategy attaches the cross exchange strategy
func (*Trader) AttachStrategyOn ¶
func (trader *Trader) AttachStrategyOn(session string, strategies ...SingleExchangeStrategy) error
AttachStrategyOn attaches the single exchange strategy on an exchange Session. Single exchange strategy is the default behavior.
func (*Trader) DisableLogging ¶
func (trader *Trader) DisableLogging()
func (*Trader) EnableLogging ¶
func (trader *Trader) EnableLogging()
func (*Trader) IterateStrategies ¶ added in v1.33.0
func (trader *Trader) IterateStrategies(f func(st StrategyID) error) error
func (*Trader) ReportPnL ¶
func (trader *Trader) ReportPnL() *PnLReporterManager
ReportPnL configure and set the PnLReporter with the given notifier
func (*Trader) RunAllSingleExchangeStrategy ¶ added in v1.11.1
func (*Trader) RunSingleExchangeStrategy ¶ added in v1.11.1
func (trader *Trader) RunSingleExchangeStrategy(ctx context.Context, strategy SingleExchangeStrategy, session *ExchangeSession, orderExecutor OrderExecutor) error
func (*Trader) SetRiskControls ¶
func (trader *Trader) SetRiskControls(riskControls *RiskControls)
SetRiskControls sets the risk controller TODO: provide a more DSL way to configure risk controls
type TrailingStop ¶ added in v1.28.0
type TrailingStop struct { // CallbackRate is the callback rate from the previous high price CallbackRate fixedpoint.Value `json:"callbackRate,omitempty"` // ClosePosition is a percentage of the position to be closed ClosePosition fixedpoint.Value `json:"closePosition,omitempty"` // MinProfit is the percentage of the minimum profit ratio. // Stop order will be activiated only when the price reaches above this threshold. MinProfit fixedpoint.Value `json:"minProfit,omitempty"` // Interval is the time resolution to update the stop order // KLine per Interval will be used for updating the stop order Interval types.Interval `json:"interval,omitempty"` // Virtual is used when you don't want to place the real order on the exchange and lock the balance. // You want to handle the stop order by the strategy itself. Virtual bool `json:"virtual,omitempty"` }
type TrailingStopController ¶ added in v1.28.0
type TrailingStopController struct { *TrailingStop Symbol string // contains filtered or unexported fields }
func NewTrailingStopController ¶ added in v1.28.0
func NewTrailingStopController(symbol string, config *TrailingStop) *TrailingStopController
func (*TrailingStopController) GenerateStopOrder ¶ added in v1.28.0
func (c *TrailingStopController) GenerateStopOrder(stopPrice, price fixedpoint.Value) *types.SubmitOrder
func (*TrailingStopController) Run ¶ added in v1.28.0
func (c *TrailingStopController) Run(ctx context.Context, session *ExchangeSession, tradeCollector *TradeCollector)
func (*TrailingStopController) Subscribe ¶ added in v1.28.0
func (c *TrailingStopController) Subscribe(session *ExchangeSession)
type TwapExecution ¶ added in v1.17.0
type TwapExecution struct { Session *ExchangeSession Symbol string Side types.SideType TargetQuantity fixedpoint.Value SliceQuantity fixedpoint.Value StopPrice fixedpoint.Value NumOfTicks int UpdateInterval time.Duration DeadlineTime time.Time // contains filtered or unexported fields }
func (*TwapExecution) Done ¶ added in v1.17.0
func (e *TwapExecution) Done() (c <-chan struct{})
func (*TwapExecution) Run ¶ added in v1.17.0
func (e *TwapExecution) Run(parentCtx context.Context) error
func (*TwapExecution) Shutdown ¶ added in v1.17.0
func (e *TwapExecution) Shutdown(shutdownCtx context.Context)
Shutdown stops the execution If we call this method, it means the execution is still running, We need to: 1. stop the order updater (by using the execution context) 2. the order updater cancels all open orders and close the user data stream
Source Files ¶
- activeorderbook.go
- activeorderbook_callbacks.go
- builder.go
- config.go
- context.go
- environment.go
- errors.go
- exchangeorderexecutor_callbacks.go
- graceful_callbacks.go
- graceful_shutdown.go
- injection.go
- interact.go
- marketdatastore.go
- marketdatastore_callbacks.go
- metrics.go
- moving_average_settings.go
- notifier.go
- order_execution.go
- order_processor.go
- order_store.go
- persistence.go
- profitstats.go
- quantity_amount.go
- quota.go
- reflect.go
- reporter.go
- risk_controls.go
- scale.go
- session.go
- smart_stops.go
- strategy_controller.go
- strategycontroller_callbacks.go
- string.go
- time.go
- trade_store.go
- tradecollector.go
- tradecollector_callbacks.go
- trader.go
- twap_order_executor.go
- wrapper.go