trading signal executions WIP
This commit is contained in:
77
test_trading_execution.py
Normal file
77
test_trading_execution.py
Normal file
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script to verify trading execution is working
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Add project root to path
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from core.orchestrator import TradingOrchestrator
|
||||
from core.data_provider import DataProvider
|
||||
from core.trading_executor import TradingExecutor
|
||||
|
||||
# Set up logging
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
async def test_trading_execution():
|
||||
"""Test that trading decisions are being executed"""
|
||||
try:
|
||||
logger.info("=== Testing Trading Execution ===")
|
||||
|
||||
# Initialize components
|
||||
data_provider = DataProvider()
|
||||
orchestrator = TradingOrchestrator(data_provider=data_provider)
|
||||
trading_executor = TradingExecutor()
|
||||
|
||||
# Connect trading executor to orchestrator
|
||||
orchestrator.set_trading_executor(trading_executor)
|
||||
logger.info("✅ TradingExecutor connected to orchestrator")
|
||||
|
||||
# Check if trading is enabled
|
||||
logger.info(f"Trading enabled: {trading_executor.trading_enabled}")
|
||||
logger.info(f"Simulation mode: {trading_executor.simulation_mode}")
|
||||
logger.info(f"Confidence threshold: {orchestrator.confidence_threshold}")
|
||||
|
||||
# Test making a single decision
|
||||
symbol = 'ETH/USDT'
|
||||
logger.info(f"\n=== Testing single decision for {symbol} ===")
|
||||
|
||||
decision = await orchestrator.make_trading_decision(symbol)
|
||||
if decision:
|
||||
logger.info(f"Decision: {decision.action} (confidence: {decision.confidence:.2f})")
|
||||
logger.info(f"Price: ${decision.price:.2f}")
|
||||
logger.info(f"Reasoning: {decision.reasoning}")
|
||||
else:
|
||||
logger.warning("No decision returned")
|
||||
|
||||
# Check current positions
|
||||
logger.info(f"\n=== Current Positions ===")
|
||||
if hasattr(trading_executor, 'positions') and trading_executor.positions:
|
||||
for symbol, position in trading_executor.positions.items():
|
||||
logger.info(f"{symbol}: {position.side} {position.quantity} @ ${position.entry_price:.2f}")
|
||||
else:
|
||||
logger.info("No open positions")
|
||||
|
||||
# Check trade history
|
||||
logger.info(f"\n=== Trade History ===")
|
||||
if hasattr(trading_executor, 'trade_records') and trading_executor.trade_records:
|
||||
for trade in trading_executor.trade_records[-5:]: # Last 5 trades
|
||||
logger.info(f"{trade.symbol}: {trade.side} ${trade.pnl:.2f} PnL")
|
||||
else:
|
||||
logger.info("No trade history")
|
||||
|
||||
logger.info("\n=== Test Complete ===")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Test failed: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(test_trading_execution())
|
||||
Reference in New Issue
Block a user