risk

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: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRiskQueueFull = errors.New("risk queue full")
View Source
var ErrRiskRejected = errors.New("risk rejected")

Functions

func OrderDeniedEvent

func OrderDeniedEvent(order model.SubmitOrder, cause error) (model.ExecutionEvent, bool)

Types

type Config

type Config struct {
	MaxOrderNotional     decimal.Decimal
	MaxPositionNotional  decimal.Decimal
	MaxAccountExposure   decimal.Decimal
	ExposureCurrency     model.Currency
	TradingState         TradingState
	QueueSize            int
	Clock                kernel.Clock
	MaxCommandsPerWindow int
	CommandRateWindow    time.Duration
	MaxOpenOrders        int
	AccountLimits        map[model.AccountID]Limits
	StrategyLimits       map[model.StrategyID]Limits
	InstrumentLimits     map[model.InstrumentID]Limits
}

type Decision

type Decision struct {
	Order model.SubmitOrder
	Error error
	Event *model.ExecutionEvent
}

func (Decision) Accepted

func (d Decision) Accepted() bool

type Engine

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

func NewEngine

func NewEngine(c *cache.Cache, cfg Config) *Engine

func (*Engine) Check

func (e *Engine) Check(order model.SubmitOrder) error

func (*Engine) CheckExistingOrder

func (e *Engine) CheckExistingOrder(order model.SubmitOrder) error

func (*Engine) EngageKillSwitch

func (e *Engine) EngageKillSwitch(reason string) error

func (*Engine) Execute

func (e *Engine) Execute(ctx context.Context, order model.SubmitOrder) (<-chan Decision, error)

func (*Engine) Health

func (e *Engine) Health() Health

func (*Engine) Process

func (e *Engine) Process(ctx context.Context, event model.ExecutionEvent) error

func (*Engine) ResumeTrading

func (e *Engine) ResumeTrading() error

func (*Engine) SetReducingOnly

func (e *Engine) SetReducingOnly(reason string) error

func (*Engine) SetTradingState

func (e *Engine) SetTradingState(state TradingState, reason string) error

func (*Engine) Start

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

func (*Engine) Stop

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

type Health

type Health struct {
	kernel.Health
	CommandQueueDepth    int
	EventQueueDepth      int
	CommandQueueCapacity int
	EventQueueCapacity   int
	TradingState         TradingState
	TradingStateReason   string
	ProcessedCommands    int64
	RejectedCommands     int64
	ProcessedEvents      int64
	DroppedCommands      int64
	DroppedEvents        int64
	ThrottledCommands    int64
}

type Limits

type Limits struct {
	MaxOrderNotional    decimal.Decimal
	MaxPositionNotional decimal.Decimal
	MaxAccountExposure  decimal.Decimal
}

type TradingState

type TradingState string
const (
	TradingStateActive   TradingState = "active"
	TradingStateHalted   TradingState = "halted"
	TradingStateReducing TradingState = "reducing"
)

Jump to

Keyboard shortcuts

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