Documentation ¶
Overview ¶
Package strategy contains types and functions to be used to create execution trading strategies. To understand how to use the code in this package see the examples strategies at https://github.com/ettec/open-trading-platform/tree/master/go/execution-venues/smart-router and https://github.com/ettec/open-trading-platform/tree/master/go/execution-venues/vwap-strategy.
Index ¶
- type Manager
- func (s *Manager) CancelOrder(_ context.Context, params *executionvenue.CancelOrderParams) (*model.Empty, error)
- func (s *Manager) CreateAndRouteOrder(_ context.Context, params *executionvenue.CreateAndRouteOrderParams) (*executionvenue.OrderId, error)
- func (s *Manager) GetExecutionParametersMetaData(_ context.Context, empty *model.Empty) (*executionvenue.ExecParamsMetaDataJson, error)
- func (s *Manager) ModifyOrder(_ context.Context, _ *executionvenue.ModifyOrderParams) (*model.Empty, error)
- type Strategy
- func (om *Strategy) CancelChildOrdersAndStrategyOrder() error
- func (om *Strategy) CheckIfDone(ctx context.Context) (done bool, err error)
- func (om *Strategy) OnChildOrderUpdate(childUpdatesChannelOpen bool, co *model.Order) error
- func (om *Strategy) SendChildOrder(side model.Side, quantity *model.Decimal64, price *model.Decimal64, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶ added in v1.4.0
type Manager struct {
// contains filtered or unexported fields
}
Manager is responsible for the creation and recovery of new strategy instances and for forwarding requests to a strategy service to the target strategy.
func NewStrategyManager ¶
func NewStrategyManager(ctx context.Context, id string, parentOrderStore orderStore, childOrderUpdates childOrderUpdates, orderRouter executionvenue.ExecutionVenueClient, executeFn func(om *Strategy)) (*Manager, error)
func (*Manager) CancelOrder ¶ added in v1.4.0
func (s *Manager) CancelOrder(_ context.Context, params *executionvenue.CancelOrderParams) (*model.Empty, error)
func (*Manager) CreateAndRouteOrder ¶ added in v1.4.0
func (s *Manager) CreateAndRouteOrder(_ context.Context, params *executionvenue.CreateAndRouteOrderParams) (*executionvenue.OrderId, error)
func (*Manager) GetExecutionParametersMetaData ¶ added in v1.4.0
func (s *Manager) GetExecutionParametersMetaData(_ context.Context, empty *model.Empty) (*executionvenue.ExecParamsMetaDataJson, error)
func (*Manager) ModifyOrder ¶ added in v1.4.0
func (s *Manager) ModifyOrder(_ context.Context, _ *executionvenue.ModifyOrderParams) (*model.Empty, error)
type Strategy ¶
type Strategy struct { // This channel must be checked and handled as part of the select statement in the strategies event loop CancelChan chan string // This channel must be checked and handled as part of the select statement in the strategies event loop ChildOrderUpdateChan <-chan *model.Order ExecVenueId string ParentOrder *ordermanagement.ParentOrder Log *slog.Logger // contains filtered or unexported fields }
Strategy is a base type to be used to build trading strategies. For examples see https://github.com/ettec/open-trading-platform/tree/master/go/execution-venues/smart-router and https://github.com/ettec/open-trading-platform/tree/master/go/execution-venues/vwap-strategy.
func NewStrategyFromCreateParams ¶
func NewStrategyFromCreateParams(parentOrderId string, params *executionvenue.CreateAndRouteOrderParams, execVenueId string, store func(context.Context, *model.Order) error, orderRouter executionvenue.ExecutionVenueClient, childOrderStream ordermanagement.OrderStream, doneChan chan<- string) (*Strategy, error)
func NewStrategyFromParentOrder ¶
func NewStrategyFromParentOrder(initialState *model.Order, store func(context.Context, *model.Order) error, execVenueId string, orderRouter executionvenue.ExecutionVenueClient, childOrderStream ordermanagement.OrderStream, doneChan chan<- string) *Strategy
func (*Strategy) CancelChildOrdersAndStrategyOrder ¶
CancelChildOrdersAndStrategyOrder should only be called from with the strategy's event processing loop as per the example strategies
func (*Strategy) CheckIfDone ¶
CheckIfDone must be called in the strategies event handling loop, see example strategies as per package documentation.
func (*Strategy) OnChildOrderUpdate ¶
OnChildOrderUpdate must be called in response to receipt of a child order update in the strategy's event processing loop as per example strategies
func (*Strategy) SendChildOrder ¶
func (om *Strategy) SendChildOrder(side model.Side, quantity *model.Decimal64, price *model.Decimal64, listingId int32, destination string, execParametersJson string) error
SendChildOrder Sends a child order to the given destination and ensures the parent order cannot become over exposed.