The NIJA Paper Trading Analytics System implements a 3-phase optimization process for systematically improving trading performance before deploying real capital:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Paper Trading Bot β
β - Executes trades with virtual money β
β - Records every trade with full context β
ββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Analytics Engine β
β - Tracks signal type performance β
β - Tracks exit strategy performance β
β - Calculates win rates, profit factors, Sharpe ratios β
β - Identifies top and bottom performers β
ββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Performance Optimizer β
β - Disables underperforming signals β
β - Reduces allocation to weak exits β
β - Promotes top-quartile strategies β
ββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Profit-Ready Validator β
β - Validates all criteria met β
β - Generates readiness report β
β - Gates transition to live trading β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Generate 150 simulated trades to see how the system works
python demo_paper_analytics.py --trades 150
# This creates demo data in ./data/demo_paper_analytics
# View comprehensive performance report
python paper_trading_manager.py --data-dir ./data/demo_paper_analytics --report
# Save report to file
python paper_trading_manager.py --report --output analytics_report.json
# Identify top and bottom performers
python paper_trading_manager.py --analyze
# Disable underperformers (interactive with confirmation)
python paper_trading_manager.py --kill-losers
# Auto-confirm (use in automated workflows)
python paper_trading_manager.py --kill-losers --auto-confirm
# Validate if ready for live trading
python paper_trading_manager.py --check-ready
# View current criteria
python paper_trading_manager.py --show-criteria
The system tracks performance for these signal types:
| Signal Type | Description |
|---|---|
dual_rsi |
Dual RSI strategy (RSI_9 + RSI_14) |
rsi_oversold |
Single RSI oversold condition |
rsi_overbought |
Single RSI overbought condition |
breakout |
Price breakout signals |
trend_following |
Momentum trend signals |
mean_reversion |
Mean reversion signals |
volatility_expansion |
Volatility-based signals |
webhook |
TradingView webhook signals |
The system tracks performance for these exit strategies:
| Exit Strategy | Description |
|---|---|
profit_target |
Hit profit target |
stop_loss |
Hit stop loss |
trailing_stop |
Trailing stop triggered |
partial_profit |
Partial profit taking |
time_exit |
Time-based exit |
signal_reversal |
Opposite signal triggered |
manual |
Manual exit |
# Return criteria
min_total_return_pct: 5.0 # Minimum 5% return
min_trades: 100 # Minimum 100 trades
max_trades: 300 # Max before decision required
# Risk criteria
max_drawdown_pct: 15.0 # Maximum 15% drawdown
min_sharpe_ratio: 1.0 # Minimum Sharpe ratio
# Performance criteria
min_win_rate: 45.0 # Minimum 45% win rate
min_profit_factor: 1.5 # Minimum 1.5 profit factor
# Operational criteria
max_scan_time_seconds: 30.0 # Maximum 30s scan time
min_utilization_pct: 60.0 # Minimum 60% capital usage
max_utilization_pct: 80.0 # Maximum 80% capital usage
# Time criteria
min_days_trading: 14 # Minimum 14 days
# Set custom profit-ready criteria
python paper_trading_manager.py --set-criteria \
--min-return 10 \
--max-drawdown 12 \
--min-sharpe 1.5 \
--min-win-rate 50 \
--min-profit-factor 2.0
For each signal type, we track:
For each exit strategy, we track:
from bot.paper_trading_analytics import get_analytics, TradeAnalytics, SignalType, ExitReason
# Get analytics instance
analytics = get_analytics(data_dir="./data/paper_analytics")
# After each trade completes, record it
trade = TradeAnalytics(
trade_id="TRADE-001",
timestamp=datetime.now().isoformat(),
symbol="BTC-USD",
signal_type=SignalType.DUAL_RSI.value,
entry_price=50000.0,
entry_size_usd=200.0,
entry_time=entry_time.isoformat(),
exit_reason=ExitReason.PROFIT_TARGET.value,
exit_price=50500.0,
exit_time=exit_time.isoformat(),
gross_pnl=100.0,
net_pnl=98.8, # After fees
pnl_pct=2.0,
duration_minutes=45,
max_favorable_excursion=150.0,
max_adverse_excursion=50.0,
risk_reward_ratio=3.0,
scan_time_seconds=15.0,
rsi_9=35.0,
rsi_14=40.0
)
analytics.record_trade(trade)
from bot.paper_trading_analytics import get_analytics
analytics = get_analytics()
# Before executing a trade, check if signal is disabled
signal_type = "dual_rsi"
if signal_type in analytics.signal_performance:
if not analytics.signal_performance[signal_type].enabled:
print(f"Signal {signal_type} is disabled - skipping trade")
return
from bot.paper_trading_analytics import get_analytics
analytics = get_analytics()
# Get current allocation for an exit strategy
exit_reason = "profit_target"
if exit_reason in analytics.exit_performance:
allocation = analytics.exit_performance[exit_reason].capital_allocation_pct
# Adjust position size based on allocation
adjusted_size = base_size * (allocation / 100.0)
# Run paper trading bot with analytics enabled
# Let it trade for 1-2 weeks
# Aim for 100-300 trades
# Check progress periodically
python paper_trading_manager.py --report
# Analyze performance
python paper_trading_manager.py --analyze
# Output will show:
# - Top performers (top 25%)
# - Underperformers (bottom 25%)
# Review underperformers and disable them
python paper_trading_manager.py --kill-losers
# This will:
# - Disable underperforming signals
# - Reduce allocation for weak exits (50% reduction)
# Monitor performance with optimized settings
# Collect 20-50 more trades to validate improvements
python paper_trading_manager.py --report
# Check if ready for live trading
python paper_trading_manager.py --check-ready
# If all criteria met:
# β
Ready to scale to live trading
{
"summary": {
"total_trades": 150,
"total_pnl": 2500.50,
"win_rate": 52.5,
"avg_pnl_per_trade": 16.67
},
"signal_performance": {
"dual_rsi": {
"total_trades": 45,
"win_rate": 55.6,
"profit_factor": 1.8,
"total_pnl": 1200.00,
"enabled": true
},
"webhook": {
"total_trades": 20,
"win_rate": 35.0,
"profit_factor": 0.7,
"total_pnl": -300.00,
"enabled": false
}
},
"exit_performance": {
"profit_target": {
"total_trades": 60,
"win_rate": 65.0,
"profit_factor": 2.5,
"capital_allocation_pct": 100.0
}
},
"profit_ready_status": {
"is_ready": true,
"message": "β
All criteria met!",
"criteria_met": {
"min_trades": true,
"min_win_rate": true,
"max_drawdown": true
}
}
}
Problem: Analytics report shows 0 trades
Solution:
Problem: Never meets profit-ready criteria
Solution:
Problem: All or most signals get disabled
Solution:
from bot.paper_trading_analytics import get_analytics
analytics = get_analytics()
# Get trades for specific signal
dual_rsi_trades = [t for t in analytics.trades if t.signal_type == "dual_rsi"]
# Calculate custom metrics
avg_duration = sum(t.duration_minutes for t in dual_rsi_trades) / len(dual_rsi_trades)
best_trade = max(dual_rsi_trades, key=lambda t: t.net_pnl)
# Add to cron or scheduled task
0 0 * * * cd /path/to/nija && python paper_trading_manager.py --report --output daily_report_$(date +\%Y\%m\%d).json
from bot.paper_trading_analytics import get_analytics
analytics = get_analytics()
# Check profit-ready status programmatically
status = analytics.validate_profit_ready()
if status.is_ready:
# Send notification, update dashboard, etc.
send_notification("β
Bot is profit-ready for live trading!")
data/paper_analytics/ # Analytics data directory
βββ trades_analytics.json # All recorded trades
βββ signal_performance.json # Signal type performance
βββ exit_performance.json # Exit strategy performance
βββ profit_ready_criteria.json # Profit-ready criteria config
βββ disabled_signals.json # List of disabled signals
The Paper Trading Analytics System provides a data-driven, systematic approach to:
This process ensures you only deploy strategies that have proven profitability in paper trading, dramatically reducing the risk of losses when transitioning to real money.
Next Steps:
python demo_paper_analytics.pypython paper_trading_manager.py --data-dir ./data/demo_paper_analytics --report