Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ updates:
patterns:
- "*"

- package-ecosystem: "pip"
- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "weekly"
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v8.2.0
with:
version: "latest"
version: "0.10.9"

- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}

- name: Install dependencies
run: uv sync --dev
run: uv sync --python ${{ env.PYTHON_VERSION }} --dev

- name: Run ruff check
run: uv run ruff check src/ tests/
Expand All @@ -42,13 +42,13 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v8.2.0
with:
version: "latest"
version: "0.10.9"

- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}

- name: Install dependencies
run: uv sync --dev
run: uv sync --python ${{ env.PYTHON_VERSION }} --dev

- name: Run ty check
run: uv run ty check
Expand All @@ -67,7 +67,7 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v8.2.0
with:
version: "latest"
version: "0.10.9"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
Expand All @@ -83,7 +83,7 @@ jobs:
sudo ldconfig

- name: Install dependencies
run: uv sync --dev --extra ta
run: uv sync --python ${{ matrix.python-version }} --dev --extra ta

- name: Run tests
run: |
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v8.2.0
with:
version: "latest"
version: "0.10.9"

- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v8.2.0
with:
version: "latest"
version: "0.10.9"

- name: Set up Python
run: uv python install 3.12

- name: Install dependencies
run: uv sync --dev --extra docs
run: uv sync --python 3.12 --dev --extra docs

- name: Build docs
run: uv run mkdocs build --strict

- name: Deploy to website repo
uses: cpina/github-action-push-to-another-repository@v1.7.3
uses: cpina/github-action-push-to-another-repository@55306faa4ed53b815ae49e564af8cfb359d32ae2 # v1.7.3
env:
SSH_DEPLOY_KEY: ${{ secrets.DOCS_DEPLOY_KEY }}
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v8.2.0
with:
version: "latest"
version: "0.10.9"

- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.14.0
uses: pypa/gh-action-pypi-publish@6733eb7d741f0b11ec6a39b58540dab7590f9b7d # v1.14.0

github-release:
name: Create GitHub Release
Expand Down
106 changes: 0 additions & 106 deletions docs/images/ml4t_ecosystem_workflow_color.svg

This file was deleted.

11 changes: 8 additions & 3 deletions src/ml4t/engineer/labeling/horizon_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,19 @@ def _trend_scanning_single_group(
# Handle numerical issues
continue

# Assign label based on trend direction
labels[i] = 1 if best_t > 0 else -1
# Assign label only when a directional trend was found.
if best_t > 0:
labels[i] = 1
elif best_t < 0:
labels[i] = -1
else:
continue
Comment thread
stefan-jansen marked this conversation as resolved.
t_values[i] = best_t
windows[i] = best_window

# Add results to dataframe
label_series = pl.Series("label", labels).fill_nan(None).cast(pl.Int8)
t_value_series = pl.Series("t_value", t_values)
t_value_series = pl.Series("t_value", t_values).fill_nan(None)
window_series = pl.Series("optimal_window", windows).fill_nan(None).cast(pl.Int32)

return data.with_columns([label_series, t_value_series, window_series])
Expand Down
2 changes: 1 addition & 1 deletion tests/features/volatility/test_volatility_comprehensive.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ def test_different_periods(self):
u10, m10, l10 = bollinger_bands(close, period=10)
u50, m50, l50 = bollinger_bands(close, period=50)

# Longer period has fewer NaN at start
# Longer period has more NaN values at the start.
assert np.sum(np.isnan(m10)) < np.sum(np.isnan(m50))

# Both should have valid values
Expand Down
15 changes: 15 additions & 0 deletions tests/test_new_labeling_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,21 @@ def test_null_handling_at_end(self, sample_prices):
# Should have some nulls at the end
assert null_count > 0

def test_no_directional_trend_returns_null_labels(self):
"""Test flat prices do not default to negative labels."""
flat_prices = pl.DataFrame(
{
"timestamp": [datetime(2024, 1, 1) + timedelta(hours=i) for i in range(20)],
"close": [100.0] * 20,
}
)

result = trend_scanning_labels(flat_prices, min_window=5, max_window=10)

assert result["label"].null_count() == result.height
assert result["t_value"].null_count() == result.height
assert result["optimal_window"].null_count() == result.height


class TestLabelingComparison:
"""Compare different labeling methods."""
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading