uLaYOTHR
uLaYOTHR

Reputation: 61

How can i adjust the leverage with Bianance API

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

Answers (4)

Zigfrid
Zigfrid

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

Marcin Dudziuk
Marcin Dudziuk

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

hljubic
hljubic

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

Wostafa
Wostafa

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)

from : https://github.com/Binance-docs/Binance_Futures_python/blob/master/example/trade/change_initial_leverage.py

Upvotes: 5

Related Questions