|
| 1 | +name: test-quant |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + paths: |
| 7 | + - "sktime_quant/**" |
| 8 | + - "docs/source/quant/**" |
| 9 | + - "examples/quant/**" |
| 10 | + - ".github/workflows/test_quant.yml" |
| 11 | + - "pyproject.toml" |
| 12 | + push: |
| 13 | + branches: [main] |
| 14 | + paths: |
| 15 | + - "sktime_quant/**" |
| 16 | + - "docs/source/quant/**" |
| 17 | + - "examples/quant/**" |
| 18 | + - ".github/workflows/test_quant.yml" |
| 19 | + - "pyproject.toml" |
| 20 | + |
| 21 | +jobs: |
| 22 | + quant-unit-tests: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v5 |
| 26 | + |
| 27 | + - uses: actions/setup-python@v6 |
| 28 | + with: |
| 29 | + python-version: "3.11" |
| 30 | + |
| 31 | + - name: install uv |
| 32 | + uses: astral-sh/setup-uv@v6 |
| 33 | + |
| 34 | + - name: install dependencies |
| 35 | + run: uv pip install .[dev,forecasting,quant] |
| 36 | + |
| 37 | + - name: run sktime_quant tests (without timescale integration) |
| 38 | + run: python -m pytest sktime_quant/tests -o addopts="" -m "not integration" |
| 39 | + |
| 40 | + - name: run quant core strategy/performance regression tests |
| 41 | + run: | |
| 42 | + python -m pytest \ |
| 43 | + sktime_quant/tests/test_walkforward.py \ |
| 44 | + sktime_quant/tests/test_risk_metrics.py \ |
| 45 | + sktime_quant/tests/test_forecast_engine_update.py \ |
| 46 | + -o addopts="" |
| 47 | +
|
| 48 | + quant-timescale-integration: |
| 49 | + runs-on: ubuntu-latest |
| 50 | + services: |
| 51 | + timescaledb: |
| 52 | + image: timescale/timescaledb:latest-pg16 |
| 53 | + ports: |
| 54 | + - 5432:5432 |
| 55 | + env: |
| 56 | + POSTGRES_DB: postgres |
| 57 | + POSTGRES_USER: postgres |
| 58 | + POSTGRES_PASSWORD: postgres |
| 59 | + options: >- |
| 60 | + --health-cmd "pg_isready -U postgres -d postgres" |
| 61 | + --health-interval 10s |
| 62 | + --health-timeout 5s |
| 63 | + --health-retries 10 |
| 64 | +
|
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v5 |
| 67 | + |
| 68 | + - uses: actions/setup-python@v6 |
| 69 | + with: |
| 70 | + python-version: "3.11" |
| 71 | + |
| 72 | + - name: install uv |
| 73 | + uses: astral-sh/setup-uv@v6 |
| 74 | + |
| 75 | + - name: install dependencies |
| 76 | + run: uv pip install .[dev,forecasting,quant] |
| 77 | + |
| 78 | + - name: run timescale integration test |
| 79 | + env: |
| 80 | + RUN_TIMESCALE_TESTS: "1" |
| 81 | + TIMESCALE_TEST_URI: "postgresql+psycopg://postgres:postgres@localhost:5432/postgres" |
| 82 | + run: python -m pytest sktime_quant/tests/test_timescale_integration.py -o addopts="" |
| 83 | + |
| 84 | + quant-cli-smoke: |
| 85 | + runs-on: ubuntu-latest |
| 86 | + steps: |
| 87 | + - uses: actions/checkout@v5 |
| 88 | + |
| 89 | + - uses: actions/setup-python@v6 |
| 90 | + with: |
| 91 | + python-version: "3.11" |
| 92 | + |
| 93 | + - name: install uv |
| 94 | + uses: astral-sh/setup-uv@v6 |
| 95 | + |
| 96 | + - name: install dependencies |
| 97 | + run: uv pip install .[dev,forecasting,quant] |
| 98 | + |
| 99 | + - name: run CLI smoke test |
| 100 | + run: | |
| 101 | + python - <<'PY' |
| 102 | + import pandas as pd |
| 103 | + from pathlib import Path |
| 104 | + import yaml |
| 105 | + import subprocess |
| 106 | + import sys |
| 107 | +
|
| 108 | + base = Path("tmp_quant_cli") |
| 109 | + base.mkdir(exist_ok=True) |
| 110 | + market = pd.DataFrame({ |
| 111 | + "timestamp": list(pd.date_range("2023-01-01", periods=160, freq="D")) * 2, |
| 112 | + "asset": ["A"] * 160 + ["B"] * 160, |
| 113 | + "close": [100 + i * 0.1 for i in range(160)] + [200 + i * 0.05 for i in range(160)], |
| 114 | + }) |
| 115 | + csv_path = base / "market.csv" |
| 116 | + market.to_csv(csv_path, index=False) |
| 117 | +
|
| 118 | + cfg = { |
| 119 | + "run_id": "ci_cli", |
| 120 | + "data": {"source_type": "csv", "csv_path": str(csv_path)}, |
| 121 | + "backtest": {"window_length": 60, "step_length": 10, "horizon": 1}, |
| 122 | + "execution": {"output_dir": str(base / "results")}, |
| 123 | + } |
| 124 | + cfg_path = base / "config.yaml" |
| 125 | + cfg_path.write_text(yaml.safe_dump(cfg), encoding="utf-8") |
| 126 | +
|
| 127 | + proc = subprocess.run( |
| 128 | + [sys.executable, "-m", "sktime_quant.run", "--config", str(cfg_path)], |
| 129 | + check=False, |
| 130 | + capture_output=True, |
| 131 | + text=True, |
| 132 | + ) |
| 133 | + print(proc.stdout) |
| 134 | + print(proc.stderr) |
| 135 | + raise SystemExit(proc.returncode) |
| 136 | + PY |
| 137 | +
|
| 138 | + quant-example-smoke: |
| 139 | + runs-on: ubuntu-latest |
| 140 | + steps: |
| 141 | + - uses: actions/checkout@v5 |
| 142 | + |
| 143 | + - uses: actions/setup-python@v6 |
| 144 | + with: |
| 145 | + python-version: "3.11" |
| 146 | + |
| 147 | + - name: install uv |
| 148 | + uses: astral-sh/setup-uv@v6 |
| 149 | + |
| 150 | + - name: install dependencies |
| 151 | + run: uv pip install .[dev,forecasting,quant] |
| 152 | + |
| 153 | + - name: run example smoke |
| 154 | + run: python examples/quant/01_quickstart_csv.py |
| 155 | + |
| 156 | + quant-docs-smoke: |
| 157 | + runs-on: ubuntu-latest |
| 158 | + steps: |
| 159 | + - uses: actions/checkout@v5 |
| 160 | + |
| 161 | + - uses: actions/setup-python@v6 |
| 162 | + with: |
| 163 | + python-version: "3.11" |
| 164 | + |
| 165 | + - name: install uv |
| 166 | + uses: astral-sh/setup-uv@v6 |
| 167 | + |
| 168 | + - name: install dependencies |
| 169 | + run: uv pip install .[docs,forecasting,quant] |
| 170 | + |
| 171 | + - name: build docs |
| 172 | + run: | |
| 173 | + make -C docs/source html SPHINXOPTS="-W --keep-going" |
| 174 | +
|
| 175 | + quant-docs-linkcheck: |
| 176 | + runs-on: ubuntu-latest |
| 177 | + steps: |
| 178 | + - uses: actions/checkout@v5 |
| 179 | + |
| 180 | + - uses: actions/setup-python@v6 |
| 181 | + with: |
| 182 | + python-version: "3.11" |
| 183 | + |
| 184 | + - name: install uv |
| 185 | + uses: astral-sh/setup-uv@v6 |
| 186 | + |
| 187 | + - name: install dependencies |
| 188 | + run: uv pip install .[docs,forecasting,quant] |
| 189 | + |
| 190 | + - name: run linkcheck for quant docs |
| 191 | + run: | |
| 192 | + sphinx-build -b linkcheck \ |
| 193 | + -D master_doc=quant/index \ |
| 194 | + -D linkcheck_timeout=15 \ |
| 195 | + -D linkcheck_retries=2 \ |
| 196 | + -D linkcheck_workers=5 \ |
| 197 | + docs/source docs/build/linkcheck |
0 commit comments