fix live updates

This commit is contained in:
Dobromir Popov
2025-12-10 14:39:06 +02:00
parent e200600a0a
commit 732c5b4941
6 changed files with 290 additions and 8 deletions

60
test_live_updates_api.py Normal file
View File

@@ -0,0 +1,60 @@
#!/usr/bin/env python3
"""
Test script to check live updates API
"""
import requests
import json
import time
from datetime import datetime
def test_live_updates():
"""Test the live-updates-batch API"""
print("Testing live-updates-batch API...")
print("-" * 50)
url = "http://localhost:8051/api/live-updates-batch"
payload = {
"symbol": "ETH/USDT",
"timeframes": ["1s", "1m"]
}
# Make 3 requests with 3 second intervals to see if data changes
for i in range(3):
try:
print(f"\n=== Request {i+1} at {datetime.now().strftime('%H:%M:%S')} ===")
response = requests.post(url, json=payload, timeout=10)
if response.status_code == 200:
data = response.json()
print(f"Success: {data.get('success')}")
print(f"Server time: {data.get('server_time')}")
if data.get('success') and data.get('chart_updates'):
for timeframe, update in data['chart_updates'].items():
candle = update.get('candle', {})
timestamp = candle.get('timestamp', 'N/A')
close_price = candle.get('close', 'N/A')
is_confirmed = update.get('is_confirmed', False)
print(f" {timeframe}: {timestamp} | Close: {close_price} | Confirmed: {is_confirmed}")
else:
print(f" Error: {data.get('error', 'Unknown error')}")
else:
print(f" HTTP Error: {response.status_code}")
print(f" Response: {response.text}")
except Exception as e:
print(f" Request failed: {e}")
if i < 2: # Don't sleep after last request
time.sleep(3)
print("\nTest completed!")
if __name__ == "__main__":
test_live_updates()