Source code
OnTradeTransaction: build a clear execution ledger
A trade request can produce several account events. A compact event ledger explains that sequence more clearly than a single message saying buy successful. It is especially useful for partial fills, pending-order activation and later manual changes.
Use event type and identity
OnTradeTransaction reports transaction types such as order addition and deal addition. The platform does not guarantee the arrival priority of transaction groups. Request and result details have their documented meaning for request-type transactions; do not read every field as valid for every event.
Sketch a record format
An illustrative ledger row can contain timestamp, transaction type, order ticket, deal ticket, position reference and quantity where applicable. Keep missing fields empty rather than inventing values. The record should describe observation, not trigger a second trade.
Reconcile instead of counting
One request may create several rows, so callback count is not trade count. After the sequence, compare the ledger with current positions and history. Include partial fills and cancellation in your test cases, not only immediate full fills.
Keep the handler small
Ask AI to avoid long network operations or large report rendering inside the handler. Capture the essentials, then perform heavier summaries elsewhere. Your acceptance check is that the account state and ledger agree after processing, even when the order of notifications differs.
Back to top












