Jul 31, 2024, 4:58 PM
Python For Finance Cookbook.pdf
Missing file
verbo_cad_ml.csv
Missing file
data
and set the 'Date' column as a datetime index, as requested. Here's a summary of what we've done:data
.cad_ig_er_index
, we can use a common approach based on the concept of drawdowns. This method is often used in financial analysis and is discussed in the Python for Finance Cookbook. Here's an explanation of the algorithm we can use:cad_ig_er_index
.cad_ig_er_index
along with its 50-day and 200-day SMAscad_ig_er_index
, combining both trend-following (SMA crossovers) and magnitude-based (drawdown) approaches.cad_ig_er_index
?cad_ig_er_index
. This comprehensive analysis will provide you with a deep understanding of the index's performance in different market regimes. Let's go through each method one by one:cad_ig_er_index
.cad_ig_er_index
.cad_ig_er_index
over time, with vertical red dashed lines indicating detected change points.cad_ig_er_index
at different levels.cad_ig_er_index
. The HMM and GMM provide direct classifications of market states, while change point detection identifies significant shifts that could indicate regime changes. The Random Forest and LSTM models offer predictive capabilities based on various features and historical patterns, respectively. Finally, the wavelet transform analysis allows for a multi-scale examination of the index's behavior.cad_ig_er_index
performed in different market regimes, the factors that influence these regimes, and how they can be identified and potentially predicted.cad_ig_er_index
. The plot showing these regimes over time was generated.cad_ig_er_index
. The plot showing these regimes was generated.Random Forest Classification Report:
precision recall f1-score support
Bear 0.55 0.55 0.55 447
Bull 0.55 0.55 0.55 453
accuracy 0.55 900
macro avg 0.55 0.55 0.55 900
weighted avg 0.55 0.55 0.55 900
LSTM Classification Report:
precision recall f1-score support
Bear 0.52 0.51 0.51 447
Bull 0.52 0.53 0.52 452
accuracy 0.52 899
macro avg 0.52 0.52 0.52 899
weighted avg 0.52 0.52 0.52 899
cad_ig_er_index
at different levels was plotted, potentially revealing patterns at various time scales.HMM Market Statistics:
Bull Market Statistics:
Average Return: 0.0004
Standard Deviation: 0.0045
Sharpe Ratio: 0.0873
Percentage of Time in Bull Market: 50.06%
Bear Market Statistics:
Average Return: -0.0004
Standard Deviation: 0.0045
Sharpe Ratio: -0.0873
Percentage of Time in Bear Market: 49.94%
GMM Market Statistics:
Bear Market Statistics:
Average Return: -0.0004
Standard Deviation: 0.0045
Sharpe Ratio: -0.0873
Percentage of Time in Bear Market: 49.94%
Bull Market Statistics:
Average Return: 0.0004
Standard Deviation: 0.0045
Sharpe Ratio: 0.0873
Percentage of Time in Bull Market: 50.06%
cad_ig_er_index
in different market regimes, as identified by various sophisticated algorithms. The HMM and GMM models show very similar results, with almost equal time spent in bull and bear markets, and symmetric returns and risk characteristics.cad_ig_er_index
.cad_ig_er_index
.cad_ig_er_index
at different levels was plotted, potentially revealing patterns at various time scales.Random Forest Classification Report:
precision recall f1-score support
Bear 0.53 0.54 0.53 41
Bull 0.56 0.55 0.55 44
accuracy 0.54 85
macro avg 0.54 0.54 0.54 85
weighted avg 0.54 0.54 0.54 85
LSTM Classification Report:
precision recall f1-score support
Bear 0.50 0.51 0.51 41
Bull 0.52 0.50 0.51 44
accuracy 0.51 85
macro avg 0.51 0.51 0.51 85
weighted avg 0.51 0.51 0.51 85
Bull Market Statistics:
Average Return: 0.0012
Standard Deviation: 0.0109
Sharpe Ratio: 0.1101
Percentage of Time in Bull Market: 50.23%
Bear Market Statistics:
Average Return: -0.0012
Standard Deviation: 0.0110
Sharpe Ratio: -0.1091
Percentage of Time in Bear Market: 49.77%
Bear Market Statistics:
Average Return: -0.0012
Standard Deviation: 0.0110
Sharpe Ratio: -0.1091
Percentage of Time in Bear Market: 49.77%
Bull Market Statistics:
Average Return: 0.0012
Standard Deviation: 0.0109
Sharpe Ratio: 0.1101
Percentage of Time in Bull Market: 50.23%