This repository offers a data-driven toolkit for analyzing candlestick patterns in stock market data. It provides robust methods for detecting patterns, visualizing them across long-term data, and statistically analysing their effectiveness.
For a detailed walkthrough of the analysis and methodology, check out our Medium articles:
- Candlestick Patterns in Trading: A Data-Driven Journey (Part 1)
- Candlestick Patterns in Trading: A Data-Driven Journey (Part 2)
- Programmatic detection of various candlestick patterns
- Interactive visualization of patterns on stock charts
- Statistical analysis of pattern returns
- Monte Carlo simulations for assessing pattern effectiveness
- Pattern effectiveness analysis
-
Clone the repository:
git clone https://github.com/CharlieNestor/statistical_analysis_candlestick_patterns.git
-
Install the required packages in a new virtual environment:
python -m venv venv source venv/bin/activate pip install -r requirements.txt
-
Run the Streamlit app:
streamlit run pattern_streamlit.py
The Streamlit app provides an interactive interface for analysing candlestick patterns. It is recommended to set the background color to white for better visibility.
- Select a stock from the dropdown or enter a custom ticker.
- Choose a candlestick pattern to analyze.
- Use the checkboxes to display:
- Stock chart with pattern occurrences
- Examples of individual pattern instances
- Click "Run Simulation" to perform statistical analysis.
- View the results, including:
- Pattern vs. Base Case Performance chart
- Significance Heatmap
patterns.py
: Contains functions for programmatically define various candlestick patternsloader.py
: Utilities for loading and preprocessing stock dataplots.py
: Functions for creating interactive visualizationsanalysis.py
: Functions for statistical analysis of pattern returnspattern_stock.py
: Defines the PatternStock class which will be used int the Streamlit apppattern_streamlit.py
: Streamlit app for interactive pattern analysisPattern_Medium_01.ipynb
: Jupyter notebook showcasing the code journey related to the first Medium publicationPattern_Medium_02.ipynb
: Jupyter notebook showcasing the code and analysis journey described in the second Medium publicationPattern_playground.ipynb
: Jupyter notebook for those who wants to directly play with the patterns and the functionalities
This repository is part of an ongoing project. Future updates will include:
- Expansion of the pattern library
- Integration of machine learning techniques for pattern recognition
- Development of a backtesting framework for trading strategies based on candlestick patterns
- Optimization of the Streamlit app for better performance and user experience
I'm committed to evolving this project into a comprehensive, easy-to-use solution for candlestick pattern analysis in stock trading.