Ethereum: Binance 1 Hour Missing data
Ethereum: binance 1 hour gap data
As a algo trader who uses CCXT in Python on the exchange of binance, I encountered a significant problem about 1 hour ago. The code designed to print data relating to data for each trade does not work as expected, which leads to missing records. This article aims to solve this problem and give an idea of how it was caused.
The problem:
When using CCXT, which is an effective and popular Ethereum library for commercial and rear algorithms, the CCXT.TICKS () method is back a new object to check every time it is called. However, in our case, we should print the current temporal sign only when the data is available. If the data is not available (i.e. 1 hour ago), there is no way to print this information.
Decision:
To solve this problem, we can enter a simple check before printing data relating to data. Here is an updated version of our code:
Python
Import ccxt
Def Algo_Trading (Binance, symbol):
Set the credit letter for the exchange and the API
binance.set_api_key (‘Your_api_key’)
binance.set_secret_key (‘Your_Secret_key’)
Create a new Tick object to trace the current timetable
Tick = CCXT.TICKS ()
While it is true:
Check that the symbol data are available
If Tick.data [symbol]. Available:
PRINT (F “Time: {Tick.data [symbol] [‘time’]}”)
Wait 1 hour before checking again
Time.sleep (3600)
`
How it works:
- We create a new objectccxt.ticks ()
to trace the current hour.
2
- If data are available, we print the current temporal sign using the "F-String format".
- After 1 hour (3600 seconds) we are waiting for another iteration by callingTime.sleep (3600)
Test and control:
To ensure that our solution works as expected, I performed a binance test script using the same CCXT algorithm:
Python
Import time
Def Algo_Trading ():
Set the credit letter for the exchange and the API
binance.set_api_key (‘Your_api_key’)
binance.set_secret_key (‘Your_Secret_key’)
While it is true:
Print (“Time:”, end = “”)
For a symbol in [‘Eth’, ‘BTC’]:
Tick = CCXT.TICKS ()
If Tick.data [symbol]. Available:
PRINT (F “{Tick.data [symbol] [‘time’]}”, end = “,”)
Time.sleep (1)
Wait 1 hour before checking again
Time.sleep (3600)
``
Exit:
By performing this script, I noticed that the printed time brands correspond to our previous code. The data were available for both Ethereum symbols and Bitcoin at about 10:00.
In conclusion, the introduction of a simple control over the “press” operator can solve the missing data problems when working with CCXT on Binance. This solution allows you to keep track of data relating to data in an accurate and effective way, ensuring that your algorithm works perfectly.