Aim
Once we spotted the opportunities, it is time to execute the strategy. This blog records some system design about how I implement the robot to automate the whole process.
System overview
Primary arbitrage gateway is the main interface between trader, brokers and all other secondary gateways. There could be multiple gateways connected to a single broker.
Trader can use the primary gateway through the UI to control the entire strategy, for example, time to start and stop arbitrage. The primary gateway also help trader to visualize live status ranged from P&L, position and lot size to connectivity status.
UI
Primary gateway
Upper part of the UI is a table showing the live status.
Trader can control the strategy when to start or stop through the button in the middle. At the bottom, there is a section for strategy inputs. Once the confirm button is click and there is data updated, the gateway will perform actions accordingly.
Secondary gateway
For secondary gateway, there is a list of live data showing the current strategy status.
Configuration
| gateway | variable | type | description |
|---|---|---|---|
| primary | symbol_0 | string | |
| primary | symbol_1 | string | |
| primary | symbol_2 | string | |
| primary | side_0 | enum | |
| primary | side_1 | enum | |
| primary | side_2 | enum | |
| primary | lot_size | double | |
| secondary | gateway_id | int |
Sequence diagram
Registration & status updates
Arbitrage controls 001: start and stop
Arbitrage controls 002: emergency stop by secondary gateway
Gateway configuration and cache data
Message
| Message type | Field name | Data type | Description |
|---|---|---|---|
| connection request | broker_name | string | |
| account_name | string | ||
| id | int | ||
| connection reply | broker_name | string | |
| account_name | string | ||
| success | int | 0: fail, 1: success | |
| interest arbitrage action | action | int | 0: fail, 1: success |
| symbol | string | ||
| side | int | 0: short, 1: success | |
| interest arbitrage action reply | success | int | 0: fail, 1: success |
| interest arbitrage data update | pnl | double | |
| lot_size | double |








Comments
Post a Comment