run

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package run provides components for dispatching orders.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompositeConflatingQueueFactory

func CompositeConflatingQueueFactory[T mkt.AnyOrder]() *utl.ConflatingQueue[string, *Composite[T]]

CompositeConflatingQueueFactory makes a composite queue for a single order process.

func ConflateTrade

func ConflateTrade(existing *mkt.Trade, latest *mkt.Trade) *mkt.Trade

ConflateTrade is a convenience function for a trade utl.ConflatingQueue.

func SubscriberQuoteQueueConnector

func SubscriberQuoteQueueConnector(queue *utl.ConflatingQueue[string, *mkt.Quote]) func(*mkt.Quote)

SubscriberQuoteQueueConnector provides the 'onQuote' callback function for a dma.Subscriber.

func SubscriberTradeQueueConnector

func SubscriberTradeQueueConnector(queue *utl.ConflatingQueue[string, *mkt.Trade]) func(*mkt.Trade)

SubscriberTradeQueueConnector provides the 'onTrade' callback function for a dma.Subscriber.

Types

type Composite

type Composite[T mkt.AnyOrder] struct {
	Instructions []T
	Quote        *mkt.Quote
	Trade        *mkt.Trade
}

Composite is a set of possible updates to be pushed into a utl.ConflatingQueue for an order process.

func ConflateComposite

func ConflateComposite[T mkt.AnyOrder](existing *Composite[T], latest *Composite[T]) *Composite[T]

ConflateComposite conflates updates to a utl.ConflatingQueue of Composite items.

type Dispatcher

type Dispatcher[T mkt.AnyOrder] struct {
	// contains filtered or unexported fields
}

Dispatcher owns all orders and routes information to them.

func NewDispatcher

func NewDispatcher[T mkt.AnyOrder](
	instructions chan T,
	subscriber dma.Subscribable,
	quotes *utl.ConflatingQueue[string, *mkt.Quote],
	trades *utl.ConflatingQueue[string, *mkt.Trade],
) *Dispatcher[T]

NewDispatcher returns a *Dispatcher ready to use.

func (*Dispatcher[T]) Run

func (x *Dispatcher[T]) Run(ctx context.Context, shutdown *sync.WaitGroup)

Run dispatching until the given context is cancelled.

type OrderProcess

type OrderProcess[T mkt.AnyOrder] struct {
	// contains filtered or unexported fields
}

OrderProcess which is associated with a single OrderID, Symbol and Side.

func (*OrderProcess[T]) Run

func (x *OrderProcess[T]) Run(ctx context.Context, shutdown *sync.WaitGroup)

Run the process until the context is cancelled.

Jump to

Keyboard shortcuts

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