(symbol, type, side, amount, price = undefined, params = {})
| 1492 | } |
| 1493 | } |
| 1494 | createRegularOrderRequest(symbol, type, side, amount, price = undefined, params = {}) { |
| 1495 | /** |
| 1496 | * @method |
| 1497 | * @ignore |
| 1498 | * @name deepcoin#createRegularOrderRequest |
| 1499 | * @description helper function to build request |
| 1500 | * @param {string} symbol unified symbol of the market to create an order in |
| 1501 | * @param {string} type 'market' or 'limit' |
| 1502 | * @param {string} side 'buy' or 'sell' |
| 1503 | * @param {float} amount how much you want to trade in units of the base currency |
| 1504 | * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 1505 | * @param {object} [params] extra parameters specific to the exchange API endpoint |
| 1506 | * @param {float} [params.cost] *spot only* the cost of the order in units of the quote currency, for market orders only |
| 1507 | * @param {string} [params.clientOrderId] a unique id for the order |
| 1508 | * @param {string} [params.timeInForce] 'GTC' (Good Till Cancel), 'IOC' (Immediate Or Cancel) or 'PO' (Post Only) |
| 1509 | * @param {bool} [params.postOnly] true to place a post only order |
| 1510 | * @param {bool} [params.reduceOnly] a mark to reduce the position size for margin and swap orders |
| 1511 | * @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at |
| 1512 | * @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at |
| 1513 | * @param {string} [params.marginMode] *swap only* 'cross' or 'isolated', the default is 'cash' for spot and 'cross' for swap |
| 1514 | * @param {string} [params.mrgPosition] *swap only* 'merge' or 'split', the default is 'merge' |
| 1515 | */ |
| 1516 | const market = this.market(symbol); |
| 1517 | let orderType = type; |
| 1518 | [orderType, params] = this.handleTypePostOnlyAndTimeInForce(type, params); |
| 1519 | const request = { |
| 1520 | 'instId': market['id'], |
| 1521 | // 'tdMode': 'cash', // 'cash' for spot, 'cross' or 'isolated' for swap |
| 1522 | // 'ccy': currency['id'], // only applicable to cross MARGIN orders in single-currency margin |
| 1523 | // 'clOrdId': clientOrderId, |
| 1524 | 'side': side, |
| 1525 | 'ordType': orderType, |
| 1526 | // 'sz': amount or cost |
| 1527 | // 'px': price, // limit orders only |
| 1528 | // 'reduceOnly': false, // a mark to reduce the position size for margin and swap orders |
| 1529 | // 'tgtCcy': 'base_ccy', // spot only 'base_ccy' or 'quote_ccy', the default is 'base_ccy' for spot orders |
| 1530 | // 'tpTriggerPx': takeProfitPrice, // take profit trigger price |
| 1531 | // 'slTriggerPx': stopLossPrice, // stop loss trigger price |
| 1532 | // 'posSide': 'long', // swap only 'long' or 'short' |
| 1533 | // 'mrgPosition': 'merge', // swap only 'merge' or 'split' |
| 1534 | // 'closePosId': 'id', // swap only position ID to close, required in split mode |
| 1535 | }; |
| 1536 | const clientOrderId = this.safeString(params, 'clientOrderId'); |
| 1537 | if (clientOrderId !== undefined) { |
| 1538 | request['clOrdId'] = clientOrderId; |
| 1539 | params = this.omit(params, 'clientOrderId'); |
| 1540 | } |
| 1541 | const stopLoss = this.safeDict(params, 'stopLoss', {}); |
| 1542 | const stopLossPrice = this.safeString(stopLoss, 'triggerPrice'); |
| 1543 | if (stopLossPrice !== undefined) { |
| 1544 | params = this.omit(params, ['stopLoss']); |
| 1545 | request['slTriggerPx'] = this.priceToPrecision(symbol, stopLossPrice); |
| 1546 | } |
| 1547 | const takeProfit = this.safeDict(params, 'takeProfit', {}); |
| 1548 | const takeProfitPrice = this.safeString(takeProfit, 'triggerPrice'); |
| 1549 | if (takeProfitPrice !== undefined) { |
| 1550 | params = this.omit(params, ['takeProfit']); |
| 1551 | request['tpTriggerPx'] = this.priceToPrecision(symbol, takeProfitPrice); |
no test coverage detected