A complete toolkit for quantitative market analysis, featuring an end-to-end Python research lab and a multi-mode, real-time statistical dashboard for TradingView. This project provides a workflow to both empirically test market theories and apply those insights in a live trading environment.
This tool was built to explore a fundamental question in financial statistics: Is there a discernible bias in the daily direction of efficient markets?
The underlying thesis, inspired by Burton Malkiel's "A Random Walk Down Wall Street," is that in an efficient market, the probability of an asset closing UP on any given day is roughly equal to the probability of it closing DOWN. This suggests a near 50/50 equilibrium in the frequency of directional days over the long term.
A key insight revealed by this tool is the crucial difference between the frequency of directional days and the magnitude of price moves. A market can experience a catastrophic crash driven by a few days of massive-magnitude losses, yet the subsequent recovery can consist of a greater number of smaller-magnitude UP days.
This project has now evolved to not only prove these principles but also to provide a live tool for monitoring them in real-time, turning academic findings into a practical analytical edge.
This repository contains two main components, each designed for a specific purpose:
A complete end-to-end data science pipeline for acquiring, cleaning, and analyzing financial data to empirically test market hypotheses. This is the academic foundation of our work.
- Ideal for researchers, data scientists, and developers.
- (Details about the Python workflow are below)
A multi-mode, real-time statistical dashboard that applies our research findings directly on your charts. It's designed for practical, day-to-day analysis by traders.
- Ideal for traders and technical analysts.
- ➡️ Click here to view the Live Indicator README, Code, and Showcase
The repository includes pre-generated results from several key analyses in the /case_study_results/ directory. These serve as a quick-start showcase of the platform's capabilities and the core findings of this research.
-
Baseline Equilibrium (Gold, 2000-2025): A 25-year analysis of Gold shows a remarkable balance, with 51.3% UP days vs. 47.9% DOWN days.
-
Resilience Under Stress (Crisis Periods):
- 2016 Brexit Referendum (GBP/USD): Exhibited a near-perfect balance: 46.4% UP days vs. 53.3% DOWN days.
- 2020 COVID-19 Pandemic (WTI Oil): Despite a historic crash, the full 2020-2021 period had more UP days (54.1%) than DOWN days.
-
The Exception That Proves the Rule (USD/JPY, 2024):
- Analysis of a market with a strong fundamental driver shows a clear directional bias (58% UP days), proving that equilibrium can be overcome by powerful trends.
You can interact with this project in two distinct ways:
Follow this path if you want to run the full data science pipeline, replicate our findings, or conduct your own research.
1_data_acquisition.py: The ingestion engine to fetch market data.2_data_cleaning.py: The quality assurance gate to clean and process data.3_run_analysis_cli.py: The batch processing engine to run analyses via the command line.4_launch_analysis_gui.py: The interactive laboratory (Streamlit GUI) for visual exploration.
For immediate analysis without any local setup, please use our live TradingView indicator.
-
Clone the repository:
git clone [https://github.com/](https://github.com/)[YourUsername]/QuantMarket-Lab.git cd QuantMarket-Lab -
Install dependencies:
pip install -r requirements.txt
-
Configure API Key:
- Open
configs/master_config.yml. - Replace
"YOUR_API_KEY_HERE"with your personal Alpha Vantage API key.
- Open
Execute the scripts from the project's root directory in their numerical order.
- Fetch latest data:
python 1_data_acquisition.py
- Clean the data:
python 2_data_cleaning.py
- Run analysis via CLI (example):
python 3_run_analysis_cli.py --asset GOLD --start_date 2020-01-01
- Launch the interactive GUI:
streamlit run 4_launch_analysis_gui.py
This project was developed using an AI-Assisted Development approach, with the Gemini Pro model serving as a powerful tool for code generation and workflow structuring. My role was that of a research director and system architect, guiding the AI to build a cohesive, end-to-end quantitative analysis platform.
My contributions were focused on the following high-level tasks:
- Hypothesis and Requirements Definition: Formulating a clear research hypothesis inspired by the "Random Walk" theory to test for directional bias in financial markets. I designed the requirements for both an integrated Python research lab and a real-time TradingView dashboard to empirically verify and practically apply the findings.
- Architectural Design: Structuring the project with a dual-component architecture: 1) A Python Research Engine built on a sequential data pipeline, and 2) A Live TradingView Dashboard that acts as the applied, real-time interface for the research results.
- Prompt Engineering: Crafting precise prompts to direct the AI in building each stage of the Python data science pipeline—from API data acquisition and cleaning to developing an interactive Streamlit GUI for visualizing the statistical results.
- Review, Testing, and Validation: Verifying the integrity of the acquired data, testing each stage of the pipeline independently, and conducting multiple case studies across different assets and time periods to ensure the system's findings were accurate and replicable.
- Full Documentation: Writing comprehensive documentation that not only explains how to use the tools but also details the research philosophy, the underlying financial theory, and the key findings, using the case studies to support the project's conclusions.
This project demonstrates how modern AI tools can be orchestrated to execute a complete research workflow, from academic theory and data analysis to practical, real-time application.