Skip to content

Get Open Trade By Order

GetOpenTradeByOrder

Retrieves an open trade by its order ID.

int GetOpenTradeByOrder(int order, TradeRecord* trade);

Parameters

  • order — integer representing the trade order ID.
  • trade — pointer to a TradeRecord structure where the retrieved trade details will be stored.

Return Value

  • RET_OK — trade found and successfully retrieved.
  • RET_NOT_FOUND — no open trade found with the specified order ID.
  • RET_* — other error codes.
  • Return Codes

Example

TradeRecord tr;
if (GetOpenTradeByOrder(123456, &tr) == RET_OK) {
    // Process trade data
}

Warning

  • The trade pointer must point to a valid, pre-allocated TradeRecord structure.
  • If no open trade is found, the function returns RET_NOT_FOUND and leaves trade unchanged.
  • Always check the return code before using the trade data.