
REMOVED DUPLICATES: - web/dashboard.py (533KB, 10474 lines) - Legacy massive file - web/dashboard_backup.py (504KB, 10022 lines) - Backup copy - web/temp_dashboard.py (132KB, 2577 lines) - Temporary file - web/scalping_dashboard.py (146KB, 2812 lines) - Duplicate functionality - web/enhanced_scalping_dashboard.py (65KB, 1407 lines) - Duplicate functionality REMOVED RUN SCRIPTS: - run_dashboard.py - Pointed to deleted legacy dashboard - run_enhanced_scalping_dashboard.py - For deleted dashboard - run_cob_dashboard.py - Simple duplicate - run_fixed_dashboard.py - Temporary fix - run_main_dashboard.py - Duplicate functionality - run_enhanced_system.py - Commented out file - simple_cob_dashboard.py - Integrated into main dashboards - simple_dashboard_fix.py - Temporary fix - start_enhanced_dashboard.py - Empty file UPDATED REFERENCES: - Fixed imports in test files to use clean_dashboard - Updated .cursorrules to reference clean_dashboard - Updated launch.json with templated dashboard config - Fixed broken import references RESULTS: - Removed ~1.4GB of duplicate dashboard code - Removed 8 duplicate run scripts - Kept essential: clean_dashboard.py, templated_dashboard.py, run_clean_dashboard.py - All launch configurations still work - Project is now slim and maintainable
95 lines
3.4 KiB
Python
95 lines
3.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script to verify enhanced fee tracking with maker/taker fees
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
import logging
|
|
from datetime import datetime, timezone
|
|
from web.clean_dashboard import CleanTradingDashboard as TradingDashboard
|
|
from core.data_provider import DataProvider
|
|
|
|
# Setup logging
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
def test_enhanced_fee_tracking():
|
|
"""Test enhanced fee tracking with maker/taker fees"""
|
|
|
|
logger.info("Testing enhanced fee tracking...")
|
|
|
|
# Create dashboard instance
|
|
data_provider = DataProvider()
|
|
dashboard = TradingDashboard(data_provider=data_provider)
|
|
|
|
# Create test trading decisions with different fee types
|
|
test_decisions = [
|
|
{
|
|
'action': 'BUY',
|
|
'symbol': 'ETH/USDT',
|
|
'price': 3500.0,
|
|
'confidence': 0.8,
|
|
'timestamp': datetime.now(timezone.utc),
|
|
'order_type': 'market', # Should use taker fee
|
|
'filled_as_maker': False
|
|
},
|
|
{
|
|
'action': 'SELL',
|
|
'symbol': 'ETH/USDT',
|
|
'price': 3520.0,
|
|
'confidence': 0.9,
|
|
'timestamp': datetime.now(timezone.utc),
|
|
'order_type': 'limit', # Should use maker fee if filled as maker
|
|
'filled_as_maker': True
|
|
}
|
|
]
|
|
|
|
# Process the trading decisions
|
|
for i, decision in enumerate(test_decisions):
|
|
logger.info(f"Processing decision {i+1}: {decision['action']} @ ${decision['price']}")
|
|
dashboard._process_trading_decision(decision)
|
|
|
|
# Check session trades
|
|
if dashboard.session_trades:
|
|
latest_trade = dashboard.session_trades[-1]
|
|
fee_type = latest_trade.get('fee_type', 'unknown')
|
|
fee_rate = latest_trade.get('fee_rate', 0)
|
|
fees = latest_trade.get('fees', 0)
|
|
|
|
logger.info(f" Trade recorded: {latest_trade.get('position_action', 'unknown')}")
|
|
logger.info(f" Fee Type: {fee_type}")
|
|
logger.info(f" Fee Rate: {fee_rate*100:.3f}%")
|
|
logger.info(f" Fee Amount: ${fees:.4f}")
|
|
|
|
# Check closed trades
|
|
if dashboard.closed_trades:
|
|
logger.info(f"\nClosed trades: {len(dashboard.closed_trades)}")
|
|
for trade in dashboard.closed_trades:
|
|
logger.info(f" Trade #{trade['trade_id']}: {trade['side']}")
|
|
logger.info(f" Fee Type: {trade.get('fee_type', 'unknown')}")
|
|
logger.info(f" Fee Rate: {trade.get('fee_rate', 0)*100:.3f}%")
|
|
logger.info(f" Total Fees: ${trade.get('fees', 0):.4f}")
|
|
logger.info(f" Net P&L: ${trade.get('net_pnl', 0):.2f}")
|
|
|
|
# Test session performance with fee breakdown
|
|
logger.info("\nTesting session performance display...")
|
|
performance = dashboard._create_session_performance()
|
|
logger.info(f"Session performance components: {len(performance)}")
|
|
|
|
# Test closed trades table
|
|
logger.info("\nTesting enhanced trades table...")
|
|
table_components = dashboard._create_closed_trades_table()
|
|
logger.info(f"Table components: {len(table_components)}")
|
|
|
|
logger.info("Enhanced fee tracking test completed!")
|
|
|
|
return True
|
|
|
|
if __name__ == "__main__":
|
|
test_enhanced_fee_tracking() |