from datetime import datetime
import sys
import os

# Add project root to Python path
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from solana_rust_bot import RaydiumTrader
from metrics import QuantumMetrics

print(f"🚀 RAYDIUM TRADING SYSTEM TEST")
print("=" * 50)

try:
    # Initialize trader
    print("\n📡 Initializing trader...")
    trader = RaydiumTrader("id.json")
    
    # Initialize metrics analyzer
    metrics = QuantumMetrics()
    
    # Check balance
    print("\n💰 Checking SOL Balance...")
    balance = trader.get_sol_balance()
    print(f"Current Balance: {balance:.4f} SOL")
    
    # Test small trade
    amount = 0.01  # 0.01 SOL
    print(f"\n🔄 Testing trade: {amount} SOL -> USDC")
    
    # Execute trade
    signature = trader.execute_trade("BUY", 23.45) # changed amount to price
    print(f"📝 Transaction signature: {signature}")
    
    # Get market data
    market_data = {
        'price': 23.45,
        'volume': 1000.0
    }
    
    # Update metrics
    metrics.update(market_data, {})
    
    # Check new balance
    new_balance = trader.get_sol_balance()
    print(f"\n💰 New Balance: {new_balance:.4f} SOL")
    print(f"💫 Balance Change: {(new_balance - balance):.4f} SOL")
    
except Exception as e:
    print(f"\n❌ Error: {str(e)}")
    raise
finally:     
    print("\n✨ Test Complete")    (quantum_beast) PS C:\solana_rust_bot> python "C:\solana_rust_bot\tests\test.py"
Loaded keypair: EHrpEhiBU13CygunXsmeGnzR6ircuYFQcFYPZT5BWUMA
🚀 Testing Solana Rust Bot
SOL Balance: 0.361457113
Error during testing: 'builtins.RaydiumTrader' object has no attribute 'get_market_state'
(quantum_beast) PS C:\solana_rust_bot> (quantum_beast) PS C:\solana_rust_bot> python "C:\solana_rust_bot\tests\test.py"
Loaded keypair: EHrpEhiBU13CygunXsmeGnzR6ircuYFQcFYPZT5BWUMA
🚀 Testing Solana Rust Bot
SOL Balance: 0.361457113
Error during testing: 'builtins.RaydiumTrader' object has no attribute 'get_market_state'
(quantum_beast) PS C:\solana_rust_bot> v(quantum_beast) PS C:\solana_rust_bot> python "C:\solana_rust_bot\tests\test.py"
Loaded keypair: EHrpEhiBU13CygunXsmeGnzR6ircuYFQcFYPZT5BWUMA
🚀 Testing Solana Rust Bot
SOL Balance: 0.361457113
Error during testing: 'builtins.RaydiumTrader' object has no attribute 'get_market_state'
(quantum_beast) PS C:\solana_rust_bot> (quantum_beast) PS C:\solana_rust_bot> python "C:\solana_rust_bot\tests\test.py"
Loaded keypair: EHrpEhiBU13CygunXsmeGnzR6ircuYFQcFYPZT5BWUMA
🚀 Testing Solana Rust Bot
SOL Balance: 0.361457113
Error during testing: 'builtins.RaydiumTrader' object has no attribute 'get_market_state'
(quantum_beast) PS C:\solana_rust_bot> (quantum_beast) PS C:\solana_rust_bot> python "C:\solana_rust_bot\tests\test.py"
Loaded keypair: EHrpEhiBU13CygunXsmeGnzR6ircuYFQcFYPZT5BWUMA
🚀 Testing Solana Rust Bot
SOL Balance: 0.361457113
Error during testing: 'builtins.RaydiumTrader' object has no attribute 'get_market_state'
(quantum_beast) PS C:\solana_rust_bot> (quantum_beast) PS C:\solana_rust_bot> python "C:\solana_rust_bot\tests\test.py"
Loaded keypair: EHrpEhiBU13CygunXsmeGnzR6ircuYFQcFYPZT5BWUMA
🚀 Testing Solana Rust Bot
SOL Balance: 0.361457113
Error during testing: 'builtins.RaydiumTrader' object has no attribute 'get_market_state'
(quantum_beast) PS C:\solana_rust_bot> (quantum_beast) PS C:\solana_rust_bot> python "C:\solana_rust_bot\tests\test.py"
Loaded keypair: EHrpEhiBU13CygunXsmeGnzR6ircuYFQcFYPZT5BWUMA
🚀 Testing Solana Rust Bot
SOL Balance: 0.361457113
Error during testing: 'builtins.RaydiumTrader' object has no attribute 'get_market_state'
(quantum_beast) PS C:\solana_rust_bot> (quantum_beast) PS C:\solana_rust_bot> python "C:\solana_rust_bot\tests\test.py"
Loaded keypair: EHrpEhiBU13CygunXsmeGnzR6ircuYFQcFYPZT5BWUMA
🚀 Testing Solana Rust Bot
SOL Balance: 0.361457113
Error during testing: 'builtins.RaydiumTrader' object has no attribute 'get_market_state'
(quantum_beast) PS C:\solana_rust_bot>