A comprehensive open-source project for mastering financial time series analysis, algorithmic trading strategies, and production-level automated trading systems using Python. This project combines theoretical knowledge with practical implementation, featuring a live production trading system that is currently operating with real capital.
Mastering Financial Time Series Analysis with Python
π Enroll in the Course
- All Sections: Course materials are fully uploaded and available
- Section 3: Live production system with real-time trading records
Currently in Live Production
This project includes a production trading system that is actively trading with real capital. Daily trading records are automatically uploaded to:
π Trading History Dashboard
The system uses broker API integration for automated trading, and all trades are transparently displayed on the website.
Status: β Course Available
Comprehensive coverage of time series fundamentals and advanced techniques:
-
Chapter 1: Fundamentals of Time Series Data Analysis
- Stationarity and non-stationarity
- Differencing and transformation
- Seasonal decomposition
-
Chapter 2: Advanced Time Series Analysis
- ADF (Augmented Dickey-Fuller) test
- AR (Autoregressive) models
- PACF (Partial Autocorrelation Function) analysis
- Random walk theory
-
Chapter 3: Univariate Time Series Analysis
- AR, MA, ARMA models
- AIC vs BIC model selection
- Auto-ARIMA
- Ljung-Box test for residual analysis
-
Chapter 4: Advanced Volatility Modeling and Forecasting
- ARCH models
- GARCH models
- ARIMA-GARCH hybrid models
- Backtesting strategies
-
Chapter 5: Multivariate Time Series Analysis
- VAR (Vector Autoregression) models
- VARMA models
- Granger causality analysis
-
Chapter 6: Advanced Multivariate Time Series Analysis
- VECM (Vector Error Correction Model)
- Johansen cointegration test
- VAR IRF (Impulse Response Function)
- VAR FEVD (Forecast Error Variance Decomposition)
- VECM-APARCH hybrid models
Status: β Course Available
Practical implementation of trading strategies:
-
Chapter 1: Dynamic Time Series Simulations
- VECM-EGARCH hybrid model
- Dynamic re-optimization
- Long/short position management
-
Chapter 2: Applying Strategies to Bitcoin Trading
- Bitcoin-specific optimizations
- Commission fee considerations
- Volatility-based re-optimization
-
Chapter 3: AI Trading Using Binance
- Binance API integration
- Real-time signal generation
- Automated order execution
Status: β Course Available π Live Production System
A production-level trading system currently operating with real capital:
-
Chapter 1: VECM-EGARCH Hybrid Model
- Vector Error Correction Model for cointegration relationships
- Exponential GARCH for volatility modeling
- Dynamic position sizing based on model confidence
- Key Features:
- β Information leakage prevention (walking forward validation)
- β Dynamic re-optimization based on ECT alpha
- β Confidence-based position sizing (0.2~0.8 fraction range)
- β Separate forecast horizons for buy (4 days) and sell (7 days)
-
Chapter 2: Reinforcement Learning (RL) Strategy
- VECM-GARCH Hybrid combined with RL Agent
- Market Regime Detection (Bull, Bear, Sideways, High Vol)
- Simple Policy RL agent for dynamic position blending
- Adaptive confidence thresholds
-
Mathematical Models:
VECM Model:
ΞY_t = Ξ±Ξ²'Y_{t-1} + ΞβΞY_{t-1} + ... + Ξ_{p-1}ΞY_{t-p+1} + Ξ΅_t- Ξ±: adjustment coefficients (speed of adjustment to equilibrium)
- Ξ²: cointegration vectors (long-run relationships)
- Ξα΅’: short-run dynamics coefficients
EGARCH Model:
log(ΟΒ²_t) = Ο + Ξ£α΅’ββα΅ (Ξ±α΅’|z_{t-i}| + Ξ³α΅’z_{t-i}) + Ξ£β±Όββα΅ Ξ²β±Όlog(ΟΒ²_{t-j})- Captures asymmetric volatility effects
- Ensures positive variance through log transformation
Hybrid Forecast:
ΕΆ_{t+1} = VECM_forecast + EGARCH_mean_adjustment -
Trading Strategy:
- Long Entry:
hybrid_yhat_buy > actual_price AND lower_price < lower_bound_mean - Long Exit:
upper_price > upper_bound_mean - Dynamic Re-optimization: When ECT alpha changes from negative to positive
- Long Entry:
Status: β Course Available
Modern statistical and ML techniques for challenging temporal structures:
- Chapter 1: State-Space Models β time-varying beta tracking and error-correction diagnostics
- Chapter 2: Kalman Filter suite (Custom, FilterPy, PyKalman EM, Particle) β dynamic beta tracking with quantile-based switching
- Chapter 3: Prophet Model β seasonality-aware forecasting with rolling re-training
- Chapter 4: Deep Learning (LSTM) β direction classification with imbalance-aware training
- Chapter 5: Tree-Based ML (XGBoost) β binary classification for direction prediction with rich technical features and ROC-optimized thresholds
- Chapter 6: Wavelet Transform β multi-resolution feature engineering for volatility regimes
- Chapter 7: Copula Models β dependence modeling and tail-risk simulation
Status: β Course Available
Theoretical foundations and practical applications of factor-based asset pricing models:
-
Chapter 1: CAPM Limitations and Fama-French Model Origins
- Empirical testing of CAPM
- Identifying market anomalies (Size, Value)
- Visualizing model limitations
-
Chapter 2: Fama-French 3-Factor Model
- Implementing the 3-factor model
- Calculating factor exposures (Betas)
- Comparing multi-factor models vs CAPM
-
Chapter 3: Fama-French 5-Factor and Extended Models
- Profitability (RMW) and Investment (CMA) factors
- Momentum factor integration (6-Factor model)
- Model selection and comparison
-
Chapter 4: Practical Application and Backtesting
- Factor-based portfolio construction
- Walk-forward validation
- Transaction cost analysis
- Performance evaluation (Sharpe, Alpha, etc.)
Status: β Available
A comprehensive guide to all financial mathematics theory used in quant trading, implemented with easy-to-understand example code:
-
Chapter 1: Linear Algebra
- Portfolio optimization
- PCA-based factor analysis
- Multi-factor regression (Fama-French)
- Matrix operations in VAR & VECM models
-
Chapter 2: Analysis & Calculus
- Gradient descent visualization
- Understanding backpropagation algorithm
- Calculus principles in GARCH models
- Wavelet Transform
- Ito's Lemma
- Bayesian Optimization
-
Chapter 3: Probability & Time Series Statistics
- Stationarity testing and understanding
- Probabilistic foundations of ARIMA models
- Cointegration and pair trading
- Dependence analysis using Copula
- Monte Carlo simulation
-
Chapter 4: Bayesian Statistics & Filtering
- Bayesian inference examples
- Understanding Kalman Filter
- State-space models
- Clone the repository:
git clone https://github.com/leesh2015/financial-timeseries-python.git
cd financial-timeseries-python- Install dependencies:
pip install -r requirements.txtSection 1 - Time Series Analysis:
cd "Section1.Financial Time Series Analysis/Chapter1.Fundamentals of Time Series Data Analysis"
python stable_data.pySection 2 - Strategy Design:
cd "Section2.Advanced Investment Strategy Design/Chapter1.Dynamic Time Series Simulations"
python dynamic_simulation.pySection 3 - Production Simulation:
# Chapter 1: VECM-EGARCH Hybrid
cd "Section3.Production Investment Strategy/Chapter1.VECM-EGARCH Hybrid"
python production_simulation_.py
# Chapter 2: Reinforcement Learning
cd "Section3.Production Investment Strategy/Chapter2.Reinforcement Learning"
python dynamic_simulation_rl.pySection 4 - Advanced Time Series Models:
cd "Section4.Advanced Time Series Models/Chapter1.State-Space Models"
python state_space_model.pySection 5 - Factor Models:
cd "Section5.Factor-Based Asset Pricing Models/Chapter4.Practical Application and Backtesting"
python factor_portfolio_backtest.pyAppendix - Financial Mathematics:
# Install dependencies from project root (skip if already installed)
pip install -r requirements.txt
cd Appendix
# Chapter 1: Linear Algebra
python Chapter1_Linear_Algebra/portfolio_optimization.py
# Chapter 2: Calculus
python Chapter2_Calculus/gradient_descent_demo.py
# Chapter 3: Probability & Statistics
python Chapter3_Probability_Statistics/stationarity_analysis.py
# Chapter 4: Bayesian
python Chapter4_Bayesian_Filtering/kalman_filter_demo.pyResults will be saved in the results/ folder within each section.
Core dependencies (see requirements.txt for full list):
- Data Science:
numpy,pandas,scipy - Time Series:
statsmodels,arch,pmdarima - Data Collection:
yfinance - Visualization:
matplotlib,seaborn - Machine Learning:
scikit-learn - Cryptocurrency:
ccxt(for Binance integration) - Excel Support:
openpyxl
- Uses data up to time t-1 to predict price at time t
- Models are re-trained at each step using only historical data (walking forward)
- No future data is used in any prediction or optimization step
- Automatic re-optimization when market conditions change
- ECT alpha monitoring for cointegration relationship health
- Volatility-based model adjustments
- Dynamic position sizing based on VECM model confidence
- Fraction range: 0.2 (low confidence) to 0.8 (high confidence)
- Adaptive threshold calculation using rolling window
- Real-time broker API integration
- Automated trade execution
- Daily performance tracking and reporting
- Transparent trade history on web dashboard
The production system tracks comprehensive performance metrics:
- Total P&L
- Win Rate
- Sharpe Ratio
- Maximum Drawdown
- Annualized Returns
- Buy-and-Hold Comparison
View live metrics at: Trading History Dashboard
This project implements state-of-the-art financial econometrics techniques:
- Cointegration Analysis: Identifying long-run equilibrium relationships
- Error Correction Models: Capturing short-term deviations from equilibrium
- GARCH Family Models: Modeling volatility clustering and asymmetry
- Hybrid Forecasting: Combining multiple models for improved accuracy
- Dynamic Optimization: Adapting to changing market regimes
| Course Section | Repository Section | Status |
|---|---|---|
| Section 1: Time Series Fundamentals | Section1.Financial Time Series Analysis/ |
β Available |
| Section 2: Strategy Design | Section2.Advanced Investment Strategy Design/ |
β Available |
| Section 3: Production System | Section3.Production Investment Strategy/ |
β Available π |
| Section 4: Advanced Time Series Models | Section4.Advanced Time Series Models/ |
β Available |
| Section 5: Factor Models | Section5.Factor-Based Asset Pricing Models/ |
β Available |
| Appendix: Financial Mathematics | Appendix/ |
β Available |
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Join the Discussion: Have questions, ideas, or want to share your results? Join our GitHub Discussions to connect with the community!
This project is licensed under the MIT License - see the LICENSE file for details.
Important: This project is for educational and research purposes. The production trading system is provided as a demonstration of the concepts taught in the course.
- Past performance does not guarantee future results
- Trading involves risk of financial loss
- Always conduct thorough backtesting before deploying any trading strategy
- The authors are not responsible for any financial losses incurred from using this code
- Udemy Course: Mastering Financial Time Series Analysis with Python
- Trading Dashboard: leenaissance.com/trading-history
- GitHub Discussions: Join the Community
For questions, suggestions, or collaboration opportunities, please open an issue on GitHub or contact through the Udemy course platform.
Made with β€οΈ for the algorithmic trading community
This project demonstrates the complete journey from theoretical time series analysis to production-level automated trading systems.