1.4 KiB
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:
- order processor:
does preliminary calculations and works on order like locking order - matching:
match orders and pass them to executor - 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:
- initializing: submit all orders with pending state(take them to ram)
- submit:
- it finds order by id with lockversion
- check state of order
- update locked and balance of account
- submit operation and accounting
- update order state to WAIT
- 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