Skip to content

Commit

Permalink
update parseWsOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmiei committed May 14, 2023
1 parent 83bb384 commit 7ab0a77
Showing 1 changed file with 39 additions and 6 deletions.
45 changes: 39 additions & 6 deletions ts/src/pro/bitget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,11 +596,15 @@ export default class bitget extends bitgetRest {
messageHash = messageHash + ':' + symbol;
}
const isStop = this.safeValue (params, 'stop', false);
params = this.omit (params, 'stop');
let type = undefined;
[ type, params ] = this.handleMarketTypeAndParams ('watchOrders', market, params);
if ((type === 'spot') && (symbol === undefined)) {
throw new ArgumentsRequired (this.id + ' watchOrders requires a symbol argument for ' + type + ' markets.');
}
if (isStop && type === 'spot') {
throw new NotSupported (this.id + ' watchOrders does not support stop orders for ' + type + ' markets.');
}
const sandboxMode = this.safeValue (this.options, 'sandboxMode', false);
let instType = undefined;
if (type === 'spot') {
Expand Down Expand Up @@ -755,12 +759,38 @@ export default class bitget extends bitgetRest {
// tgtCcy: 'USDT',
// uTime: 1656510642518
// }
// algo order
// {
// "actualPx":"50.000000000",
// "actualSz":"0.000000000",
// "cOid":"1041588152132243456",
// "cTime":"1684059887917",
// "eps":"api",
// "hM":"double_hold",
// "id":"1041588152132243457",
// "instId":"LTCUSDT_UMCBL",
// "key":"1041588152132243457",
// "ordPx":"55.000000000",
// "ordType":"limit",
// "planType":"pl",
// "posSide":"long",
// "side":"buy",
// "state":"not_trigger",
// "sz":"0.100000000",
// "tS":"open_long",
// "tgtCcy":"USDT",
// "triggerPx":"55.000000000",
// "triggerPxType":"mark",
// "triggerTime":"1684059887917",
// "userId":"3704614084",
// "version":1041588152090300400
// }
//
const marketId = this.safeString (order, 'instId');
market = this.safeMarket (marketId, market);
const id = this.safeString (order, 'ordId');
const clientOrderId = this.safeString (order, 'clOrdId');
const price = this.safeString (order, 'px');
const id = this.safeString2 (order, 'ordId', 'id');
const clientOrderId = this.safeString2 (order, 'clOrdId', 'cOid');
const price = this.safeString2 (order, 'px', 'actualPx');
const filled = this.safeString (order, 'fillSz');
const amount = this.safeString (order, 'sz');
const cost = this.safeString2 (order, 'notional', 'notionalUsd');
Expand All @@ -774,7 +804,7 @@ export default class bitget extends bitgetRest {
} else if ((side === 'close_long') || (side === 'open_short')) {
side = 'sell';
}
const rawStatus = this.safeString (order, 'status', 'state');
const rawStatus = this.safeString2 (order, 'status', 'state');
const timeInForce = this.safeString (order, 'force');
const status = this.parseWsOrderStatus (rawStatus);
const orderFee = this.safeValue (order, 'orderFee', []);
Expand All @@ -788,6 +818,7 @@ export default class bitget extends bitgetRest {
'currency': this.safeCurrencyCode (feeCurrency),
};
}
const stopPrice = this.safeString (order, 'triggerPx');
return this.safeOrder ({
'info': order,
'symbol': symbol,
Expand All @@ -801,8 +832,8 @@ export default class bitget extends bitgetRest {
'postOnly': undefined,
'side': side,
'price': price,
'stopPrice': undefined,
'triggerPrice': undefined,
'stopPrice': stopPrice,
'triggerPrice': stopPrice,
'amount': amount,
'cost': cost,
'average': average,
Expand All @@ -821,6 +852,7 @@ export default class bitget extends bitgetRest {
'full-fill': 'closed',
'filled': 'closed',
'cancelled': 'canceled',
'not_trigger': 'open',
};
return this.safeString (statuses, status, status);
}
Expand Down Expand Up @@ -1202,6 +1234,7 @@ export default class bitget extends bitgetRest {
'ticker': this.handleTicker,
'trade': this.handleTrades,
'orders': this.handleOrder,
'ordersAlgo': this.handleOrder,
'account': this.handleBalance,
};
const arg = this.safeValue (message, 'arg', {});
Expand Down

0 comments on commit 7ab0a77

Please sign in to comment.