python-binance icon indicating copy to clipboard operation
python-binance copied to clipboard

Add - futures_modify_order function

Open danywayGit opened this issue 2 years ago • 1 comments

Simple but missing function, to be able to modify an existing order. For example it is usefull for modifing the quantity, or the price of an open order.

Using the same url (order) as for creating a new order but with a PUT method instead of a POST method.

danywayGit avatar Jun 13 '24 19:06 danywayGit

I have testing the function, like this:

def modify_take_profit_order_oneway_mode(symbol: str, orderId: int, side: str, quantity: float, price: float)-> dict: price = round(float(price),get_price_precision_futures(symbol)) price = round_step_size(float(price), get_tick_size_futures(symbol)) try: order = client.futures_modify_order( symbol=symbol, orderId=orderId, side=side, quantity=quantity, price=price, timeInForce='GTC' ) return order except Exception as e: log_to_file("ERROR modify_take_profit_order_oneway_mode : " + type(e).name, symbol) log_to_file("ERROR modify_take_profit_order_oneway_mode : " + str(e), symbol)

#Example : Modify an existing Take Profit Order, for a Long(BUY) Position in One Way Mode #print(modify_take_profit_order_oneway_mode(symbol="HIGHUSDT", side="BUY", orderId=2397071111, quantity=20, price=2.844300))

danywayGit avatar Jun 13 '24 19:06 danywayGit

Thanks @danywayGit

sammchardy avatar Aug 14 '24 06:08 sammchardy