dydxprotocol / dydx-v3-python

Python client for dYdX (API v3)
Apache License 2.0
306 stars 176 forks source link

Unable to place stop and take profit orders #182

Closed DemoFD closed 1 year ago

DemoFD commented 1 year ago

I seem to be unable to place reduceOnly and/or stopLoss / takeProfit orders.

If I choose stop_limit or take_profit as type, there is an error telling me the (optional) triggerPrice parameter is needed.

When I try to add any (optional) parameter to my order parameters however there is an error saying "unexpected keyword argument". (I get the unexpected keyword error also when using just the reduceOnly parameter in addition with a market/limit order) How do I fix this issue?

Here is my order_parameters code: order_params = { 'position_id': self.position_id, 'market': market, 'side': side, 'order_type': order_type, 'post_only': False, 'size': str(abs(size)), 'price': str(round(price, tick_size)), 'limit_fee': '0.015', 'expiration_epoch_seconds': expiration } if order_type != 'LIMIT': order_params['reduce_only'] = True order_params['post_only'] = True order_params['trigger_price'] = price

The upper parameters work fine to place a LIMIT order. However I need to be able to place STOP_MARKET and TAKE_PROFIT both with reduce_only=True .