decouple external API and local data consumption
This commit is contained in:
60
test_simplified_data_provider.py
Normal file
60
test_simplified_data_provider.py
Normal file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script for the simplified data provider
|
||||
"""
|
||||
|
||||
import time
|
||||
import logging
|
||||
from core.data_provider import DataProvider
|
||||
|
||||
# Set up logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def test_data_provider():
|
||||
"""Test the simplified data provider"""
|
||||
logger.info("Testing simplified data provider...")
|
||||
|
||||
# Initialize data provider
|
||||
dp = DataProvider()
|
||||
|
||||
# Wait for initial data load
|
||||
logger.info("Waiting for initial data load...")
|
||||
time.sleep(10)
|
||||
|
||||
# Check health
|
||||
health = dp.health_check()
|
||||
logger.info(f"Health check: {health}")
|
||||
|
||||
# Get cached data summary
|
||||
summary = dp.get_cached_data_summary()
|
||||
logger.info(f"Cached data summary: {summary}")
|
||||
|
||||
# Test getting historical data (should be from cache only)
|
||||
for symbol in ['ETH/USDT', 'BTC/USDT']:
|
||||
for timeframe in ['1s', '1m', '1h', '1d']:
|
||||
data = dp.get_historical_data(symbol, timeframe, limit=10)
|
||||
if data is not None and not data.empty:
|
||||
logger.info(f"{symbol} {timeframe}: {len(data)} candles, latest price: {data.iloc[-1]['close']}")
|
||||
else:
|
||||
logger.warning(f"{symbol} {timeframe}: No data available")
|
||||
|
||||
# Test current prices
|
||||
for symbol in ['ETH/USDT', 'BTC/USDT']:
|
||||
price = dp.get_current_price(symbol)
|
||||
logger.info(f"Current price for {symbol}: {price}")
|
||||
|
||||
# Wait and check if data is being updated
|
||||
logger.info("Waiting 30 seconds to check data updates...")
|
||||
time.sleep(30)
|
||||
|
||||
# Check data again
|
||||
summary2 = dp.get_cached_data_summary()
|
||||
logger.info(f"Updated cached data summary: {summary2}")
|
||||
|
||||
# Stop data maintenance
|
||||
dp.stop_automatic_data_maintenance()
|
||||
logger.info("Test completed")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_data_provider()
|
Reference in New Issue
Block a user