TheFourGreatErrors / alpha-rptr

A trading bot for automated algorithmic trading on Binance Futures, Bybit, BitMEX and FTX written in python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please help me! After starting the program, it works until the purchase is made, and then it returns an error. python main.py --account binanceaccount1 --exchange binance --pair BTCUSDT --strategy Sample

dapsi0404 opened this issue · comments

2020-09-12 17:56:05,657 - INFO - pos_size: 0.0
2020-09-12 17:56:06,235 - ERROR - An error occurred. APIError(code=-1111): Precision is over the maximum defined for this asset.
2020-09-12 17:56:06,235 - ERROR - Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\MARZA\alpha-rptr-master\src\binance_futures.py", line 778, in __update_ohlcv
self.strategy(open, close, high, low, volume)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\MARZA\alpha-rptr-master\src\strategy.py", line 299, in strategy
self.exchange.entry("Long", True, lot/20)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\MARZA\alpha-rptr-master\src\binance_futures.py", line 444, in entry
self.order(id, long, ord_qty, limit, stop, post_only, reduce_only, trailing_stop, activationPrice, when)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\MARZA\alpha-rptr-master\src\binance_futures.py", line 477, in order
self.__new_order(ord_id, side, ord_qty, limit, stop, post_only, reduce_only, trailing_stop, activationPrice)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\MARZA\alpha-rptr-master\src\binance_futures.py", line 375, in _new_order
retry(lambda: self.client.futures_create_order(symbol=self.pair, type=ord_type, newClientOrderId=ord_id,
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\MARZA\alpha-rptr-master\src_init
.py", line 119, in retry_binance_futures
ret, res = func()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\MARZA\alpha-rptr-master\src\binance_futures.py", line 376, in
side=side, quantity=ord_qty))
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\MARZA\alpha-rptr-master\src\binance_futures_api.py", line 393, in futures_create_order
return self._request_futures_api('post', 'order', True, data=params)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\MARZA\alpha-rptr-master\src\binance_futures_api.py", line 220, in _request_futures_api
return self._request(method, uri, signed, True, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\MARZA\alpha-rptr-master\src\binance_futures_api.py", line 195, in _request
return self._handle_response()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\MARZA\alpha-rptr-master\src\binance_futures_api.py", line 229, in _handle_response
raise BinanceAPIException(self.response)
src.exceptions.BinanceAPIException: APIError(code=-1111): Precision is over the maximum defined for this asset.

Hello, this error is regarding proper decimals/rounding which the exchange is expecting you to make before sending orders, in your case it seems you are using a market order, therefore there isnt an issue with the price level(limit orders could trigger this error for the limit parameter not being properly rounded) but quantity, respectively the size of your order. Basically every pair has different precision specification, so you need to take care of proper rounding in your case it would be rounding the quantity qty parameter in self.exchange.entry("Long", True, lot/20) entry function call, both for long and short entries. You could round the lot calculation lot = self.exchange.get_lot() like this for instanace lot = round(self.exchange.get_lot(), 3), which should round the lot quantity calculation (which is based on your balance) to 3 decimals.

Thank you, it's me who needs to make a change to strategy.py?

For now, yes you need to modify it yourself and use round_decimals parameter in function calls for other functions as well, when available. I will update the documentation eventually, there is a lot of changes coming so it will be a part of a major update sometime in the future.

Hello, You can show in the code where you need to make a change to make the program work correctly, thank you in advance!

Please be more specific about which strategy you would like to use and what exactly do you want. Is it only the rounding issue or do you need help with utilizing other functionality? Actually I would prefer, if we could talk in more detail on the dedicated discord server, because its more practical for instructions of that sort, please join https://discord.gg/ah3MGeN this discord server, if its not a problem for whatever reason. But in general you find lot variable in strategy.py in your chosen strategy class and inside of strategy function definition, usually among the first couple of variables. Then you can change it the way i described above or modify it to more closely meet your criteria.

python main.py --account binanceaccount1 --exchange binance --pair BTCUSDT --strategy Sample