trade.add¶
Direction: server → modules. External Moleculer event name: trade.add.
Source and occurrence¶
C++ payload: TradeRecord or TradeCalcRecord. Internal EventBus name: trade.push.
Router accepts EV_RECORD_ADD = 0 or EV_RECORD_ACTIVATE_TRADE = 5 with state TS_OPEN_NORMAL = 0. The open-admission producer uses TradeCalcRecord; pending activation retains its original code 5. Financial ADD records in OPEN_NORMAL are also included.
Pending creation and position restoration are excluded. This event does not establish first trade or first deposit; consumers must distinguish commands and evaluate history. reason is order source, not a closing cause.
JSON payload¶
The payload is flat; there is no data wrapper. All listed fields are emitted.
{
"event_id": "a89e743cf46a4855986aa6769e47a075",
"event_code": 0,
"occurred_at": 1789080000,
"schema_version": 1,
"order": 500101,
"login": 2000066,
"brand": "ion4",
"symbol": "EURUSD",
"cmd": 0,
"volume": 100,
"open_price": 1.0842,
"reason": 6,
"activation": 0,
"state": 0,
"sl": 0,
"tp": 1.095
}
| Domain field | JSON type |
|---|---|
order |
integer |
login |
integer |
brand |
string |
symbol |
string |
cmd |
integer |
volume |
integer |
open_price |
number |
reason |
integer |
activation |
integer |
state |
integer |
sl |
number |
tp |
number |
Common fields: event_id (32-character random hex string), event_code (original integer code), occurred_at (Unix seconds), schema_version (integer, currently 1). Volume retains platform units (lots × 100). Brand is resolved through current in-memory account/group managers, and can be empty if the lookup fails. occurred_at uses the source timestamp; zero remains zero. Margin uses transition time.
Subscription and delivery¶
Subscribe through the module's normal Moleculer event handler for trade.add.
Enabled with server nats.enable. Publication is asynchronous, fire-and-forget,
without ACK, retry or durable replay. Queue limit: 4096 business messages; JSON limit:
16 KiB. New messages can be dropped at either limit; order is not guaranteed.
event_id supports consumer deduplication, not exactly-once delivery.
See shared outbound rules for lifecycle, observability and trust limits. See outbound catalogue for other event families.