'There must be a Syntax Error in Phemex JSON: How do you make an order with a StopLoss and TakeProfit?

def placeBUYStopLimitOrder(dollars, BTC_VALUE):
# boolean is on/off switch of client creation, False or True
client = Client(testnet_api_key, testnet_api_secret, True)

tid = "P_buy_100" + str(datetime.datetime.now())

# a 15% larger trigger
# print("BTC_VALUE: ", BTC_VALUE)
coreBTCValue = float(BTC_VALUE) * 10000
bullTriggerPrice = coreBTCValue * 1.15
bearTriggerPrice = coreBTCValue * 0.95

r = client.place_order(
{
    "clOrdID": tid,
    "symbol": "BTCUSD",
    "side": "Buy",
    "priceEp": coreBTCValue,
    "orderQty": dollars,
    "ordType": "Limit",
    "takeProfitEp": bullTriggerPrice,
    "tpTrigger": "ByLastPrice",
    "stopLossEp": bearTriggerPrice,
    "slTrigger": "ByMarkPrice"
})

This is a simple question with an elusive answer. Can anyone help by suggesting the correct JSON to send to the PHEMEX API?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source