From 641b1925bfb3f50ce4e70c22ba81bf2f8ae890b7 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Tue, 16 Apr 2024 00:04:50 +0200 Subject: [PATCH 01/62] add GitHub actions workflow for Python testing --- .github/workflows/tests.yaml | 79 ++++++++++++++++++++++++++++++++++++ coverage | 6 +-- 2 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 00000000..d788a07e --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,79 @@ +name: Test code and documentation + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test-code: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] # Add versions as needed + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m venv venv + source venv/bin/activate + pip install -r requirements.txt + + - name: Run Pylint + run: | + source venv/bin/activate + pylint arbitragelab tests --rcfile=.pylintrc -f text + + - name: Run tests with coverage + run: | + source venv/bin/activate + bash coverage + + - name: Upload test results + uses: actions/upload-artifact@v3 + with: + name: test-reports-${{ matrix.python-version }} + path: test-reports + + test-docs: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install requirements + run: | + python -m venv venv + source venv/bin/activate + pip install -r requirements.txt + pip install -r docs/source/requirements.txt + + - name: Build documentation + run: | + source venv/bin/activate + make -C docs html + + - name: Run doctests + run: | + source venv/bin/activate + make -C docs doctest diff --git a/coverage b/coverage index 0e89836f..635fd13e 100755 --- a/coverage +++ b/coverage @@ -14,7 +14,7 @@ coverage run --concurrency=multiprocessing -m pytest tests/ res_test=$? if [ $res_test -ne 0 ] then - echo -e "Circle CI Build FAILURE: Unit tests failed" + echo -e "Build FAILURE: Unit tests failed" exit 1 fi @@ -24,7 +24,7 @@ coverage combine res_combine=$? if [ $res_combine -ne 0 ] then - echo -e "Circle CI Build FAILURE: Coverage combine failed" + echo -e "Build FAILURE: Coverage combine failed" exit 1 fi @@ -33,6 +33,6 @@ coverage report --fail-under=100 coverage_report=$? if [ $coverage_report -ne 0 ] then - echo -e "Circle CI Build FAILURE: Coverage percentage failed" + echo -e "Build FAILURE: Coverage percentage failed" exit 1 fi From 6c306520f21bfa3d99c0756b484f608acb52b445 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Tue, 16 Apr 2024 00:07:43 +0200 Subject: [PATCH 02/62] change name to workflow file --- .github/workflows/{tests.yaml => python-tests.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{tests.yaml => python-tests.yaml} (100%) diff --git a/.github/workflows/tests.yaml b/.github/workflows/python-tests.yaml similarity index 100% rename from .github/workflows/tests.yaml rename to .github/workflows/python-tests.yaml From 4fd602822b91b2012dcd86c3ce5cc48633c32b8a Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Tue, 16 Apr 2024 00:47:35 +0200 Subject: [PATCH 03/62] change target branch to 'develop' for GitHub workflow configuration --- .github/workflows/python-tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index d788a07e..1c5b1fbf 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -3,10 +3,10 @@ name: Test code and documentation on: push: branches: - - main + - develop pull_request: branches: - - main + - develop jobs: test-code: From a8a14f58714f61a020f21414e37666dd0e1229e8 Mon Sep 17 00:00:00 2001 From: Jackal08 Date: Tue, 16 Apr 2024 21:04:58 +0400 Subject: [PATCH 04/62] Linter: rm redundant __init__ --- .../time_series_approach/ou_optimal_threshold_bertram.py | 7 ------- .../time_series_approach/ou_optimal_threshold_zeng.py | 7 ------- 2 files changed, 14 deletions(-) diff --git a/arbitragelab/time_series_approach/ou_optimal_threshold_bertram.py b/arbitragelab/time_series_approach/ou_optimal_threshold_bertram.py index 82e006b3..122794e4 100644 --- a/arbitragelab/time_series_approach/ou_optimal_threshold_bertram.py +++ b/arbitragelab/time_series_approach/ou_optimal_threshold_bertram.py @@ -19,13 +19,6 @@ class OUModelOptimalThresholdBertram(OUModelOptimalThreshold): `_ """ - def __init__(self): - """ - Initializes the module parameters. - """ - - super().__init__() - def expected_trade_length(self, a: float, m: float) -> float: """ Calculates equation (9) in the paper to get the expected trade length. diff --git a/arbitragelab/time_series_approach/ou_optimal_threshold_zeng.py b/arbitragelab/time_series_approach/ou_optimal_threshold_zeng.py index e0d5fbea..8811979b 100644 --- a/arbitragelab/time_series_approach/ou_optimal_threshold_zeng.py +++ b/arbitragelab/time_series_approach/ou_optimal_threshold_zeng.py @@ -20,13 +20,6 @@ class OUModelOptimalThresholdZeng(OUModelOptimalThreshold): `_. """ - def __init__(self): - """ - Initializes the module parameters. - """ - - super().__init__() - def expected_trade_length(self, a: float, b: float) -> float: """ Calculates the expected trade length. From 0c4deaf8f5fe73ead9bdbe072b73e94a6cfd4770 Mon Sep 17 00:00:00 2001 From: Jackal08 Date: Tue, 16 Apr 2024 21:09:38 +0400 Subject: [PATCH 05/62] Github Actions: split linter, coverage, doctest --- .github/workflows/python-tests.yaml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 1c5b1fbf..a6290420 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -9,7 +9,7 @@ on: - develop jobs: - test-code: + test-code-style: runs-on: ubuntu-latest strategy: matrix: @@ -35,6 +35,27 @@ jobs: source venv/bin/activate pylint arbitragelab tests --rcfile=.pylintrc -f text +test-coverage: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] # Add versions as needed + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m venv venv + source venv/bin/activate + pip install -r requirements.txt + - name: Run tests with coverage run: | source venv/bin/activate @@ -46,6 +67,7 @@ jobs: name: test-reports-${{ matrix.python-version }} path: test-reports + test-docs: runs-on: ubuntu-latest strategy: From 0c95d7bc4722de1defa1f16bc38a7f72797c0e14 Mon Sep 17 00:00:00 2001 From: Jackal08 Date: Tue, 16 Apr 2024 21:10:12 +0400 Subject: [PATCH 06/62] Github Actions: split linter, coverage, doctest --- .github/workflows/python-tests.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index a6290420..7daf5316 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -67,7 +67,6 @@ test-coverage: name: test-reports-${{ matrix.python-version }} path: test-reports - test-docs: runs-on: ubuntu-latest strategy: From 949f5f66c19bf7a6780f63bd81e04680be51b7c7 Mon Sep 17 00:00:00 2001 From: Jackal08 Date: Tue, 16 Apr 2024 21:11:58 +0400 Subject: [PATCH 07/62] Github Actions: split linter, coverage, doctest --- .github/workflows/python-tests.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 7daf5316..76db28af 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -35,7 +35,8 @@ jobs: source venv/bin/activate pylint arbitragelab tests --rcfile=.pylintrc -f text -test-coverage: + + test-coverage: runs-on: ubuntu-latest strategy: matrix: From aaa827985c420d18d5327396dcd329690fe33bd8 Mon Sep 17 00:00:00 2001 From: Jackal08 Date: Tue, 16 Apr 2024 22:00:32 +0400 Subject: [PATCH 08/62] Trying to fix bug --- arbitragelab/util/data_importer.py | 13 ++++++++----- tests/test_data_importer.py | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arbitragelab/util/data_importer.py b/arbitragelab/util/data_importer.py index 2c5dba94..ca7524e4 100644 --- a/arbitragelab/util/data_importer.py +++ b/arbitragelab/util/data_importer.py @@ -116,7 +116,7 @@ def get_ticker_sector_info(self, tickers: list, yf_call_chunk: int = 20) -> pd.D # Set end as the limit value equals to the chunk size. # If we hit the last chunk, set the end value as the # full length of the ticker list. - end = i+yf_call_chunk if i <= len(tickers) else len(tickers) + end = i + yf_call_chunk if i <= len(tickers) else len(tickers) ticker_sector_queue.append(self._sector_info_helper(tickers[i: end])) @@ -132,13 +132,16 @@ def _sector_info_helper(tickers: list) -> pd.DataFrame: and industry information. """ - tckrs = yf.Tickers(' '.join(tickers)) + tickers_obj = yf.Tickers(' '.join(tickers)) tckr_info = [] + for name in tickers: - for tckr in tickers: - ticker_info = tckrs.tickers[tckr].info - tckr_tuple = (tckr, ticker_info['industry'], ticker_info['sector']) + sector = tickers_obj.tickers[name].info.get('sector', 'NA') + industry = tickers_obj.tickers[name].info.get('industry', 'NA') + + # Append to list storage + tckr_tuple = (name, industry, sector) tckr_info.append(tckr_tuple) return pd.DataFrame(data=tckr_info, columns=['ticker', 'industry', 'sector']) diff --git a/tests/test_data_importer.py b/tests/test_data_importer.py index 4843b6b0..5bd383b8 100644 --- a/tests/test_data_importer.py +++ b/tests/test_data_importer.py @@ -9,6 +9,7 @@ import numpy as np from arbitragelab.util import DataImporter + class TestDataImporter(unittest.TestCase): """ Tests Data Importer class. From 24e11a9b034e988e8269cb7c95e0a6d40dd5b8a2 Mon Sep 17 00:00:00 2001 From: Benedetto Leto Date: Tue, 16 Apr 2024 20:14:36 +0000 Subject: [PATCH 09/62] update yfinance version to fix issues related with the data_importe.py file --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e5a1b229..5e89ac1b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,7 +25,7 @@ tensorflow-macos==2.12.0; sys_platform == 'darwin' and platform_machine == 'arm6 tensorflow==2.12.0; sys_platform != 'darwin' or platform_machine != 'arm64' werkzeug==2.2.3 yahoo-fin==0.8.9.1 -yfinance==0.2.24 +yfinance==0.2.37 # Develop coverage==7.2.7 From e33a45bf9610b98d933b631942baca064b2bdd04 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 18 Apr 2024 19:56:48 +0200 Subject: [PATCH 10/62] setting-up poetry, modify workflow, upgrade some packages to ensure compatibility --- .coveragerc | 1 + .github/workflows/python-tests.yaml | 65 ++++++++++++++------- pyproject.toml | 91 +++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+), 21 deletions(-) create mode 100644 pyproject.toml diff --git a/.coveragerc b/.coveragerc index c9a46bc4..5fd5c26f 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,6 +3,7 @@ directory = build/coverage/html [run] branch = True +parallel = True omit = *__init__* arbitragelab/network/imports.py diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 76db28af..67bbe973 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -24,16 +24,24 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Install Poetry + run: | + 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 + pylint arbitragelab tests --rcfile=.pylintrc --output-format=text --reports=y --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: @@ -51,22 +59,29 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Install Poetry + run: | + 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 xml + + - name: Upload Coverage XML Report as Artifact + uses: actions/upload-artifact@v2 with: - name: test-reports-${{ matrix.python-version }} - path: test-reports + name: coverage-xml + path: coverage.xml + + - name: Check coverage + run: poetry run coverage report --fail-under=100 test-docs: runs-on: ubuntu-latest @@ -83,19 +98,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 + poetry run make doctest + + - name: Upload doctest results as an artifact + uses: actions/upload-artifact@v2 + with: + name: doctest-results + path: build/doctest/output.txt + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..1b0767ab --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,91 @@ +[tool.poetry] +name = "arbitragelab" +version = "0.9.1" +description = "ArbitrageLab is a collection of algorithms from the best academic journals and graduate-level textbooks, which focuses on the branch of statistical arbitrage known as pairs trading. We have extended the implementations to include the latest methods that trade a portfolio of n-assets (mean-reverting portfolios)." +authors = ["Hudson and Thames Quantitative Research "] +license = "BSD-3-Clause" +readme = "README.md" +homepage = "https://www.hudsonthames.org/" +repository = "https://github.com/hudson-and-thames/arbitragelab" +documentation = "https://hudson-and-thames-arbitragelab.readthedocs-hosted.com/en/latest/index.html" +keywords = ["arbitrage", "finance", "investment", "education", "trading"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "Intended Audience :: Financial and Insurance Industry", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.8", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Artificial Intelligence", + "Topic :: Office/Business :: Financial :: Investment" +] + +packages = [ + { include = "arbitragelab" } +] + +exclude = ["contrib", "docs", "tests"] + +[tool.poetry.dependencies] +python = "~3.8" +POT = "0.9.0" +arch = "5.5.0" +cvxpy = {version = "1.3.1", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'"} # install manually with command conda install -c conda-forge cvxpy +cython = "0.29.28" +dash = "2.10.2" +jupyter-dash = { version = ">=0.2.0,<1.0.0" } +keras = "2.12.0" +lxml = { version = "^4.9.1" } +matplotlib = "3.7.1" +mpmath = "1.2.1" +networkx = { version = ">=2.2,<2.6" } +numpy = "1.23.5" +pandas = "2.0.0" +pmdarima = "2.0.3" +protobuf = { version = ">=3.20.3" } +pyvinecopulib = "0.6.5" +requests_html = "0.10.0" +scikit-learn = "1.1.3" +scipy = { version = ">=1.2.0,<2.0.0" } +scs = { version = "3.2.0", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'" } # install manually with command conda install -c conda-forge scs + +seaborn = "0.12.2" +statsmodels = "0.14.0" +tensorflow-macos = { version = "2.12.0", markers = "sys_platform == 'darwin' and platform_machine == 'arm64'" } +tensorflow = { version = "2.12.0", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'" } +werkzeug = "2.2.3" +yahoo-fin = "0.8.9.1" +yfinance = "0.2.37" + +[tool.poetry.urls] +"Bug Reports" = "https://github.com/hudson-and-thames/arbitragelab/issues" +"Blog" = "https://hudsonthames.org/blog/" +"Apprenticeship Program" = "https://hudsonthames.org/apprenticeship-program/" + +[build-system] +requires = ["poetry-core>=1.0"] +build-backend = "poetry.core.masonry.api" + + +[tool.poetry.dev-dependencies] +coverage = "7.2.7" +docutils = "0.18.1" +hudsonthames-sphinx-theme = "0.1.5" +jinja2 = "<3.1" +pylint = "3.1.0" +pytest = "7.3.1" +releases = "1.6.3" +sphinx-rtd-theme = "1.2.0" +sphinx-tabs = "3.4.1" +sphinx = "6.2.1" +sphinx-autoapi = "3.0.0" +sphinx-copybutton = "0.5.2" +myst-parser = "2.0.0" +pyarmor = "8.5.2" +pytest-cov = "3.0.0" + +[tool.poetry.extras] +docs = ["sphinx", "sphinx-rtd-theme", "sphinx-tabs", "sphinx-autoapi", "sphinx-copybutton", "myst-parser", "hudsonthames-sphinx-theme", "docutils", "jinja2", "releases"] \ No newline at end of file From d6935bfbf8992aea26c2e00cd9bee173072ad99d Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 18 Apr 2024 20:02:23 +0200 Subject: [PATCH 11/62] add dependency --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 1b0767ab..5f6dad19 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,6 +56,7 @@ seaborn = "0.12.2" statsmodels = "0.14.0" tensorflow-macos = { version = "2.12.0", markers = "sys_platform == 'darwin' and platform_machine == 'arm64'" } tensorflow = { version = "2.12.0", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'" } +tensorflow-io-gcs-filesystem = { version = "0.27.0"} werkzeug = "2.2.3" yahoo-fin = "0.8.9.1" yfinance = "0.2.37" From 3df638418647a9aab50bb23b47f410dc00982c3b Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 18 Apr 2024 20:08:35 +0200 Subject: [PATCH 12/62] fix pylint run and remove env activation --- .github/workflows/python-tests.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 67bbe973..60fbbe5d 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -35,7 +35,7 @@ jobs: - name: Run Pylint run: | - pylint arbitragelab tests --rcfile=.pylintrc --output-format=text --reports=y --output=pylint-report.txt + poetry run pylint arbitragelab tests --rcfile=.pylintrc --output-format=text --reports=y --output=pylint-report.txt - name: Upload test results uses: actions/upload-artifact@v3 @@ -113,7 +113,6 @@ jobs: - name: Run doctests run: | - source venv/bin/activate poetry run make doctest - name: Upload doctest results as an artifact From 751d7a157b105fc9096ed6dc93b3bd711a82ead4 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 18 Apr 2024 20:13:08 +0200 Subject: [PATCH 13/62] fix folder doctest --- .github/workflows/python-tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 60fbbe5d..fad3a0b4 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -113,6 +113,7 @@ jobs: - name: Run doctests run: | + cd docs poetry run make doctest - name: Upload doctest results as an artifact From f16ab759fff19f40476b1ae284fd6edfc6500af2 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 18 Apr 2024 20:18:16 +0200 Subject: [PATCH 14/62] remove report creation for pylint --- .github/workflows/python-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index fad3a0b4..aa963cc4 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -35,7 +35,7 @@ jobs: - name: Run Pylint run: | - poetry run pylint arbitragelab tests --rcfile=.pylintrc --output-format=text --reports=y --output=pylint-report.txt + poetry run pylint arbitragelab tests --rcfile=.pylintrc --output-format=text - name: Upload test results uses: actions/upload-artifact@v3 From c54fab5a7ec3c4696a17c3660e6fe0f87166d61d Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 18 Apr 2024 20:42:14 +0200 Subject: [PATCH 15/62] fix version and separate dependencies --- .github/workflows/python-tests.yaml | 8 ++++---- pyproject.toml | 21 ++++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index aa963cc4..91aaaef4 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -31,7 +31,7 @@ jobs: - name: Install dependencies run: | - poetry install + poetry install --only dev - name: Run Pylint run: | @@ -65,7 +65,7 @@ jobs: - name: Install dependencies run: | - poetry install + poetry install --only dev - name: Run tests with coverage run: | @@ -104,7 +104,7 @@ jobs: - name: Install requirements run: | - poetry install + poetry install --only docs - name: Build documentation run: | @@ -120,5 +120,5 @@ jobs: uses: actions/upload-artifact@v2 with: name: doctest-results - path: build/doctest/output.txt + path: docs/build/doctest/output.txt diff --git a/pyproject.toml b/pyproject.toml index 5f6dad19..2d74e666 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,7 +56,7 @@ seaborn = "0.12.2" statsmodels = "0.14.0" tensorflow-macos = { version = "2.12.0", markers = "sys_platform == 'darwin' and platform_machine == 'arm64'" } tensorflow = { version = "2.12.0", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'" } -tensorflow-io-gcs-filesystem = { version = "0.27.0"} +tensorflow-io-gcs-filesystem = { version = "0.27.0", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'"} werkzeug = "2.2.3" yahoo-fin = "0.8.9.1" yfinance = "0.2.37" @@ -71,22 +71,25 @@ requires = ["poetry-core>=1.0"] build-backend = "poetry.core.masonry.api" -[tool.poetry.dev-dependencies] +[tool.poetry.group.dev.dependencies] coverage = "7.2.7" -docutils = "0.18.1" -hudsonthames-sphinx-theme = "0.1.5" -jinja2 = "<3.1" -pylint = "3.1.0" +pylint = "2.6.0" pytest = "7.3.1" releases = "1.6.3" +pyarmor = "8.5.2" +pytest-cov = "3.0.0" + +[tool.poetry.group.doc.dependencies] +jinja2 = "<3.1" +docutils = "0.18.1" +hudsonthames-sphinx-theme = "0.1.5" +myst-parser = "2.0.0" sphinx-rtd-theme = "1.2.0" sphinx-tabs = "3.4.1" sphinx = "6.2.1" sphinx-autoapi = "3.0.0" sphinx-copybutton = "0.5.2" -myst-parser = "2.0.0" -pyarmor = "8.5.2" -pytest-cov = "3.0.0" +pylint = "2.17.0" [tool.poetry.extras] docs = ["sphinx", "sphinx-rtd-theme", "sphinx-tabs", "sphinx-autoapi", "sphinx-copybutton", "myst-parser", "hudsonthames-sphinx-theme", "docutils", "jinja2", "releases"] \ No newline at end of file From fa5230aefd9b821cdac633e94f6c6e1a21107548 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 18 Apr 2024 21:16:56 +0200 Subject: [PATCH 16/62] fix version dependencies and comply with pylint new version --- .github/workflows/python-tests.yaml | 8 +++--- arbitragelab/__init__.py | 28 +++++++++---------- .../cointegration_approach/multi_coint.py | 7 +++++ .../copula_approach/vinecop_generate.py | 6 ++-- pyproject.toml | 3 +- tests/test_copula_pairs_selection.py | 2 +- tests/test_copulas.py | 6 ++-- 7 files changed, 33 insertions(+), 27 deletions(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 91aaaef4..299d0007 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -31,11 +31,11 @@ jobs: - name: Install dependencies run: | - poetry install --only dev + poetry install - name: Run Pylint run: | - poetry run pylint arbitragelab tests --rcfile=.pylintrc --output-format=text + poetry run pylint arbitragelab tests --rcfile=.pylintrc --output-format=text --output-file=pylint-report.txt - name: Upload test results uses: actions/upload-artifact@v3 @@ -65,7 +65,7 @@ jobs: - name: Install dependencies run: | - poetry install --only dev + poetry install - name: Run tests with coverage run: | @@ -104,7 +104,7 @@ jobs: - name: Install requirements run: | - poetry install --only docs + poetry install - name: Build documentation run: | diff --git a/arbitragelab/__init__.py b/arbitragelab/__init__.py index ec992d79..8a54f99a 100644 --- a/arbitragelab/__init__.py +++ b/arbitragelab/__init__.py @@ -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 diff --git a/arbitragelab/cointegration_approach/multi_coint.py b/arbitragelab/cointegration_approach/multi_coint.py index bec930df..1c043cd8 100644 --- a/arbitragelab/cointegration_approach/multi_coint.py +++ b/arbitragelab/cointegration_approach/multi_coint.py @@ -31,6 +31,13 @@ def __init__(self): self.__asset_df = None self.__coint_vec = None + @property + def coint_vec(self): + """ + Accessor for the cointegration vector. + """ + return self.__coint_vec + def set_train_dataset(self, price_df: pd.DataFrame): """ Provide price series for model to calculate the cointegration coefficient and beta. diff --git a/arbitragelab/copula_approach/vinecop_generate.py b/arbitragelab/copula_approach/vinecop_generate.py index 0bb4930c..97a64c50 100644 --- a/arbitragelab/copula_approach/vinecop_generate.py +++ b/arbitragelab/copula_approach/vinecop_generate.py @@ -10,7 +10,7 @@ import numpy as np import pandas as pd import pyvinecopulib as pv -import scipy.integrate as integrate +from scipy import integrate class RVineCop: @@ -87,8 +87,8 @@ def fit_auto(self, data: pd.DataFrame, pv_target_idx: int = 1, if_renew: bool = # Fit among all possible structures. controls = pv.FitControlsVinecop(family_set=self._bicop_family) # Bivar copula constituents for the C-vine - aics = dict() # Dictionary for AIC values for all candidate C-vine copulas - cvine_cops = dict() # Dictionary for storing all candidate C-vine copulas + aics = {} # Dictionary for AIC values for all candidate C-vine copulas + cvine_cops = {} # Dictionary for storing all candidate C-vine copulas for cvine_structure in possible_cvine_structures: temp_cvine_struct = pv.CVineStructure(order=cvine_structure) # Specific C-vine structure temp_cvine_cop = pv.Vinecop(structure=temp_cvine_struct) # Construct the C-vine copula diff --git a/pyproject.toml b/pyproject.toml index 2d74e666..4c86aa88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,7 +73,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry.group.dev.dependencies] coverage = "7.2.7" -pylint = "2.6.0" +pylint = "2.10.0" pytest = "7.3.1" releases = "1.6.3" pyarmor = "8.5.2" @@ -89,7 +89,6 @@ sphinx-tabs = "3.4.1" sphinx = "6.2.1" sphinx-autoapi = "3.0.0" sphinx-copybutton = "0.5.2" -pylint = "2.17.0" [tool.poetry.extras] docs = ["sphinx", "sphinx-rtd-theme", "sphinx-tabs", "sphinx-autoapi", "sphinx-copybutton", "myst-parser", "hudsonthames-sphinx-theme", "docutils", "jinja2", "releases"] \ No newline at end of file diff --git a/tests/test_copula_pairs_selection.py b/tests/test_copula_pairs_selection.py index 5b1e3795..9bddf4ff 100644 --- a/tests/test_copula_pairs_selection.py +++ b/tests/test_copula_pairs_selection.py @@ -8,7 +8,7 @@ import numpy as np import pandas as pd -import arbitragelab.copula_approach.pairs_selection as pairs_selection +from arbitragelab.copula_approach import pairs_selection class TestPairsSelector(unittest.TestCase): diff --git a/tests/test_copulas.py b/tests/test_copulas.py index 877892d6..94a3ef71 100644 --- a/tests/test_copulas.py +++ b/tests/test_copulas.py @@ -698,7 +698,7 @@ def test_fit_copula(self): # Fit through the copulas and the last one we do not update copulas = [Gumbel, Clayton, Frank, Joe, N13, N14, GaussianCopula, StudentCopula] - aics = dict() + aics = {} for cop in copulas: result_dict, _, _, _ = fit_copula_to_empirical_data(x=BKD_clr, y=ESC_clr, copula=cop) @@ -709,7 +709,7 @@ def test_fit_copula(self): 'N13': -2211.6295423299603, 'N14': -2111.9831835080827, 'Gaussian': -2211.4486204860873, 'Student': -2275.069087841567} - for key in aics: + for key, _ in aics.items(): self.assertAlmostEqual(aics[key], expeced_aics[key], delta=1) @staticmethod @@ -823,7 +823,7 @@ def test_plot_abs_class_method(self): student = StudentCopula(cov=cov, nu=nu) # Initiate without an axes - axs = dict() + axs = {} axs['Gumbel'] = gumbel.plot_scatter(200) axs['Frank'] = frank.plot_scatter(200) axs['Clayton'] = clayton.plot_scatter(200) From 1c61cb5ba3099f6c730bcf3b9709a7c53e00e1f2 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 18 Apr 2024 21:27:38 +0200 Subject: [PATCH 17/62] fix pylint --- .github/workflows/python-tests.yaml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 299d0007..7458b826 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -35,7 +35,7 @@ jobs: - name: Run Pylint run: | - poetry run pylint arbitragelab tests --rcfile=.pylintrc --output-format=text --output-file=pylint-report.txt + poetry run pylint arbitragelab tests --rcfile=.pylintrc --output-format=text --output=pylint-report.txt - name: Upload test results uses: actions/upload-artifact@v3 diff --git a/pyproject.toml b/pyproject.toml index 4c86aa88..fb8a2588 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,7 +87,7 @@ myst-parser = "2.0.0" sphinx-rtd-theme = "1.2.0" sphinx-tabs = "3.4.1" sphinx = "6.2.1" -sphinx-autoapi = "3.0.0" +sphinx-autoapi = "2.1.1" sphinx-copybutton = "0.5.2" [tool.poetry.extras] From 7efcba04621ab22001f0512adc7d5b88f7cccffa Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 18 Apr 2024 21:31:24 +0200 Subject: [PATCH 18/62] fix pylint --- .github/workflows/python-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 7458b826..640cc13d 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -35,7 +35,7 @@ jobs: - name: Run Pylint run: | - poetry run pylint arbitragelab tests --rcfile=.pylintrc --output-format=text --output=pylint-report.txt + poetry run pylint arbitragelab tests --rcfile=.pylintrc --output-format=text - name: Upload test results uses: actions/upload-artifact@v3 From 7367acb0588c92e8b240ef80c3ce9282f0b84809 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 18 Apr 2024 21:39:18 +0200 Subject: [PATCH 19/62] fix warning --- tests/test_copulas.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_copulas.py b/tests/test_copulas.py index 94a3ef71..1ff5b081 100644 --- a/tests/test_copulas.py +++ b/tests/test_copulas.py @@ -709,8 +709,8 @@ def test_fit_copula(self): 'N13': -2211.6295423299603, 'N14': -2111.9831835080827, 'Gaussian': -2211.4486204860873, 'Student': -2275.069087841567} - for key, _ in aics.items(): - self.assertAlmostEqual(aics[key], expeced_aics[key], delta=1) + for key, aic_item in aics.items(): + self.assertAlmostEqual(aic_item, expeced_aics[key], delta=1) @staticmethod def test_construct_ecdf_lin(): From b4b6da0243077eebaebaa809a39c2c56096e779a Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 18 Apr 2024 22:31:27 +0200 Subject: [PATCH 20/62] fix unused variable warning --- .github/workflows/python-tests.yaml | 8 ++++---- arbitragelab/cointegration_approach/multi_coint.py | 9 +-------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 640cc13d..a85fa9b0 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -35,7 +35,7 @@ jobs: - name: Run Pylint run: | - poetry run pylint arbitragelab tests --rcfile=.pylintrc --output-format=text + poetry run pylint arbitragelab tests --rcfile=.pylintrc --output-format=text --output=pylint-report.txt - name: Upload test results uses: actions/upload-artifact@v3 @@ -72,13 +72,13 @@ jobs: poetry run pytest tests/ --cov=arbitragelab --cov-report=term --cov-branch --cov-config=.coveragerc - name: Generate coverage XML report - run: poetry run coverage xml + run: poetry run coverage html - name: Upload Coverage XML Report as Artifact uses: actions/upload-artifact@v2 with: - name: coverage-xml - path: coverage.xml + name: coverage-html + path: coverage.html - name: Check coverage run: poetry run coverage report --fail-under=100 diff --git a/arbitragelab/cointegration_approach/multi_coint.py b/arbitragelab/cointegration_approach/multi_coint.py index 1c043cd8..82b64ed8 100644 --- a/arbitragelab/cointegration_approach/multi_coint.py +++ b/arbitragelab/cointegration_approach/multi_coint.py @@ -31,13 +31,6 @@ def __init__(self): self.__asset_df = None self.__coint_vec = None - @property - def coint_vec(self): - """ - Accessor for the cointegration vector. - """ - return self.__coint_vec - def set_train_dataset(self, price_df: pd.DataFrame): """ Provide price series for model to calculate the cointegration coefficient and beta. @@ -154,7 +147,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, ...]: From 692abbb9888682244d23626403a5ccec505bad27 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Fri, 19 Apr 2024 10:24:49 +0200 Subject: [PATCH 21/62] update changelog --- docs/source/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 166cb4ba..2c704186 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -9,6 +9,8 @@ Changelog * :feature:`50` Add a distutils command for marbles * :bug:`58` Fixed test failure on OSX +:support:`93` Add poetry package manager for dependency management. + * :release:`0.9.1 <2024-01-10>` * :bug:`92` Released a new version because of pypi version was wrong From 988e373833c8da3f32a1c044060174bd4be00f95 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Fri, 19 Apr 2024 10:32:53 +0200 Subject: [PATCH 22/62] fix changelog --- docs/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 2c704186..19c36609 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -9,7 +9,7 @@ Changelog * :feature:`50` Add a distutils command for marbles * :bug:`58` Fixed test failure on OSX -:support:`93` Add poetry package manager for dependency management. +* :support:`93` Add poetry package manager for dependency management. * :release:`0.9.1 <2024-01-10>` * :bug:`92` Released a new version because of pypi version was wrong From 8523d4470aebb4c4a17f82de4175bd6c81d4e733 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Sun, 21 Apr 2024 17:19:56 +0200 Subject: [PATCH 23/62] remove circleCI workflow, remove setuptools, add poetry support for python 3.9, 3.10, 3.11, 3.12, upgrade pylint version and cover new warning --- .circleci/config.yml | 66 --------------- .pylintrc | 12 +-- .../codependence/codependence_matrix.py | 2 +- .../codependence/optimal_transport.py | 1 + .../cointegration_approach/coint_sim.py | 1 + .../cointegration_approach/engle_granger.py | 1 - .../cointegration_approach/minimum_profit.py | 3 +- .../cointegration_approach/multi_coint.py | 1 + .../sparse_mr_portfolio.py | 3 +- .../copula_approach/archimedean/joe.py | 2 +- .../copula_approach/archimedean/n13.py | 2 +- .../copula_approach/copula_calculation.py | 2 +- .../mixed_copulas/cfg_mix_copula.py | 2 +- .../mixed_copulas/ctg_mix_copula.py | 2 +- .../vine_copula_partner_selection.py | 2 +- .../basic_distance_approach.py | 2 +- .../optics_dbscan_pairs_clustering.py | 1 + .../optimal_mean_reversion/cir_model.py | 2 +- .../optimal_mean_reversion/heat_potentials.py | 1 + .../optimal_mean_reversion/ou_model.py | 1 + .../optimal_mean_reversion/xou_model.py | 2 +- arbitragelab/spread_selection/base.py | 2 +- .../spread_selection/cointegration.py | 2 +- .../optimal_convergence.py | 2 +- .../ou_model_jurek.py | 2 +- .../ou_model_mudchanatongsuk.py | 2 +- arbitragelab/tearsheet/tearsheet.py | 6 +- .../time_series_approach/arima_predict.py | 1 + .../time_series_approach/h_strategy.py | 2 +- .../ou_optimal_threshold.py | 2 +- .../ou_optimal_threshold_bertram.py | 2 +- .../ou_optimal_threshold_zeng.py | 2 +- .../quantile_time_series.py | 1 + .../regime_switching_arbitrage_rule.py | 7 +- docs/source/conf.py | 6 +- docs/source/index.rst | 2 + pyproject.toml | 84 ++++++++++++++----- requirements.txt | 4 +- setup.cfg | 80 ------------------ setup.py | 21 ----- tests/test_copulas.py | 3 +- tests/test_neural_networks.py | 8 +- tests/test_optics_dbscan_pairs_clustering.py | 2 + tests/test_regime_switching_arbitrage_rule.py | 16 ++-- tests/test_spread_modeling_helper.py | 4 - tests/test_trading_copula_strategy_mpi.py | 14 ++-- 46 files changed, 136 insertions(+), 252 deletions(-) delete mode 100644 .circleci/config.yml delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index a80dc918..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,66 +0,0 @@ -version: 2.1 - -workflows: - version: 2 - main: - jobs: - - test-code - - test-docs - -jobs: - test-code: - docker: - - image: circleci/python:3.8 - steps: - # Step 1: obtain repo from GitHub - - checkout - # Step 2: create virtual env and install dependencies - - run: - name: Create Virtualenv - command: | - virtualenv venv - - run: - name: Install Dependencies - command: | - . venv/bin/activate - pip3 install -r requirements.txt - # Step 3: run pylint styling check - - run: - name: Run Pylint Check - command: | - . venv/bin/activate - pylint arbitragelab tests --rcfile=.pylintrc -f text - # Step 4: run coverage check - - run: - name: Run Unit Tests and Coverage Check - command: | - bash coverage - - store_test_results: - path: test-reports - - store_artifacts: - path: test-reports - - test-docs: - docker: - - image: circleci/python:3.8 - steps: - - checkout - - run: - name: Install requirements - command: | - python3 -m venv venv - . venv/bin/activate - pip install -r requirements.txt - pip install -r docs/source/requirements.txt - - - run: - name: Build documentation - command: | - . venv/bin/activate - make -C docs html - - - run: - name: Run doctests - command: | - . venv/bin/activate - make -C docs doctest diff --git a/.pylintrc b/.pylintrc index 30bc5156..b9b01a8b 100644 --- a/.pylintrc +++ b/.pylintrc @@ -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, @@ -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 @@ -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]+))$ @@ -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 diff --git a/arbitragelab/codependence/codependence_matrix.py b/arbitragelab/codependence/codependence_matrix.py index 231d3702..75b40334 100644 --- a/arbitragelab/codependence/codependence_matrix.py +++ b/arbitragelab/codependence/codependence_matrix.py @@ -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', diff --git a/arbitragelab/codependence/optimal_transport.py b/arbitragelab/codependence/optimal_transport.py index 1fc0ca43..5aa109ee 100644 --- a/arbitragelab/codependence/optimal_transport.py +++ b/arbitragelab/codependence/optimal_transport.py @@ -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 diff --git a/arbitragelab/cointegration_approach/coint_sim.py b/arbitragelab/cointegration_approach/coint_sim.py index bd0f5a8b..bdd27ab3 100644 --- a/arbitragelab/cointegration_approach/coint_sim.py +++ b/arbitragelab/cointegration_approach/coint_sim.py @@ -2,6 +2,7 @@ """ This module allows simulation of cointegrated time series pairs. """ +# pylint: disable=consider-using-f-string from typing import Tuple, Optional diff --git a/arbitragelab/cointegration_approach/engle_granger.py b/arbitragelab/cointegration_approach/engle_granger.py index 93a28244..b30395bb 100644 --- a/arbitragelab/cointegration_approach/engle_granger.py +++ b/arbitragelab/cointegration_approach/engle_granger.py @@ -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 diff --git a/arbitragelab/cointegration_approach/minimum_profit.py b/arbitragelab/cointegration_approach/minimum_profit.py index 1d3d7866..f6d9d5ea 100644 --- a/arbitragelab/cointegration_approach/minimum_profit.py +++ b/arbitragelab/cointegration_approach/minimum_profit.py @@ -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 diff --git a/arbitragelab/cointegration_approach/multi_coint.py b/arbitragelab/cointegration_approach/multi_coint.py index 82b64ed8..f146a7c7 100644 --- a/arbitragelab/cointegration_approach/multi_coint.py +++ b/arbitragelab/cointegration_approach/multi_coint.py @@ -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 diff --git a/arbitragelab/cointegration_approach/sparse_mr_portfolio.py b/arbitragelab/cointegration_approach/sparse_mr_portfolio.py index 73ed01c0..7220378c 100644 --- a/arbitragelab/cointegration_approach/sparse_mr_portfolio.py +++ b/arbitragelab/cointegration_approach/sparse_mr_portfolio.py @@ -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: @@ -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 diff --git a/arbitragelab/copula_approach/archimedean/joe.py b/arbitragelab/copula_approach/archimedean/joe.py index 726579cf..f841389f 100644 --- a/arbitragelab/copula_approach/archimedean/joe.py +++ b/arbitragelab/copula_approach/archimedean/joe.py @@ -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 diff --git a/arbitragelab/copula_approach/archimedean/n13.py b/arbitragelab/copula_approach/archimedean/n13.py index f98756fa..27a7a271 100644 --- a/arbitragelab/copula_approach/archimedean/n13.py +++ b/arbitragelab/copula_approach/archimedean/n13.py @@ -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 diff --git a/arbitragelab/copula_approach/copula_calculation.py b/arbitragelab/copula_approach/copula_calculation.py index 5033ab81..5035642d 100644 --- a/arbitragelab/copula_approach/copula_calculation.py +++ b/arbitragelab/copula_approach/copula_calculation.py @@ -20,7 +20,7 @@ `__ """ -# pylint: disable = invalid-name +# pylint: disable=invalid-name, unnecessary-lambda-assignment from typing import Callable, Tuple import numpy as np diff --git a/arbitragelab/copula_approach/mixed_copulas/cfg_mix_copula.py b/arbitragelab/copula_approach/mixed_copulas/cfg_mix_copula.py index b90d0b01..555413a0 100644 --- a/arbitragelab/copula_approach/mixed_copulas/cfg_mix_copula.py +++ b/arbitragelab/copula_approach/mixed_copulas/cfg_mix_copula.py @@ -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 diff --git a/arbitragelab/copula_approach/mixed_copulas/ctg_mix_copula.py b/arbitragelab/copula_approach/mixed_copulas/ctg_mix_copula.py index 3b3c79d8..7c96e478 100644 --- a/arbitragelab/copula_approach/mixed_copulas/ctg_mix_copula.py +++ b/arbitragelab/copula_approach/mixed_copulas/ctg_mix_copula.py @@ -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 diff --git a/arbitragelab/copula_approach/vine_copula_partner_selection.py b/arbitragelab/copula_approach/vine_copula_partner_selection.py index ba8cce6f..f7f3b193 100644 --- a/arbitragelab/copula_approach/vine_copula_partner_selection.py +++ b/arbitragelab/copula_approach/vine_copula_partner_selection.py @@ -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 diff --git a/arbitragelab/distance_approach/basic_distance_approach.py b/arbitragelab/distance_approach/basic_distance_approach.py index 51d04351..21fba865 100644 --- a/arbitragelab/distance_approach/basic_distance_approach.py +++ b/arbitragelab/distance_approach/basic_distance_approach.py @@ -4,7 +4,7 @@ "Pairs trading: Performance of a relative-value arbitrage rule." (2006) https://papers.ssrn.com/sol3/papers.cfm?abstract_id=141615. """ - +# pylint: disable=broad-exception-raised) import numpy as np import pandas as pd import matplotlib.pyplot as plt diff --git a/arbitragelab/ml_approach/optics_dbscan_pairs_clustering.py b/arbitragelab/ml_approach/optics_dbscan_pairs_clustering.py index b7a87190..2d298157 100644 --- a/arbitragelab/ml_approach/optics_dbscan_pairs_clustering.py +++ b/arbitragelab/ml_approach/optics_dbscan_pairs_clustering.py @@ -2,6 +2,7 @@ This module implements the ML based Pairs Selection Framework described by Simão Moraes Sarmento and Nuno Horta in `"A Machine Learning based Pairs Trading Investment Strategy." `__. """ +# pylint: disable=broad-exception-raised) import itertools import numpy as np diff --git a/arbitragelab/optimal_mean_reversion/cir_model.py b/arbitragelab/optimal_mean_reversion/cir_model.py index a5b56928..e7caf149 100644 --- a/arbitragelab/optimal_mean_reversion/cir_model.py +++ b/arbitragelab/optimal_mean_reversion/cir_model.py @@ -1,4 +1,4 @@ -# pylint: disable=missing-module-docstring, invalid-name, no-name-in-module +# pylint: disable=missing-module-docstring, invalid-name, no-name-in-module, unnecessary-lambda-assignment import warnings import numpy as np diff --git a/arbitragelab/optimal_mean_reversion/heat_potentials.py b/arbitragelab/optimal_mean_reversion/heat_potentials.py index 67900da0..c462d4ed 100644 --- a/arbitragelab/optimal_mean_reversion/heat_potentials.py +++ b/arbitragelab/optimal_mean_reversion/heat_potentials.py @@ -1,4 +1,5 @@ # pylint: disable=missing-module-docstring, invalid-name, too-many-locals +# pylint: disable=unnecessary-lambda-assignment, consider-using-generator from typing import Callable import numpy as np diff --git a/arbitragelab/optimal_mean_reversion/ou_model.py b/arbitragelab/optimal_mean_reversion/ou_model.py index b76c2714..f96515d2 100644 --- a/arbitragelab/optimal_mean_reversion/ou_model.py +++ b/arbitragelab/optimal_mean_reversion/ou_model.py @@ -1,4 +1,5 @@ # pylint: disable=missing-module-docstring, invalid-name, too-many-instance-attributes +# pylint: disable=unnecessary-lambda-assignment, broad-exception-raised import warnings from scipy.integrate import quad from scipy.optimize import root_scalar diff --git a/arbitragelab/optimal_mean_reversion/xou_model.py b/arbitragelab/optimal_mean_reversion/xou_model.py index df97647c..24756a1b 100644 --- a/arbitragelab/optimal_mean_reversion/xou_model.py +++ b/arbitragelab/optimal_mean_reversion/xou_model.py @@ -1,4 +1,4 @@ -# pylint: disable=missing-module-docstring, invalid-name +# pylint: disable=missing-module-docstring, invalid-name, unnecessary-lambda-assignment, broad-exception-raised import warnings from scipy.optimize import root_scalar, fsolve, minimize import numpy as np diff --git a/arbitragelab/spread_selection/base.py b/arbitragelab/spread_selection/base.py index 4bf14525..018243ac 100644 --- a/arbitragelab/spread_selection/base.py +++ b/arbitragelab/spread_selection/base.py @@ -1,7 +1,7 @@ """ Abstract pair selector class. """ - +# pylint: disable=consider-using-f-string from abc import ABC from abc import abstractmethod diff --git a/arbitragelab/spread_selection/cointegration.py b/arbitragelab/spread_selection/cointegration.py index a81ab65f..4e143c9e 100644 --- a/arbitragelab/spread_selection/cointegration.py +++ b/arbitragelab/spread_selection/cointegration.py @@ -3,7 +3,7 @@ Sarmento and Nuno Horta in `"A Machine Learning based Pairs Trading Investment Strategy." `__. """ -# pylint: disable=arguments-differ +# pylint: disable=arguments-differ, consider-using-f-string from functools import reduce import numpy as np diff --git a/arbitragelab/stochastic_control_approach/optimal_convergence.py b/arbitragelab/stochastic_control_approach/optimal_convergence.py index dcc91023..6b0bef70 100644 --- a/arbitragelab/stochastic_control_approach/optimal_convergence.py +++ b/arbitragelab/stochastic_control_approach/optimal_convergence.py @@ -3,7 +3,7 @@ `Liu, J. and Timmermann, A., 2013. Optimal convergence trade strategies. The Review of Financial Studies, 26(4), pp.1048-1086. `__ """ -# pylint: disable=invalid-name, too-many-instance-attributes +# pylint: disable=invalid-name, too-many-instance-attributes, broad-exception-raised import warnings import numpy as np diff --git a/arbitragelab/stochastic_control_approach/ou_model_jurek.py b/arbitragelab/stochastic_control_approach/ou_model_jurek.py index 9cf5b856..099e2284 100644 --- a/arbitragelab/stochastic_control_approach/ou_model_jurek.py +++ b/arbitragelab/stochastic_control_approach/ou_model_jurek.py @@ -6,7 +6,7 @@ `Jurek, J.W. and Yang, H., 2007, April. Dynamic portfolio selection in arbitrage. In EFA 2006 Meetings Paper. `__ """ -# pylint: disable=invalid-name, too-many-instance-attributes, too-many-locals +# pylint: disable=invalid-name, too-many-instance-attributes, too-many-locals, broad-exception-raised import warnings import cvxpy as cp diff --git a/arbitragelab/stochastic_control_approach/ou_model_mudchanatongsuk.py b/arbitragelab/stochastic_control_approach/ou_model_mudchanatongsuk.py index 3c4814d4..a46a7257 100644 --- a/arbitragelab/stochastic_control_approach/ou_model_mudchanatongsuk.py +++ b/arbitragelab/stochastic_control_approach/ou_model_mudchanatongsuk.py @@ -6,7 +6,7 @@ `Mudchanatongsuk, S., Primbs, J.A. and Wong, W., 2008, June. Optimal pairs trading: A stochastic control approach. `__ """ -# pylint: disable=invalid-name, too-many-instance-attributes +# pylint: disable=invalid-name, too-many-instance-attributes, broad-exception-raised import math import numpy as np diff --git a/arbitragelab/tearsheet/tearsheet.py b/arbitragelab/tearsheet/tearsheet.py index 9e6bff3f..fc6d051f 100644 --- a/arbitragelab/tearsheet/tearsheet.py +++ b/arbitragelab/tearsheet/tearsheet.py @@ -1,11 +1,10 @@ """ This module implements interactive Tear Sheets for various modules of the ArbitrageLab package. """ -# pylint: disable=too-many-lines, too-many-locals, invalid-name, unused-argument -# pylint: disable=too-many-arguments, too-many-statements, unused-variable, broad-except +# pylint: disable=too-many-lines, too-many-locals, invalid-name, unused-argument, use-dict-literal, broad-except +# pylint: disable=too-many-arguments, too-many-statements, unused-variable, consider-using-f-string import warnings - import pandas as pd import numpy as np from scipy import stats @@ -18,7 +17,6 @@ from dash import dash_table import plotly.graph_objects as go from jupyter_dash import JupyterDash - from arbitragelab.optimal_mean_reversion import OrnsteinUhlenbeck from arbitragelab.cointegration_approach import (get_half_life_of_mean_reversion, EngleGrangerPortfolio, JohansenPortfolio) diff --git a/arbitragelab/time_series_approach/arima_predict.py b/arbitragelab/time_series_approach/arima_predict.py index bbd0a3db..38f9be88 100644 --- a/arbitragelab/time_series_approach/arima_predict.py +++ b/arbitragelab/time_series_approach/arima_predict.py @@ -1,6 +1,7 @@ """ The module implements the ARIMA forecast of any time series using the Auto-ARIMA approach. """ +# pylint: disable=consider-using-f-string, broad-exception-raised import warnings import sys diff --git a/arbitragelab/time_series_approach/h_strategy.py b/arbitragelab/time_series_approach/h_strategy.py index 1fa7709a..f67f830f 100644 --- a/arbitragelab/time_series_approach/h_strategy.py +++ b/arbitragelab/time_series_approach/h_strategy.py @@ -3,7 +3,7 @@ `Bogomolov, T. (2013). Pairs trading based on statistical variability of the spread process. Quantitative Finance, 13(9): 1411–1430. `_ """ -# pylint: disable=invalid-name +# pylint: disable=invalid-name, broad-exception-raised from itertools import compress, combinations diff --git a/arbitragelab/time_series_approach/ou_optimal_threshold.py b/arbitragelab/time_series_approach/ou_optimal_threshold.py index 663cda6a..16051e12 100644 --- a/arbitragelab/time_series_approach/ou_optimal_threshold.py +++ b/arbitragelab/time_series_approach/ou_optimal_threshold.py @@ -1,7 +1,7 @@ """ The module implements the base class for OU Optimal Threshold Model. """ -# pylint: disable=invalid-name +# pylint: disable=invalid-name, broad-exception-raised, unnecessary-lambda-assignment from typing import Union diff --git a/arbitragelab/time_series_approach/ou_optimal_threshold_bertram.py b/arbitragelab/time_series_approach/ou_optimal_threshold_bertram.py index 122794e4..441678f0 100644 --- a/arbitragelab/time_series_approach/ou_optimal_threshold_bertram.py +++ b/arbitragelab/time_series_approach/ou_optimal_threshold_bertram.py @@ -1,7 +1,7 @@ """ The module implements the Bertram class for OU Optimal Threshold Model. """ -# pylint: disable=invalid-name +# pylint: disable=invalid-name, unnecessary-lambda-assignment, broad-exception-raised, consider-iterating-dictionary import numpy as np from scipy import optimize, special diff --git a/arbitragelab/time_series_approach/ou_optimal_threshold_zeng.py b/arbitragelab/time_series_approach/ou_optimal_threshold_zeng.py index 8811979b..0e8f30a3 100644 --- a/arbitragelab/time_series_approach/ou_optimal_threshold_zeng.py +++ b/arbitragelab/time_series_approach/ou_optimal_threshold_zeng.py @@ -1,7 +1,7 @@ """ The module implements the Zeng class for OU Optimal Threshold Model. """ -# pylint: disable=invalid-name +# pylint: disable=invalid-name, unnecessary-lambda-assignment, broad-exception-raised, consider-iterating-dictionary import numpy as np from scipy import optimize diff --git a/arbitragelab/time_series_approach/quantile_time_series.py b/arbitragelab/time_series_approach/quantile_time_series.py index d4c1ed59..4bbe6551 100644 --- a/arbitragelab/time_series_approach/quantile_time_series.py +++ b/arbitragelab/time_series_approach/quantile_time_series.py @@ -3,6 +3,7 @@ `"A Machine Learning based Pairs Trading Investment Strategy" `__ (pages 37-43) by Simão Moraes Sarmento and Nuno Horta. """ +# pylint: disable=consider-using-f-string import pandas as pd import seaborn as sns diff --git a/arbitragelab/time_series_approach/regime_switching_arbitrage_rule.py b/arbitragelab/time_series_approach/regime_switching_arbitrage_rule.py index 60299dff..eec2027c 100644 --- a/arbitragelab/time_series_approach/regime_switching_arbitrage_rule.py +++ b/arbitragelab/time_series_approach/regime_switching_arbitrage_rule.py @@ -1,7 +1,7 @@ """ The module implements a statistical arbitrage strategy based on the Markov regime-switching model. """ -# pylint: disable=invalid-name +# pylint: disable=invalid-name, unnecessary-lambda-assignment, broad-exception-raised from typing import Union, Callable import warnings @@ -128,7 +128,8 @@ def get_signal(self, data: Union[np.array, pd.Series, pd.DataFrame], switching_v res = mod.fit() except (RuntimeError, LinAlgError): warnings.warn("Unable to get a fit") - return np.full(4, False) # Since we were unable to detect the regime, we just return False for every possible strategy. + return np.full(4, + False) # Since we were unable to detect the regime, we just return False for every possible strategy. # Unpacking parameters mu = res.params[2:4] @@ -230,7 +231,7 @@ def get_trades(self, signals: np.array) -> np.array: if not (long_exit[i] or short_exit[i]): positions[i] = positions[i - 1] else: - positions[i] = 0 + positions[i] = 0 # pragma: no cover return np.column_stack((long_entry, long_exit, short_entry, short_exit)) diff --git a/docs/source/conf.py b/docs/source/conf.py index 07d537a0..c67fef22 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -82,7 +82,11 @@ # # html_theme_options = {} -html_context = {'logo': 'logo_white.png', 'theme_logo_only': True} +html_logo = '_static/logo_white.png' +html_theme_options = { + 'logo_only': True, + 'display_version': True, +} html_favicon = '_static/favicon_arbitragelab.png' # Add any paths that contain custom static files (such as style sheets) here, diff --git a/docs/source/index.rst b/docs/source/index.rst index 22cbb476..b8733046 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -3,6 +3,7 @@ :target: https://hudsonthames.org/ | + =============================================== Welcome to the Statistical Arbitrage Laboratory =============================================== @@ -117,6 +118,7 @@ Including publications from: :target: https://hudsonthames.org/ | + Who is Hudson & Thames? +++++++++++++++++++++++ diff --git a/pyproject.toml b/pyproject.toml index fb8a2588..63ae200d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,36 +30,74 @@ packages = [ exclude = ["contrib", "docs", "tests"] [tool.poetry.dependencies] -python = "~3.8" +python = "^3.8" POT = "0.9.0" arch = "5.5.0" -cvxpy = {version = "1.3.1", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'"} # install manually with command conda install -c conda-forge cvxpy +werkzeug = "2.2.3" +yahoo-fin = "0.8.9.1" +yfinance = "0.2.37" cython = "0.29.28" dash = "2.10.2" -jupyter-dash = { version = ">=0.2.0,<1.0.0" } -keras = "2.12.0" -lxml = { version = "^4.9.1" } -matplotlib = "3.7.1" mpmath = "1.2.1" -networkx = { version = ">=2.2,<2.6" } -numpy = "1.23.5" pandas = "2.0.0" -pmdarima = "2.0.3" -protobuf = { version = ">=3.20.3" } +pmdarima = "2.0.4" pyvinecopulib = "0.6.5" requests_html = "0.10.0" -scikit-learn = "1.1.3" -scipy = { version = ">=1.2.0,<2.0.0" } -scs = { version = "3.2.0", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'" } # install manually with command conda install -c conda-forge scs - +pyzmq = "26.0.0" seaborn = "0.12.2" -statsmodels = "0.14.0" -tensorflow-macos = { version = "2.12.0", markers = "sys_platform == 'darwin' and platform_machine == 'arm64'" } -tensorflow = { version = "2.12.0", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'" } -tensorflow-io-gcs-filesystem = { version = "0.27.0", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'"} -werkzeug = "2.2.3" -yahoo-fin = "0.8.9.1" -yfinance = "0.2.37" + +statsmodels = {version = "0.14.0" } +lxml = { version = "^4.9.1" } +protobuf = { version = ">=3.20.3" } +networkx = { version = ">=2.2,<2.6" } +jupyter-dash = { version = ">=0.2.0,<1.0.0" } + +numpy = [ + { version = "1.23.5", python = ">=3.8,<3.12" }, + { version = "1.26.4", python = ">=3.12,<4" }, +] + +matplotlib = [ + { version = "3.7.1", python = ">=3.8,<3.12" }, + { version = "3.8.4", python = ">=3.12,<4" }, +] + +scikit-learn = [ + { version = "1.1.3", python = ">=3.8,<3.12" }, + { version = "1.3.0", python = ">=3.12,<4" }, +] + +scipy = [ + { version = "1.10.1", python = ">=3.8,<3.9" }, + { version = "1.11.0", python = ">=3.9,<3.10" }, + { version = "1.12.0", python = ">=3.10,<4" }, +] + +tensorflow-macos = [ + { version = "2.13.0", markers = "sys_platform == 'darwin' and platform_machine == 'arm64'", python = ">=3.8, <3.12" }, + { version = "2.16.1", markers = "sys_platform == 'darwin' and platform_machine == 'x86_64'", python = ">=3.12, <4" } +] + +tensorflow = [ + { version = "2.13.0", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'", python = ">=3.8, <3.12" }, + { version = "2.16.1", markers = "sys_platform != 'darwin' or platform_machine != 'x86_64'", python = ">=3.12, <4" } +] + +tensorflow-io-gcs-filesystem = { version = "0.34.0", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'", python = ">=3.8, <3.12" } + +keras = [ + { version = "2.13.1", python = ">=3.8,<3.12" }, + { version = "3.0.0", python = ">=3.12,<4" }, +] + +wrapt = { version = "1.14.0" , python = ">=3.8,<3.12" } + +cvxpy = [ + { version = "1.4.3", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'", python = ">=3.8,<3.10"}, + { version = "1.4.3", python = ">=3.10,<4"}, +] # install manually with command conda install -c conda-forge cvxpy, + # otherwise causes problems whit some of its dependecy 'ecos' and 'scs -> + #refer to this link: https://apple.stackexchange.com/questions/254380/why-am-i-getting-an-invalid-active-developer-path-when-attempting-to-use-git-a [tool.poetry.urls] "Bug Reports" = "https://github.com/hudson-and-thames/arbitragelab/issues" @@ -73,7 +111,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry.group.dev.dependencies] coverage = "7.2.7" -pylint = "2.10.0" +pylint = "3.1.0" pytest = "7.3.1" releases = "1.6.3" pyarmor = "8.5.2" @@ -87,7 +125,7 @@ myst-parser = "2.0.0" sphinx-rtd-theme = "1.2.0" sphinx-tabs = "3.4.1" sphinx = "6.2.1" -sphinx-autoapi = "2.1.1" +sphinx-autoapi = "3.0.0" sphinx-copybutton = "0.5.2" [tool.poetry.extras] diff --git a/requirements.txt b/requirements.txt index 5e89ac1b..8ed5add0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ # Production POT==0.9.0 arch==5.5.0 -cvxpy==1.3.1 +#cvxpy==1.3.1 cython==0.29.28 dash==2.10.2 jupyter-dash>=0.2.0, <1.0.0 @@ -14,7 +14,7 @@ numpy==1.23.5 pandas==2.0.0 pmdarima==2.0.3 protobuf>=3.20.3 -pyvinecopulib==0.5.5 +pyvinecopulib==0.6.5 requests_html==0.10.0 scikit-learn==1.1.3 scipy>=1.2.0, <2.0.0 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index ef34907e..00000000 --- a/setup.cfg +++ /dev/null @@ -1,80 +0,0 @@ -[metadata] -name = arbitragelab -version = 0.9.1 -author = Hudson and Thames Quantitative Research -author_email = opensource@hudsonthames.org -licence = BSD 3-Clause License -licence-file = LICENSE.txt -description = ArbitrageLab is a collection of algorithms from the best academic journals and graduate-level textbooks, which focuses on the branch of statistical arbitrage known as pairs trading. We have extended the implementations to include the latest methods that trade a portfolio of n-assets (mean-reverting portfolios). -long_description = file: README.md -long_description_content_type = text/markdown -platform = any -url = https://www.hudsonthames.org/ -project_urls = - Documentation = https://hudson-and-thames-arbitragelab.readthedocs-hosted.com/en/latest/index.html - Bug Reports = https://github.com/hudson-and-thames/arbitragelab/issues - Source = https://github.com/hudson-and-thames/arbitragelab - Blog = https://hudsonthames.org/blog/ - Apprenticeship Program = https://hudsonthames.org/apprenticeship-program/ -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - Intended Audience :: Education - Intended Audience :: Science/Research - Intended Audience :: Financial and Insurance Industry - License :: OSI Approved :: BSD License - Operating System :: OS Independent - Programming Language :: Python :: 3.8 - Topic :: Scientific/Engineering - Topic :: Scientific/Engineering :: Artificial Intelligence - Topic :: Office/Business :: Financial :: Investment -keywords = - arbitrage - finance - investment - education - trading - -[options] -include_package_data = True -packages = find: -python_requires = - ~=3.8 -setup_requires = - setuptools -install_requires = - POT==0.9.1 - arch==5.5.0 - cvxpy==1.3.1 - cython==0.29.28 - dash==2.10.2 - jupyter-dash>=0.2.0, <1.0.0 - keras==2.12.0 - lxml>=4.9.1 - matplotlib==3.7.1 - mpmath==1.2.1 - networkx>=2.2, <2.6 - numpy==1.23.5 - pandas==2.0.0 - pmdarima==2.0.3 - protobuf>=3.20.3 - pyvinecopulib==0.5.5 - requests_html==0.10.0 - scikit-learn==1.1.3 - scipy>=1.2.0, <2.0.0 - scs==3.2.0 - seaborn==0.12.2 - statsmodels==0.14.0 - tensorflow-macos==2.12.0; sys_platform == 'darwin' and platform_machine == 'arm64' - tensorflow==2.12.0; sys_platform != 'darwin' or platform_machine != 'arm64' - werkzeug==2.2.3 - yahoo-fin==0.8.9.1 - yfinance==0.2.24 - -[options.packages.find] -package_dir = - arbitragelab -exclude = - contrib - docs - tests diff --git a/setup.py b/setup.py deleted file mode 100644 index 41c16ce9..00000000 --- a/setup.py +++ /dev/null @@ -1,21 +0,0 @@ -# Always prefer setuptools over distutils -from setuptools import setup - -setup() - -# ---------------------------------------------------------------------------------- - -# Pull new commits -# Bump version -# Update Changelog release -# Update version in docs cfg and library setup.cfg -# Make sure you double check pushing all changes to git: git push - -# Tagging -# git tag [1.4.0] -# git push origin [1.4.0] -# On Github, go to tags and use the GUI to push a Release. - -# Create package -# python setup.py bdist_wheel -# twine upload dist/* (This is official repo) diff --git a/tests/test_copulas.py b/tests/test_copulas.py index 1ff5b081..a6e28bda 100644 --- a/tests/test_copulas.py +++ b/tests/test_copulas.py @@ -1,7 +1,8 @@ """ Unit tests for copula functions. """ -# pylint: disable = invalid-name, protected-access, too-many-locals, unexpected-keyword-arg, too-many-public-methods +# pylint: disable=invalid-name, protected-access, too-many-locals, unexpected-keyword-arg +# pylint: disable=too-many-public-methods, unnecessary-lambda-assignment import os import unittest diff --git a/tests/test_neural_networks.py b/tests/test_neural_networks.py index b5b7c8bd..6eb4368c 100644 --- a/tests/test_neural_networks.py +++ b/tests/test_neural_networks.py @@ -5,7 +5,7 @@ import unittest import numpy as np import tensorflow as tf -from keras.engine.training import Model +from keras.models import Model from keras.callbacks import History from sklearn.model_selection import train_test_split from sklearn.datasets import make_regression @@ -29,9 +29,9 @@ def setUp(self): np.random.seed(seed_value) tf.random.set_seed(seed_value) - session_conf = tf.compat.v1.ConfigProto(intra_op_parallelism_threads=1, inter_op_parallelism_threads=1) - sess = tf.compat.v1.Session(graph=tf.compat.v1.get_default_graph(), config=session_conf) - tf.compat.v1.keras.backend.set_session(sess) + #session_conf = tf.compat.v1.ConfigProto(intra_op_parallelism_threads=1, inter_op_parallelism_threads=1) + #sess = tf.compat.v1.Session(graph=tf.compat.v1.get_default_graph(), config=session_conf) + #tf.compat.v1.keras.backend.set_session(sess) self.seed_value = seed_value diff --git a/tests/test_optics_dbscan_pairs_clustering.py b/tests/test_optics_dbscan_pairs_clustering.py index 9cd8ac91..deadf9e9 100644 --- a/tests/test_optics_dbscan_pairs_clustering.py +++ b/tests/test_optics_dbscan_pairs_clustering.py @@ -139,10 +139,12 @@ def test_plotting_methods(self): self.assertTrue(isinstance(knee_plot_pyplot_obj, Axes)) # Test 2d cluster plot return object. + self.pair_selector.dimensionality_reduction_by_components(2) twod_pyplot_obj = self.pair_selector.plot_clustering_info(n_dimensions=2) self.assertTrue(isinstance(twod_pyplot_obj, Axes)) # Test 3d cluster plot return object. + self.pair_selector.dimensionality_reduction_by_components(3) threed_pyplot_obj = self.pair_selector.plot_clustering_info(n_dimensions=3) self.assertTrue(isinstance(threed_pyplot_obj, Axes)) diff --git a/tests/test_regime_switching_arbitrage_rule.py b/tests/test_regime_switching_arbitrage_rule.py index 337af4e5..77495178 100644 --- a/tests/test_regime_switching_arbitrage_rule.py +++ b/tests/test_regime_switching_arbitrage_rule.py @@ -2,6 +2,7 @@ Tests functions from Regime Switching Arbitrage Rule module. """ # pylint: disable=invalid-name +# pylint: disable=unnecessary-lambda-assignment import unittest import os @@ -26,8 +27,7 @@ def setUp(self): self.path = project_path + '/test_data/CL=F_NG=F_data.csv' data = pd.read_csv(self.path) data = data.set_index('Date') - Ratt = data["NG=F"]/data["CL=F"] - + Ratt = data["NG=F"] / data["CL=F"] self.Ratts = Ratt.values, Ratt, pd.DataFrame(Ratt) @@ -37,7 +37,7 @@ def test_signal(self): """ # Creating an object of class - test = RegimeSwitchingArbitrageRule(delta = 1.5, rho = 0.6) + test = RegimeSwitchingArbitrageRule(delta=1.5, rho=0.6) # Setting window size window_size = 60 @@ -97,9 +97,9 @@ def test_change(self): window_size = 60 # Changing rules in the high regime - ol_rule = lambda Xt, mu, delta, sigma: Xt <= mu - delta*sigma + ol_rule = lambda Xt, mu, delta, sigma: Xt <= mu - delta * sigma cl_rule = lambda Xt, mu, delta, sigma: Xt >= mu - os_rule = lambda Xt, mu, delta, sigma: Xt >= mu + delta*sigma + os_rule = lambda Xt, mu, delta, sigma: Xt >= mu + delta * sigma cs_rule = lambda Xt, mu, delta, sigma: Xt <= mu test.change_strategy("High", "Long", "Open", ol_rule) @@ -114,9 +114,9 @@ def test_change(self): self.assertEqual(test.strategy["High"]["Short"]["Close"], cs_rule) # Changing rules in the low regime - ol_rule = lambda Xt, mu, delta, sigma, prob: Xt <= mu - delta*sigma and prob >= 0.7 + ol_rule = lambda Xt, mu, delta, sigma, prob: Xt <= mu - delta * sigma and prob >= 0.7 cl_rule = lambda Xt, mu, delta, sigma: Xt >= mu - os_rule = lambda Xt, mu, delta, sigma, prob, rho: Xt >= mu + delta*sigma and prob >= rho + os_rule = lambda Xt, mu, delta, sigma, prob, rho: Xt >= mu + delta * sigma and prob >= rho cs_rule = lambda Xt, mu, delta, sigma: Xt <= mu test.change_strategy("Low", "Long", "Open", ol_rule) @@ -144,5 +144,5 @@ def test_change(self): # Testing the exception with self.assertRaises(Exception): - ol_rule = lambda Xt, mu, delta, sigma, error: Xt <= mu - delta*sigma*error + ol_rule = lambda Xt, mu, delta, sigma, error: Xt <= mu - delta * sigma * error test.change_strategy("High", "Long", "Open", ol_rule) diff --git a/tests/test_spread_modeling_helper.py b/tests/test_spread_modeling_helper.py index 5a741fa7..c19e72b8 100644 --- a/tests/test_spread_modeling_helper.py +++ b/tests/test_spread_modeling_helper.py @@ -26,10 +26,6 @@ def setUp(self): np.random.seed(seed_value) tf.random.set_seed(seed_value) - session_conf = tf.compat.v1.ConfigProto(intra_op_parallelism_threads=1, inter_op_parallelism_threads=1) - sess = tf.compat.v1.Session(graph=tf.compat.v1.get_default_graph(), config=session_conf) - tf.compat.v1.keras.backend.set_session(sess) - # Collect all contract price data. project_path = os.path.dirname(__file__) diff --git a/tests/test_trading_copula_strategy_mpi.py b/tests/test_trading_copula_strategy_mpi.py index fa0d9bf4..cb00e2f7 100644 --- a/tests/test_trading_copula_strategy_mpi.py +++ b/tests/test_trading_copula_strategy_mpi.py @@ -2,7 +2,7 @@ Unit tests for copula strategy using mispricing index (MPI). """ -# pylint: disable = invalid-name, protected-access +# pylint: disable=invalid-name, protected-access import os import unittest @@ -324,9 +324,9 @@ def test_get_position_and_reset_flag_or_and(): (-1, False, [-1, 2]), (-1, False, [-1, 1]), (1, False, [1, 2]), (1, False, [1, 1]), (-1, False, [-1, 1]), (-1, False, [-1, 1])] # Check matching with expecteation - np.testing.assert_array_equal(results_1, expected) + np.testing.assert_array_equal(np.array(results_1, dtype=object), np.array(expected, dtype=object)) # Check results are indep of open_based_on conditions - np.testing.assert_array_equal(results_1, results_2) + np.testing.assert_array_equal(np.array(results_1, dtype=object), np.array(results_2, dtype=object)) def test_cur_flag_and_position_or_and(self): """ @@ -486,9 +486,9 @@ def test_get_position_and_reset_flag_and_or(): (1, False, [-1, 2]), (1, False, [-1, 1]), (-1, False, [1, 2]), (-1, False, [1, 1]), (0, True, [0, 0]), (0, True, [0, 0]), (-1, False, [-1, 2])] # Check matching with expecteation - np.testing.assert_array_equal(results_1, expected) + np.testing.assert_array_equal(np.array(results_1, dtype=object), np.array(expected, dtype=object)) # Check results are indep of open_based_on conditions - np.testing.assert_array_equal(results_1, results_2) + np.testing.assert_array_equal(np.array(results_1, dtype=object), np.array(results_2, dtype=object)) def test_cur_flag_and_position_and_or(self): """ @@ -651,9 +651,9 @@ def test_get_position_and_reset_flag_and_and(): (1, False, [-1, 2]), (1, False, [-1, 1]), (-1, False, [1, 2]), (-1, False, [1, 1]), (-1, False, [-1, 1]), (-1, False, [-1, 1]), (-1, False, [-1, 2])] # Check matching with expecteation - np.testing.assert_array_equal(results_1, expected) + np.testing.assert_array_equal(np.array(results_1, dtype=object), np.array(expected, dtype=object)) # Check results are indep of open_based_on conditions - np.testing.assert_array_equal(results_1, results_2) + np.testing.assert_array_equal(np.array(results_1, dtype=object), np.array(results_2, dtype=object)) def test_cur_flag_and_position_and_and(self): """ From c0ea13ec3125d3fa4e7d856af7e67c6600c9b769 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Sun, 21 Apr 2024 17:42:55 +0200 Subject: [PATCH 24/62] add new versions in python-tests.yaml --- .github/workflows/python-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index a85fa9b0..978a4722 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -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 From 53274f3c437fe50ef2dc0e4d6cf1f3f7f395a7c9 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Sun, 21 Apr 2024 17:44:52 +0200 Subject: [PATCH 25/62] check version 3.8, 3.9 --- .github/workflows/python-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 978a4722..524005e1 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9, 3.10, 3.11, 3.12] # Add versions as needed + python-version: [3.8, 3.9] # Add versions as needed steps: - name: Checkout code From 0343912b9ac5e32e82741b3a8885f839b92de2c8 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Sun, 21 Apr 2024 17:46:01 +0200 Subject: [PATCH 26/62] check version 3.8, 3.9, 3.10 --- .github/workflows/python-tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 524005e1..c73a6808 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9] # Add versions as needed + python-version: [3.8, 3.9, 3.10] # Add versions as needed steps: - name: Checkout code @@ -48,7 +48,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8] # Add versions as needed + python-version: [3.8, 3.9, 3.10] # Add versions as needed steps: - name: Checkout code From b0bda468a8eea9c953deeb72015db5ed02a6d4f2 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Sun, 21 Apr 2024 17:49:44 +0200 Subject: [PATCH 27/62] fix python 3.10 workflow execution --- .github/workflows/python-tests.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index c73a6808..7005941c 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9, 3.10] # Add versions as needed + python-version: ['3.8', '3.9', '3.10'] # Add versions as needed steps: - name: Checkout code @@ -26,6 +26,7 @@ jobs: - name: Install Poetry run: | + pip install --upgrade pip pip install poetry @@ -48,7 +49,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9, 3.10] # Add versions as needed + python-version: ['3.8', '3.9', '3.10'] # Add versions as needed steps: - name: Checkout code @@ -61,6 +62,7 @@ jobs: - name: Install Poetry run: | + pip install --upgrade pip pip install poetry - name: Install dependencies From 9f63bdb80fe522e6c7ce7af03f31a9c176b11a97 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Sun, 21 Apr 2024 18:24:03 +0200 Subject: [PATCH 28/62] add 3.11, 3.12 python versions in test workflow --- .github/workflows/python-tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 7005941c..b022ec75 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8', '3.9', '3.10'] # Add versions as needed + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] # Add versions as needed steps: - name: Checkout code @@ -49,7 +49,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8', '3.9', '3.10'] # Add versions as needed + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] # Add versions as needed steps: - name: Checkout code From bda18ee7b6f99731d8cea3c55e9b5cd0d67e409f Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Sun, 21 Apr 2024 18:42:28 +0200 Subject: [PATCH 29/62] reintroducing session setting in tensorflow --- tests/test_neural_networks.py | 8 ++++---- tests/test_spread_modeling_helper.py | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test_neural_networks.py b/tests/test_neural_networks.py index 6eb4368c..2fbc6c01 100644 --- a/tests/test_neural_networks.py +++ b/tests/test_neural_networks.py @@ -9,6 +9,7 @@ from keras.callbacks import History from sklearn.model_selection import train_test_split from sklearn.datasets import make_regression +from tensorflow.python.keras import backend from arbitragelab.ml_approach.neural_networks import MultiLayerPerceptron, RecurrentNeuralNetwork, PiSigmaNeuralNetwork @@ -28,10 +29,9 @@ def setUp(self): seed_value = 0 np.random.seed(seed_value) tf.random.set_seed(seed_value) - - #session_conf = tf.compat.v1.ConfigProto(intra_op_parallelism_threads=1, inter_op_parallelism_threads=1) - #sess = tf.compat.v1.Session(graph=tf.compat.v1.get_default_graph(), config=session_conf) - #tf.compat.v1.keras.backend.set_session(sess) + session_conf = tf.compat.v1.ConfigProto(intra_op_parallelism_threads=1, inter_op_parallelism_threads=1) + sess = tf.compat.v1.Session(graph=tf.compat.v1.get_default_graph(), config=session_conf) + backend.set_session(sess) self.seed_value = seed_value diff --git a/tests/test_spread_modeling_helper.py b/tests/test_spread_modeling_helper.py index c19e72b8..d7791c55 100644 --- a/tests/test_spread_modeling_helper.py +++ b/tests/test_spread_modeling_helper.py @@ -6,7 +6,7 @@ import numpy as np import pandas as pd import tensorflow as tf - +from tensorflow.python.keras import backend from arbitragelab.cointegration_approach.johansen import JohansenPortfolio from arbitragelab.ml_approach.regressor_committee import RegressorCommittee from arbitragelab.util.spread_modeling_helper import SpreadModelingHelper @@ -26,6 +26,10 @@ def setUp(self): np.random.seed(seed_value) tf.random.set_seed(seed_value) + session_conf = tf.compat.v1.ConfigProto(intra_op_parallelism_threads=1, inter_op_parallelism_threads=1) + sess = tf.compat.v1.Session(graph=tf.compat.v1.get_default_graph(), config=session_conf) + backend.set_session(sess) + # Collect all contract price data. project_path = os.path.dirname(__file__) From f3640e61efde476ba1158a398c126d4082528cc3 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Sun, 21 Apr 2024 18:58:52 +0200 Subject: [PATCH 30/62] suppress warnings --- tests/test_neural_networks.py | 4 +--- tests/test_spread_modeling_helper.py | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_neural_networks.py b/tests/test_neural_networks.py index 2fbc6c01..0ec49261 100644 --- a/tests/test_neural_networks.py +++ b/tests/test_neural_networks.py @@ -1,6 +1,7 @@ """ Tests Spread Modeling Neural Network Classes. """ +# pylint: disable=unbalanced-tuple-unpacking, no-name-in-module import unittest import numpy as np @@ -10,11 +11,8 @@ from sklearn.model_selection import train_test_split from sklearn.datasets import make_regression from tensorflow.python.keras import backend - from arbitragelab.ml_approach.neural_networks import MultiLayerPerceptron, RecurrentNeuralNetwork, PiSigmaNeuralNetwork -# pylint: disable=unbalanced-tuple-unpacking - class TestNeuralNetworks(unittest.TestCase): """ Test Neural Network Implementations. diff --git a/tests/test_spread_modeling_helper.py b/tests/test_spread_modeling_helper.py index d7791c55..3b7a5109 100644 --- a/tests/test_spread_modeling_helper.py +++ b/tests/test_spread_modeling_helper.py @@ -1,6 +1,8 @@ """ Tests Spread Modeling Helper Class. """ +# pylint: disable=no-name-in-module + import os import unittest import numpy as np From f4cb322e6e748581be14aa21427b94d4d075d819 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Sun, 21 Apr 2024 19:28:30 +0200 Subject: [PATCH 31/62] reinstate db_scan test and instantiate TSNE with parameter 'init="random"' to extend compatibility across multiple python versions --- arbitragelab/ml_approach/optics_dbscan_pairs_clustering.py | 2 +- tests/test_optics_dbscan_pairs_clustering.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/arbitragelab/ml_approach/optics_dbscan_pairs_clustering.py b/arbitragelab/ml_approach/optics_dbscan_pairs_clustering.py index 2d298157..0f3d824c 100644 --- a/arbitragelab/ml_approach/optics_dbscan_pairs_clustering.py +++ b/arbitragelab/ml_approach/optics_dbscan_pairs_clustering.py @@ -168,7 +168,7 @@ def plot_clustering_info(self, n_dimensions: int = 2, method: str = "", fig = plt.figure(facecolor='white', figsize=figsize) - tsne = TSNE(n_components=n_dimensions) + tsne = TSNE(n_components=n_dimensions, init='random') tsne_fv = pd.DataFrame(tsne.fit_transform(self.feature_vector), index=self.feature_vector.index) diff --git a/tests/test_optics_dbscan_pairs_clustering.py b/tests/test_optics_dbscan_pairs_clustering.py index deadf9e9..9cd8ac91 100644 --- a/tests/test_optics_dbscan_pairs_clustering.py +++ b/tests/test_optics_dbscan_pairs_clustering.py @@ -139,12 +139,10 @@ def test_plotting_methods(self): self.assertTrue(isinstance(knee_plot_pyplot_obj, Axes)) # Test 2d cluster plot return object. - self.pair_selector.dimensionality_reduction_by_components(2) twod_pyplot_obj = self.pair_selector.plot_clustering_info(n_dimensions=2) self.assertTrue(isinstance(twod_pyplot_obj, Axes)) # Test 3d cluster plot return object. - self.pair_selector.dimensionality_reduction_by_components(3) threed_pyplot_obj = self.pair_selector.plot_clustering_info(n_dimensions=3) self.assertTrue(isinstance(threed_pyplot_obj, Axes)) From 5b4f6ec3a616f90b85281475b3034242bd3f2437 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Wed, 24 Apr 2024 18:45:20 +0200 Subject: [PATCH 32/62] import mode changed --- arbitragelab/__init__.py | 29 +++++++++++++------------ docs/source/visualization/tearsheet.rst | 4 ++++ pyproject.toml | 6 ++--- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/arbitragelab/__init__.py b/arbitragelab/__init__.py index 8a54f99a..e5a0f45d 100644 --- a/arbitragelab/__init__.py +++ b/arbitragelab/__init__.py @@ -2,18 +2,19 @@ ArbitrageLab helps portfolio managers and traders who want to leverage the power of Statistical Arbitrage by providing reproducible, interpretable, and easy to use tools. """ +# pylint: disable=consider-using-from-import -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 +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 diff --git a/docs/source/visualization/tearsheet.rst b/docs/source/visualization/tearsheet.rst index f643b390..c51abe80 100644 --- a/docs/source/visualization/tearsheet.rst +++ b/docs/source/visualization/tearsheet.rst @@ -88,11 +88,14 @@ Implementation ************** .. automodule:: arbitragelab.tearsheet.tearsheet + :noindex: .. autoclass:: TearSheet + :noindex: :members: __init__ .. automethod:: TearSheet.cointegration_tearsheet + :noindex: Code Example ************ @@ -172,6 +175,7 @@ Implementation ************** .. automethod:: TearSheet.ou_tearsheet + :noindex: Code Example ************ diff --git a/pyproject.toml b/pyproject.toml index 63ae200d..3f0f3f21 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -121,9 +121,9 @@ pytest-cov = "3.0.0" jinja2 = "<3.1" docutils = "0.18.1" hudsonthames-sphinx-theme = "0.1.5" -myst-parser = "2.0.0" -sphinx-rtd-theme = "1.2.0" -sphinx-tabs = "3.4.1" +myst-parser = "2.0.0" #3.0.0 +sphinx-rtd-theme = "2.0.0" #2.0.0 +sphinx-tabs = "3.4.1" #3.4.5 sphinx = "6.2.1" sphinx-autoapi = "3.0.0" sphinx-copybutton = "0.5.2" From c0b4e4d1d34a5ca770b0e2bc71fe867a14dc9aaf Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Wed, 24 Apr 2024 18:55:37 +0200 Subject: [PATCH 33/62] update readthedocs.yml --- .readthedocs.yml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index d2a0bb56..9d3d2685 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -2,23 +2,24 @@ # Read the Docs configuration file # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details -# Required version: 2 build: - os: ubuntu-22.04 + os: "ubuntu-22.04" tools: python: "3.8" + jobs: + post_create_environment: + # Install poetry + # https://python-poetry.org/docs/#installing-manually + - pip install poetry + post_install: + # Install dependencies with 'docs' dependency group + # https://python-poetry.org/docs/managing-dependencies/#dependency-groups + # VIRTUAL_ENV needs to be set manually for now. + # See https://github.com/readthedocs/readthedocs.org/pull/11152/ + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --only doc -# Build documentation in the docs/ directory with Sphinx sphinx: - configuration: docs/source/conf.py - -# Optionally build your docs in additional formats such as PDF -formats: [] - -# Optionally set the version of Python and requirements required to build your docs -python: - install: - - requirements: docs/source/requirements.txt + configuration: docs/conf.py From 95bc4567bedfdabdece6989ecb42e284aab777a5 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Wed, 24 Apr 2024 18:59:48 +0200 Subject: [PATCH 34/62] fix configuration docs path --- .readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 9d3d2685..9781cbc5 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -21,5 +21,5 @@ build: - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --only doc sphinx: - configuration: docs/conf.py + configuration: docs/source/conf.py From 873dde5a9774919e946552ac0ee3a100e60efbca Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Wed, 24 Apr 2024 19:04:03 +0200 Subject: [PATCH 35/62] add releases to docs dependencies --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3f0f3f21..472985ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,11 +113,11 @@ build-backend = "poetry.core.masonry.api" coverage = "7.2.7" pylint = "3.1.0" pytest = "7.3.1" -releases = "1.6.3" pyarmor = "8.5.2" pytest-cov = "3.0.0" [tool.poetry.group.doc.dependencies] +releases = "1.6.3" jinja2 = "<3.1" docutils = "0.18.1" hudsonthames-sphinx-theme = "0.1.5" From d30c3842bee973cd20028ae3f0318c0e73d3fc12 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Wed, 24 Apr 2024 19:07:24 +0200 Subject: [PATCH 36/62] add six to docs dependencies --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 472985ea..eb5c42d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -127,6 +127,7 @@ sphinx-tabs = "3.4.1" #3.4.5 sphinx = "6.2.1" sphinx-autoapi = "3.0.0" sphinx-copybutton = "0.5.2" +six = "*" [tool.poetry.extras] docs = ["sphinx", "sphinx-rtd-theme", "sphinx-tabs", "sphinx-autoapi", "sphinx-copybutton", "myst-parser", "hudsonthames-sphinx-theme", "docutils", "jinja2", "releases"] \ No newline at end of file From c2558515866493b57e47fc5a752b651bb8f7f213 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 25 Apr 2024 12:00:22 +0200 Subject: [PATCH 37/62] remove requirements in txt form and bumpversion.cfg file --- .bumpversion.cfg | 9 -------- docs/source/requirements.txt | 45 ------------------------------------ requirements.txt | 39 ------------------------------- 3 files changed, 93 deletions(-) delete mode 100644 .bumpversion.cfg delete mode 100644 docs/source/requirements.txt delete mode 100644 requirements.txt diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index aced4326..00000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,9 +0,0 @@ -[bumpversion] -current_version = 0.9.1 -commit = False -tag = False -tag_name = {new_version} - -[bumpversion:file:setup.cfg] - -[bumpversion:file:docs/source/conf.py] diff --git a/docs/source/requirements.txt b/docs/source/requirements.txt deleted file mode 100644 index 1aea1fb9..00000000 --- a/docs/source/requirements.txt +++ /dev/null @@ -1,45 +0,0 @@ -# Production -POT==0.9.0 -analytics-python>=1.2.7, <2.0.0 -arch==5.5.0 -cvxpy==1.3.1 -cython==0.29.28 -dash==2.10.2 -getmac>=0.8.0, <1.0.0 -jupyter-dash>=0.2.0, <1.0.0 -keras==2.12.0 -lxml>=4.9.1 -matplotlib==3.7.1 -mpmath==1.2.1 -networkx>=2.2, <2.6 -numpy==1.23.5 -pandas==2.0.0 -pmdarima==2.0.3 -protobuf>=3.20.3 -pyvinecopulib==0.5.5 -requests_html==0.10.0 -scikit-learn==1.1.3 -scipy>=1.2.0, <2.0.0 -scs==3.2.0 -seaborn==0.12.2 -statsmodels==0.14.0 -tensorflow-macos==2.12.0; sys_platform == 'darwin' and platform_machine == 'arm64' -tensorflow==2.12.0; sys_platform != 'darwin' or platform_machine != 'arm64' -werkzeug==2.2.3 -yahoo-fin==0.8.9.1 -yfinance==0.2.24 - -# Develop -coverage==7.2.7 -docutils==0.18.1 # Docs -hudsonthames-sphinx-theme==0.1.5 # Docs -jinja2<3.1 # Docs -pyarmor==8.2.5 # Encryption -pylint==2.17.4 -pytest==7.3.1 -releases==1.6.3 # Docs -sphinx-copybutton==0.5.2 # docs -sphinx-rtd-theme==1.2.2 # docs -sphinx-autoapi==2.1.1 -sphinx-tabs==3.4.1 -myst-parser==2.0.0 # Docs diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 8ed5add0..00000000 --- a/requirements.txt +++ /dev/null @@ -1,39 +0,0 @@ -# Production -POT==0.9.0 -arch==5.5.0 -#cvxpy==1.3.1 -cython==0.29.28 -dash==2.10.2 -jupyter-dash>=0.2.0, <1.0.0 -keras==2.12.0 -lxml>=4.9.1 -matplotlib==3.7.1 -mpmath==1.2.1 -networkx>=2.2, <2.6 -numpy==1.23.5 -pandas==2.0.0 -pmdarima==2.0.3 -protobuf>=3.20.3 -pyvinecopulib==0.6.5 -requests_html==0.10.0 -scikit-learn==1.1.3 -scipy>=1.2.0, <2.0.0 -scs==3.2.0 -seaborn==0.12.2 -statsmodels==0.14.0 -tensorflow-macos==2.12.0; sys_platform == 'darwin' and platform_machine == 'arm64' -tensorflow==2.12.0; sys_platform != 'darwin' or platform_machine != 'arm64' -werkzeug==2.2.3 -yahoo-fin==0.8.9.1 -yfinance==0.2.37 - -# Develop -coverage==7.2.7 -docutils==0.16 # Docs -hudsonthames-sphinx-theme==0.1.5 # Docs -jinja2<3.1 # Docs -pylint==2.6.0 -pytest==7.3.1 -releases==1.6.3 # Docs -sphinx-rtd-theme==0.5.2 # Docs -sphinx==3.4.3 # Docs From 6d6230df83ae6437e80f3cf20d357c20b9dab0ed Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 25 Apr 2024 12:23:57 +0200 Subject: [PATCH 38/62] reinstate bumpversion.cfg file for poetry configuration --- .bumpversion.cfg | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .bumpversion.cfg diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 00000000..9b6b4b2f --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,12 @@ +[bumpversion] +current_version = 0.9.1 +commit = True +tag = True + +[bumpversion:file:pyproject.toml] +search = version = "{current_version}" +replace = version = "{new_version}" + +[bumpversion:file:docs/source/conf.py] +search = release = "{current_version}" +replace = release = "{new_version}" \ No newline at end of file From 016e15d5a9719af37e32ffeb774d0f3ea9cfe464 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 25 Apr 2024 12:26:23 +0200 Subject: [PATCH 39/62] =?UTF-8?q?Bump=20version:=200.9.1=20=E2=86=92=200.9?= =?UTF-8?q?.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 4 ++-- docs/source/conf.py | 2 +- pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 9b6b4b2f..1451a31f 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.9.1 +current_version = 0.9.2 commit = True tag = True @@ -9,4 +9,4 @@ replace = version = "{new_version}" [bumpversion:file:docs/source/conf.py] search = release = "{current_version}" -replace = release = "{new_version}" \ No newline at end of file +replace = release = "{new_version}" diff --git a/docs/source/conf.py b/docs/source/conf.py index c67fef22..b3b036ce 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -21,7 +21,7 @@ author = 'Hudson & Thames Quantitative Research' # The full version, including alpha/beta/rc tags -release = '0.9.1' +release = "0.9.2" # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index eb5c42d5..fe09b081 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "arbitragelab" -version = "0.9.1" +version = "0.9.2" description = "ArbitrageLab is a collection of algorithms from the best academic journals and graduate-level textbooks, which focuses on the branch of statistical arbitrage known as pairs trading. We have extended the implementations to include the latest methods that trade a portfolio of n-assets (mean-reverting portfolios)." authors = ["Hudson and Thames Quantitative Research "] license = "BSD-3-Clause" From f9f7ba75bec2c9140f5c0ef8272b30786a4d4c05 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 25 Apr 2024 12:28:34 +0200 Subject: [PATCH 40/62] reinstate bumpversion.cfg file for poetry configuration --- docs/source/conf.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index b3b036ce..e6a8e6af 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -21,7 +21,7 @@ author = 'Hudson & Thames Quantitative Research' # The full version, including alpha/beta/rc tags -release = "0.9.2" +release = "0.9.1" # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index fe09b081..eb5c42d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "arbitragelab" -version = "0.9.2" +version = "0.9.1" description = "ArbitrageLab is a collection of algorithms from the best academic journals and graduate-level textbooks, which focuses on the branch of statistical arbitrage known as pairs trading. We have extended the implementations to include the latest methods that trade a portfolio of n-assets (mean-reverting portfolios)." authors = ["Hudson and Thames Quantitative Research "] license = "BSD-3-Clause" From 7307955aa159097b8d602a695ec9108456ca740b Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 25 Apr 2024 12:32:30 +0200 Subject: [PATCH 41/62] fix version --- .bumpversion.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 1451a31f..441e03b3 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.9.2 +current_version = 0.9.1 commit = True tag = True From 4292bfba206e62f555dcde4ac94d5ca562f31639 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 25 Apr 2024 13:35:28 +0200 Subject: [PATCH 42/62] git revert tag --- docs/source/conf.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index b3b036ce..e6a8e6af 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -21,7 +21,7 @@ author = 'Hudson & Thames Quantitative Research' # The full version, including alpha/beta/rc tags -release = "0.9.2" +release = "0.9.1" # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index fe09b081..eb5c42d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "arbitragelab" -version = "0.9.2" +version = "0.9.1" description = "ArbitrageLab is a collection of algorithms from the best academic journals and graduate-level textbooks, which focuses on the branch of statistical arbitrage known as pairs trading. We have extended the implementations to include the latest methods that trade a portfolio of n-assets (mean-reverting portfolios)." authors = ["Hudson and Thames Quantitative Research "] license = "BSD-3-Clause" From 497ebb7620e549203738a07c7c2563ddb24f3ff3 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 25 Apr 2024 13:48:46 +0200 Subject: [PATCH 43/62] git revert tag --- .bumpversion.cfg | 2 +- docs/source/conf.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 441e03b3..51f957ec 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.9.1 +current_version = 0.9.3 commit = True tag = True diff --git a/docs/source/conf.py b/docs/source/conf.py index e6a8e6af..869c57ad 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -21,7 +21,7 @@ author = 'Hudson & Thames Quantitative Research' # The full version, including alpha/beta/rc tags -release = "0.9.1" +release = "0.9.3" # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index eb5c42d5..f672b2ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "arbitragelab" -version = "0.9.1" +version = "0.9.3" description = "ArbitrageLab is a collection of algorithms from the best academic journals and graduate-level textbooks, which focuses on the branch of statistical arbitrage known as pairs trading. We have extended the implementations to include the latest methods that trade a portfolio of n-assets (mean-reverting portfolios)." authors = ["Hudson and Thames Quantitative Research "] license = "BSD-3-Clause" From f7f5dd3605a80f07471e47c1a350c57b1e368118 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 25 Apr 2024 13:52:46 +0200 Subject: [PATCH 44/62] git revert tag --- .bumpversion.cfg | 2 +- docs/source/conf.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 51f957ec..441e03b3 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.9.3 +current_version = 0.9.1 commit = True tag = True diff --git a/docs/source/conf.py b/docs/source/conf.py index 869c57ad..e6a8e6af 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -21,7 +21,7 @@ author = 'Hudson & Thames Quantitative Research' # The full version, including alpha/beta/rc tags -release = "0.9.3" +release = "0.9.1" # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index f672b2ac..eb5c42d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "arbitragelab" -version = "0.9.3" +version = "0.9.1" description = "ArbitrageLab is a collection of algorithms from the best academic journals and graduate-level textbooks, which focuses on the branch of statistical arbitrage known as pairs trading. We have extended the implementations to include the latest methods that trade a portfolio of n-assets (mean-reverting portfolios)." authors = ["Hudson and Thames Quantitative Research "] license = "BSD-3-Clause" From 760be1acc510f1c1ebc33b60e7fe61447cba34be Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 25 Apr 2024 16:38:19 +0200 Subject: [PATCH 45/62] disable auto commit and tag bumpversion --- .bumpversion.cfg | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 441e03b3..883c7898 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,7 +1,8 @@ [bumpversion] current_version = 0.9.1 -commit = True -tag = True +commit = False +tag = False +tag_name = {new_version} [bumpversion:file:pyproject.toml] search = version = "{current_version}" From f261166c8fa4a41d992e32f30c1a392ae774cb70 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 25 Apr 2024 17:03:34 +0200 Subject: [PATCH 46/62] redefine dependencies to install fewer packages and speed up CI/CD --- .github/workflows/python-tests.yaml | 6 +++--- .readthedocs.yml | 2 +- pyproject.toml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index b022ec75..059fdf95 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -32,7 +32,7 @@ jobs: - name: Install dependencies run: | - poetry install + poetry install --without docs - name: Run Pylint run: | @@ -67,7 +67,7 @@ jobs: - name: Install dependencies run: | - poetry install + poetry install --without docs - name: Run tests with coverage run: | @@ -106,7 +106,7 @@ jobs: - name: Install requirements run: | - poetry install + poetry install --only docs - name: Build documentation run: | diff --git a/.readthedocs.yml b/.readthedocs.yml index 9781cbc5..9cf53657 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -18,7 +18,7 @@ build: # https://python-poetry.org/docs/managing-dependencies/#dependency-groups # VIRTUAL_ENV needs to be set manually for now. # See https://github.com/readthedocs/readthedocs.org/pull/11152/ - - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --only doc + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --only docs sphinx: configuration: docs/source/conf.py diff --git a/pyproject.toml b/pyproject.toml index eb5c42d5..7d486184 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -109,14 +109,14 @@ requires = ["poetry-core>=1.0"] build-backend = "poetry.core.masonry.api" -[tool.poetry.group.dev.dependencies] +[tool.poetry.group.tests.dependencies] coverage = "7.2.7" pylint = "3.1.0" pytest = "7.3.1" pyarmor = "8.5.2" pytest-cov = "3.0.0" -[tool.poetry.group.doc.dependencies] +[tool.poetry.group.docs.dependencies] releases = "1.6.3" jinja2 = "<3.1" docutils = "0.18.1" From 4f6d24136ce107e6800ed7c570a27e6860d00deb Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Thu, 25 Apr 2024 17:07:00 +0200 Subject: [PATCH 47/62] fix workflow dependency installation --- .github/workflows/python-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 059fdf95..9dd78293 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -106,7 +106,7 @@ jobs: - name: Install requirements run: | - poetry install --only docs + poetry install --without tests - name: Build documentation run: | From 782c3de34aa4f7073c0e6ad53ffd6bf767ec7368 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Fri, 26 Apr 2024 17:18:15 +0200 Subject: [PATCH 48/62] upload workflow to publish distribution on TestPypi before merging into main and on Pypi to release the final version --- .github/workflows/publish-final-dist.yaml | 38 ++++++++++++++++++++++ .github/workflows/publish-test-dist.yaml | 39 +++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 .github/workflows/publish-final-dist.yaml create mode 100644 .github/workflows/publish-test-dist.yaml diff --git a/.github/workflows/publish-final-dist.yaml b/.github/workflows/publish-final-dist.yaml new file mode 100644 index 00000000..d235facc --- /dev/null +++ b/.github/workflows/publish-final-dist.yaml @@ -0,0 +1,38 @@ +name: Publish Distribution to PyPI + +on: + pull_request: + branches: + - develop + paths: + - 'release/*' + +jobs: + build-and-publish-final-dist: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + + - name: Install Poetry + run: | + pip install poetry + + - name: Install dependencies + run: | + poetry install --no-dev + + - name: Build the package + run: | + poetry build + + - name: Publish to TestPyPI + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} + run: | + poetry publish diff --git a/.github/workflows/publish-test-dist.yaml b/.github/workflows/publish-test-dist.yaml new file mode 100644 index 00000000..4facb60f --- /dev/null +++ b/.github/workflows/publish-test-dist.yaml @@ -0,0 +1,39 @@ +name: Publish Distribution to TestPyPI + +on: + pull_request: + branches: + - develop + paths: + - 'release/*' + +jobs: + build-and-publish-test-dist: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + + - name: Install Poetry + run: | + pip install poetry + + - name: Install dependencies + run: | + poetry install --no-dev + + - name: Build the package + run: | + poetry build + + - name: Publish to TestPyPI + env: + POETRY_PYPI_TOKEN_TESTPYPI: ${{ secrets.TEST_PYPI_API_TOKEN }} + run: | + poetry config repositories.testpypi https://test.pypi.org/legacy/ + poetry publish -r testpypi From 1b5d3e16098168f8192ff1ea1b4c08f7669f5576 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Fri, 26 Apr 2024 17:19:37 +0200 Subject: [PATCH 49/62] fix branch to publish final distribution --- .github/workflows/publish-final-dist.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/publish-final-dist.yaml b/.github/workflows/publish-final-dist.yaml index d235facc..f2ec47e3 100644 --- a/.github/workflows/publish-final-dist.yaml +++ b/.github/workflows/publish-final-dist.yaml @@ -3,9 +3,7 @@ name: Publish Distribution to PyPI on: pull_request: branches: - - develop - paths: - - 'release/*' + - master jobs: build-and-publish-final-dist: From cfab545b668b36b36837c88693368794d775d927 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Fri, 26 Apr 2024 17:31:37 +0200 Subject: [PATCH 50/62] fix workflow dependencies installation --- .github/workflows/publish-final-dist.yaml | 2 +- .github/workflows/publish-test-dist.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-final-dist.yaml b/.github/workflows/publish-final-dist.yaml index f2ec47e3..8fe325c1 100644 --- a/.github/workflows/publish-final-dist.yaml +++ b/.github/workflows/publish-final-dist.yaml @@ -23,7 +23,7 @@ jobs: - name: Install dependencies run: | - poetry install --no-dev + poetry install --without docs tests - name: Build the package run: | diff --git a/.github/workflows/publish-test-dist.yaml b/.github/workflows/publish-test-dist.yaml index 4facb60f..0a74b979 100644 --- a/.github/workflows/publish-test-dist.yaml +++ b/.github/workflows/publish-test-dist.yaml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies run: | - poetry install --no-dev + poetry install --without docs tests - name: Build the package run: | From ca4dbbf5f1f7016307145926c653e8307f5a03d3 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Fri, 26 Apr 2024 18:30:09 +0200 Subject: [PATCH 51/62] resolve warning node js --- .github/workflows/python-tests.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 9dd78293..6976eaf5 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -17,10 +17,10 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -39,7 +39,7 @@ jobs: poetry run pylint arbitragelab tests --rcfile=.pylintrc --output-format=text --output=pylint-report.txt - name: Upload test results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pylint-report-${{ matrix.python-version }} path: pylint-report.txt @@ -53,10 +53,10 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -77,7 +77,7 @@ jobs: run: poetry run coverage html - name: Upload Coverage XML Report as Artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: coverage-html path: coverage.html @@ -93,10 +93,10 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -119,7 +119,7 @@ jobs: poetry run make doctest - name: Upload doctest results as an artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: doctest-results path: docs/build/doctest/output.txt From 023d4c739a60f62a2fdeaf34a57421e3c7aa43f5 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Fri, 26 Apr 2024 18:48:20 +0200 Subject: [PATCH 52/62] refactor readthedocs.yml --- .readthedocs.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 9cf53657..5df10a44 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,6 +1,5 @@ # .readthedocs.yml # Read the Docs configuration file -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details version: 2 @@ -11,13 +10,9 @@ build: jobs: post_create_environment: # Install poetry - # https://python-poetry.org/docs/#installing-manually - pip install poetry post_install: - # Install dependencies with 'docs' dependency group - # https://python-poetry.org/docs/managing-dependencies/#dependency-groups - # VIRTUAL_ENV needs to be set manually for now. - # See https://github.com/readthedocs/readthedocs.org/pull/11152/ + # Install dependencies - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --only docs sphinx: From dca5f1e0aff500e62bda63f3fb6ec7199a92be93 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Fri, 3 May 2024 21:48:43 +0200 Subject: [PATCH 53/62] code style optimization and upgrade action setups --- .github/workflows/publish-final-dist.yaml | 4 ++-- .github/workflows/publish-test-dist.yaml | 4 ++-- .github/workflows/python-tests.yaml | 6 +++--- pyproject.toml | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish-final-dist.yaml b/.github/workflows/publish-final-dist.yaml index 8fe325c1..92db233a 100644 --- a/.github/workflows/publish-final-dist.yaml +++ b/.github/workflows/publish-final-dist.yaml @@ -10,10 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: '3.8' diff --git a/.github/workflows/publish-test-dist.yaml b/.github/workflows/publish-test-dist.yaml index 0a74b979..922157b4 100644 --- a/.github/workflows/publish-test-dist.yaml +++ b/.github/workflows/publish-test-dist.yaml @@ -12,10 +12,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.8' diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 6976eaf5..3b731435 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -73,14 +73,14 @@ jobs: run: | poetry run pytest tests/ --cov=arbitragelab --cov-report=term --cov-branch --cov-config=.coveragerc - - name: Generate coverage XML report + - name: Generate coverage HTML report run: poetry run coverage html - - name: Upload Coverage XML Report as Artifact + - name: Upload Coverage HTML Report as Artifact uses: actions/upload-artifact@v4 with: name: coverage-html - path: coverage.html + path: build/coverage/html/index.html - name: Check coverage run: poetry run coverage report --fail-under=100 diff --git a/pyproject.toml b/pyproject.toml index 7d486184..4a15208f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ packages = [ { include = "arbitragelab" } ] -exclude = ["contrib", "docs", "tests"] +exclude = ["docs", "tests"] [tool.poetry.dependencies] python = "^3.8" @@ -130,4 +130,5 @@ sphinx-copybutton = "0.5.2" six = "*" [tool.poetry.extras] +tests = ["coverage", "pylint", "pytest", "pytest-cov", "pyarmor"] docs = ["sphinx", "sphinx-rtd-theme", "sphinx-tabs", "sphinx-autoapi", "sphinx-copybutton", "myst-parser", "hudsonthames-sphinx-theme", "docutils", "jinja2", "releases"] \ No newline at end of file From 912439af0eb52efe30b2ad2ae3a315717627d67e Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Fri, 3 May 2024 22:33:02 +0200 Subject: [PATCH 54/62] fix coverage workflow --- .github/workflows/python-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 3b731435..e7d03171 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -79,7 +79,7 @@ jobs: - name: Upload Coverage HTML Report as Artifact uses: actions/upload-artifact@v4 with: - name: coverage-html + name: coverage-html-${{ matrix.python-version }} path: build/coverage/html/index.html - name: Check coverage From a0347130a58365670a0ea6b23eefefc32b0931de Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Fri, 3 May 2024 23:35:54 +0200 Subject: [PATCH 55/62] remove comments --- .github/workflows/python-tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index e7d03171..a7819a07 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] # Add versions as needed + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - name: Checkout code @@ -49,7 +49,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] # Add versions as needed + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - name: Checkout code From 72e23410fd10399ebdde391b04e70d6258754b71 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Sat, 4 May 2024 13:10:21 +0200 Subject: [PATCH 56/62] change docs build (trial) --- .readthedocs.yml | 22 ++++++++++-------- docs/source/requirements.txt | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 docs/source/requirements.txt diff --git a/.readthedocs.yml b/.readthedocs.yml index 5df10a44..d2a0bb56 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,20 +1,24 @@ # .readthedocs.yml # Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details +# Required version: 2 build: - os: "ubuntu-22.04" + os: ubuntu-22.04 tools: python: "3.8" - jobs: - post_create_environment: - # Install poetry - - pip install poetry - post_install: - # Install dependencies - - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --only docs +# Build documentation in the docs/ directory with Sphinx sphinx: - configuration: docs/source/conf.py + configuration: docs/source/conf.py + +# Optionally build your docs in additional formats such as PDF +formats: [] + +# Optionally set the version of Python and requirements required to build your docs +python: + install: + - requirements: docs/source/requirements.txt diff --git a/docs/source/requirements.txt b/docs/source/requirements.txt new file mode 100644 index 00000000..ad13dad9 --- /dev/null +++ b/docs/source/requirements.txt @@ -0,0 +1,45 @@ +# Production +POT==0.9.0 +analytics-python>=1.2.7, <2.0.0 +arch==5.5.0 +cvxpy==1.3.1 +cython==0.29.28 +dash==2.10.2 +getmac>=0.8.0, <1.0.0 +jupyter-dash>=0.2.0, <1.0.0 +keras==2.12.0 +lxml>=4.9.1 +matplotlib==3.7.1 +mpmath==1.2.1 +networkx>=2.2, <2.6 +numpy==1.23.5 +pandas==2.0.0 +pmdarima==2.0.3 +protobuf>=3.20.3 +pyvinecopulib==0.5.5 +requests_html==0.10.0 +scikit-learn==1.1.3 +scipy>=1.2.0, <2.0.0 +scs==3.2.0 +seaborn==0.12.2 +statsmodels==0.14.0 +tensorflow-macos==2.12.0; sys_platform == 'darwin' and platform_machine == 'arm64' +tensorflow==2.12.0; sys_platform != 'darwin' or platform_machine != 'arm64' +werkzeug==2.2.3 +yahoo-fin==0.8.9.1 +yfinance==0.2.24 + +# Develop +coverage==7.2.7 +docutils==0.18.1 # Docs +hudsonthames-sphinx-theme==0.1.5 # Docs +jinja2<3.1 # Docs +pyarmor==8.2.5 # Encryption +pylint==2.17.4 +pytest==7.3.1 +releases==1.6.3 # Docs +sphinx-copybutton==0.5.2 # docs +sphinx-rtd-theme==1.2.2 # docs +sphinx-autoapi==2.1.1 +sphinx-tabs==3.4.1 +myst-parser==2.0.0 # Docs \ No newline at end of file From 674527fd738b5c4a4b26a21bfe0b93bdf6e67e96 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Sat, 4 May 2024 13:14:45 +0200 Subject: [PATCH 57/62] reinstate previous doc building --- .readthedocs.yml | 22 ++++++++---------- docs/source/requirements.txt | 45 ------------------------------------ 2 files changed, 9 insertions(+), 58 deletions(-) delete mode 100644 docs/source/requirements.txt diff --git a/.readthedocs.yml b/.readthedocs.yml index d2a0bb56..5df10a44 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,24 +1,20 @@ # .readthedocs.yml # Read the Docs configuration file -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details -# Required version: 2 build: - os: ubuntu-22.04 + os: "ubuntu-22.04" tools: python: "3.8" + jobs: + post_create_environment: + # Install poetry + - pip install poetry + post_install: + # Install dependencies + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --only docs -# Build documentation in the docs/ directory with Sphinx sphinx: - configuration: docs/source/conf.py - -# Optionally build your docs in additional formats such as PDF -formats: [] - -# Optionally set the version of Python and requirements required to build your docs -python: - install: - - requirements: docs/source/requirements.txt + configuration: docs/source/conf.py diff --git a/docs/source/requirements.txt b/docs/source/requirements.txt deleted file mode 100644 index ad13dad9..00000000 --- a/docs/source/requirements.txt +++ /dev/null @@ -1,45 +0,0 @@ -# Production -POT==0.9.0 -analytics-python>=1.2.7, <2.0.0 -arch==5.5.0 -cvxpy==1.3.1 -cython==0.29.28 -dash==2.10.2 -getmac>=0.8.0, <1.0.0 -jupyter-dash>=0.2.0, <1.0.0 -keras==2.12.0 -lxml>=4.9.1 -matplotlib==3.7.1 -mpmath==1.2.1 -networkx>=2.2, <2.6 -numpy==1.23.5 -pandas==2.0.0 -pmdarima==2.0.3 -protobuf>=3.20.3 -pyvinecopulib==0.5.5 -requests_html==0.10.0 -scikit-learn==1.1.3 -scipy>=1.2.0, <2.0.0 -scs==3.2.0 -seaborn==0.12.2 -statsmodels==0.14.0 -tensorflow-macos==2.12.0; sys_platform == 'darwin' and platform_machine == 'arm64' -tensorflow==2.12.0; sys_platform != 'darwin' or platform_machine != 'arm64' -werkzeug==2.2.3 -yahoo-fin==0.8.9.1 -yfinance==0.2.24 - -# Develop -coverage==7.2.7 -docutils==0.18.1 # Docs -hudsonthames-sphinx-theme==0.1.5 # Docs -jinja2<3.1 # Docs -pyarmor==8.2.5 # Encryption -pylint==2.17.4 -pytest==7.3.1 -releases==1.6.3 # Docs -sphinx-copybutton==0.5.2 # docs -sphinx-rtd-theme==1.2.2 # docs -sphinx-autoapi==2.1.1 -sphinx-tabs==3.4.1 -myst-parser==2.0.0 # Docs \ No newline at end of file From 6351d8198e171abbb2db656b6bd3a3b1e883abdf Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Wed, 8 May 2024 11:23:38 +0200 Subject: [PATCH 58/62] remove unnecessary dependency package --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4a15208f..0cd24886 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,7 +113,6 @@ build-backend = "poetry.core.masonry.api" coverage = "7.2.7" pylint = "3.1.0" pytest = "7.3.1" -pyarmor = "8.5.2" pytest-cov = "3.0.0" [tool.poetry.group.docs.dependencies] @@ -130,5 +129,5 @@ sphinx-copybutton = "0.5.2" six = "*" [tool.poetry.extras] -tests = ["coverage", "pylint", "pytest", "pytest-cov", "pyarmor"] +tests = ["coverage", "pylint", "pytest", "pytest-cov"] docs = ["sphinx", "sphinx-rtd-theme", "sphinx-tabs", "sphinx-autoapi", "sphinx-copybutton", "myst-parser", "hudsonthames-sphinx-theme", "docutils", "jinja2", "releases"] \ No newline at end of file From 5b2f49818945950d6c28531133018aa6ab35c768 Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Fri, 10 May 2024 16:15:27 +0200 Subject: [PATCH 59/62] modify workflow and update changelog.rst --- .github/workflows/publish-final-dist.yaml | 6 ++++-- .github/workflows/publish-test-dist.yaml | 6 +++--- docs/source/changelog.rst | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-final-dist.yaml b/.github/workflows/publish-final-dist.yaml index 92db233a..414aeb6e 100644 --- a/.github/workflows/publish-final-dist.yaml +++ b/.github/workflows/publish-final-dist.yaml @@ -1,9 +1,11 @@ name: Publish Distribution to PyPI on: - pull_request: + push: branches: - - master + - develop + tags: + - '[0-9]+.[0-9]+.[0-9]' jobs: build-and-publish-final-dist: diff --git a/.github/workflows/publish-test-dist.yaml b/.github/workflows/publish-test-dist.yaml index 922157b4..3ee4ee76 100644 --- a/.github/workflows/publish-test-dist.yaml +++ b/.github/workflows/publish-test-dist.yaml @@ -1,11 +1,11 @@ name: Publish Distribution to TestPyPI on: - pull_request: + push: branches: - develop - paths: - - 'release/*' + tags: + - '[0-9]+.[0-9]+.[0-9]+-dev' jobs: build-and-publish-test-dist: diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 19c36609..cf7a06ca 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -9,6 +9,8 @@ Changelog * :feature:`50` Add a distutils command for marbles * :bug:`58` Fixed test failure on OSX + +* :release:`1.0.0 <2024-05-10>` * :support:`93` Add poetry package manager for dependency management. * :release:`0.9.1 <2024-01-10>` From 05e7b886eaeac34242f1fd3a8b1f85def577748a Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Fri, 10 May 2024 17:58:35 +0200 Subject: [PATCH 60/62] fix workflow branch --- .github/workflows/publish-final-dist.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-final-dist.yaml b/.github/workflows/publish-final-dist.yaml index 414aeb6e..2884801f 100644 --- a/.github/workflows/publish-final-dist.yaml +++ b/.github/workflows/publish-final-dist.yaml @@ -3,7 +3,7 @@ name: Publish Distribution to PyPI on: push: branches: - - develop + - master tags: - '[0-9]+.[0-9]+.[0-9]' From 1ea9939323d9f29deffa1868c8ce5d8915f9f05f Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Fri, 10 May 2024 23:02:46 +0200 Subject: [PATCH 61/62] Bumpversion 0.9.1 -> 1.0.0 --- .bumpversion.cfg | 2 +- docs/source/conf.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 883c7898..7268e3d8 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.9.1 +current_version = 1.0.0 commit = False tag = False tag_name = {new_version} diff --git a/docs/source/conf.py b/docs/source/conf.py index e6a8e6af..ed8e39be 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -21,7 +21,7 @@ author = 'Hudson & Thames Quantitative Research' # The full version, including alpha/beta/rc tags -release = "0.9.1" +release = "1.0.0" # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index 0cd24886..93263f18 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "arbitragelab" -version = "0.9.1" +version = "1.0.0" description = "ArbitrageLab is a collection of algorithms from the best academic journals and graduate-level textbooks, which focuses on the branch of statistical arbitrage known as pairs trading. We have extended the implementations to include the latest methods that trade a portfolio of n-assets (mean-reverting portfolios)." authors = ["Hudson and Thames Quantitative Research "] license = "BSD-3-Clause" From 31669a96039e9dd0028024bec8d2995ce783316c Mon Sep 17 00:00:00 2001 From: benedettoleto Date: Sat, 11 May 2024 12:21:19 +0200 Subject: [PATCH 62/62] fix workflow execution --- .github/workflows/publish-final-dist.yaml | 4 +--- .github/workflows/publish-test-dist.yaml | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-final-dist.yaml b/.github/workflows/publish-final-dist.yaml index 2884801f..75af550c 100644 --- a/.github/workflows/publish-final-dist.yaml +++ b/.github/workflows/publish-final-dist.yaml @@ -2,8 +2,6 @@ name: Publish Distribution to PyPI on: push: - branches: - - master tags: - '[0-9]+.[0-9]+.[0-9]' @@ -25,7 +23,7 @@ jobs: - name: Install dependencies run: | - poetry install --without docs tests + poetry install --without docs,tests - name: Build the package run: | diff --git a/.github/workflows/publish-test-dist.yaml b/.github/workflows/publish-test-dist.yaml index 3ee4ee76..50172a74 100644 --- a/.github/workflows/publish-test-dist.yaml +++ b/.github/workflows/publish-test-dist.yaml @@ -2,8 +2,6 @@ name: Publish Distribution to TestPyPI on: push: - branches: - - develop tags: - '[0-9]+.[0-9]+.[0-9]+-dev' @@ -25,7 +23,7 @@ jobs: - name: Install dependencies run: | - poetry install --without docs tests + poetry install --without docs,tests - name: Build the package run: |