diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml index 6d52fc9..72fa882 100644 --- a/.github/workflows/basic.yml +++ b/.github/workflows/basic.yml @@ -13,12 +13,12 @@ jobs: with: extra_args: '--verbose --all-files' - test: + experiment: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: testing + - name: experiments shell: bash run: | - make test + make experiment diff --git a/.gitignore b/.gitignore index aed7658..7f99f47 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +checkpoints + .idea .vscode .python-version diff --git a/Makefile b/Makefile index 2ce5085..285d239 100644 --- a/Makefile +++ b/Makefile @@ -14,11 +14,6 @@ fmt: install ## Run autoformatting and linting ${VENV}/bin/pre-commit install ${VENV}/bin/pre-commit run --all-files -.PHONY: test -test: install ## Run tests - ${VENV}/bin/pip install pytest - ${VENV}/bin/pytest tests - .PHONY: clean clean: ## Clean up caches and build artifacts @git clean -X -d -f diff --git a/experiments.py b/experiments.py index 0347854..65be312 100644 --- a/experiments.py +++ b/experiments.py @@ -1,4 +1,7 @@ +from pathlib import Path + from experiments.taming import main as taming_main if __name__ == "__main__": + Path("checkpoints").mkdir(exist_ok=True) taming_main() diff --git a/experiments/backtest.py b/experiments/backtest.py index 8373de8..c691b4c 100644 --- a/experiments/backtest.py +++ b/experiments/backtest.py @@ -4,16 +4,12 @@ from functools import lru_cache from pathlib import Path import pickle -import sys import time from typing import Callable import numpy as np import cvxpy as cp import pandas as pd -from utils import synthetic_returns - -# hack to allow importing from parent directory without having a package -sys.path.append(str(Path(__file__).parent.parent)) +from experiments.utils import synthetic_returns def data_folder(): diff --git a/markowitz.py b/experiments/markowitz.py similarity index 100% rename from markowitz.py rename to experiments/markowitz.py diff --git a/experiments/taming.py b/experiments/taming.py index 963fe29..dfb63f1 100644 --- a/experiments/taming.py +++ b/experiments/taming.py @@ -1,8 +1,8 @@ import numpy as np import pandas as pd import cvxpy as cp -from backtest import BacktestResult, OptimizationInput, run_backtest -from markowitz import Data, Parameters, markowitz +from experiments.backtest import BacktestResult, OptimizationInput, run_backtest +from experiments.markowitz import Data, Parameters, markowitz def basic_markowitz(inputs: OptimizationInput) -> np.ndarray: diff --git a/requirements.txt b/requirements.txt index ff3c8a1..8115d95 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ cvxpy numpy -pandas +pandas[output-formatting] matplotlib diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/conftest.py b/tests/conftest.py deleted file mode 100644 index 7290113..0000000 --- a/tests/conftest.py +++ /dev/null @@ -1,17 +0,0 @@ -"""global fixtures""" -from __future__ import annotations - -from pathlib import Path -import pytest - - -@pytest.fixture(scope="session", name="resource_dir") -def resource_fixture(): - """resource fixture""" - return Path(__file__).parent / "resources" - - -@pytest.fixture(scope="session", name="data_dir") -def data_fixture(): - """resource fixture""" - return Path(__file__).parent.parent / "data" diff --git a/tests/resources/.gitkeep b/tests/resources/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_markowitz.py b/tests/test_markowitz.py deleted file mode 100644 index 11d6f7d..0000000 --- a/tests/test_markowitz.py +++ /dev/null @@ -1,12 +0,0 @@ -# """ -# testing the builder -# """ -import numpy as np - -from markowitz import Data - - -def test_foo(resource_dir, data_dir): - assert True - data = Data - data.idio_volas = np.array([1, 2, 3])