fixed sac issues
This commit is contained in:
Binary file not shown.
@@ -97,7 +97,7 @@ SAC_REWARD_SCALE = 1.0 # Decreased from 10.0 -> 2.0 -> 1.0
|
||||
SAC_USE_BATCH_NORM = True
|
||||
SAC_USE_RESIDUAL = True
|
||||
SAC_MODEL_DIR = 'models/simplified_sac' # Default dir within the agent class
|
||||
SAC_EPOCHS = 50 # Keep this from previous config for training loop control
|
||||
SAC_EPOCHS = 5 # Keep this from previous config for training loop control
|
||||
|
||||
# V7.9 Experience Generation Config (Based on instructions.txt)
|
||||
# TOTAL_TRAINING_STEPS = 1000 # Removed - Not used in current training loop
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+41
@@ -0,0 +1,41 @@
|
||||
# GRU+SAC Backtesting Performance Report
|
||||
|
||||
Report generated on: 2025-04-16 18:25:01.350032
|
||||
Data range: N/A
|
||||
Total duration: N/A
|
||||
|
||||
## Strategy Performance Metrics
|
||||
|
||||
* **Initial capital:** $0.00
|
||||
* **Final portfolio value:** $0.00
|
||||
* **Total return:** 0.00%
|
||||
* **Annualized return:** 0.00%
|
||||
* **Sharpe ratio (annualized):** 0.0000
|
||||
* **Sortino ratio (annualized):** 0.0000
|
||||
* **Volatility (annualized):** 0.00%
|
||||
* **Maximum drawdown:** 0.00%
|
||||
* **Total trades:** 0
|
||||
|
||||
## Buy and Hold Benchmark
|
||||
|
||||
* *Buy and Hold benchmark could not be calculated.*
|
||||
|
||||
## Position & Prediction Analysis
|
||||
|
||||
* **Average absolute position size:** 0.0000
|
||||
* **Position sign accuracy vs return:** 0.00%
|
||||
* **Prediction sign accuracy vs return:** 0.00%
|
||||
* **Prediction RMSE (on returns):** 0.000000
|
||||
|
||||
## Correlations
|
||||
|
||||
* **Prediction-Return correlation:** 0.0000
|
||||
* **Prediction-Position correlation:** 0.0000
|
||||
* **Uncertainty-Position Size correlation:** 0.0000
|
||||
|
||||
## Notes
|
||||
|
||||
* Transaction cost used: 0.0500% per position change value.
|
||||
* GRU lookback period: 60 minutes.
|
||||
* V6 features + return features used.
|
||||
* Uncertainty estimated via MC Dropout standard deviation.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 187 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
+41
@@ -0,0 +1,41 @@
|
||||
# GRU+SAC Backtesting Performance Report
|
||||
|
||||
Report generated on: 2025-04-16 18:31:42.150811
|
||||
Data range: N/A
|
||||
Total duration: N/A
|
||||
|
||||
## Strategy Performance Metrics
|
||||
|
||||
* **Initial capital:** $0.00
|
||||
* **Final portfolio value:** $0.00
|
||||
* **Total return:** 0.00%
|
||||
* **Annualized return:** 0.00%
|
||||
* **Sharpe ratio (annualized):** 0.0000
|
||||
* **Sortino ratio (annualized):** 0.0000
|
||||
* **Volatility (annualized):** 0.00%
|
||||
* **Maximum drawdown:** 0.00%
|
||||
* **Total trades:** 0
|
||||
|
||||
## Buy and Hold Benchmark
|
||||
|
||||
* *Buy and Hold benchmark could not be calculated.*
|
||||
|
||||
## Position & Prediction Analysis
|
||||
|
||||
* **Average absolute position size:** 0.0000
|
||||
* **Position sign accuracy vs return:** 0.00%
|
||||
* **Prediction sign accuracy vs return:** 0.00%
|
||||
* **Prediction RMSE (on returns):** 0.000000
|
||||
|
||||
## Correlations
|
||||
|
||||
* **Prediction-Return correlation:** 0.0000
|
||||
* **Prediction-Position correlation:** 0.0000
|
||||
* **Uncertainty-Position Size correlation:** 0.0000
|
||||
|
||||
## Notes
|
||||
|
||||
* Transaction cost used: 0.0500% per position change value.
|
||||
* GRU lookback period: 60 minutes.
|
||||
* V6 features + return features used.
|
||||
* Uncertainty estimated via MC Dropout standard deviation.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 186 KiB |
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"run_id": "20250416_183051",
|
||||
"db_dir": "../downloaded_data",
|
||||
"ticker": "BTC-USD",
|
||||
"exchange": "COINBASE",
|
||||
"start_date": "2025-03-01",
|
||||
"end_date": "2025-03-10",
|
||||
"interval": "1min",
|
||||
"model_save_path": "gru_sac_predictor/models/run_20250416_183051",
|
||||
"results_plot_path": "gru_sac_predictor/results/20250416_183051/backtest_results_20250416_183051.png",
|
||||
"report_save_path": "gru_sac_predictor/results/20250416_183051/backtest_performance_report_20250416_183051.md",
|
||||
"train_ratio": 0.6,
|
||||
"validation_ratio": 0.2,
|
||||
"gru_lookback": 60,
|
||||
"gru_prediction_horizon": 1,
|
||||
"gru_epochs": 20,
|
||||
"gru_batch_size": 32,
|
||||
"gru_patience": 10,
|
||||
"gru_lr_factor": 0.5,
|
||||
"gru_return_scale": 0.03,
|
||||
"gru_model_load_run_id": "20250416_142744",
|
||||
"sac_state_dim": 5,
|
||||
"sac_hidden_size": 64,
|
||||
"sac_gamma": 0.97,
|
||||
"sac_tau": 0.02,
|
||||
"sac_actor_lr": 1.5e-05,
|
||||
"sac_critic_lr": 2.5e-05,
|
||||
"sac_batch_size": 64,
|
||||
"sac_buffer_max_size": 20000,
|
||||
"sac_min_buffer_size": 1000,
|
||||
"sac_update_interval": 1,
|
||||
"sac_target_update_interval": 2,
|
||||
"sac_gradient_clip": 1.0,
|
||||
"sac_reward_scale": 1.0,
|
||||
"sac_use_batch_norm": true,
|
||||
"sac_use_residual": true,
|
||||
"sac_model_dir": "models/simplified_sac",
|
||||
"sac_epochs": 5,
|
||||
"experience_config": {
|
||||
"initial_experiences": 3000,
|
||||
"experiences_per_batch": 64,
|
||||
"batch_generation_interval": 500,
|
||||
"balance_market_regimes": false,
|
||||
"recency_bias_strength": 0.5,
|
||||
"high_uncertainty_quantile": 0.75,
|
||||
"extreme_return_quantile": 0.1,
|
||||
"min_uncertainty_ratio": 0.2,
|
||||
"min_extreme_return_ratio": 0.1,
|
||||
"use_parallel_generation": false,
|
||||
"precompute_all_gru_outputs": true,
|
||||
"buffer_update_strategy": "fifo",
|
||||
"training_iterations_per_step": 1
|
||||
},
|
||||
"initial_capital": 10000.0,
|
||||
"transaction_cost": 0.0005,
|
||||
"opportunity_cost_penalty_factor": 0.0,
|
||||
"high_return_threshold": 0.002,
|
||||
"action_tolerance": 0.3,
|
||||
"load_existing_system": true,
|
||||
"train_gru_model": false,
|
||||
"train_sac_agent": true,
|
||||
"load_sac_agent": false,
|
||||
"run_backtest": true,
|
||||
"generate_plots": true,
|
||||
"generate_report": true
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 59 KiB |
+42
@@ -0,0 +1,42 @@
|
||||
# GRU+SAC Backtesting Performance Report
|
||||
|
||||
Report generated on: 2025-04-16 18:36:19.355066
|
||||
Data range: 2025-03-06 15:23:00+00:00 to 2025-03-07 23:57:00+00:00
|
||||
Total duration: 1 days 08:34:00
|
||||
|
||||
## Strategy Performance Metrics
|
||||
|
||||
* **Initial capital:** $10,000.00
|
||||
* **Final portfolio value:** $10,102.70
|
||||
* **Total return:** 1.03%
|
||||
* **Annualized return:** 1484.12%
|
||||
* **Sharpe ratio (annualized):** 3.2039
|
||||
* **Sortino ratio (annualized):** 4.8489
|
||||
* **Volatility (annualized):** 102.65%
|
||||
* **Maximum drawdown:** 7.56%
|
||||
* **Total trades:** 1489
|
||||
|
||||
## Buy and Hold Benchmark
|
||||
|
||||
* **Final value (B&H):** $9,658.75
|
||||
* **Total return (B&H):** -3.41%
|
||||
|
||||
## Position & Prediction Analysis
|
||||
|
||||
* **Average absolute position size:** 0.9056
|
||||
* **Position sign accuracy vs return:** 50.93%
|
||||
* **Prediction sign accuracy vs return:** 48.92%
|
||||
* **Prediction RMSE (on returns):** 0.004036
|
||||
|
||||
## Correlations
|
||||
|
||||
* **Prediction-Return correlation:** -0.0042
|
||||
* **Prediction-Position correlation:** 0.1459
|
||||
* **Uncertainty-Position Size correlation:** 0.8410
|
||||
|
||||
## Notes
|
||||
|
||||
* Transaction cost used: 0.0500% per position change value.
|
||||
* GRU lookback period: 60 minutes.
|
||||
* V6 features + return features used.
|
||||
* Uncertainty estimated via MC Dropout standard deviation.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 384 KiB |
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"run_id": "20250416_183508",
|
||||
"db_dir": "../downloaded_data",
|
||||
"ticker": "BTC-USD",
|
||||
"exchange": "COINBASE",
|
||||
"start_date": "2025-03-01",
|
||||
"end_date": "2025-03-10",
|
||||
"interval": "1min",
|
||||
"model_save_path": "gru_sac_predictor/models/run_20250416_183508",
|
||||
"results_plot_path": "gru_sac_predictor/results/20250416_183508/backtest_results_20250416_183508.png",
|
||||
"report_save_path": "gru_sac_predictor/results/20250416_183508/backtest_performance_report_20250416_183508.md",
|
||||
"train_ratio": 0.6,
|
||||
"validation_ratio": 0.2,
|
||||
"gru_lookback": 60,
|
||||
"gru_prediction_horizon": 1,
|
||||
"gru_epochs": 20,
|
||||
"gru_batch_size": 32,
|
||||
"gru_patience": 10,
|
||||
"gru_lr_factor": 0.5,
|
||||
"gru_return_scale": 0.03,
|
||||
"gru_model_load_run_id": "20250416_142744",
|
||||
"sac_state_dim": 5,
|
||||
"sac_hidden_size": 64,
|
||||
"sac_gamma": 0.97,
|
||||
"sac_tau": 0.02,
|
||||
"sac_actor_lr": 1.5e-05,
|
||||
"sac_critic_lr": 2.5e-05,
|
||||
"sac_batch_size": 64,
|
||||
"sac_buffer_max_size": 20000,
|
||||
"sac_min_buffer_size": 1000,
|
||||
"sac_update_interval": 1,
|
||||
"sac_target_update_interval": 2,
|
||||
"sac_gradient_clip": 1.0,
|
||||
"sac_reward_scale": 1.0,
|
||||
"sac_use_batch_norm": true,
|
||||
"sac_use_residual": true,
|
||||
"sac_model_dir": "models/simplified_sac",
|
||||
"sac_epochs": 5,
|
||||
"experience_config": {
|
||||
"initial_experiences": 3000,
|
||||
"experiences_per_batch": 64,
|
||||
"batch_generation_interval": 500,
|
||||
"balance_market_regimes": false,
|
||||
"recency_bias_strength": 0.5,
|
||||
"high_uncertainty_quantile": 0.75,
|
||||
"extreme_return_quantile": 0.1,
|
||||
"min_uncertainty_ratio": 0.2,
|
||||
"min_extreme_return_ratio": 0.1,
|
||||
"use_parallel_generation": false,
|
||||
"precompute_all_gru_outputs": true,
|
||||
"buffer_update_strategy": "fifo",
|
||||
"training_iterations_per_step": 1
|
||||
},
|
||||
"initial_capital": 10000.0,
|
||||
"transaction_cost": 0.0005,
|
||||
"opportunity_cost_penalty_factor": 0.0,
|
||||
"high_return_threshold": 0.002,
|
||||
"action_tolerance": 0.3,
|
||||
"load_existing_system": true,
|
||||
"train_gru_model": false,
|
||||
"train_sac_agent": true,
|
||||
"load_sac_agent": false,
|
||||
"run_backtest": true,
|
||||
"generate_plots": true,
|
||||
"generate_report": true
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
Binary file not shown.
@@ -375,7 +375,7 @@ class TradingSystem:
|
||||
if self.gru_model and self.gru_model.is_loaded:
|
||||
self.feature_scaler = self.gru_model.feature_scaler
|
||||
self.y_scaler = self.gru_model.y_scaler
|
||||
self._logger.info("Scalers initialized from pre-loaded GRU model.")
|
||||
_logger.info("Scalers initialized from pre-loaded GRU model.")
|
||||
# V7.23: Attempt to set indices if scaler loaded
|
||||
self._set_feature_indices()
|
||||
|
||||
@@ -1262,6 +1262,13 @@ class ExtendedBacktester:
|
||||
feature_logger.error(f"Error during pre-computation evaluate call on test data: {e}", exc_info=True) # Use feature_logger
|
||||
return None
|
||||
|
||||
# --- Calculate num_sequences FIRST ---
|
||||
# Moved from below to be available for feature extraction
|
||||
num_sequences = len(all_pred_returns)
|
||||
if num_sequences <= 1:
|
||||
feature_logger.warning("Not enough sequences generated from test data to perform backtest.") # Use feature_logger
|
||||
return None
|
||||
|
||||
# --- V7.13 START: Extract Momentum and Volatility Features ---
|
||||
# These features should be aligned with the *sequences* used for GRU prediction
|
||||
# Use test_features_df which is aligned with the sequences' start times
|
||||
@@ -1300,11 +1307,6 @@ class ExtendedBacktester:
|
||||
return None
|
||||
# --- V7.13 END: Extract Momentum and Volatility Features ---
|
||||
|
||||
num_sequences = len(all_pred_returns)
|
||||
if num_sequences <= 1:
|
||||
feature_logger.warning("Not enough sequences generated from test data to perform backtest.") # Use feature_logger
|
||||
return None
|
||||
|
||||
feature_logger.info("--- GRU Pre-computation Complete. Starting Backtest Simulation ---") # Use feature_logger
|
||||
|
||||
# --- Refined Timestamp Handling START (from original test_data before preprocessing) ---
|
||||
|
||||
Reference in New Issue
Block a user