sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
6.01k stars 2.2k forks source link

How do you open furures trade via python on binance, or how do you open short positions #822

Open cryptobot123-123 opened 3 years ago

cryptobot123-123 commented 3 years ago

i want to be able to short but i dont know how to laverage on marigin or how to trade on futures on binance

hoangdh5 commented 3 years ago

Example: open Long market in HEGDE MODE client.futures_create_order(symbol='BTTUSDT',side='BUY',type='MARKET',positionSide='LONG',quantity=100000)

cryptobot123-123 commented 3 years ago

do you maybe know how to use laverage on this?

cryptobot123-123 commented 3 years ago

APIError(code=-4061): Order's position side does not match user's setting.

I get this error if i try to buy like you said.

dnlfrst commented 3 years ago

@cryptobot123-123 You need to assure that the trading settings reflect your intentions. In particular, you need to set the position mode to be in hedge mode to be able to use positionSide=LONG:

client.futures_change_position_mode(dualPositionMode='true')

If you want to trade futures on USDⓈ-M with leverage, you need to set the leverage for the corresponding symbol before creating an order:

client.futures_change_leverage(symbol='BTTUSDT', leverage=5)

where leverage would set your orders to have a 5× leverage.

Karlheinzniebuhr commented 2 years ago

I'm trying to call client.futures_change_position_mode(dualPositionMode='true') But it's giving me this error APIError(code=-1102): Mandatory parameter 'dualSidePosition' was not sent, was empty/null, or malformed. Formatting it like this isn't working either, what am I missing? client.futures_change_position_mode(data={'dualPositionMode':'true'}) APIError(code=-1022): Signature for this request is not valid.