Skip to content

Latest commit

 

History

History
23 lines (15 loc) · 2.58 KB

0008-TRAD-trading_workflow.md

File metadata and controls

23 lines (15 loc) · 2.58 KB

Trading Workflow

Outline

This is an attempt to document the flow of processing orchestrated by the trading core when processing market instructions and dealing with the resulting new Trades and Order updates.

Acceptance Criteria

The order of processing of transactions happens in the order defined in the diagram, specifically:

  1. Before a valid order is processed in any other way by Vega, the party's margin levels are checked as though they had the order in their position, and any transfers that are needed to support that order occur. (0008-TRAD-001)
  2. Following all of the matching of trades resulting from a single order or the acceptance of an order onto the order book, there will be changes in positions for one or more traders. (0008-TRAD-002)
  3. Following all of the matching of trades resulting from a single order or the acceptance of an order onto the order book, there may be a change to the Mark Price. (0008-TRAD-003). For product spot: (0008-TRAD-008)
  4. Following the above 3 actions, a mark to market settlement is run for all parties against their most recently updated positions and Mark Price. This will result in a set of transfers between the parties' accounts and possibly may result in loss socialisation occurring if a party has insufficient collateral to cover the move. (0008-TRAD-004)
  5. Following the mark to market settlement, the margin liabilities for traders are evaluated against their collateral balances. Any traders that do not have sufficient collateral to support their positions (after collateral searches have been done to their main account) will undergo position resolution. (0008-TRAD-005)
  6. After position resolution has occurred, margins are recalculated and evaluated against balances for any traders that gained positions as a result of supplying liquidity on the order book to the network during position resolution. (0008-TRAD-006)
  7. This continues until no position resolution occurs. Then the next transaction is processed. (0008-TRAD-007)

Trading workflow

See also