Nija

NIJA Command Center

The NIJA Command Center is a comprehensive live dashboard that provides real-time visibility into 8 critical performance metrics for the NIJA trading bot.

Features

The Command Center displays the following metrics:

1. ✅ Equity Curve

2. ✅ Risk Heat

3. ✅ Trade Quality Score

4. ✅ Signal Accuracy

5. ✅ Slippage

6. ✅ Fee Impact

7. ✅ Strategy Efficiency

8. ✅ Capital Growth Velocity

Quick Start

1. Generate Sample Data

Run the test script to generate sample trading data:

python bot/test_command_center.py

This will:

2. Start the Dashboard Server

python bot/dashboard_server.py

The server will start on port 5001.

3. Access the Command Center

Open your browser and navigate to:

http://localhost:5001/command-center

Dashboard Features

API Endpoints

The Command Center provides the following REST API endpoints:

Get All Metrics

GET /api/command-center/metrics

Returns a complete snapshot of all 8 metrics.

Get Individual Metrics

Health Check

GET /api/command-center/health

Integration with Trading Bot

To integrate the Command Center with your live trading bot:

1. Import the Metrics Tracker

from bot.command_center_metrics import get_command_center_metrics

# Initialize metrics tracker
metrics = get_command_center_metrics(initial_capital=1000.0)

2. Update Equity

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
)

3. Record Trades

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
)

4. Record Signals

When your strategy generates trading signals:

metrics.record_signal(success=True)  # or False if signal failed

5. Save State (Optional)

The metrics tracker automatically saves state, but you can manually trigger it:

metrics._save_state()

File Structure

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

Data Persistence

All metrics are automatically saved to data/command_center_metrics.json and loaded on startup. This ensures your metrics persist across restarts.

Customization

Change Lookback Period

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
)

Adjust Auto-Refresh Interval

Edit bot/templates/command_center.html and change:

const REFRESH_INTERVAL = 5000; // milliseconds (5 seconds)

Troubleshooting

Dashboard Shows Zero Values

If the dashboard shows all zeros:

  1. Run python bot/test_command_center.py to generate sample data
  2. Refresh the dashboard
  3. Verify the file data/command_center_metrics.json exists

Server Won’t Start

Ensure dependencies are installed:

pip install Flask==2.3.3 Flask-CORS==4.0.0 psutil

API Returns 500 Errors

Check the server logs for error details. Common issues:

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:

Production Deployment

For production use:

  1. Use a production WSGI server (gunicorn, uWSGI)
  2. Set up reverse proxy (nginx, Apache)
  3. Enable HTTPS/SSL
  4. Configure authentication
  5. Set appropriate CORS policies

Example with gunicorn:

gunicorn -w 4 -b 0.0.0.0:5001 bot.dashboard_server:app

Future Enhancements

Potential future additions:

Support

For issues or questions about the Command Center, please check:

Version History