Hi.
I use ccxt 2.4.79 and try to use positionSide/dual method.
My code is:
import ccxt
exchange_id = 'binance'
exchange_class = getattr(ccxt, exchange_id)
exchange = exchange_class({
'options' : {
'defaultType': 'future',
},
'apiKey': 'xxx',
'secret': 'xxx',
})
exchange.set_sandbox_mode(True)
exchange.verbose = True
symbol = 'BTC/USDT'
try:
exchange.set_position_mode(hedged=True, symbol=symbol)
except Exception as e:
print(e)
pass
After starting everything is ok, I can get the balance. But i get error when i try to set hedged=True.
My log:
fetch Request: binance POST https://testnet.binancefuture.com/fapi/v1/positionSide/dual RequestHeaders: {'X-MBX-APIKEY': 'xxx', 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'python-requests/2.28.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} RequestBody: timestamp=1673788480480&dualSidePosition=true&recvWindow=10000&signature=xxx
fetch Response: binance POST https://testnet.binancefuture.com/fapi/v1/positionSide/dual 401 ResponseHeaders: {'Content-Type': 'application/json', 'Content-Length': '94', 'Connection': 'keep-alive', 'Date': 'Sun, 15 Jan 2023 13:14:40 GMT', 'Server': 'Bengine', 'X-MBX-USED-WEIGHT-1M': '1', 'x-response-time': '4ms', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 3bdef981159de9c713020c64476ba0e4.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'AMS1-P2', 'X-Amz-Cf-Id': 'xxx'} ResponseBody: {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action, request ip: xxx"}
binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action, request ip: xxx"}