feat: Add core trading modules for risk management, backtesting, and execution algorithms, alongside a new ML transparency widget and related frontend dependencies.
Some checks are pending
Documentation / build-docs (push) Waiting to run
Tests / test (macos-latest, 3.11) (push) Waiting to run
Tests / test (macos-latest, 3.12) (push) Waiting to run
Tests / test (macos-latest, 3.13) (push) Waiting to run
Tests / test (macos-latest, 3.14) (push) Waiting to run
Tests / test (ubuntu-latest, 3.11) (push) Waiting to run
Tests / test (ubuntu-latest, 3.12) (push) Waiting to run
Tests / test (ubuntu-latest, 3.13) (push) Waiting to run
Tests / test (ubuntu-latest, 3.14) (push) Waiting to run

This commit is contained in:
2025-12-31 21:25:06 -05:00
parent 099432bf3f
commit 7bd6be64a4
743 changed files with 8617 additions and 5042 deletions

View File

@@ -6,14 +6,15 @@ Welcome to the Crypto Trader user manual. This guide will help you get started w
1. [Getting Started](getting_started.md) - Installation and first steps
2. [Configuration](configuration.md) - Setting up the application
3. [Trading](trading.md) - How to trade cryptocurrencies
3. [Trading](trading.md) - How to trade cryptocurrencies with advanced order types
4. [Strategies](strategies.md) - Creating and managing trading strategies
5. [Backtesting](backtesting.md) - Testing strategies on historical data
6. [Portfolio](portfolio.md) - Managing your portfolio
7. [Alerts](alerts.md) - Setting up price and indicator alerts
8. [Reporting](reporting.md) - Exporting data and generating reports
9. [Troubleshooting](troubleshooting.md) - Common issues and solutions
10. [FAQ](faq.md) - Frequently asked questions
5. [Backtesting](backtesting.md) - Testing strategies with walk-forward analysis and Monte Carlo simulation
6. [Portfolio](portfolio.md) - Managing your portfolio with risk analysis and rebalancing
7. [Trade Journal](trade_journal.md) - Analyzing trade history, filtering, and exporting trade data
8. [Alerts](alerts.md) - Setting up price and indicator alerts
9. [Reporting](reporting.md) - Exporting data and generating reports
10. [Troubleshooting](troubleshooting.md) - Common issues and solutions
11. [FAQ](faq.md) - Frequently asked questions
## Quick Links

View File

@@ -49,14 +49,57 @@ After a backtest completes, you can export the results:
Both exports are automatically named with the current date for easy organization.
## Advanced Backtesting Features
### Walk-Forward Analysis
Walk-forward analysis provides robust parameter optimization by using rolling windows:
1. **Training Period**: Strategy parameters are optimized on training data (e.g., 90 days)
2. **Testing Period**: Optimized parameters are tested on out-of-sample data (e.g., 30 days)
3. **Rolling Window**: Window advances by step size (e.g., 30 days) and process repeats
This method prevents overfitting and provides more realistic performance estimates than single-period optimization.
**Benefits**:
- Prevents overfitting to historical data
- Tests strategy robustness across different market conditions
- Provides confidence intervals for parameter estimates
- Validates strategy performance on unseen data
### Monte Carlo Simulation
Monte Carlo simulation tests strategy robustness by running thousands of random scenarios:
- **Random Parameter Variation**: Tests strategy performance across parameter ranges
- **Statistical Analysis**: Provides distribution of returns, Sharpe ratios, and drawdowns
- **Confidence Intervals**: Shows expected performance ranges (e.g., 95% confidence)
- **Risk Assessment**: Identifies worst-case scenarios and tail risks
Use Monte Carlo simulation to:
- Validate strategy robustness
- Assess parameter sensitivity
- Understand potential downside risks
- Estimate performance under various market conditions
## Parameter Optimization
Parameter optimization allows you to automatically find the best strategy parameters. This feature requires backend API support and will be available once the optimization endpoints are implemented.
Parameter optimization allows you to automatically find the best strategy parameters using multiple algorithms:
The UI includes an information card explaining this feature. When available, you'll be able to:
- **Grid Search**: Exhaustive search across parameter grid (best for small parameter spaces)
- **Bayesian Optimization**: Efficient exploration using Gaussian process (best for expensive evaluations)
- **Genetic Algorithms**: Evolutionary search that finds good solutions efficiently
Optimization metrics include:
- Sharpe Ratio (risk-adjusted returns)
- Total Return
- Maximum Drawdown
- Win Rate
When available via the backend API, you'll be able to:
- Select parameters to optimize
- Set parameter ranges
- Choose optimization method (Grid Search, Genetic Algorithm, Bayesian Optimization)
- Choose optimization method
- View optimization progress
- Compare optimization results

View File

@@ -190,6 +190,44 @@ Configure risk limits in the Settings page:
Settings are validated before saving and you'll see error messages if values are invalid.
### Advanced Risk Settings
#### Value at Risk (VaR)
VaR configuration is managed through the risk management API. Default settings:
- **Confidence Level**: 95% (typical: 90%, 95%, 99%)
- **Holding Period**: 1 day (typical: 1 day, 10 days, 30 days)
- **Lookback Period**: 252 days (1 trading year)
VaR methods available:
- Historical VaR
- Parametric (Variance-Covariance) VaR
- Monte Carlo VaR
- Conditional VaR (CVaR)
#### Portfolio Correlation Analysis
Correlation analysis settings:
- **Lookback Period**: 90 days default
- **Correlation Threshold**: Configurable maximum correlation for position limits
- **Diversification Scoring**: Automatic calculation
#### Position Sizing
Advanced position sizing methods available:
- **Volatility-Adjusted**: Adjusts position size based on asset volatility (ATR-based)
- **Fractional Kelly**: Configurable fraction of Kelly Criterion (default: 0.25)
- **Regime-Aware**: Adjusts position size based on market regime
- **Confidence-Based**: ML model confidence-adjusted position sizing
#### Portfolio Rebalancing
Rebalancing configuration:
- **Threshold**: Deviation threshold to trigger rebalancing (default: 1%)
- **Rebalance Interval**: Time-based interval in days (optional)
- **Fee Threshold**: Minimum fee threshold to avoid unnecessary rebalancing
## Data Storage
Data is stored in `~/.local/share/crypto_trader/`:

View File

@@ -79,12 +79,13 @@ When you first launch Crypto Trader:
3. **Paper Trading**: By default, the application starts in paper trading mode with $100 virtual capital.
4. **UI Overview**: The web interface contains six main pages accessible via the navigation menu:
- **Dashboard**: Overview with AutoPilot controls, system health, and real-time market data
4. **UI Overview**: The web interface contains seven main pages accessible via the navigation menu:
- **Dashboard**: Overview with AutoPilot controls, system health, real-time market data, live P&L widgets, ML confidence gauge, and market regime indicators
- **Strategies**: Create, edit, delete, and manage trading strategies with full parameter configuration
- **Trading**: Manual order placement, order management, and position closing
- **Portfolio**: View portfolio performance, holdings, allocation charts, and risk metrics
- **Backtesting**: Configure and run backtests on historical data with progress tracking
- **Trading**: Manual order placement with advanced order types (trailing stop, bracket orders, OCO, iceberg, TWAP/VWAP), order management, and position closing
- **Portfolio**: View portfolio performance, holdings, allocation charts, risk metrics, and automated rebalancing
- **Backtesting**: Configure and run backtests on historical data with walk-forward analysis, Monte Carlo simulation, and parameter optimization
- **Trade Journal**: Comprehensive trade history with filtering, statistics, analysis, and CSV export
- **Settings**: Manage exchanges, risk settings, alerts, alert history, and application configuration
## Adding Your First Exchange

View File

@@ -75,6 +75,40 @@ Export functionality for:
The equity curve chart shows portfolio value over time, helping you visualize performance trends.
## Advanced Risk Management
### Value at Risk (VaR)
Crypto Trader provides comprehensive Value at Risk calculations using multiple methods:
- **Historical VaR**: Based on historical portfolio return distribution
- **Parametric VaR**: Assumes normal distribution (variance-covariance method)
- **Monte Carlo VaR**: Simulates future returns using estimated parameters
- **Conditional VaR (CVaR)**: Expected loss given that loss exceeds VaR threshold
VaR helps quantify potential portfolio losses at specified confidence levels (e.g., 95% confidence, 1-day holding period).
### Portfolio Correlation Analysis
Monitor portfolio diversification and correlation risk:
- **Correlation Matrix**: View correlation between all portfolio positions
- **Diversification Score**: Measure how well-diversified your portfolio is
- **Concentration Risk**: Identify over-concentration in correlated assets
- **Correlation-based Limits**: Automatically prevent over-concentration
Lower correlation between positions indicates better diversification and reduced portfolio risk.
## Portfolio Rebalancing
Automated portfolio rebalancing helps maintain your target asset allocation and can be triggered by:
- **Threshold-based**: Rebalance when allocation drifts beyond specified threshold (e.g., 5% deviation)
- **Time-based**: Rebalance at regular intervals (e.g., daily, weekly, monthly)
- **Fee-aware**: Considers trading fees when determining if rebalancing is cost-effective
Rebalancing automatically calculates required trades to restore target allocations while minimizing fees and market impact.
## Understanding Metrics
### Sharpe Ratio

View File

@@ -0,0 +1,111 @@
# Trade Journal Guide
The Trade Journal provides comprehensive analysis of your trading history with advanced filtering, statistics, and export capabilities.
## Overview
The Trade Journal page (`/journal`) allows you to:
- View complete trade history across all symbols and order types
- Filter trades by status, side, symbol, and date range
- Analyze trade statistics and performance metrics
- Export trade data to CSV for external analysis
- Track fees, volumes, and win rates
## Accessing the Trade Journal
1. Navigate to the **Trade Journal** page from the main navigation menu
2. The journal displays all trades for the selected trading mode (Paper or Live)
## Trade Statistics
The Trade Journal displays key statistics at the top of the page:
- **Total Trades**: Number of all trades matching current filters
- **Filled Trades**: Number of successfully executed trades
- **Total Volume**: Sum of all trade quantities
- **Total Fees**: Cumulative fees paid across all trades
## Filtering Trades
Use the filter panel to narrow down your trade history:
### Status Filter
- All
- Filled
- Open
- Pending
- Cancelled
- Rejected
### Side Filter
- All
- Buy
- Sell
### Symbol Filter
- Enter symbol name to search (e.g., "BTC/USD")
- Partial matching supported
### Date Range Filter
- **Start Date**: Filter trades from this date onwards
- **End Date**: Filter trades up to this date
- Both fields optional; leave empty to show all dates
### Trading Mode Toggle
- Switch between Paper Trading and Live Trading data
## Trade Table
The trade table displays detailed information for each trade:
- **ID**: Unique order identifier
- **Symbol**: Trading pair (e.g., BTC/USD)
- **Side**: Buy or Sell (color-coded chips)
- **Type**: Order type (Market, Limit, Stop Loss, Trailing Stop, etc.)
- **Quantity**: Order size
- **Price**: Limit price (or "Market" for market orders)
- **Status**: Current order status (color-coded chips)
- **Filled**: Quantity that has been executed
- **Fee**: Trading fee for this order
- **Created At**: Timestamp when order was placed
## Exporting Data
To export trade data:
1. Apply desired filters to narrow down trades
2. Click the **Export CSV** button
3. A CSV file will download with all filtered trades
4. File name includes date: `trade_journal_YYYY-MM-DD.csv`
The CSV includes all columns from the trade table for easy analysis in Excel, Google Sheets, or other tools.
## Use Cases
### Performance Analysis
- Filter by filled trades to analyze executed strategy performance
- Use date range to analyze performance over specific periods
- Compare buy vs sell trade performance
### Fee Tracking
- View total fees to understand trading costs
- Filter by symbol to see fees per trading pair
- Export to calculate tax implications
### Strategy Review
- Filter by order type to analyze strategy effectiveness
- Review cancelled/rejected orders to identify issues
- Track order types used in different market conditions
### Reporting
- Export data for tax reporting
- Create custom reports in spreadsheet software
- Track compliance with trading limits
## Tips
- Use multiple filters together for precise analysis
- Export data regularly for backup and external analysis
- Review rejected/cancelled orders to identify systematic issues
- Compare paper and live trading statistics separately

View File

@@ -75,6 +75,10 @@ The Autopilot feature provides autonomous trading signal generation with two dis
- ✅ Optimizes strategy selection
- ✅ Market condition analysis
- ✅ Performance tracking and learning
-**Online Learning**: Continuously improves from live trading data
-**Confidence Calibration**: Accurate confidence scores using Platt scaling/isotonic regression
-**Model Explainability**: SHAP values for understanding model decisions
-**Advanced Regime Detection**: HMM/GMM-based market regime classification
**Tradeoffs**:
- ❌ Requires training data (needs historical trades)