Reputation: 61
I want to create a python script which trades on binance futures and i was wondering how i can set a leverage for a order. I search on google but didnt found anything abt it.
client.futures_create_order(symbol='VETUSDT', side='BUY', type='MARKET', quantity = 1000)
Upvotes: 4
Views: 10818
Reputation: 1
You're all wrong. Leverage should be in str (string).
new_lvrg = '10'
symb = 'BTCUSDT'
client = Client(your_api_key, your_api_secret)
client.futures_change_leverage(leverage=new_lvrg, symb=symbol)
Upvotes: 0
Reputation: 3
You can't do it with the order. You have to do it separately:
new_lvrg = 10
symbol = 'BTCUSDT'
client = Client(your_api_key, your_api_secret)
client.futures_change_leverage(leverage=new_lvrg, symbol=symbol)
Upvotes: 0
Reputation: 139
To change leverage with python-binance library you should use futures_change_leverage() method. Code example:
new_lvrg = 10
client = Client(your_api_key, your_api_secret)
client.futures_change_leverage(leverage=new_lvrg)
Upvotes: 1
Reputation: 151
Leverage can not be sent with the order. You must first change the leverage and then send the order. See: https://binance-docs.github.io/apidocs/futures/en/#change-initial-leverage-trade
request_client = RequestClient(api_key=g_api_key, secret_key=g_secret_key)
result = request_client.change_initial_leverage(symbol="BTCUSDT", leverage=10)
Upvotes: 5