exchange.create_order(
symbol=SYMBOL,
type="TAKE_PROFIT",
side="sell", # sell if you want to close a long order / buy if you want to close a short orderprice=ORDER_PRICE,
amount=VOLUME,
params={
"stopPrice": ORDER_PRICE, # can be changed"reduceOnly": True,
},
)
order=exchange.create_order (
symbol=SYMBOL,
type="TAKE_PROFIT_MARKET",
price=32780,
side="SELL",
amount=VOLUME,
params={"positionSide": "LONG","stopPrice":32780},
)
# to close a LONG order => positionSide = "LONG" and side="SELL"# to close a SHORT order => positionSide = "SHORT" and side="BUY"# i recomend to set price = stopPrice
exchange.create_order (
symbol=SYMBOL,
type="limit",
price=PRICE,
side="SELL",
amount=PRICE,
params={"positionSide": "LONG"},
)
# to close a LONG order => positionSide = "LONG" and side="SELL"# to close a SHORT order => positionSide = "SHORT" and side="BUY"
API call from config file / Future market / Binance Hedge mode / Binance Set Leverage
defverify_open_order(trade_id,symbol):
orders=exchange.fetch_open_orders(symbol)
fororderinorders:
iftrade_id==order["info"]["orderId"]:
returnTrue# ORDER IS ACTIVE, ORDER_ID MATCHEDelse:
returnFalse# ORDER NOT ACTIVE, NO ORDER MATCH