Files
Dena/docs/zagros/order-trade-steps/processor.md
2026-08-13 19:50:53 +03:30

1.4 KiB

trading: order processor

Sprint: ?

###DOC for matching and executing orders openware creates a flow that manage by RabbitMQ and its consumers. we have three consumers that works on trades:

  1. order processor:
    does preliminary calculations and works on order like locking order
  2. matching:
    match orders and pass them to executor
  3. trade executor:
    execute trades that matching creates
stateDiagram-v2
    [*] --> API
    API --> RabbitMQ
    RabbitMQ --> OrderProcessor
    OrderProcessor --> RabbitMQ
    RabbitMQ --> Matching
    Matching --> RabbitMQ
    RabbitMQ --> Executor
    Executor --> Notify
    Notify --> [*]

Order Processor

what does order processor do step by step:
  1. initializing: submit all orders with pending state(take them to ram)
  2. submit:
    1. it finds order by id with lockversion
    2. check state of order
    3. update locked and balance of account
    4. submit operation and accounting
    5. update order state to WAIT
    6. enqueue in rabbit (pass orders to matching)
graph TD
    A[api] -->|enque| B(RabbitMQ)
    B --> C(order processor)
    C --> |submit order in ram|D{check state}
    D -->|pending| E[order locking]
    D -->|else| B
    E -->G[submit operation and accounting]
    G --> F[update state to wait]
    F --> |enque to matching| B