I am currently in the midst of writing myself a little python bot for binance using their API and I find the documentation rather lackluster and wondered whether someone on here might be able to help.
Let's say I want to open up a futures trade in the BTCUSDT pairing with a leverage of 5x and a margin of 100 USDT at market price, with a take profit at 50% and a stop loss at 10%.
from binance.client import Client
import cfg
client = Client(cfg.api_key, cfg.api_secret)
client.futures_create_order(symbol='BNBUSDT', side='LONG', type='MARKET', quantity = 100 USDT * leverage / asset_price)
This is about as far as I get. I don't see any leverage attribute, however there is another function called
futures_change_leverage()
which is able to change your leverage, so I do have to initialize a position and then change the leverage? Wouldn't that also just scale my margin down?
I am also rather lost as to how the later attributes work and how I would be able to place a take profit and stop loss order.
Thanks for any help.