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

Method createTriggerOrderRequest

js/src/deepcoin.js:1610–1690  ·  view source on GitHub ↗
(symbol, type, side, amount, price = undefined, params = {})

Source from the content-addressed store, hash-verified

1608 return this.extend(request, params);
1609 }
1610 createTriggerOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
1611 /**
1612 * @method
1613 * @ignore
1614 * @name deepcoin#createTriggerOrderRequest
1615 * @description helper function to build request
1616 * @param {string} symbol unified symbol of the market to create an order in
1617 * @param {string} type 'market' or 'limit'
1618 * @param {string} side 'buy' or 'sell'
1619 * @param {float} amount how much you want to trade in units of the base currency
1620 * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1621 * @param {object} [params] extra parameters specific to the exchange API endpoint
1622 * @param {bool} [params.reduceOnly] a mark to reduce the position size for margin orders
1623 * @param {string} [params.marginMode] *swap only* 'cross' or 'isolated', the default is 'cash' for spot and 'cross' for swap
1624 */
1625 const market = this.market(symbol);
1626 const request = {
1627 'instId': market['id'],
1628 'productGroup': this.capitalize(market['type']),
1629 'sz': this.amountToPrecision(symbol, amount),
1630 'side': side,
1631 // 'posSide': 'long', // 'long' or 'short' - required when product type is SWAP
1632 // 'price': price,
1633 // 'isCrossMargin': 1, // 1 for cross margin, 0 for isolated margin
1634 'orderType': type,
1635 // 'triggerPrice': triggerPrice,
1636 // 'mrgPosition': 'merge', // 'merge' or 'split', the default is 'merge' - required when product type is SWAP
1637 // 'tdMode': 'cash', // 'cash' for spot, 'cross' or 'isolated' for swap
1638 };
1639 const triggerPrice = this.safeString(params, 'triggerPrice');
1640 // const takeProfitPrice = this.safeString (params, 'takeProfitPrice');
1641 // const stopLossPrice = this.safeString (params, 'stopLossPrice');
1642 // const isTpOrSlOrder = (takeProfitPrice !== undefined) || (stopLossPrice !== undefined);
1643 // if (isTpOrSlOrder) {
1644 // if (takeProfitPrice !== undefined) {
1645 // request['triggerPrice'] = this.priceToPrecision (symbol, takeProfitPrice);
1646 // } else {
1647 // request['triggerPrice'] = this.priceToPrecision (symbol, stopLossPrice);
1648 // }
1649 // } else {
1650 request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
1651 // }
1652 if (price !== undefined) {
1653 request['price'] = this.priceToPrecision(symbol, price);
1654 }
1655 else if (type === 'limit') {
1656 throw new ArgumentsRequired(this.id + ' createOrder() requires a price argument for limit trigger orders');
1657 }
1658 let marginMode = 'cross';
1659 [marginMode, params] = this.handleMarginModeAndParams('createOrder', params, marginMode);
1660 let isCrossMargin = 1;
1661 if (marginMode === 'isolated') {
1662 isCrossMargin = 0;
1663 }
1664 const reduceOnly = this.safeBool(params, 'reduceOnly', false);
1665 params = this.omit(params, 'reduceOnly');
1666 request['isCrossMargin'] = isCrossMargin;
1667 request['tdMode'] = marginMode;

Callers 1

createOrderRequestMethod · 0.95

Calls 10

marketMethod · 0.45
capitalizeMethod · 0.45
amountToPrecisionMethod · 0.45
safeStringMethod · 0.45
priceToPrecisionMethod · 0.45
safeBoolMethod · 0.45
omitMethod · 0.45
handleOptionAndParamsMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected