Files
gogo2/test_chart_data_fix.py
Dobromir Popov bfaba556ea merge annotate /ANNOTATE/core into /core.
fix chart updates
2025-12-10 14:07:14 +02:00

54 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""
Test script to verify chart data API works after refactoring
"""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent))
from core.data_provider import DataProvider
from core.config import get_config
def test_chart_data():
"""Test that data provider can provide chart data for annotation UI"""
print("Testing chart data after ANNOTATE/core refactoring...")
print("-" * 50)
try:
# Initialize config and data provider
config = get_config()
data_provider = DataProvider(config)
print("✅ DataProvider initialized successfully")
# Test the annotation-specific method
symbol = 'ETH/USDT'
timeframe = '1m'
limit = 10
print(f"\nTesting get_data_for_annotation({symbol}, {timeframe}, limit={limit})...")
df = data_provider.get_data_for_annotation(
symbol=symbol,
timeframe=timeframe,
limit=limit,
direction='latest'
)
if df is not None and not df.empty:
print(f"✅ Got {len(df)} candles")
print(f" Latest timestamp: {df.index[-1]}")
print(f" Latest close: {df.iloc[-1]['close']}")
print("✅ Chart data API working correctly!")
else:
print("❌ No data returned")
except Exception as e:
print(f"❌ Error: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
test_chart_data()