Introduction
This repository hosts the Python package developed from the research presented in the paper "Topological Tail Dependence: Evidence from Forecasting Realized Volatility" by Hugo Gobato Souto. The package is designed to implement the methodologies and techniques described in the paper, focusing on the application of topological data analysis to understand tail dependence in financial markets.
The core of this package lies in its ability to model and forecast realized volatility in financial markets through the lens of topological data analysis. It presents a novel approach to understanding the complex relationships in financial data, especially during periods of high volatility or market stress.
Installation
> pip install fintda
You can also install the stable version with
>>> pip install https://github.com/ibaris/finance-tda/archive/main.zip
To install the in-development version, change the branch name main to the other available branch names.
Documentation
The documentation code documentation is in build/docs.
Example
Setup and Data Retrieval
Import Libraries: Import necessary libraries, including numpy, yfinance, and modules from the fintda package.
import numpy as np
import yfinance as yf
from fintda import fintda
from fintda.auxiliary import get_data_range
%matplotlib inline
Define Financial Indexes and Date Range: Select the financial indexes and the date range for analysis.
index_names = ['^GSPC', '^DJI', '^RUT'] # S&P 500, Dow Jones, Russell 2000
start_date_string = "2000-01-01"
end_date_string = "2022-03-30"
Retrieve Data from Yahoo Finance: Use yfinance to download historical data for the specified indexes and date range.
raw_data = yf.download(index_names, start=start_date_string, end=end_date_string)
[*********************100%%**********************] 3 of 3 completed
Data Preprocessing: Focus on adjusted closing prices and compute logarithmic returns.
df_close = raw_data['Adj Close'].dropna(axis='rows')
returns = np.log(df_close.pct_change() + 1)
returns.dropna(inplace=True)
Financial Time Series Analysis with fintda
Initialize fintda: Create an instance of fintda with the processed returns and predefined weights.
weights = np.array([0.5, 0.3, 0.2]) # Define portfolio weights
ftda = fintda(returns, weights, log_returns=False)
Rips(maxdim=2, thresh=inf, coeff=2, do_cocycles=False, n_perm = None, verbose=True)
Compute Moving Persistence Diagrams: Use the compute_moving_dgm method to calculate persistence diagrams. This method is essential for analyzing the topological features of the financial time series data.
distance = ftda.compute_moving_dgm(plot=True)
Computing Moving Diagrams: 100%|██████████| 5556/5556 [00:09<00:00, 580.01it/s]
Reference
The development of this package is based on the research published in the following paper:
Souto, H.G. (2023). Topological Tail Dependence: Evidence from Forecasting Realized Volatility. The Journal of Finance and Data Science, 9. DOI: 10.1016/j.jfds.2023.100107
The initial implementation from hugogobato can be found at:
Topological Tail-Dependence Evidence
Metadata
Release files for fintda 2024.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fintda-2024.2.3.tar.gz | 197.0 kB | Without provenance | Details for fintda-2024.2.3.tar.gz |
Release files / fintda-2024.2.3.tar.gz
| Download URL | fintda-2024.2.3.tar.gz |
|---|---|
| Size | 197.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
73ad7baa4d0ef2709dafb73bb7381b002a2143e1850c896781389cdd331d9c85
|
|
BLAKE2b-256 checksum How to use checksums |
b7fbb7c91d3abd63ac3e9b33252169d6c8b43d0088e790ae2d782b5dd36c3ed3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for fintda 2024.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.