This research aims to fetch stock data for specific tickers and perform various analyses including normalization, calculation of Value-at-Risk (VaR), Conditional Value-at-Risk (CVaR), and Topological Data Analysis (TDA) using persistent homology. The program also plots the stock data and persistence diagrams for better visualization.
- yfinance
- numpy
- matplotlib
- gudhi
- scipy
You can install these dependencies using pip:
pip install yfinance numpy matplotlib gudhi scipy
Fetches the stock data for a given ticker
and period
.
Normalizes the time-series data between 0 and 1.
Calculates the daily returns of a stock based on its time series.
Calculates VaR and CVaR based on the given returns and confidence level.
Computes persistent homology for the time series.
Plots the persistence diagrams.
Cleans the array by removing NaN and infinite values.
- Clone this repository.
- Run
pip install -r requirements.txt
to install dependencies. - Execute the script using
python <script_name>.py
.
- Prints VaR and CVaR values for each stock at a 95% confidence interval.
- Plots the persistence diagrams for each stock.
- Computes and prints the Euclidean distance between the baseline and stress scenarios for each stock.
This project is open-source and available under the MIT License.