SetTradeGatewayData¶
Updates external gateway metadata for an existing trade by order.
int SetTradeGatewayData(const PluginTradeGatewayDataUpdateRecord& update);
This method is intended for liquidity bridge, gateway, and execution plugins that need to attach provider-side identifiers or execution prices to an already existing trade.
It updates only gateway metadata in the trade cache and persists the updated trade snapshot to the database. It does not pass the trade through the main trading flow.
Behavior¶
SetTradeGatewayData:
- finds an existing trade in runtime cache by
order - updates only fields marked by
has_*flags - writes the updated snapshot to the trades database
- updates
TradeRecord.update_time - returns
RET_NOT_FOUNDwhen the order does not exist
It does not:
- open, close, modify, activate, cancel, or delete a trade
- recalculate margin, profit, swaps, balance, equity, or stop out state
- enqueue the trade into
mainLoop - emit trade events
- broadcast an update to clients
- call plugin trade update callbacks
Parameters¶
PluginTradeGatewayDataUpdateRecord¶
| Field | Type | Required | Description |
|---|---|---|---|
order |
int |
Yes | Internal trade order/ticket to update. |
has_gw_order |
bool |
No | If true, update gw_order. |
gw_order |
std::string |
No | External gateway order number. |
has_gw_source |
bool |
No | If true, update gw_source. |
gw_source |
std::string |
No | External gateway source, provider, bridge, or liquidity venue name. |
has_gw_uuid |
bool |
No | If true, update gw_uuid. |
gw_uuid |
std::string |
No | External UUID or unique execution identifier. |
has_gw_open_price |
bool |
No | If true, update gw_open_price. |
gw_open_price |
double |
No | External gateway open/fill price. 0.0 is valid when the flag is true. |
has_gw_close_price |
bool |
No | If true, update gw_close_price. |
gw_close_price |
double |
No | External gateway close/fill price. 0.0 is valid when the flag is true. |
At least one has_* flag must be true.
Return Value¶
RET_OK— gateway metadata was updated in cache and scheduled for DB persistence.RET_INVALID_DATA—order <= 0or nohas_*field was provided.RET_NOT_FOUND— trade with thisorderwas not found in cache.RET_ERROR— database update could not be queued.- Return Codes
Example¶
PluginTradeGatewayDataUpdateRecord update;
update.order = 123456;
update.has_gw_order = true;
update.gw_order = "LP-987654";
update.has_gw_source = true;
update.gw_source = "liquidity-provider-a";
update.has_gw_uuid = true;
update.gw_uuid = "b23d6f2e-2f6a-4f6e-91f8-6a8b5e6c19a1";
update.has_gw_open_price = true;
update.gw_open_price = 1.08421;
const int ret = server->SetTradeGatewayData(update);
if (ret != RET_OK) {
// handle RET_NOT_FOUND / RET_INVALID_DATA / RET_ERROR
}
Warning
Use this method only for external gateway metadata. It is not a replacement for OpenTrade, CloseTrade, UpdateOpenTrade, or UpdateCloseTrade.
Persistence
The method updates runtime cache immediately and queues a database upsert. The DB write is asynchronous, but the returned RET_OK means the update was accepted by the server.
SEO¶
ScaleTrade SetTradeGatewayData helps broker plugin developers integrate liquidity bridges, external execution gateways, order routing providers, LP execution identifiers, gateway order IDs, gateway UUID tracking, and external fill price reconciliation without changing the core trading lifecycle.