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.
Metadata
Release files for plutus-pairtrading 1.1.1
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 |
|---|---|---|---|---|
| plutus_pairtrading-1.1.1.tar.gz | 17.6 kB | Without provenance | Details for plutus_pairtrading-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| plutus_pairtrading-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for plutus_pairtrading-1.1.1-py3-none-any.whl |
Total release size: 39.1 kB
Release files / plutus_pairtrading-1.1.1.tar.gz
| Download URL | plutus_pairtrading-1.1.1.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91698391950cee05e8fdc99ca8d1f0e70c0cdee06d04dc202eb5db93a11f460d
|
|
BLAKE2b-256 checksum How to use checksums |
1229792bb024a5600a60dc640bc64da9e5a504a14dac30dcae3917e46a7bc320
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Release files / plutus_pairtrading-1.1.1-py3-none-any.whl
| Download URL | plutus_pairtrading-1.1.1-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
205d36207411e950f1b43933456587597feafd4d04650180d762a153603b3780
|
|
BLAKE2b-256 checksum How to use checksums |
33b5588080fd81bb028952c5e8a09e97e36605ae311f99dd251fad4fd535d69b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Security for plutus-pairtrading 1.1.1
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.