Hi, guys,
While trading, an error occurred below.
Do you know the reason?
I use ubuntu 16.04.
An error occurred { Error: binance GET https://api.binance.com/api/v1/aggTrades?symbol=XRPBTC&startTime=1514038924092&endTime=1514082124092 400 Bad Request {"code":-1127,"msg":"More than 1 hours between startTime and endTime."} (possible reasons: invalid API keys, bad or old nonce, exchange is down or offline, on maintenance, DDoS protection, rate-limiting)
at binance.defaultErrorHandler (/home/satoko/zenbot/node_modules/ccxt/js/base/Exchange.js:400:15)
at response.text.then.text (/home/satoko/zenbot/node_modules/ccxt/js/base/Exchange.js:413:25)
at
at process._tickCallback (internal/process/next_tick.js:188:7) constructor: [Function: ExchangeNotAvailable] }
I have the same problem, just appeared today from nowhere, there were no any changes in configuration. Ubuntu and MacOS – same error.
Change this in extensions/exchanges/binance/exchange.js
getTrades: function (opts, cb) {
var func_args = [].slice.call(arguments)
var args = {};
if (opts.from) {
args.startTime = opts.from
}
if (opts.to) {
args.endTime = opts.to
}
if (args.startTime && !args.endTime) {
// add 1 hour instead of 12
args.endTime = args.startTime + 3600000
}
else if (args.endTime && !args.startTime) {
// subtract only 1 hour instead of 12
args.startTime = args.endTime - 3600000
}
// Credit to jadedgeek on discord
This is an issue w/ Binance servers where their servers are behind. Their devs had said to change the time server sync interval. I fixed it by modifying the module 'cctx' binance exchange code to send that 'recvWindow' parameter with a large value
Thanks @Jarel1337 🍺 - Looks like I created a duplicate at #513
@paroxysm, Please share your modifications as I was also looking into the changing cctx, updated package.json but never circled back.
Thank you so much, guys!
It works now.
I had the same issue, @Jarel1337 fix is quick to apply and works fine for now, and @paroxysm can fix the core issue in ccxt 👍
Well, the issue has to do w/ your local machine time syncing frequency. The fix in cctx is to bypass this by giving it a huge time "window" to mitigate the problem but it's a hack fix as well. Jarel's fix is just as good as trying to hackfix 'cctx' module.
@receptor, @paroxysm I did see the issues related to recvWindow being a potential fix, however seems this particular hack doesn't quite solve the issue when running via docker-compose
For those running zenbot with docker or via docker-compose, the workaround for the Timestamp issue below requires adding the respective TZ= env variable under environment: to your docker-compose.yml to sync the time inside the container
server:
build: .
volumes:
- ./conf.js:/app/conf.js
- ./extensions:/app/extensions
- ./simulations:/app/simulations
links:
- mongodb
command: [ "trade", "--paper" ]
restart: always
tty: true
environment:
- "TZ=America/New_York" # offset = -05:00 / DST -04:00
...
docker-compose kill
docker-compose rm --force
docker-compose build
docker-compose up -d
md5-15102230c60e88bf092d04a7829e71be
binance GET https://api.binance.com/api/v3/account?timestamp=1514521618096&recvWindow=20000000&signature=0fcjsdae8bb40876593e1977836d3e5ac8dec89aea1c7debd0339148ea589670671eb
Request:
{ 'X-MBX-APIKEY': 'goonies' } undefined
An error occurred { Error: binance {"code":-1021,"msg":"Timestamp for this request was 1000ms ahead of the server's time."}
at binance.handleErrors (/app/node_modules/ccxt/js/binance.js:752:27)
at response.text.then.text (/app/node_modules/ccxt/js/base/Exchange.js:433:18)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7) constructor: [Function: ExchangeError] }
Binance API is down! unable to call getBalance, retrying in 20s
@ramene https://github.com/ccxt/ccxt/issues/773
The above "More than 1 hours between startTime and endTime" problem with was caused by the exchange cutting down trade history limits from 24hrs (which was their default previously) to 1hr, this issue is now fixed in ccxt here: https://github.com/ccxt/ccxt/pull/995
Most helpful comment
Change this in extensions/exchanges/binance/exchange.js
// Credit to jadedgeek on discord