No project description provided
Project description
PLUTUS: Pair-Trading Toolkit
PLUTUS is a Python-based toolkit for performing pair-trading analysis. This project is designed for educational purposes and provides tools for:
- Fetching and processing financial data.
- Conducting statistical tests (stationarity and cointegration).
- Performing feature engineering.
- Visualizing financial time-series data.
Table of Contents
Documentation
The full documentation is available on GitHub Pages.
Key Features
1. Data Acquisition
- Fetch historical financial data using Yahoo Finance API.
- Store and manage time-series data in a structured format.
- Combine and preprocess data for analysis.
2. Statistical Tests
-
Stationarity Tests
- Augmented Dickey-Fuller Test (ADF): Tests whether a time series is stationary.
- Phillips-Perron Test (PP): Handles autocorrelations and heteroskedasticity.
- KPSS Test: Tests for trend stationarity.
-
Cointegration Tests
- Engle-Granger Test: Identifies long-term equilibrium relationships.
- Phillips-Ouliaris Test: Handles residual-based cointegration testing.
- Johansen Test: Detects multiple cointegration vectors.
3. Feature Engineering
- Compute periodic returns (daily, weekly, monthly).
- Apply logarithmic and exponential transformations.
- Calculate correlation matrices and filter securities based on thresholds.
- Identify cointegrated pairs for pair trading.
4. Data Visualization
- Plot financial time-series data.
- Generate dual-axis plots for comparing securities.
- Visualize correlation matrices.
- Plot autocorrelation and partial autocorrelation.
Installation
Install Plutus Pair-Trading Toolkit using pip:
pip install plutus-pairtrading
Note: Requires Python 3.10 or above.
Quick Start
Here’s a quick example to use PLUTUS pair-trading tookit.
import plutus_pairtrading.data_acquisitions as dacq
import plutus_pairtrading.data_generations as dgen
import plutus_pairtrading.data_visualizations as dviz
# Fetch stock data for multiple securities
AAPL_df = dacq.fetch_yahoo_finance_data("AAPL", start_date="2015-01-01", end_date="2021-01-01")
MSFT_df = dacq.fetch_yahoo_finance_data("MSFT", start_date="2015-01-01", end_date="2021-01-01")
GOOG_df = dacq.fetch_yahoo_finance_data("GOOG", start_date="2015-01-01", end_date="2021-01-01")
TSLA_df = dacq.fetch_yahoo_finance_data("TSLA", start_date="2015-01-01", end_date="2021-01-01")
# Combine the data into a single DataFrame
stock_df = dacq.combine_dataframes([AAPL_df, MSFT_df, GOOG_df, TSLA_df])
# Perform pair identification
pairs_df = dgen.pairs_identification(
data=stock_df,
stationarity_method="ADF",
cointegration_method="phillips-ouliaris",
stationarity_significance_level=0.05,
coint_significance_level=0.05,
)
# Display the identified pairs
print(pairs_df)
Contribution
We welcome contributions! Visit our Github repository, and to contribute:
- Fork the repository.
- Create a branch (
git checkout -b feature/NewFeature). - Commit your changes (
git commit -m 'Add NewFeature'). - Push to the branch (
git push origin feature/NewFeature). - Open a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plutus_pairtrading-1.0.1.tar.gz.
File metadata
- Download URL: plutus_pairtrading-1.0.1.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3538ae2e5dc699997b029384e0e947f433030bcdc49cb81d517648db16d9f102
|
|
| MD5 |
870c0c247aff4336607c79eab6d1d9a1
|
|
| BLAKE2b-256 |
052d723d870778364450536b99adebbe7c2cd4eb005cbf0e47a695d0ec372254
|
File details
Details for the file plutus_pairtrading-1.0.1-py3-none-any.whl.
File metadata
- Download URL: plutus_pairtrading-1.0.1-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1677abf468f84967f3294e5b00b8faa04284df8ab9652446e517a74042c86825
|
|
| MD5 |
88e247bcebce2403cfbd7c6de6d39b0f
|
|
| BLAKE2b-256 |
4737d93f8352ae1adad63a090706bcc814ecdee732b7c47ba12fa5d405e3665f
|