Skip to content

Repo standards relating to markets.

ZeroOrderSizeError

Bases: ValueError

Raised when an order wire resolves to a zero submitted size.

Trading System Constants

This module defines various constants used throughout the trading system. These constants are used for defining fields in transaction records, account details, order types, and more.

String fields use None for missing values. standard_types(...) normalizes empty strings to None for fields declared as str.

General Constants

  • TIMESTAMP (int): "timestamp"
  • TICKER (str): "ticker"
  • AMOUNT (Decimal): "amount"
  • PRICE (Decimal): "price"
  • ENTRY (Decimal): "entry"
  • LEVERAGE (float): "leverage"
  • LIQUIDATION (Decimal): "liquidation"
  • MARGIN (float): "margin"
  • VALUE (float): "value"
  • REALIZED_PNL (float): "realized_pnl"
  • UNREALIZED_PNL (float): "unrealized_pnl"

Account Constants

  • ACCOUNT_EQUITY (float): "equity_total"
  • ACCOUNT_WITHDRAWABLE (float): "equity_withdrawable"
  • ACCOUNT_NOTIONAL_POS (float): "notional_position"
  • ACCOUNT_UNREALIZED_PNL (float): "unrealized_pnl"
  • MARGIN_MAINTENANCE (float): "margin_maintenance"
  • MARGIN_TOTAL (float): "margin_total"
  • MARGIN_AVAILABLE (float): "margin_available"

Position Constants

POSITION_FIELDS is the lean materialized position state used by Position and Positions: ticker, signed amount, and average entry. HTTP position snapshots may carry additional venue-provided risk/accounting fields, so wrappers that expose them use POSITION_SNAPSHOT_FIELDS. Snapshot fields are available-basis fields: wrappers may omit unsupported keys or return None when the venue does not provide a value.

  • POSITION_TICKER (str): "ticker"
  • POSITION_AMOUNT (Decimal): "amount"
  • POSITION_ENTRY (Decimal): "entry"
  • POSITION_VALUE (float): "value"
  • POSITION_MARGIN (float): "margin"
  • POSITION_LEVERAGE (float): "leverage"
  • POSITION_LIQUIDATION (Decimal): "liquidation"
  • POSITION_REALIZED_PNL (float): "realized_pnl"
  • POSITION_UNREALIZED_PNL (float): "unrealized_pnl"
  • POSITION_DELTA (Decimal): "delta"
  • POSITION_FILL_ENTRY (Decimal): "fill_entry"
  • POSITION_TS_EXCH_NS (int): "ts_exch_ns"
  • POSITION_TS_UPDATE_NS (int): "ts_update_ns"

Field Registries

Standardized wrappers populate fields on an available basis. The field registries define the normalized key surface for each object or message; they do not guarantee every key is present or non-null for every venue response.

  • FIELD_REGISTRY["account_balance"]: account balance snapshot fields.
  • FIELD_REGISTRY["position"]: lean materialized Position fields.
  • FIELD_REGISTRY["position_snapshot"]: richer positions_get(...) snapshot fields populated on an available basis.
  • FIELD_REGISTRY["position_delta"]: position delta message fields emitted by Positions.update_position(...).
  • FIELD_REGISTRY["order"]: normalized order fields.
  • FIELD_REGISTRY["fill"]: normalized fill fields.

Order Constants

  • ORDER_PRICE (Decimal): "price"
  • ORDER_ID (str): "oid"
  • ORDER_CLOID (str): "cloid"
  • ORDER_TAG (str): "order_tag"
  • ORDER_AMOUNT (Decimal): "amount"
  • ORDER_SIZE (Decimal): "order_sz"
  • ORDER_FILLED_SIZE (Decimal): "filled_sz"
  • ORDER_LAST_FILL_SIZE (Decimal): "last_fill_sz"
  • ORDER_FILLS (list): "fills", ordered fill records attached to the order
  • ORDER_TS_SUBMIT_NS (int): "ts_submit_ns"
  • ORDER_TS_CANCEL_NS (int): "ts_cancel_ns"
  • ORDER_TS_EXCH_NS (int): "ts_exch_ns"
  • ORDER_TS_UPDATE_NS (int): "ts_update_ns"

Order Update Events

Order is a durable state artifact. Mutation labels are emitted in update envelopes as {ORDER_EVENT: <label>, "order": <Order>} and are not stored on the order itself.

  • ORDER_EVENT (str): "order_event"

Fill Constants

  • FILL_ID (str): "tid"
  • FILL_FEE (Decimal): "fee"
  • FILL_FEE_CCY (str): "fee_ccy"
  • FILL_IS_MAKER (bool): "is_maker"
  • FILL_REALIZED_PNL (float): "realized_pnl"
  • FILL_TS_EXCH_NS (int): "ts_exch_ns"
  • FILL_TS_UPDATE_NS (int): "ts_update_ns"

Order Types

  • ORDER_TYPE (str): "order_type"
  • ORDER_TYPE_MARKET (str): "market"
  • ORDER_TYPE_LIMIT (str): "limit"
  • ORDER_TYPE_STOP_MARKET (str): "stop_market"
  • ORDER_TYPE_STOP_LIMIT (str): "stop_limit"
  • ORDER_TYPE_TWAP (str): "twap"

Price Rule Types

  • PRICE_RULE_OPPONENT_1 (str): "OPPONENT"
  • PRICE_RULE_OPPONENT_5 (str): "OPPONENT_5"
  • PRICE_RULE_OPPONENT_10 (str): "OPPONENT_10"
  • PRICE_RULE_OPPONENT_20 (str): "OPPONENT_20"
  • PRICE_RULE_QUEUE_1 (str): "QUEUE"
  • PRICE_RULE_QUEUE_5 (str): "QUEUE_5"
  • PRICE_RULE_QUEUE_10 (str): "QUEUE_10"
  • PRICE_RULE_QUEUE_20 (str): "QUEUE_20"

Time In Force Constants

  • TIME_IN_FORCE (str): "tif"
  • TIME_IN_FORCE_GTC (str): 'GTC'
  • TIME_IN_FORCE_IOC (str): 'IOC'
  • TIME_IN_FORCE_FOK (str): 'FOK'
  • TIME_IN_FORCE_GTD (str): 'GTD'
  • TIME_IN_FORCE_MOC (str): 'MOC'
  • TIME_IN_FORCE_MOO (str): 'MOO'
  • TIME_IN_FORCE_ALO (str): "ALO"

Contract Constants

  • SYMBOL_MIN_QTY (Decimal): "min_qty"
  • SYMBOL_PRICE_PRECISION (int): "price_precision"
  • SYMBOL_QUOTE_PRECISION (int): "quote_precision"
  • SYMBOL_QUANTITY_PRECISION (int): "quantity_precision"
  • SYMBOL_MIN_NOTIONAL (Decimal): "min_notional"

Funding and Reference Price Constants

  • FUNDING_RATE (float): "funding_rate"
  • FUNDING_INTERVAL (int): "funding_interval"
  • MARK_PRICE (Decimal): "mark_price"
  • LAST_SALE (Decimal): "last_sale"
  • INDEX_PRICE (Decimal): "index_price"
  • LAST_FUNDING (int): "last_funding"
  • NEXT_FUNDING (int): "next_funding"