Move 17 library crates into crates/, CLI binary into bin/fxt, consolidate 10 test crates into testing/, split config crate from deployment config files. Root directory reduced from 38+ to ~17 directories. All Cargo.toml paths and build.rs proto refs updated. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6.7 KiB
6.7 KiB
TLI ML Trading Commands
Complete guide to using TLI's ML-powered trading commands for automated order submission, prediction history, and model performance monitoring.
Prerequisites
- TLI installed and authenticated (
tli auth login) - API Gateway running (port 50051)
- Trading Service running (port 50052)
- Valid JWT with
trading.submitandtrading.viewscopes
Commands Overview
tli trade ml submit # Submit ML-generated orders
tli trade ml predictions # View prediction history
tli trade ml performance # View model performance metrics
1. Submit ML Orders
Basic Usage (Ensemble Mode)
tli trade ml submit --symbol ES.FUT --account my_account
Output:
✅ ML order submitted successfully!
Order ID: 550e8400-e29b-41d4-a716-446655440000
Symbol: ES.FUT
Model: Ensemble (4 models)
Predicted Action: BUY
Confidence: 87.2%
Quantity: 1
Account: my_account
Single Model Mode
tli trade ml submit --symbol ES.FUT --account my_account --model DQN
Available Models:
DQN- Deep Q-Network (RL agent)MAMBA2- Mamba-2 State Space ModelPPO- Proximal Policy OptimizationTFT- Temporal Fusion TransformerTLOB- Temporal Limit Order Book (requires L2 data, pending training)Liquid- Liquid Neural Network (CUDA validation complete, pending training)
Arguments
| Argument | Required | Description |
|---|---|---|
--symbol |
✅ | Trading symbol (ES.FUT, NQ.FUT, etc.) |
--account |
✅ | Account ID for order submission |
--model |
❌ | Specific model (default: ensemble) |
Examples
# Ensemble prediction for ES.FUT
tli trade ml submit --symbol ES.FUT --account prod_account
# MAMBA-2 prediction for NQ.FUT
tli trade ml submit --symbol NQ.FUT --account test_account --model MAMBA2
# PPO prediction for ZN.FUT
tli trade ml submit --symbol ZN.FUT --account rl_account --model PPO
2. View ML Predictions
Basic Usage
tli trade ml predictions --symbol ES.FUT
Output:
ML Predictions for ES.FUT (Last 10)
┌─────────────────────┬────────┬─────────┬────────┬────────────┬─────────┐
│ Timestamp │ Model │ Symbol │ Action │ Confidence │ Outcome │
├─────────────────────┼────────┼─────────┼────────┼────────────┼─────────┤
│ 2025-10-16 07:30:00 │ DQN │ ES.FUT │ BUY │ 87.2% │ +0.5% │
│ 2025-10-16 07:25:00 │ MAMBA2 │ ES.FUT │ HOLD │ 72.1% │ N/A │
│ 2025-10-16 07:20:00 │ PPO │ ES.FUT │ SELL │ 81.3% │ +0.3% │
└─────────────────────┴────────┴─────────┴────────┴────────────┴─────────┘
With Filters
# Filter by model
tli trade ml predictions --symbol ES.FUT --model MAMBA2
# Limit results
tli trade ml predictions --symbol ES.FUT --limit 50
# Combined filters
tli trade ml predictions --symbol ES.FUT --model DQN --limit 20
Arguments
| Argument | Required | Description |
|---|---|---|
--symbol |
✅ | Trading symbol to query |
--model |
❌ | Filter by specific model |
--limit |
❌ | Max results (default: 10, max: 100) |
3. View Model Performance
All Models
tli trade ml performance
Output:
ML Model Performance (Last 30 days)
┌────────┬──────────┬──────────────┬──────────────┬───────────┬────────────┐
│ Model │ Accuracy │ Predictions │ Sharpe Ratio │ Avg Return│ Max Drawdown│
├────────┼──────────┼──────────────┼──────────────┼───────────┼────────────┤
│ DQN │ 68.2% │ 1,243 │ 1.42 │ +2.1% │ -3.2% │
│ MAMBA2 │ 72.5% │ 1,189 │ 1.67 │ +2.8% │ -2.1% │
│ PPO │ 65.3% │ 1,156 │ 1.18 │ +1.5% │ -4.5% │
│ TFT │ 70.1% │ 1,221 │ 1.53 │ +2.4% │ -2.8% │
└────────┴──────────┴──────────────┴──────────────┴───────────┴────────────┘
Ensemble Confidence Threshold: 0.60
Active Models: 4/6 (TLOB and Liquid NN training pending)
Single Model
tli trade ml performance --model MAMBA2
Arguments
| Argument | Required | Description |
|---|---|---|
--model |
❌ | Filter by specific model (shows all if omitted) |
Performance Metrics Explained
- Accuracy: Percentage of correct predictions (BUY when price goes up, SELL when down)
- Sharpe Ratio: Risk-adjusted returns (>1.0 is good, >2.0 is excellent)
- Avg Return: Average profit/loss per trade
- Max Drawdown: Largest peak-to-trough decline
Ensemble Mode
When no --model is specified, TLI uses ensemble mode:
- Queries all active models
- Weights predictions by confidence scores
- Calculates ensemble vote
- Uses weighted average for final decision
Benefits:
- More robust predictions
- Reduced single-model bias
- Higher confidence threshold (0.60 vs 0.50)
Troubleshooting
"Not authenticated"
tli auth login
"Permission denied"
Verify JWT has trading.submit and trading.view scopes:
tli auth token --decode
"Trading Service unavailable"
Check service status:
docker-compose ps trading_service
curl http://localhost:8081/health
"Model not found"
Ensure model is trained and deployed. Check model status:
tli trade ml performance
Best Practices
- Start with Ensemble Mode: More reliable than single models
- Monitor Performance: Check
tli trade ml performanceweekly - Use Paper Trading First: Test in simulation before live capital
- Set Confidence Thresholds: Only trade when confidence >70%
- Diversify Across Models: Don't rely on single model predictions