execution

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ReconciliationCaseExternalOrders = "TC-REC08"
View Source
const ReconciliationCaseFillBeforeOrder = "TC-REC05"
View Source
const ReconciliationCaseMassStatus = "TC-REC01"
View Source
const ReconciliationCaseMissingFills = "TC-REC02"
View Source
const ReconciliationCaseOrderDiscrepancy = "TC-REC03"

Variables

View Source
var (
	ErrClientNotFound     = errors.New("execution client not found")
	ErrAlgorithmNotFound  = errors.New("execution algorithm not found")
	ErrAlgorithmIDMissing = errors.New("execution algorithm id missing")
)
View Source
var (
	ErrInvalidTransition = errors.New("invalid execution transition")
	ErrOverfill          = errors.New("execution overfill")
)

Functions

This section is empty.

Types

type BatchCanceler

type BatchCanceler interface {
	BatchCancelOrders(context.Context, model.BatchCancelOrders) ([]model.OrderStatusReport, error)
}

type CancelAllCanceler

type CancelAllCanceler interface {
	CancelAllOrders(context.Context, model.CancelAllOrders) ([]model.OrderStatusReport, error)
}

type Client

type Client interface {
	venue.ExecutionClient
}

type Config

type Config struct {
	Cache          *cache.Cache
	AllowOverfills bool
	PositionIDMode PositionIDMode
}

type EmulatedRelease

type EmulatedRelease struct {
	Order     model.SubmitOrder
	Triggered model.OrderStatusReport
	Released  model.OrderStatusReport
}

type Emulator

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

func NewEmulator

func NewEmulator(cfg EmulatorConfig) *Emulator

func (*Emulator) CancelOrder

func (e *Emulator) CancelOrder(cancel model.CancelOrder) (model.OrderStatusReport, bool, error)

func (*Emulator) ModifyOrder

func (*Emulator) ProcessMarketEvent

func (e *Emulator) ProcessMarketEvent(event model.MarketEvent) ([]EmulatedRelease, error)

func (*Emulator) SubmitOrder

type EmulatorConfig

type EmulatorConfig struct {
	Cache   *cache.Cache
	Manager *Manager
}

type Engine

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

func NewEngine

func NewEngine(cfg EngineConfig) *Engine

func (*Engine) AddAlgorithm

func (e *Engine) AddAlgorithm(algorithm ExecutionAlgorithm) error

func (*Engine) AddClient

func (e *Engine) AddClient(client Client) error

func (*Engine) BatchCancelOrders

func (e *Engine) BatchCancelOrders(ctx context.Context, batch model.BatchCancelOrders) ([]model.OrderStatusReport, error)

func (*Engine) CancelAllOrders

func (e *Engine) CancelAllOrders(ctx context.Context, cancelAll model.CancelAllOrders) ([]model.OrderStatusReport, error)

func (*Engine) CancelOrder

func (e *Engine) CancelOrder(ctx context.Context, cancel model.CancelOrder) (model.OrderStatusReport, error)

func (*Engine) Events

func (e *Engine) Events() <-chan model.ExecutionEvent

func (*Engine) ExternalOrderClaim

func (e *Engine) ExternalOrderClaim(instrumentID model.InstrumentID) (model.StrategyID, bool)

func (*Engine) ExternalOrderClaimInstruments

func (e *Engine) ExternalOrderClaimInstruments() []model.InstrumentID

func (*Engine) GenerateExecutionMassStatus

func (e *Engine) GenerateExecutionMassStatus(ctx context.Context, command model.GenerateExecutionMassStatus) (model.ExecutionMassStatus, error)

func (*Engine) GenerateFillReports

func (e *Engine) GenerateFillReports(ctx context.Context, command model.GenerateFillReports) ([]model.FillReport, error)

func (*Engine) GenerateOrderStatusReports

func (e *Engine) GenerateOrderStatusReports(ctx context.Context, command model.GenerateOrderStatusReports) ([]model.OrderStatusReport, error)

func (*Engine) GeneratePositionStatusReports

func (e *Engine) GeneratePositionStatusReports(ctx context.Context, command model.GeneratePositionStatusReports) ([]model.PositionStatusReport, error)

func (*Engine) Health

func (e *Engine) Health() Health

func (*Engine) Manager

func (e *Engine) Manager() *Manager

func (*Engine) ModifyOrder

func (e *Engine) ModifyOrder(ctx context.Context, modify model.ModifyOrder) (model.OrderStatusReport, error)

func (*Engine) ProcessMarketEvent

func (e *Engine) ProcessMarketEvent(ctx context.Context, event model.MarketEvent) ([]model.OrderStatusReport, error)

func (*Engine) Purge

func (e *Engine) Purge(accountID model.AccountID, policy cache.PurgePolicy) cache.PurgeResult

func (*Engine) QueryAccount

func (e *Engine) QueryAccount(ctx context.Context, query model.QueryAccount) (model.AccountSnapshot, error)

func (*Engine) QueryOrder

func (e *Engine) QueryOrder(ctx context.Context, query model.QueryOrder) (model.OrderStatusReport, error)

func (*Engine) RegisterExternalOrderClaim

func (e *Engine) RegisterExternalOrderClaim(instrumentID model.InstrumentID, strategyID model.StrategyID) error

func (*Engine) Snapshot

func (e *Engine) Snapshot(accountID model.AccountID) cache.Snapshot

func (*Engine) Start

func (e *Engine) Start(ctx context.Context) error

func (*Engine) Stop

func (e *Engine) Stop(ctx context.Context) error

func (*Engine) SubmitOrder

func (e *Engine) SubmitOrder(ctx context.Context, order model.SubmitOrder) (model.OrderStatusReport, error)

func (*Engine) SubmitOrderList

func (e *Engine) SubmitOrderList(ctx context.Context, command model.SubmitOrderList) ([]model.OrderStatusReport, error)

type EngineConfig

type EngineConfig struct {
	Cache    *cache.Cache
	Manager  *Manager
	Emulator *Emulator
}

type ExecutionAlgorithm

type ExecutionAlgorithm interface {
	ID() model.ExecAlgorithmID
	SubmitOrder(context.Context, model.SubmitOrder) (model.OrderStatusReport, error)
}

type ExternalOrderPolicy

type ExternalOrderPolicy struct {
	AllowImport bool
	StrategyID  model.StrategyID
}

type Health

type Health struct {
	kernel.Health
	Clients    int
	Algorithms int
	Starts     int64
	Stops      int64
	Submits    int64
	Cancels    int64
	Modifies   int64
	Queries    int64
}

type HeldOrderListChildren

type HeldOrderListChildren struct {
	ParentClientOrderID model.ClientOrderID
	Orders              []model.SubmitOrder
}

type Manager

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

func NewManager

func NewManager(cfg Config) *Manager

func (*Manager) ApplyFill

func (m *Manager) ApplyFill(fill model.FillReport) (bool, error)

func (*Manager) ApplyOrderReport

func (m *Manager) ApplyOrderReport(report model.OrderStatusReport) error

func (*Manager) CacheSubmitCommand

func (m *Manager) CacheSubmitCommand(order model.SubmitOrder) error

func (*Manager) DeterminePositionID

func (m *Manager) DeterminePositionID(accountID model.AccountID, instrumentID model.InstrumentID, strategyID model.StrategyID) model.PositionID

func (*Manager) HandleOrderListProgress

func (m *Manager) HandleOrderListProgress(order model.OrderStatusReport) (OrderListActions, error)

func (*Manager) IndexOrderList

func (m *Manager) IndexOrderList(list model.OrderList) error

func (*Manager) OrderListSnapshot

func (m *Manager) OrderListSnapshot(accountID model.AccountID, orderListID model.OrderListID) (OrderListSnapshot, bool)

func (*Manager) OrderListSnapshots

func (m *Manager) OrderListSnapshots(accountID model.AccountID) []OrderListSnapshot

func (*Manager) PopSubmitCommand

func (m *Manager) PopSubmitCommand(clientOrderID model.ClientOrderID) (model.SubmitOrder, bool)

func (*Manager) SubmitCommand

func (m *Manager) SubmitCommand(clientOrderID model.ClientOrderID) (model.SubmitOrder, bool)

type OrderListActions

type OrderListActions struct {
	Submit []model.SubmitOrder
	Modify []model.ModifyOrder
	Cancel []model.CancelOrder
}

type OrderListAlgorithm

type OrderListAlgorithm interface {
	SubmitOrderList(context.Context, model.SubmitOrderList) ([]model.OrderStatusReport, error)
}

type OrderListFillProgress

type OrderListFillProgress struct {
	OrderID        model.OrderID
	FilledQuantity decimal.Decimal
}

type OrderListSnapshot

type OrderListSnapshot struct {
	AccountID     model.AccountID
	OrderListID   model.OrderListID
	Kind          model.OrderListKind
	Status        OrderListStatus
	MemberCount   int
	OpenCount     int
	TerminalCount int
	HeldCount     int
	Members       []model.ClientOrderID
	HeldChildren  []HeldOrderListChildren
	FillProgress  []OrderListFillProgress
	Orders        []model.OrderStatusReport
}

type OrderListStatus

type OrderListStatus string
const (
	OrderListStatusInitialized OrderListStatus = "initialized"
	OrderListStatusOpen        OrderListStatus = "open"
	OrderListStatusClosed      OrderListStatus = "closed"
)

type OrderListSubmitter

type OrderListSubmitter interface {
	SubmitOrderList(context.Context, model.SubmitOrderList) ([]model.OrderStatusReport, error)
}

type PositionIDMode

type PositionIDMode string
const (
	PositionIDModeNetting PositionIDMode = "netting"
	PositionIDModeHedging PositionIDMode = "hedging"
)

type Reconciler

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

func NewReconciler

func NewReconciler(cfg ReconciliationConfig) *Reconciler

func (*Reconciler) AuditTrail

func (r *Reconciler) AuditTrail() ReconciliationAudit

func (*Reconciler) DetectOrderDiscrepancies

func (r *Reconciler) DetectOrderDiscrepancies(reports []model.OrderStatusReport) (ReconciliationResult, error)

func (*Reconciler) LastResult

func (r *Reconciler) LastResult() ReconciliationResult

func (*Reconciler) ReconcileExternalOrders

func (r *Reconciler) ReconcileExternalOrders(reports []model.OrderStatusReport, policy ExternalOrderPolicy) (ReconciliationResult, error)

func (*Reconciler) ReconcileMassStatus

func (r *Reconciler) ReconcileMassStatus(status model.ExecutionMassStatus) (ReconciliationResult, error)

func (*Reconciler) ReconcileMissingFills

func (r *Reconciler) ReconcileMissingFills(reports []model.FillReport, lookbackStart time.Time) (ReconciliationResult, error)

type ReconciliationAudit

type ReconciliationAudit struct {
	LastResult      ReconciliationResult
	LastSuccess     ReconciliationResult
	LastError       string
	LastErrorResult ReconciliationResult
	Unresolved      []ReconciliationDiscrepancy
	History         []ReconciliationResult
}

type ReconciliationConfig

type ReconciliationConfig struct {
	Cache   *cache.Cache
	Manager *Manager
}

type ReconciliationDiscrepancy

type ReconciliationDiscrepancy struct {
	Kind         string
	AccountID    model.AccountID
	InstrumentID model.InstrumentID
	OrderID      model.OrderID
	PositionID   model.PositionID
	TradeID      model.TradeID
	Reason       string
}

type ReconciliationResult

type ReconciliationResult struct {
	CaseID            string
	AccountID         model.AccountID
	InstrumentID      model.InstrumentID
	StartedAt         time.Time
	CompletedAt       time.Time
	AccountsApplied   int
	OrdersApplied     int
	FillsApplied      int
	FillsDeferred     int
	PositionsApplied  int
	ReportsScanned    int
	DuplicatesSkipped int
	LookbackSkipped   int
	Unresolved        []ReconciliationDiscrepancy
}

Jump to

Keyboard shortcuts

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