strategy

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

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

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 (*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

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

func (om *Strategy) CancelChildOrdersAndStrategyOrder() error

CancelChildOrdersAndStrategyOrder should only be called from with the strategy's event processing loop as per the example strategies

func (*Strategy) CheckIfDone

func (om *Strategy) CheckIfDone(ctx context.Context) (done bool, err error)

CheckIfDone must be called in the strategies event handling loop, see example strategies as per package documentation.

func (*Strategy) OnChildOrderUpdate

func (om *Strategy) OnChildOrderUpdate(childUpdatesChannelOpen bool, co *model.Order) error

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.

Jump to

Keyboard shortcuts

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