Skip to Content
raikiri

Risk and limits

What is checked before an order leaves, how to set the limits and how to stop everything.

Every new order passes one check inside strategyd. Cancels skip it and always go out.

Declare capital first

A fresh installation refuses every order with no desk capital has been set. Declare a figure on the Risk page, with POST /v1/risk/capital, or with strategyd --seed-capital <dollars> the first time. It is a person's statement that the limits were looked at. Only the simulated venue sets its own.

Set the limits

config/risk.yaml
defaults:
  max_order_notional: 20          # one order, in quote currency
  max_instrument_notional: 20     # worst case on one instrument
  max_strategy_notional: 100      # worst case over everything the strategy holds
  max_open_orders: 64
  max_price_band_bp: 500          # distance from mid
  max_orders_in_window: 100       # per order_window_ms
  order_window_ms: 1000
  max_quote_age_ms: 10000         # do not open on an older quote
strategies:
  my-maker: { max_order_notional: 100, duplicate_window_ms: 0 }

The shipped limits are small on purpose. defaults applies to everything, and an entry under strategies overrides it by name or id. Limits can also be changed on a running desk through /v1/risk, where anything that lets more through must be confirmed.

Exposure is counted at its worst: working orders on the same side count as filled, and orders on the other side are not netted off. An order that reduces a position is not held back by the notional limits.

Books

Orders, fills, positions and limits belong to a book: one for each strategy, one for manual trading, one for each API client. A book is active, reducing (only orders that shrink a position) or halted (only cancels).

Stop trading

CallEffect
POST /v1/risk/killhalts everything and cancels every open order
POST /v1/risk/books/{id}/killthe same for one book
POST /v1/risk/resumelifts the desk's halt

A halt survives a restart and only a person lifts it. It does not close positions.

Why was my order refused

A strategy sees only Risk. The limit that refused, and the numbers, are in strategyd's log and at GET /v1/audit.

Edit this page on GitHub

On this page