Volatility Scanner is a comprehensive Python-based tool designed to analyze historical market data, calculate volatility metrics, and simulate future price movements. It features a modular backend (engine and simulator) and a web-based frontend for interactive analysis.
main.py: The web application entry point (likely Flask or similar). It routes user requests to the backend logic and renders thetemplates.engine.py: The core computational unit. This module is responsible for:- Fetching historical price data (OHLC).
- Computing logarithmic returns.
- Calculating rolling statistical volatility.
simulator.py: A quantitative module that uses the data fromengine.pyto project future scenarios, likely employing Monte Carlo simulations or random walk models.templates/: HTML interfaces for the dashboard and data visualization.
This project relies on fundamental financial mathematics to assess risk. Below is the breakdown of the quantitative methods used in the Volatility Engine.
Instead of simple percentage changes, the scanner likely uses Log Returns for time-additive properties, which are essential for accurate volatility modeling over time.
- Where
$P_t$ is the price at time$t$ and$P_{t-1}$ is the price at time$t-1$ .
The core metric of the scanner is the standard deviation (
-
$N$ : Number of observations (e.g., trading days). -
$\bar{r}$ : The average return over the period.
To make the daily volatility comparable to annual metrics (like interest rates or implied volatility), the engine applies an annualization factor. Since there are typically 252 trading days in a year, the formula is:
The simulator.py likely projects future price paths using the Geometric Brownian Motion (GBM) model, which assumes prices drift by expected return (
-
$\mu$ : Expected drift (average return). -
$\sigma$ : Historical volatility calculated by the engine. -
$dW_t$ : A stochastic process (Wiener process) representing random market noise.
-
Clone the repository
git clone [https://github.com/allenwang0/volatilityscanner.git](https://github.com/allenwang0/volatilityscanner.git) cd volatilityscanner -
Install Dependencies Ensure you have
pandas,numpy, and web framework dependencies installed.pip install -r requirements.txt
-
Run the Application
python main.py
Access the scanner at
http://localhost:5000(default port).
- Input Ticker: Enter a stock symbol (e.g.,
SPY,AAPL) in the web interface. - Select Window: Choose the lookback period for volatility calculation (e.g., 30-day, 90-day).
- Run Simulation: Trigger
simulator.pyto generate potential future price paths based on current volatility regimes.