Repository: ccxt/ccxt
File: ts/src/bybit.ts (TypeScript)

Code before:
        const isTrailingAmountOrder = trailingAmount !== undefined;
        const isTriggerOrder = triggerPrice !== undefined;
        const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
        const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
        const isStopLoss = stopLoss !== undefined;
        const isTakeProfit = takeProfit !== undefined;
        const isMarket = lowerCaseType === 'market';
        const isLimit = lowerCaseType === 'limit';
        const isBuy = side === 'buy';
        let defaultMethod = undefined;
        if ((isTrailingAmountOrder || isStopLossTriggerOrder || isTakeProfitTriggerOrder) && !market['spot']) {
            defaultMethod = 'privatePostV5PositionTradingStop';
        } else {
            defaultMethod = 'privatePostV5OrderCreate';
        }
        let method = undefined;
        [ method, params ] = this.handleOptionAndParams (params, 'createOrder', 'method', defaultMethod);
        const isAlternativeEndpoint = method === 'privatePostV5PositionTradingStop';
        const amountString = this.getAmount (symbol, amount);
        const priceString = (price !== undefined) ? this.getPrice (symbol, this.numberToString (price)) : undefined;
        if (isTrailingAmountOrder || isAlternativeEndpoint) {
            if (isStopLoss || isTakeProfit || isTriggerOrder || market['spot']) {
                throw new InvalidOrder (this.id + ' the API endpoint used only supports contract trailingAmount, stopLossPrice and takeProfitPrice orders');
            }
            if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
                if (isStopLossTriggerOrder) {
                    request['stopLoss'] = this.getPrice (symbol, stopLossTriggerPrice);
                    if (isLimit) {
                        request['tpslMode'] = 'Partial';
                        request['slOrderType'] = 'Limit';
                        request['slLimitPrice'] = priceString;
                        request['slSize'] = amountString;
                    }
                } else if (isTakeProfitTriggerOrder) {
                    request['takeProfit'] = this.getPrice (symbol, takeProfitTriggerPrice);
                    if (isLimit) {
                        request['tpslMode'] = 'Partial';
                        request['tpOrderType'] = 'Limit';
                        request['tpLimitPrice'] = priceString;
                        request['tpSize'] = amountString;
                    }
                }
            }
        } else {
            request['side'] = this.capitalize (side);
            request['orderType'] = this.capitalize (lowerCaseType);
            const timeInForce = this.safeStringLower (params, 'timeInForce'); // this is same as exchange specific param
            let postOnly = undefined;
            [ postOnly, params ] = this.handlePostOnly (isMarket, timeInForce === 'postonly', params);
            if (postOnly) {
                request['timeInForce'] = 'PostOnly';

Review comment (suggestion):
@hoangbn since this param is not unified we should use precisely the exchange-specific term, in this case `Full` and `Partial` (capitalized) 

Code after:
        const isTriggerOrder = triggerPrice !== undefined;
        const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
        const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
        const isStopLoss = stopLoss !== undefined;
        const isTakeProfit = takeProfit !== undefined;
        const isMarket = lowerCaseType === 'market';
        const isLimit = lowerCaseType === 'limit';
        const isBuy = side === 'buy';
        let defaultMethod = undefined;
        if ((isTrailingAmountOrder || isStopLossTriggerOrder || isTakeProfitTriggerOrder) && !market['spot']) {
            defaultMethod = 'privatePostV5PositionTradingStop';
        } else {
            defaultMethod = 'privatePostV5OrderCreate';
        }
        let method = undefined;
        [ method, params ] = this.handleOptionAndParams (params, 'createOrder', 'method', defaultMethod);
        const isAlternativeEndpoint = method === 'privatePostV5PositionTradingStop';
        const amountString = this.getAmount (symbol, amount);
        const priceString = (price !== undefined) ? this.getPrice (symbol, this.numberToString (price)) : undefined;
        if (isTrailingAmountOrder || isAlternativeEndpoint) {
            if (isStopLoss || isTakeProfit || isTriggerOrder || market['spot']) {
                throw new InvalidOrder (this.id + ' the API endpoint used only supports contract trailingAmount, stopLossPrice and takeProfitPrice orders');
            }
            if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
                const tpslMode = this.safeString (params, 'tpslMode', 'Partial');
                const isFullTpsl = tpslMode === 'Full';
                const isPartialTpsl = tpslMode === 'Partial';
                if (isLimit && isFullTpsl) {
                    throw new InvalidOrder (this.id + ' tpsl orders with "full" tpslMode only support "market" type');
                }
                request['tpslMode'] = tpslMode;
                if (isStopLossTriggerOrder) {
                    request['stopLoss'] = this.getPrice (symbol, stopLossTriggerPrice);
                    if (isPartialTpsl) {
                        request['slSize'] = amountString;
                    }
                    if (isLimit) {
                        request['slOrderType'] = 'Limit';
                        request['slLimitPrice'] = priceString;
                    }
                } else if (isTakeProfitTriggerOrder) {
                    request['takeProfit'] = this.getPrice (symbol, takeProfitTriggerPrice);
                    if (isPartialTpsl) {
                        request['tpSize'] = amountString;
                    }
                    if (isLimit) {
                        request['tpOrderType'] = 'Limit';
                        request['tpLimitPrice'] = priceString;
                    }
                }
            }