Using future margin
See original GitHub issue- OS: Windows 10
- Programming Language version: Python
- CCXT version: 1.40.11
Hello, i’m trying to use ccxt to trade on binance future. I have lot of trouble with the doc to understand how it works 😕
So, first i create_market_buy_order, that work well. Then i put my stoploss / takeprofit. The problem is i don’t know if i don’t use correctly the library, or if i don’t use correctly the parameters to create a TAKE_PROFIT.
I have this error:
Traceback (most recent call last): File "main.py", line 93, in <module> buy(binance, crypto, price, r1, s1) File "main.py", line 41, in buy print(exchange.create_order('{}/USDT'.format(crypto), 'STOP', 'sell', size_to_buy, params)) File "/mnt/c/Projects/arbitrage/venv/lib/python3.8/site-packages/ccxt/binance.py", line 1655, in create_order request['price'] = self.price_to_precision(symbol, price) File "/mnt/c/Projects/arbitrage/venv/lib/python3.8/site-packages/ccxt/base/exchange.py", line 1285, in price_to_precision return self.decimal_to_precision(price, ROUND, self.markets[symbol]['precision']['price'], self.precisionMode, self.paddingMode) File "/mnt/c/Projects/arbitrage/venv/lib/python3.8/site-packages/ccxt/base/decimal_to_precision.py", line 55, in decimal_to_precision dec = decimal.Decimal(str(n)) decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]
Here my code
exchange_class = getattr(ccxt, 'binance')
binance = exchange_class({
'apiKey': 'KEY',
'secret': 'SECRET',
'timeout': 3000,
'enableRateLimit': True,
'options': {
'defaultType': 'future', # ←-------------- quotes and 'future'
},
})
crypto = 'KSM'
size_to_buy = 2.8921478159368905
params = {
'quantity': size_to_buy,
'price': float("{:0.0{}f}".format(r1 - (r1 * 10 / 100), 8)),
'stopPrice': float("{:0.0{}f}".format(r1 - (r1 * 10 / 100), 8)),
'type': 'TAKE_PROFIT',
}
binance.create_order('{}/USDT'.format(crypto), 'TAKE_PROFIT', 'sell', size_to_buy, params)
Can you help me please 😒 ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (8 by maintainers)
@yanis7774 yep, looks like Binance has fixed the default limit to 500 and the max limit to 1500, as documented in their docs. I’ve pushed a fix for that, so if you upgrade to 1.41.53+ you will be able to get up to 1500 candles in a single request or all of them with pagination. Thank you for pointing it out! The new build will arrive in ~20 minutes.
I still can get more than 500 candles in early version of the lib (1.39.41 e.g.)