This guide covers three critical improvements to NIJA that provide high-leverage value:
Automated security scanning integrated into the CI/CD pipeline to detect vulnerabilities before they reach production.
.github/workflows/codeql.yml)
.github/workflows/security-scan.yml)
Security scanning is automatically enabled once the workflows are merged to main.
View Security Results:
GitHub Repository → Security Tab → Code scanning alerts
Manual Security Scan:
# Install security tools
pip install safety bandit
# Run dependency scan
safety check
# Run Bandit security linting
bandit -r . --exclude ./archive,./venv,./mobile,./frontend
# Generate reports
bandit -r . -f json -o bandit-report.json
safety check --json --output safety-report.json
See SECURITY_HARDENING_GUIDE.md for complete details:
Comprehensive backtesting across 5 years of historical data with analysis broken down by market regime (bull/bear/ranging/volatile).
# Run 5-year backtest on BTC-USD
python run_5year_backtest.py \
--symbol BTC-USD \
--years 5 \
--initial-balance 10000 \
--strategy APEX_V71 \
--output results/5year_backtest_btc.json
# Run on ETH-USD
python run_5year_backtest.py \
--symbol ETH-USD \
--years 5 \
--output results/5year_backtest_eth.json
# Custom parameters
python run_5year_backtest.py \
--symbol BTC-USD \
--years 3 \
--initial-balance 50000 \
--commission 0.0006 \
--slippage 0.0003 \
--output results/custom_backtest.json
The script generates a comprehensive JSON report with:
Overall Performance:
Regime Analysis: For each market regime (bull/bear/ranging/volatile):
Monte Carlo Simulation:
Statistical Significance:
================================================================================
5-YEAR MULTI-REGIME BACKTEST SUMMARY
================================================================================
📊 BACKTEST DETAILS
Symbol: BTC-USD
Strategy: APEX_V71
Period: 2021-01-28 to 2026-01-28 (5 years)
Initial Balance: $10,000.00
💰 OVERALL PERFORMANCE
Final Balance: $45,230.00
Total Return: 352.30%
Total Trades: 1,247
Win Rate: 61.2%
Profit Factor: 2.35
Sharpe Ratio: 1.92
Max Drawdown: 8.45%
📈 REGIME ANALYSIS
BULL Market:
Duration: 450 days
Trades: 387
Win Rate: 64.3%
Return: 145.20%
Profit Factor: 2.68
Max DD: 5.20%
BEAR Market:
Duration: 380 days
Trades: 312
Win Rate: 55.8%
Return: 42.10%
Profit Factor: 1.95
Max DD: 8.45%
RANGING Market:
Duration: 620 days
Trades: 428
Win Rate: 62.4%
Return: 118.60%
Profit Factor: 2.42
Max DD: 6.30%
VOLATILE Market:
Duration: 380 days
Trades: 120
Win Rate: 58.3%
Return: 46.40%
Profit Factor: 2.15
Max DD: 7.80%
🎲 MONTE CARLO SIMULATION (1000 runs)
Expected Return: 352.30% ± 45.20%
95% Confidence: [275.40%, 428.60%]
Expected Sharpe: 1.92
📊 STATISTICAL SIGNIFICANCE
Sample Size: 1,247 trades
P-Value: 0.0001
Conclusion: Strategy shows statistically significant edge
================================================================================
The script expects historical OHLCV data in data/ directory:
timestamp,open,high,low,close,volume{SYMBOL}_historical_5y.csv (e.g., BTC-USD_historical_5y.csv)If data file not found, the script automatically generates synthetic data for demonstration.
To use real data:
data/ directoryLive paper trading system that runs for 30 days to validate strategy performance in real market conditions without risking capital.
Day 1-30: Record Daily Metrics
Run this once per day (set up as cron job):
# Record today's performance
python run_30day_paper_trading.py --record-daily
# Specify custom data directory
python run_30day_paper_trading.py --record-daily --data-dir data/paper_jan2026
Weekly Reports
# Generate week 1 report
python run_30day_paper_trading.py --weekly-report 1
# Generate week 2 report
python run_30day_paper_trading.py --weekly-report 2
# And so on...
Final 30-Day Report
# Generate comprehensive 30-day report
python run_30day_paper_trading.py --final-report
# Compare to backtest
python run_30day_paper_trading.py \
--compare-backtest results/5year_backtest_btc.json \
--final-report
============================================================
DAILY PAPER TRADING REPORT - 2026-01-28
============================================================
💰 BALANCE
Starting: $10,000.00
Ending: $10,234.50
P&L: +$234.50 (+2.35%)
📊 TRADING
Trades: 8
Wins: 5 (62.5%)
Losses: 3
Best: +$125.30
Worst: -$45.20
📍 POSITIONS
Open: 3
Exposure: $3,045.20 (29.7% of balance)
============================================================
📊 WEEK 1 REPORT
Period: 2026-01-21 to 2026-01-27
Return: +12.45%
Trades: 47
Win Rate: 59.6%
Profit Factor: 2.28
Sharpe: 1.85
Max DD: 3.20%
================================================================================
30-DAY PAPER TRADING FINAL REPORT
================================================================================
📅 Period: 2026-01-01 to 2026-01-30
💰 Return: +48.50%
📊 Trades: 187
✅ Win Rate: 61.5%
📈 Sharpe: 1.94
📉 Max DD: 6.80%
================================================================================
Set up daily cron job:
# Edit crontab
crontab -e
# Add daily execution at market close (5pm EST = 22:00 UTC)
0 22 * * * cd /path/to/Nija && python run_30day_paper_trading.py --record-daily >> logs/paper_trading.log 2>&1
# Weekly report on Sundays at 9am
0 9 * * 0 cd /path/to/Nija && python run_30day_paper_trading.py --weekly-report $(($(date +\%W) % 4 + 1)) >> logs/paper_weekly.log 2>&1
The system automatically generates alerts for:
Alerts are saved in data/paper_trading_30day/alerts.json and logged.
python run_30day_paper_trading.py \
--compare-backtest results/5year_backtest_btc.json
Output:
================================================================================
PAPER vs BACKTEST COMPARISON
================================================================================
WIN_RATE:
Backtest: 0.612
Paper: 0.615
Diff: +0.003
SHARPE_RATIO:
Backtest: 1.920
Paper: 1.940
Diff: +0.020
MAX_DRAWDOWN:
Backtest: 8.450
Paper: 6.800
Diff: -1.650
✅ EXCELLENT - Paper trading matches backtest expectations
================================================================================
Week 1: Security Hardening
Week 2: Run 5-Year Backtests
Week 3-6: 30-Day Paper Trading
Week 7: Go Live Decision
Once all three components are validated:
bot/paper_trading.pyFor issues or questions: