The Order class (internal to ExchangeNDAXAPI) provides a ToExchangeOrderResult method to map raw NDAX order data into a standardized ExchangeOrderResult.
To use this method, you must provide a Dictionary<string, long> that maps market symbols (e.g., "BTC/CAD") to their corresponding NDAX instrument IDs. The method performs the following mappings:
- Side: Maps "buy" (case-insensitive) to
IsBuy = true. - OrderState: Maps NDAX states to
ExchangeAPIOrderResult:working $\rightarrow$ Openrejected $\rightarrow$ Rejectedcanceled or expired $\rightarrow$ Canceledfullyexecuted $\rightarrow$ Filledunknown $\rightarrow$ Unknown
- MarketSymbol: Resolved by looking up the
Instrument ID in the provided mapping. - OrderDate: Derived from
ReceiveTime using UnixTimeStampToDateTimeMilliseconds().
Note: If the OrderState is not one of the recognized values, the method throws a NotImplementedException.
// Assuming access to an instance of the internal Order class via ExchangeNDAXAPI
var symbolMapping = new Dictionary<string, long> { { "BTC/CAD", 123 } };
ExchangeOrderResult result = ndaxOrder.ToExchangeOrderResult(symbolMapping);
// result properties:
// result.Amount == ndaxOrder.Quantity
// result.IsBuy == (ndaxOrder.Side == "buy")
// result.MarketSymbol == "BTC/CAD"
// result.Price == ndaxOrder.Price
// result.Result == ExchangeAPIOrderResult
// result.OrderDate == DateTime
// result.OrderId == ndaxOrder.OrderId.ToString()