The NIJA Command Center is a comprehensive live dashboard that provides real-time visibility into 8 critical performance metrics for the NIJA trading bot.
The Command Center displays the following metrics:
Run the test script to generate sample trading data:
python bot/test_command_center.py
This will:
python bot/dashboard_server.py
The server will start on port 5001.
Open your browser and navigate to:
http://localhost:5001/command-center
The Command Center provides the following REST API endpoints:
GET /api/command-center/metrics
Returns a complete snapshot of all 8 metrics.
GET /api/command-center/equity-curve?hours=24 - Equity curve dataGET /api/command-center/risk-heat - Risk heat metricsGET /api/command-center/trade-quality - Trade quality scoreGET /api/command-center/signal-accuracy - Signal accuracy metricsGET /api/command-center/slippage - Slippage metricsGET /api/command-center/fee-impact - Fee impact metricsGET /api/command-center/strategy-efficiency - Strategy efficiencyGET /api/command-center/growth-velocity - Capital growth velocityGET /api/command-center/health
To integrate the Command Center with your live trading bot:
from bot.command_center_metrics import get_command_center_metrics
# Initialize metrics tracker
metrics = get_command_center_metrics(initial_capital=1000.0)
Call this periodically (e.g., every hour or on every trade):
metrics.update_equity(
equity=current_portfolio_value,
cash=available_cash,
positions_value=total_position_value
)
After each completed trade:
metrics.record_trade(
symbol='BTC-USD',
side='long', # or 'short'
entry_price=45000.0,
exit_price=46000.0,
size=1000.0, # Position size in USD
fees=1.0,
slippage=0.5 # Optional
)
When your strategy generates trading signals:
metrics.record_signal(success=True) # or False if signal failed
The metrics tracker automatically saves state, but you can manually trigger it:
metrics._save_state()
bot/
├── command_center_metrics.py # Core metrics calculation engine
├── command_center_api.py # Flask API endpoints
├── test_command_center.py # Test script with sample data
├── templates/
│ └── command_center.html # Dashboard UI
└── dashboard_server.py # Main dashboard server (includes Command Center)
data/
└── command_center_metrics.json # Persisted metrics data
All metrics are automatically saved to data/command_center_metrics.json and loaded on startup. This ensures your metrics persist across restarts.
By default, the metrics tracker keeps 30 days of history. To change this:
metrics = get_command_center_metrics(
initial_capital=1000.0,
lookback_days=60 # Keep 60 days of history
)
Edit bot/templates/command_center.html and change:
const REFRESH_INTERVAL = 5000; // milliseconds (5 seconds)
If the dashboard shows all zeros:
python bot/test_command_center.py to generate sample datadata/command_center_metrics.json existsEnsure dependencies are installed:
pip install Flask==2.3.3 Flask-CORS==4.0.0 psutil
Check the server logs for error details. Common issues:
data/command_center_metrics.json and regenerate)From the main dashboard (http://localhost:5001/), click the “⚡ Command Center” button to access the Command Center.
From the Command Center, you can return to:
For production use:
Example with gunicorn:
gunicorn -w 4 -b 0.0.0.0:5001 bot.dashboard_server:app
Potential future additions:
For issues or questions about the Command Center, please check: