fix emojies

This commit is contained in:
Dobromir Popov
2025-11-22 21:46:35 +02:00
parent e541e16e7e
commit 9a06288911
37 changed files with 528 additions and 181 deletions

View File

@@ -36,7 +36,7 @@ class BinanceExample:
if isinstance(data, OrderBookSnapshot):
self.orderbook_count += 1
logger.info(
f"📊 Order Book {self.orderbook_count}: {data.symbol} - "
f"Order Book {self.orderbook_count}: {data.symbol} - "
f"Mid: ${data.mid_price:.2f}, Spread: ${data.spread:.2f}, "
f"Bids: {len(data.bids)}, Asks: {len(data.asks)}"
)
@@ -68,22 +68,22 @@ class BinanceExample:
logger.info(" Connected to Binance successfully")
# Get available symbols
logger.info("📋 Getting available symbols...")
logger.info("Getting available symbols...")
symbols = await self.connector.get_symbols()
logger.info(f"📋 Found {len(symbols)} trading symbols")
logger.info(f"Found {len(symbols)} trading symbols")
# Show some popular symbols
popular_symbols = ['BTCUSDT', 'ETHUSDT', 'ADAUSDT', 'BNBUSDT']
available_popular = [s for s in popular_symbols if s in symbols]
logger.info(f"📋 Popular symbols available: {available_popular}")
logger.info(f"Popular symbols available: {available_popular}")
# Get order book snapshot
if 'BTCUSDT' in symbols:
logger.info("📊 Getting BTC order book snapshot...")
logger.info("Getting BTC order book snapshot...")
orderbook = await self.connector.get_orderbook_snapshot('BTCUSDT', depth=10)
if orderbook:
logger.info(
f"📊 BTC Order Book: Mid=${orderbook.mid_price:.2f}, "
f"BTC Order Book: Mid=${orderbook.mid_price:.2f}, "
f"Spread=${orderbook.spread:.2f}"
)
@@ -102,18 +102,18 @@ class BinanceExample:
logger.info(" Subscribed to ETHUSDT order book")
# Let it run for a while
logger.info("Collecting data for 30 seconds...")
logger.info("Collecting data for 30 seconds...")
await asyncio.sleep(30)
# Show statistics
stats = self.connector.get_binance_stats()
logger.info("📈 Final Statistics:")
logger.info(f" 📊 Order books received: {self.orderbook_count}")
logger.info("Final Statistics:")
logger.info(f" Order books received: {self.orderbook_count}")
logger.info(f" 💰 Trades received: {self.trade_count}")
logger.info(f" 📡 Total messages: {stats['message_count']}")
logger.info(f" Errors: {stats['error_count']}")
logger.info(f" 🔗 Active streams: {stats['active_streams']}")
logger.info(f" 📋 Subscriptions: {list(stats['subscriptions'].keys())}")
logger.info(f" Subscriptions: {list(stats['subscriptions'].keys())}")
# Unsubscribe and disconnect
logger.info("🔌 Cleaning up...")
@@ -129,7 +129,7 @@ class BinanceExample:
logger.info(" Disconnected successfully")
except KeyboardInterrupt:
logger.info("⏹️ Interrupted by user")
logger.info("Interrupted by user")
except Exception as e:
logger.error(f" Example failed: {e}")
finally:

View File

@@ -45,7 +45,7 @@ class MultiExchangeManager:
try:
if isinstance(data, OrderBookSnapshot):
self.data_received[exchange]['orderbooks'] += 1
logger.info(f"📊 {exchange.upper()}: Order book for {data.symbol} - "
logger.info(f"{exchange.upper()}: Order book for {data.symbol} - "
f"Bids: {len(data.bids)}, Asks: {len(data.asks)}")
# Show best bid/ask if available
@@ -102,7 +102,7 @@ class MultiExchangeManager:
if connector.is_connected:
# Subscribe to order book
await connector.subscribe_orderbook(symbol)
logger.info(f"📈 Subscribed to {symbol} order book on {name}")
logger.info(f"Subscribed to {symbol} order book on {name}")
# Subscribe to trades
await connector.subscribe_trades(symbol)
@@ -131,7 +131,7 @@ class MultiExchangeManager:
def _print_statistics(self):
"""Print current data statistics."""
logger.info("📊 Current Statistics:")
logger.info("Current Statistics:")
total_orderbooks = 0
total_trades = 0

View File

@@ -36,7 +36,7 @@ def check_health():
all_healthy = False
if all_healthy:
print("\n🎉 Overall Health: HEALTHY")
print("\nOverall Health: HEALTHY")
return 0
else:
print("\n Overall Health: DEGRADED")
@@ -91,7 +91,7 @@ def main():
print("=" * 50)
if api_healthy and ws_healthy:
print("🎉 COBY System: FULLY HEALTHY")
print("COBY System: FULLY HEALTHY")
return 0
elif api_healthy:
print(" COBY System: PARTIALLY HEALTHY (API only)")

View File

@@ -14,7 +14,7 @@ try:
from api.rest_api import create_app
from caching.redis_manager import redis_manager
from utils.logging import get_logger, setup_logging
print("All imports successful")
print("All imports successful")
except ImportError as e:
print(f"✗ Import error: {e}")
sys.exit(1)
@@ -29,11 +29,11 @@ async def test_health_endpoints():
# Test Redis manager
await redis_manager.initialize()
ping_result = await redis_manager.ping()
print(f"Redis ping: {ping_result}")
print(f"Redis ping: {ping_result}")
# Test app creation
app = create_app()
print("FastAPI app created successfully")
print("FastAPI app created successfully")
# Test health endpoint logic
from api.response_formatter import ResponseFormatter
@@ -46,7 +46,7 @@ async def test_health_endpoints():
}
response = formatter.status_response(health_data)
print(f"Health response format: {type(response)}")
print(f"Health response format: {type(response)}")
return True
@@ -63,19 +63,19 @@ async def test_static_files():
index_path = os.path.join(static_path, "index.html")
if os.path.exists(static_path):
print(f"Static directory exists: {static_path}")
print(f"Static directory exists: {static_path}")
else:
print(f"✗ Static directory missing: {static_path}")
return False
if os.path.exists(index_path):
print(f"Index.html exists: {index_path}")
print(f"Index.html exists: {index_path}")
# Test reading the file
with open(index_path, 'r', encoding='utf-8') as f:
content = f.read()
if "COBY" in content:
print("Index.html contains COBY content")
print("Index.html contains COBY content")
else:
print("✗ Index.html missing COBY content")
return False
@@ -101,7 +101,7 @@ async def test_websocket_config():
host=config.api.host,
port=config.api.websocket_port
)
print(f"WebSocket server configured: {config.api.host}:{config.api.websocket_port}")
print(f"WebSocket server configured: {config.api.host}:{config.api.websocket_port}")
return True
@@ -139,13 +139,13 @@ async def main():
total = len(results)
for i, result in enumerate(results):
status = "PASS" if result else "FAIL"
status = "PASS" if result else "FAIL"
print(f" Test {i+1}: {status}")
print(f"\nOverall: {passed}/{total} tests passed")
if passed == total:
print("🎉 All tests passed! COBY system should work correctly.")
print("All tests passed! COBY system should work correctly.")
return 0
else:
print(" Some tests failed. Please check the issues above.")

View File

@@ -40,10 +40,10 @@ async def test_database_connection():
# Test storage stats
stats = await manager.get_storage_stats()
logger.info(f"📊 Found {len(stats.get('table_sizes', []))} tables")
logger.info(f"Found {len(stats.get('table_sizes', []))} tables")
for table_info in stats.get('table_sizes', []):
logger.info(f" 📋 {table_info['table']}: {table_info['size']}")
logger.info(f" {table_info['table']}: {table_info['size']}")
await manager.close()
return True
@@ -55,7 +55,7 @@ async def test_database_connection():
async def test_data_storage():
"""Test storing and retrieving data"""
logger.info("💾 Testing data storage operations...")
logger.info("Testing data storage operations...")
try:
manager = TimescaleManager()
@@ -181,7 +181,7 @@ async def test_batch_operations():
async def test_configuration():
"""Test configuration system"""
logger.info("⚙️ Testing configuration system...")
logger.info("Testing configuration system...")
try:
# Test database configuration
@@ -237,7 +237,7 @@ async def run_all_tests():
# Summary
logger.info("\n" + "=" * 50)
logger.info("📋 TEST SUMMARY")
logger.info("TEST SUMMARY")
logger.info("=" * 50)
passed = sum(1 for _, result in results if result)
@@ -250,7 +250,7 @@ async def run_all_tests():
logger.info(f"\nOverall: {passed}/{total} tests passed")
if passed == total:
logger.info("🎉 All tests passed! System is ready.")
logger.info("All tests passed! System is ready.")
return True
else:
logger.error(" Some tests failed. Check configuration and database connection.")
@@ -265,7 +265,7 @@ if __name__ == "__main__":
success = asyncio.run(run_all_tests())
if success:
print("\n🎉 Integration tests completed successfully!")
print("\nIntegration tests completed successfully!")
print("The system is ready for the next development phase.")
sys.exit(0)
else:

View File

@@ -104,7 +104,7 @@ class TestAllConnectors:
await connector.unsubscribe_orderbook('BTCUSDT')
await connector.unsubscribe_trades('ETHUSDT')
print(f"{name} subscription interface works")
print(f"{name} subscription interface works")
except Exception as e:
print(f"{name} subscription interface failed: {e}")
@@ -140,7 +140,7 @@ class TestAllConnectors:
assert 'exchange' in stats
assert stats['exchange'] == name
assert 'connection_status' in stats
print(f"{name} statistics interface works")
print(f"{name} statistics interface works")
except Exception as e:
print(f"{name} statistics interface failed: {e}")
@@ -160,7 +160,7 @@ class TestAllConnectors:
connector.remove_data_callback(test_callback)
assert test_callback not in connector.data_callbacks
print(f"{name} callback system works")
print(f"{name} callback system works")
except Exception as e:
print(f"{name} callback system failed: {e}")
@@ -176,7 +176,7 @@ class TestAllConnectors:
is_connected = connector.is_connected
assert isinstance(is_connected, bool)
print(f"{name} connection status interface works")
print(f"{name} connection status interface works")
except Exception as e:
print(f"{name} connection status interface failed: {e}")
@@ -206,25 +206,25 @@ async def test_connector_compatibility():
# Test initialization
assert connector.exchange_name == name
print(f" Initialization: {connector.exchange_name}")
print(f" Initialization: {connector.exchange_name}")
# Test symbol normalization
btc_symbol = connector.normalize_symbol('BTCUSDT')
eth_symbol = connector.normalize_symbol('ETHUSDT')
print(f" Symbol normalization: BTCUSDT -> {btc_symbol}, ETHUSDT -> {eth_symbol}")
print(f" Symbol normalization: BTCUSDT -> {btc_symbol}, ETHUSDT -> {eth_symbol}")
# Test message type detection
test_msg = {'type': 'test'} if name != 'kraken' else [1, {}, 'test', 'symbol']
msg_type = connector._get_message_type(test_msg)
print(f" Message type detection: {msg_type}")
print(f" Message type detection: {msg_type}")
# Test statistics
stats = connector.get_stats()
print(f" Statistics: {len(stats)} fields")
print(f" Statistics: {len(stats)} fields")
# Test connection status
status = connector.get_connection_status()
print(f" Connection status: {status.value}")
print(f" Connection status: {status.value}")
print(f" {name.upper()} connector passed all tests")
@@ -265,7 +265,7 @@ async def test_multi_connector_data_flow():
try:
await connector.subscribe_orderbook(symbol)
await connector.subscribe_trades(symbol)
print(f"Subscribed to {symbol} on {name}")
print(f"Subscribed to {symbol} on {name}")
except Exception as e:
print(f"✗ Failed to subscribe to {symbol} on {name}: {e}")

View File

@@ -306,7 +306,7 @@ async def test_bybit_integration():
test_message = {'topic': 'orderbook.50.BTCUSDT', 'data': {}}
assert connector._get_message_type(test_message) == 'orderbook'
print("Bybit connector integration test passed")
print("Bybit connector integration test passed")
return True
except Exception as e:

View File

@@ -349,7 +349,7 @@ async def test_coinbase_integration():
test_message = {'type': 'l2update', 'product_id': 'BTC-USD'}
assert connector._get_message_type(test_message) == 'l2update'
print("Coinbase connector integration test passed")
print("Coinbase connector integration test passed")
return True
except Exception as e:

View File

@@ -383,7 +383,7 @@ async def test_kraken_integration():
status_message = {'event': 'systemStatus', 'status': 'online'}
assert connector._get_message_type(status_message) == 'systemStatus'
print("Kraken connector integration test passed")
print("Kraken connector integration test passed")
return True
except Exception as e:

View File

@@ -344,7 +344,7 @@ async def test_integration_suite():
price = adapter.get_current_price('BTCUSDT')
assert price == 50000.0
logger.info(f"Current price retrieval: {price}")
logger.info(f"Current price retrieval: {price}")
# Test subscription
callback_called = False
@@ -355,17 +355,17 @@ async def test_integration_suite():
subscriber_id = adapter.subscribe_to_ticks(test_callback, ['BTCUSDT'])
assert subscriber_id != ""
logger.info(f"Subscription created: {subscriber_id}")
logger.info(f"Subscription created: {subscriber_id}")
# Test data quality
quality = adapter.get_data_quality_indicators('BTCUSDT')
assert quality['symbol'] == 'BTCUSDT'
logger.info(f"Data quality check: {quality['quality_score']}")
logger.info(f"Data quality check: {quality['quality_score']}")
# Test system metadata
metadata = adapter.get_system_metadata()
assert metadata['system'] == 'COBY'
logger.info(f"System metadata: {metadata['mode']}")
logger.info(f"System metadata: {metadata['mode']}")
logger.info("All integration tests passed successfully!")
return True
@@ -379,7 +379,7 @@ if __name__ == "__main__":
# Run the integration tests
success = asyncio.run(test_integration_suite())
if success:
print("COBY orchestrator integration tests completed successfully")
print("COBY orchestrator integration tests completed successfully")
else:
print("✗ COBY orchestrator integration tests failed")
exit(1)