Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -62,13 +62,16 @@ def fetch_data(symbol='ETHUSDT', interval='1h', start_date='2021-01-01'):
|
|
| 62 |
while start_date < end_date:
|
| 63 |
url = f'https://api.binance.com/api/v3/klines?symbol={symbol}&interval={interval}&startTime={int(start_date.timestamp() * 1000)}'
|
| 64 |
response = requests.get(url)
|
|
|
|
|
|
|
|
|
|
| 65 |
data = response.json()
|
| 66 |
if not data:
|
| 67 |
print("Fetched data is empty. Please check the API request and parameters.")
|
| 68 |
break
|
| 69 |
else:
|
| 70 |
print("Fetched data successfully.")
|
| 71 |
-
print(data
|
| 72 |
klines += data
|
| 73 |
start_date = datetime.utcfromtimestamp(data[-1][6] / 1000)
|
| 74 |
|
|
|
|
| 62 |
while start_date < end_date:
|
| 63 |
url = f'https://api.binance.com/api/v3/klines?symbol={symbol}&interval={interval}&startTime={int(start_date.timestamp() * 1000)}'
|
| 64 |
response = requests.get(url)
|
| 65 |
+
if response.status_code != 200:
|
| 66 |
+
print(f"Error fetching data: {response.status_code} {response.text}")
|
| 67 |
+
break
|
| 68 |
data = response.json()
|
| 69 |
if not data:
|
| 70 |
print("Fetched data is empty. Please check the API request and parameters.")
|
| 71 |
break
|
| 72 |
else:
|
| 73 |
print("Fetched data successfully.")
|
| 74 |
+
print(data
|
| 75 |
klines += data
|
| 76 |
start_date = datetime.utcfromtimestamp(data[-1][6] / 1000)
|
| 77 |
|