Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poetry Setup for Enhanced Compatibility Across Python 3.8, 3.9, 3.10, 3.11, 3.12 #107

Merged
merged 22 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 0 additions & 66 deletions .circleci/config.yml

This file was deleted.

1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ directory = build/coverage/html

[run]
branch = True
parallel = True
omit =
*__init__*
arbitragelab/network/imports.py
Expand Down
73 changes: 49 additions & 24 deletions .github/workflows/python-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8] # Add versions as needed
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] # Add versions as needed

steps:
- name: Checkout code
Expand All @@ -24,23 +24,32 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: |
pip install --upgrade pip
pip install poetry


- name: Install dependencies
run: |
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
poetry install

- name: Run Pylint
run: |
source venv/bin/activate
pylint arbitragelab tests --rcfile=.pylintrc -f text
poetry run pylint arbitragelab tests --rcfile=.pylintrc --output-format=text --output=pylint-report.txt

- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: pylint-report-${{ matrix.python-version }}
path: pylint-report.txt


test-coverage:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8] # Add versions as needed
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] # Add versions as needed

steps:
- name: Checkout code
Expand All @@ -51,22 +60,30 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: |
pip install --upgrade pip
pip install poetry

- name: Install dependencies
run: |
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
poetry install

- name: Run tests with coverage
run: |
source venv/bin/activate
bash coverage
poetry run pytest tests/ --cov=arbitragelab --cov-report=term --cov-branch --cov-config=.coveragerc

- name: Upload test results
uses: actions/upload-artifact@v3
- name: Generate coverage XML report
run: poetry run coverage html

- name: Upload Coverage XML Report as Artifact
uses: actions/upload-artifact@v2
with:
name: test-reports-${{ matrix.python-version }}
path: test-reports
name: coverage-html
path: coverage.html

- name: Check coverage
run: poetry run coverage report --fail-under=100

test-docs:
runs-on: ubuntu-latest
Expand All @@ -83,19 +100,27 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: |
pip install poetry

- name: Install requirements
run: |
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install -r docs/source/requirements.txt
poetry install

- name: Build documentation
run: |
source venv/bin/activate
make -C docs html
cd docs
poetry run make html

- name: Run doctests
run: |
source venv/bin/activate
make -C docs doctest
cd docs
poetry run make doctest

- name: Upload doctest results as an artifact
uses: actions/upload-artifact@v2
with:
name: doctest-results
path: docs/build/doctest/output.txt

12 changes: 6 additions & 6 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ load-plugins=
# Reference: http://pylint-messages.wikidot.com/all-codes
disable=I,
maybe-no-member,
star-args,
abstract-class-not-used,
# star-args,
# abstract-class-not-used,
duplicate-code,
superfluous-parens,
abstract-class-little-used,
# abstract-class-little-used,
too-few-public-methods,
RP0401,
RP0801,
Expand All @@ -70,7 +70,7 @@ output-format=text
# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]".
files-output=no
#files-output=no

# Tells whether to display a full report or only the messages
reports=yes
Expand All @@ -91,7 +91,7 @@ msg-template={C}:{line:3d},{column:2d}: [{obj}] {msg} ({msg_id} - {symbol})
[BASIC]

# List of builtins function names that should not be used, separated by a comma
bad-functions=map,filter,apply,input
#bad-functions=map,filter,apply,input

# Regular expression which should only match correct module names
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
Expand Down Expand Up @@ -275,4 +275,4 @@ int-import-graph=

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
overgeneral-exceptions=builtins.Exception
28 changes: 14 additions & 14 deletions arbitragelab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
reproducible, interpretable, and easy to use tools.
"""

import arbitragelab.codependence as codependence
import arbitragelab.cointegration_approach as cointegration_approach
import arbitragelab.copula_approach as copula_approach
import arbitragelab.distance_approach as distance_approach
import arbitragelab.hedge_ratios as hedge_ratios
import arbitragelab.ml_approach as ml_approach
import arbitragelab.optimal_mean_reversion as optimal_mean_reversion
import arbitragelab.other_approaches as other_approaches
import arbitragelab.spread_selection as spread_selection
import arbitragelab.stochastic_control_approach as stochastic_control_approach
import arbitragelab.tearsheet as tearsheet
import arbitragelab.time_series_approach as time_series_approach
import arbitragelab.trading as trading
import arbitragelab.util as util
from arbitragelab import codependence
from arbitragelab import cointegration_approach
from arbitragelab import copula_approach
from arbitragelab import distance_approach
from arbitragelab import hedge_ratios
from arbitragelab import ml_approach
from arbitragelab import optimal_mean_reversion
from arbitragelab import other_approaches
from arbitragelab import spread_selection
from arbitragelab import stochastic_control_approach
from arbitragelab import tearsheet
from arbitragelab import time_series_approach
from arbitragelab import trading
from arbitragelab import util
2 changes: 1 addition & 1 deletion arbitragelab/codependence/codependence_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from arbitragelab.codependence.optimal_transport import optimal_transport_dependence


# pylint: disable=invalid-name
# pylint: disable=invalid-name, unnecessary-lambda-assignment
def get_dependence_matrix(df: pd.DataFrame, dependence_method: str, theta: float = 0.5,
n_bins: int = None, normalize: bool = True,
estimator: str = 'standard', target_dependence: str = 'comonotonicity',
Expand Down
1 change: 1 addition & 0 deletions arbitragelab/codependence/optimal_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Implementations of Optimal Copula Transport dependence measure proposed by Marti et al.: https://arxiv.org/abs/1610.09659
And implemented in the blog post by Marti: https://gmarti.gitlab.io/qfin/2020/06/25/copula-optimal-transport-dependence.html
"""
# pylint: disable=broad-exception-raised

import warnings
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions arbitragelab/cointegration_approach/coint_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
This module allows simulation of cointegrated time series pairs.
"""
# pylint: disable=consider-using-f-string

from typing import Tuple, Optional

Expand Down
1 change: 0 additions & 1 deletion arbitragelab/cointegration_approach/engle_granger.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import pandas as pd
from statsmodels.tsa.stattools import adfuller
from sklearn.linear_model import LinearRegression

from arbitragelab.cointegration_approach.base import CointegratedPortfolio


Expand Down
3 changes: 2 additions & 1 deletion arbitragelab/cointegration_approach/minimum_profit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# pylint: disable=invalid-name, too-many-arguments
"""
This module optimizes the upper and lower bounds for mean-reversion cointegration pair trading.
"""
# pylint: disable=invalid-name, too-many-arguments
# pylint: disable=broad-exception-raised, consider-using-f-string

import sys
import warnings
Expand Down
3 changes: 2 additions & 1 deletion arbitragelab/cointegration_approach/multi_coint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This module generates a cointegration vector for mean-reversion trading of three or more cointegrated assets.
"""
# pylint: disable=consider-using-f-string

import warnings
from typing import Tuple, Optional
Expand Down Expand Up @@ -147,7 +148,7 @@ def fit(self, log_price: pd.DataFrame, sig_level: str = "95%", suppress_warnings
coint_vec = jo_portfolio.cointegration_vectors.loc[0]
self.__coint_vec = coint_vec

return coint_vec
return self.__coint_vec

# pylint: disable=invalid-name, too-many-locals
def get_coint_vec(self) -> Tuple[pd.DataFrame, ...]:
Expand Down
3 changes: 2 additions & 1 deletion arbitragelab/cointegration_approach/sparse_mr_portfolio.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=invalid-name
"""
This module selects sparse mean-reverting portfolios out of an asset universe. The methods implemented in this module
include the following:
Expand All @@ -12,6 +11,8 @@
7. Semidefinite programming approach to portmanteau statistics optimization under a minimum volatility constraint.
8. Semidefinite programming approach to crossing statistics optimization under a minimum volatility constraint.
"""
# pylint: disable=consider-using-f-string
# pylint: disable=invalid-name

from typing import Tuple
import warnings
Expand Down
2 changes: 1 addition & 1 deletion arbitragelab/copula_approach/archimedean/joe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Module that houses Joe copula class.
"""

# pylint: disable = invalid-name, too-many-lines
# pylint: disable=invalid-name, too-many-lines, unnecessary-lambda-assignment
from typing import Callable

import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion arbitragelab/copula_approach/archimedean/n13.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Module that houses N13 copula class.
"""

# pylint: disable = invalid-name, too-many-lines
# pylint: disable=invalid-name, too-many-lines, unnecessary-lambda-assignment
from typing import Callable

import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion arbitragelab/copula_approach/copula_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<https://www.tandfonline.com/doi/pdf/10.1080/01621459.2013.873366?casa_token=sey8HrojSgYAAAAA:TEMBX8wLYdGFGyM78UXSYm6hXl1Qp_K6wiLgRJf6kPcqW4dYT8z3oA3I_odrAL48DNr3OSoqkQsEmQ>`__
"""

# pylint: disable = invalid-name
# pylint: disable=invalid-name, unnecessary-lambda-assignment
from typing import Callable, Tuple

import numpy as np
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Module that implements Clayton, Frank and Gumbel mixed copula.
"""

# pylint: disable = invalid-name, too-many-locals, arguments-differ
# pylint: disable=invalid-name, too-many-locals, arguments-differ, arguments-renamed
import numpy as np
import pandas as pd
from scipy.optimize import minimize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Module that implements Clayton, Student-t and Gumbel mixed copula.
"""

# pylint: disable = invalid-name, too-many-locals, arguments-differ
# pylint: disable=invalid-name, too-many-locals, arguments-differ, arguments-renamed
import numpy as np
import pandas as pd
from scipy.optimize import minimize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Module for implementing partner selection approaches for vine copulas.
"""

# pylint: disable = invalid-name
# pylint: disable = invalid-name, broad-exception-raised
import functools
import itertools
import matplotlib.pyplot as plt
Expand Down
Loading
Loading