MCPcopy Create free account
hub / github.com/ccxt/ccxt / parseOrder

Method parseOrder

ts/src/modetrade.ts:1306–1420  ·  view source on GitHub ↗
(order: Dict, market: Market = undefined)

Source from the content-addressed store, hash-verified

1304 }
1305
1306 parseOrder (order: Dict, market: Market = undefined): Order {
1307 //
1308 // Possible input functions:
1309 // * createOrder
1310 // * createOrders
1311 // * cancelOrder
1312 // * fetchOrder
1313 // * fetchOrders
1314 // const isFromFetchOrder = ('order_tag' in order); TO_DO
1315 //
1316 // stop order after creating it:
1317 // {
1318 // "orderId": "1578938",
1319 // "clientOrderId": "0",
1320 // "algoType": "STOP_LOSS",
1321 // "quantity": "0.1"
1322 // }
1323 // stop order after fetching it:
1324 // {
1325 // "algoOrderId": "1578958",
1326 // "clientOrderId": "0",
1327 // "rootAlgoOrderId": "1578958",
1328 // "parentAlgoOrderId": "0",
1329 // "symbol": "SPOT_LTC_USDT",
1330 // "orderTag": "default",
1331 // "algoType": "STOP_LOSS",
1332 // "side": "BUY",
1333 // "quantity": "0.1",
1334 // "isTriggered": false,
1335 // "triggerPrice": "100",
1336 // "triggerStatus": "USELESS",
1337 // "type": "LIMIT",
1338 // "rootAlgoStatus": "CANCELLED",
1339 // "algoStatus": "CANCELLED",
1340 // "triggerPriceType": "MARKET_PRICE",
1341 // "price": "75",
1342 // "triggerTime": "0",
1343 // "totalExecutedQuantity": "0",
1344 // "averageExecutedPrice": "0",
1345 // "totalFee": "0",
1346 // "feeAsset": '',
1347 // "reduceOnly": false,
1348 // "createdTime": "1686149609.744",
1349 // "updatedTime": "1686149903.362"
1350 // }
1351 //
1352 const timestamp = this.safeIntegerN (order, [ 'timestamp', 'created_time', 'createdTime' ]);
1353 const orderId = this.safeStringN (order, [ 'order_id', 'orderId', 'algoOrderId' ]);
1354 const clientOrderId = this.omitZero (this.safeString2 (order, 'client_order_id', 'clientOrderId')); // Somehow, this always returns 0 for limit order
1355 const marketId = this.safeString (order, 'symbol');
1356 market = this.safeMarket (marketId, market);
1357 const symbol = market['symbol'];
1358 const price = this.safeString2 (order, 'order_price', 'price');
1359 const amount = this.safeString2 (order, 'order_quantity', 'quantity'); // This is base amount
1360 const cost = this.safeString2 (order, 'order_amount', 'amount'); // This is quote amount
1361 const orderType = this.safeStringLower2 (order, 'order_type', 'type');
1362 let status = this.safeValue2 (order, 'status', 'algoStatus');
1363 const success = this.safeBool (order, 'success');

Callers 4

createOrderMethod · 0.95
editOrderMethod · 0.95
cancelOrderMethod · 0.95
fetchOrderMethod · 0.95

Calls 15

parseOrderStatusMethod · 0.95
parseOrderTypeMethod · 0.95
parseTimeInForceMethod · 0.95
safeInteger2Method · 0.80
safeIntegerNMethod · 0.45
safeStringNMethod · 0.45
omitZeroMethod · 0.45
safeString2Method · 0.45
safeStringMethod · 0.45
safeMarketMethod · 0.45
safeStringLower2Method · 0.45
safeValue2Method · 0.45

Tested by

no test coverage detected