3

Hello fairly simple issue here, I am simply trying to use CCXT on Python to place margin limit orders on Phemex. Almost everything works great, I have the orders successfully going through. The issue I'm running into is adding a take profit and stop loss to the orders similar to how you can on the Phemex UI. Here is the code that does the above. Does anyone know what modifications are needed to successfully add in the SL/TP? Thanks so much!

phemex = ccxt.phmex({'apiKey':..., 'secret':...})
symbol = ...
price = ....
amount = ....
type = 'limit'
side = 'buy'
params = {'type': 'margin'}
if addStopLoss:
    params['stopPrice'] = price * 0.9 # (add 10% SL)
    params['type'] = 'stopLimit'
order = phemex.create_order(symbol, type, side, amount, price, params)

Any help or suggestions would be much appreciated! Thanks!

Tristan Neate
  • 83
  • 1
  • 7
  • About to embark on a similar adventure, did you manage to solve the issue? Have you been able to change the position of the stopLimit or must that be done with a cancelOrder then a createOrder call? – Tommy Cox Green Dec 28 '21 at 14:13

0 Answers0