eod-market-data 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. eod_market_data-0.1.0/.github/workflows/ci.yml +32 -0
  2. eod_market_data-0.1.0/.github/workflows/pypi.yml +34 -0
  3. eod_market_data-0.1.0/.github/workflows/release.yml +66 -0
  4. eod_market_data-0.1.0/.gitignore +8 -0
  5. eod_market_data-0.1.0/.python-version +1 -0
  6. eod_market_data-0.1.0/CHANGELOG.md +18 -0
  7. eod_market_data-0.1.0/LICENSE +21 -0
  8. eod_market_data-0.1.0/Makefile +8 -0
  9. eod_market_data-0.1.0/PKG-INFO +89 -0
  10. eod_market_data-0.1.0/README.md +61 -0
  11. eod_market_data-0.1.0/examples/universe.yaml +37 -0
  12. eod_market_data-0.1.0/pyproject.toml +64 -0
  13. eod_market_data-0.1.0/scripts/test.sh +8 -0
  14. eod_market_data-0.1.0/src/eod_market_data/__init__.py +29 -0
  15. eod_market_data-0.1.0/src/eod_market_data/_io.py +30 -0
  16. eod_market_data-0.1.0/src/eod_market_data/calendar.py +184 -0
  17. eod_market_data-0.1.0/src/eod_market_data/cli.py +103 -0
  18. eod_market_data-0.1.0/src/eod_market_data/fx_backfill.py +131 -0
  19. eod_market_data-0.1.0/src/eod_market_data/providers/__init__.py +13 -0
  20. eod_market_data-0.1.0/src/eod_market_data/providers/alphavantage.py +113 -0
  21. eod_market_data-0.1.0/src/eod_market_data/providers/base.py +43 -0
  22. eod_market_data-0.1.0/src/eod_market_data/providers/exchange_closes.py +175 -0
  23. eod_market_data-0.1.0/src/eod_market_data/providers/lse.py +183 -0
  24. eod_market_data-0.1.0/src/eod_market_data/providers/treasury.py +97 -0
  25. eod_market_data-0.1.0/src/eod_market_data/providers/twelvedata.py +250 -0
  26. eod_market_data-0.1.0/src/eod_market_data/providers/yfinance.py +118 -0
  27. eod_market_data-0.1.0/src/eod_market_data/py.typed +0 -0
  28. eod_market_data-0.1.0/src/eod_market_data/splits.py +66 -0
  29. eod_market_data-0.1.0/src/eod_market_data/store.py +118 -0
  30. eod_market_data-0.1.0/src/eod_market_data/universe.py +90 -0
  31. eod_market_data-0.1.0/tests/__init__.py +0 -0
  32. eod_market_data-0.1.0/tests/test_calendar_and_splits.py +65 -0
  33. eod_market_data-0.1.0/tests/test_providers_and_cli.py +349 -0
  34. eod_market_data-0.1.0/tests/test_store_and_universe.py +116 -0
  35. eod_market_data-0.1.0/uv.lock +1267 -0
@@ -0,0 +1,32 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [main]
7
+ workflow_dispatch:
8
+ workflow_call:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ concurrency:
14
+ group: ci-${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
15
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
16
+
17
+ jobs:
18
+ test:
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ python: ['3.11', '3.12', '3.13']
23
+ runs-on: ubuntu-latest
24
+ timeout-minutes: 10
25
+ steps:
26
+ - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
27
+ with:
28
+ persist-credentials: false
29
+ - uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
30
+ with:
31
+ python-version: ${{ matrix.python }}
32
+ - run: make check
@@ -0,0 +1,34 @@
1
+ name: PyPI
2
+
3
+ on:
4
+ push:
5
+ tags: ['v*.*.*']
6
+ workflow_dispatch: {}
7
+
8
+ permissions: {}
9
+
10
+ concurrency:
11
+ group: pypi-${{ github.ref }}
12
+ cancel-in-progress: false
13
+
14
+ jobs:
15
+ publish:
16
+ if: github.ref_type == 'tag' && (github.event_name == 'workflow_dispatch' || vars.PYPI_PUBLISH == 'true')
17
+ runs-on: ubuntu-latest
18
+ timeout-minutes: 10
19
+ environment: pypi
20
+ permissions:
21
+ contents: read
22
+ id-token: write
23
+ steps:
24
+ - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
25
+ with:
26
+ persist-credentials: false
27
+ - uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
28
+ - name: Build
29
+ run: |
30
+ version="$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
31
+ [ "${GITHUB_REF_NAME#v}" = "$version" ] || { echo "tag $GITHUB_REF_NAME is not version $version" >&2; exit 1; }
32
+ uv build
33
+ - name: Upload
34
+ run: uv publish --trusted-publishing always --check-url https://pypi.org/simple/
@@ -0,0 +1,66 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ['v*.*.*']
6
+ workflow_dispatch: {}
7
+
8
+ permissions: {}
9
+
10
+ concurrency:
11
+ group: release-${{ github.ref }}
12
+ cancel-in-progress: false
13
+
14
+ jobs:
15
+ released:
16
+ runs-on: ubuntu-latest
17
+ timeout-minutes: 5
18
+ permissions:
19
+ contents: read
20
+ outputs:
21
+ done: ${{ steps.check.outputs.done }}
22
+ steps:
23
+ - id: check
24
+ env:
25
+ GH_TOKEN: ${{ github.token }}
26
+ TAG: ${{ github.ref_name }}
27
+ run: |
28
+ done=false
29
+ if [ "$GITHUB_REF_TYPE" = tag ] && gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
30
+ done=true
31
+ echo "$TAG is already released: nothing to do"
32
+ fi
33
+ echo "done=$done" >> "$GITHUB_OUTPUT"
34
+
35
+ ci:
36
+ needs: released
37
+ if: needs.released.outputs.done != 'true'
38
+ uses: ./.github/workflows/ci.yml
39
+ permissions:
40
+ contents: read
41
+
42
+ github-release:
43
+ needs: ci
44
+ if: github.event_name == 'push' && github.ref_type == 'tag'
45
+ runs-on: ubuntu-latest
46
+ timeout-minutes: 10
47
+ permissions:
48
+ contents: write
49
+ steps:
50
+ - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
51
+ with:
52
+ persist-credentials: false
53
+ - uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
54
+ - name: Build
55
+ run: |
56
+ version="$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
57
+ [ "${GITHUB_REF_NAME#v}" = "$version" ] || { echo "tag $GITHUB_REF_NAME is not version $version" >&2; exit 1; }
58
+ uv build
59
+ - env:
60
+ GH_TOKEN: ${{ github.token }}
61
+ TAG: ${{ github.ref_name }}
62
+ run: |
63
+ object=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$TAG" --jq 'select(.object.type == "tag") | .object.sha')
64
+ test -n "$object" || { echo "::error::$TAG is not an annotated tag carrying release notes"; exit 1; }
65
+ gh api "repos/$GITHUB_REPOSITORY/git/tags/$object" --jq .message > "$RUNNER_TEMP/notes.md"
66
+ gh release create "$TAG" dist/* --repo "$GITHUB_REPOSITORY" --verify-tag --title "$TAG" --notes-file "$RUNNER_TEMP/notes.md"
@@ -0,0 +1,8 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ dist/
7
+ build/
8
+ *.egg-info/
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0] - 2026-11-29
4
+
5
+ ### Added
6
+
7
+ - Initial standalone release of `eod-market-data`:
8
+ - Canonical long-format CSV store with atomic writes, idempotent `upsert_series`, `replace_other_sources` protection, and `series_columns` / `series_matrix` views (`store`).
9
+ - Holiday- and DST-aware multi-venue exchange calendars with `XATH` (Athens) and STOXX dissemination support (`calendar`).
10
+ - Split-event `Source` parser and cumulative split-divisor helpers (`splits`).
11
+ - YAML-driven `UniverseConfig` and `Security` model plus `GapFillProvider` plugin protocol (`universe`, `providers.base`).
12
+ - Official and keyed providers: `yfinance`, `twelvedata` (EOD FX, equities, 17:00 NY spot gold), `alphavantage`, `lse`, `exchange_closes` (Nasdaq/HKEX), and `treasury` (US Treasury par-yield CSV).
13
+ - Append-only FX backfill (`fx_backfill`) and `eod-data` CLI (`inspect`, `treasury`, `gold-spot`, `backfill-fx`).
14
+
15
+ ### Upgrade
16
+
17
+ - Action required: None (initial release).
18
+ - Rollback: Not applicable.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 benjamin-di
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ .PHONY: bootstrap check lock
2
+ bootstrap:
3
+ uv sync --locked
4
+ check:
5
+ ./scripts/test.sh
6
+ @if [ -f publish/config.toml ] && command -v publish-public >/dev/null 2>&1; then publish-public --check-head .; fi
7
+ lock:
8
+ uv lock
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.5
2
+ Name: eod-market-data
3
+ Version: 0.1.0
4
+ Summary: Canonical EOD market-data CSV time-series store, exchange-calendar awareness, split-boundary guards, and pluggable multi-source price/FX/rate feeds
5
+ Project-URL: Homepage, https://github.com/benjamin-di/eod-market-data
6
+ Project-URL: Issues, https://github.com/benjamin-di/eod-market-data/issues
7
+ Author: benjamin-di
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: eod,exchange-calendars,finance,fx,market-data,treasury,twelvedata,yfinance
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Financial and Insurance Industry
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Office/Business :: Financial :: Investment
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: exchange-calendars<5,>=4.5
23
+ Requires-Dist: pandas<3.1,>=2.2
24
+ Requires-Dist: pyyaml<7,>=6
25
+ Requires-Dist: requests<3,>=2.32
26
+ Requires-Dist: yfinance<2,>=0.2.50
27
+ Description-Content-Type: text/markdown
28
+
29
+ # eod-market-data
30
+
31
+ Canonical EOD market-data CSV time-series store, exchange-calendar awareness, split-boundary guards, and pluggable multi-source price/FX/rate feeds for Python.
32
+
33
+ ## Features
34
+
35
+ - **Canonical long-format CSV store** (`store`): One tidy table (`Date`, `ISIN`, `Ticker`, `Bloomberg`, `Name`, `Asset class`, `Currency`, `Close local`, `FX EUR/Local`, `Close EUR`, `Volume`, `Source`, `Price basis`) with atomic writes, idempotent `upsert_series(..., replace_other_sources=False)`, and `series_matrix()` views.
36
+ - **Multi-venue exchange calendars** (`calendar`): Holiday- and DST-aware session resolution via `exchange-calendars` (including custom `XATH` Euronext Athens registration and STOXX dissemination calendar) so US holidays never stall European listings and vice versa.
37
+ - **Split-boundary guards** (`splits`): Parses `; split event <k>` annotations and computes cumulative split divisors while keeping raw closes unadjusted and reproducible.
38
+ - **Official & keyed EOD feeds** (`providers`):
39
+ - `yfinance`: equities, ETFs, FX fallback, dividends, and split detection.
40
+ - `twelvedata`: true EOD FX primary (`EUR/USD`, etc.), US equity gap-fill, and 17:00 `America/New_York` XAU/USD spot gold.
41
+ - `alphavantage`: throttled, budget-capped non-US/US equity gap-fill.
42
+ - `lse`: dated native London closes from the public LSE instrument JSON endpoint (`lastclose`/`lastclosedate`, GBX→GBP normalization, ISIN/SEDOL verification).
43
+ - `exchange_closes`: config-driven Nasdaq historical JSON and HKEX Daily Quotations gap-fill.
44
+ - `treasury`: official US Treasury daily par-yield curve CSV.
45
+ - **Extensible plugin protocol** (`providers.base.GapFillProvider`): Register custom or private venue feeds without modifying the core library.
46
+ - **Config-driven universe** (`universe`): Load securities, FX pairs, and LSE/exchange mappings from `universe.yaml` (see [examples/universe.yaml](examples/universe.yaml)).
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ pip install eod-market-data
52
+ ```
53
+
54
+ Or with `uv`:
55
+
56
+ ```bash
57
+ uv add eod-market-data
58
+ ```
59
+
60
+ ## Quick start
61
+
62
+ ```python
63
+ from pathlib import Path
64
+ from eod_market_data import calendar, store, universe
65
+
66
+ cfg = universe.load_universe(Path("examples/universe.yaml"))
67
+ df = store.read_history_df(Path("market-data-history.csv"))
68
+ print("Expected XNYS session:", calendar.expected_session_for("XNYS"))
69
+ ```
70
+
71
+ ### CLI
72
+
73
+ ```bash
74
+ # Inspect an existing CSV store
75
+ eod-data inspect --store market-data-history.csv
76
+
77
+ # Fetch latest US Treasury par-yield curve
78
+ eod-data treasury
79
+
80
+ # Fetch 17:00 New York XAU/USD spot gold (requires TWELVEDATA_API_KEY)
81
+ eod-data gold-spot --store market-data-history.csv
82
+
83
+ # Prepare an append-only FX backfill CSV
84
+ eod-data backfill-fx --source market-data-history.csv --out candidate.csv --currency JPY --start 2026-01-01 --end 2026-01-31
85
+ ```
86
+
87
+ ## License
88
+
89
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,61 @@
1
+ # eod-market-data
2
+
3
+ Canonical EOD market-data CSV time-series store, exchange-calendar awareness, split-boundary guards, and pluggable multi-source price/FX/rate feeds for Python.
4
+
5
+ ## Features
6
+
7
+ - **Canonical long-format CSV store** (`store`): One tidy table (`Date`, `ISIN`, `Ticker`, `Bloomberg`, `Name`, `Asset class`, `Currency`, `Close local`, `FX EUR/Local`, `Close EUR`, `Volume`, `Source`, `Price basis`) with atomic writes, idempotent `upsert_series(..., replace_other_sources=False)`, and `series_matrix()` views.
8
+ - **Multi-venue exchange calendars** (`calendar`): Holiday- and DST-aware session resolution via `exchange-calendars` (including custom `XATH` Euronext Athens registration and STOXX dissemination calendar) so US holidays never stall European listings and vice versa.
9
+ - **Split-boundary guards** (`splits`): Parses `; split event <k>` annotations and computes cumulative split divisors while keeping raw closes unadjusted and reproducible.
10
+ - **Official & keyed EOD feeds** (`providers`):
11
+ - `yfinance`: equities, ETFs, FX fallback, dividends, and split detection.
12
+ - `twelvedata`: true EOD FX primary (`EUR/USD`, etc.), US equity gap-fill, and 17:00 `America/New_York` XAU/USD spot gold.
13
+ - `alphavantage`: throttled, budget-capped non-US/US equity gap-fill.
14
+ - `lse`: dated native London closes from the public LSE instrument JSON endpoint (`lastclose`/`lastclosedate`, GBX→GBP normalization, ISIN/SEDOL verification).
15
+ - `exchange_closes`: config-driven Nasdaq historical JSON and HKEX Daily Quotations gap-fill.
16
+ - `treasury`: official US Treasury daily par-yield curve CSV.
17
+ - **Extensible plugin protocol** (`providers.base.GapFillProvider`): Register custom or private venue feeds without modifying the core library.
18
+ - **Config-driven universe** (`universe`): Load securities, FX pairs, and LSE/exchange mappings from `universe.yaml` (see [examples/universe.yaml](examples/universe.yaml)).
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install eod-market-data
24
+ ```
25
+
26
+ Or with `uv`:
27
+
28
+ ```bash
29
+ uv add eod-market-data
30
+ ```
31
+
32
+ ## Quick start
33
+
34
+ ```python
35
+ from pathlib import Path
36
+ from eod_market_data import calendar, store, universe
37
+
38
+ cfg = universe.load_universe(Path("examples/universe.yaml"))
39
+ df = store.read_history_df(Path("market-data-history.csv"))
40
+ print("Expected XNYS session:", calendar.expected_session_for("XNYS"))
41
+ ```
42
+
43
+ ### CLI
44
+
45
+ ```bash
46
+ # Inspect an existing CSV store
47
+ eod-data inspect --store market-data-history.csv
48
+
49
+ # Fetch latest US Treasury par-yield curve
50
+ eod-data treasury
51
+
52
+ # Fetch 17:00 New York XAU/USD spot gold (requires TWELVEDATA_API_KEY)
53
+ eod-data gold-spot --store market-data-history.csv
54
+
55
+ # Prepare an append-only FX backfill CSV
56
+ eod-data backfill-fx --source market-data-history.csv --out candidate.csv --currency JPY --start 2026-01-01 --end 2026-01-31
57
+ ```
58
+
59
+ ## License
60
+
61
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,37 @@
1
+ # Example universe configuration for eod-market-data
2
+ base_currency: EUR
3
+ start_date: "2025-12-30"
4
+ ytd_anchor: "2025-12-31"
5
+
6
+ securities:
7
+ - isin: US0000000001
8
+ bloomberg: ACME US
9
+ name: Acme Corp
10
+ asset_class: Equity
11
+ currency: USD
12
+ yf_ticker: ACME
13
+ fx_pair: EURUSD=X
14
+
15
+ - isin: GB0000000002
16
+ bloomberg: DEMO LN
17
+ name: Demo PLC
18
+ asset_class: Equity
19
+ currency: GBP
20
+ yf_ticker: DEMO.L
21
+ fx_pair: EURGBP=X
22
+ price_divisor: 100.0
23
+ av_symbol: DEMO.LON
24
+ lse:
25
+ tidm: DEMO
26
+ sedol: "0000001"
27
+ segment: SET1
28
+ quote_unit: GBX
29
+ yahoo_close_compatible: true
30
+
31
+ - isin: DE0000000003
32
+ bloomberg: EURO GR
33
+ name: Euro Index ETF
34
+ asset_class: Equity ETF
35
+ currency: EUR
36
+ yf_ticker: EURO.DE
37
+ fx_pair: ""
@@ -0,0 +1,64 @@
1
+ [project]
2
+ name = "eod-market-data"
3
+ version = "0.1.0"
4
+ description = "Canonical EOD market-data CSV time-series store, exchange-calendar awareness, split-boundary guards, and pluggable multi-source price/FX/rate feeds"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ authors = [{ name = "benjamin-di" }]
9
+ requires-python = ">=3.11"
10
+ keywords = ["market-data", "finance", "eod", "fx", "exchange-calendars", "yfinance", "twelvedata", "treasury"]
11
+ classifiers = [
12
+ "Development Status :: 4 - Beta",
13
+ "Intended Audience :: Developers",
14
+ "Intended Audience :: Financial and Insurance Industry",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Operating System :: OS Independent",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Topic :: Office/Business :: Financial :: Investment",
22
+ ]
23
+ dependencies = [
24
+ "exchange-calendars>=4.5,<5",
25
+ "pandas>=2.2,<3.1",
26
+ "PyYAML>=6,<7",
27
+ "requests>=2.32,<3",
28
+ "yfinance>=0.2.50,<2",
29
+ ]
30
+
31
+ [project.scripts]
32
+ eod-data = "eod_market_data.cli:main"
33
+
34
+ [project.urls]
35
+ Homepage = "https://github.com/benjamin-di/eod-market-data"
36
+ Issues = "https://github.com/benjamin-di/eod-market-data/issues"
37
+
38
+ [dependency-groups]
39
+ dev = [
40
+ "pytest>=8",
41
+ "ruff>=0.14",
42
+ ]
43
+
44
+ [build-system]
45
+ requires = ["hatchling"]
46
+ build-backend = "hatchling.build"
47
+
48
+ [tool.hatch.build.targets.wheel]
49
+ packages = ["src/eod_market_data"]
50
+
51
+ [tool.pytest.ini_options]
52
+ testpaths = ["tests"]
53
+ addopts = "-q"
54
+
55
+ [tool.ruff]
56
+ line-length = 120
57
+ target-version = "py311"
58
+
59
+ [tool.ruff.lint]
60
+ select = ["E", "F", "I", "B", "UP", "S", "RUF"]
61
+ ignore = ["S101", "S310", "RUF001", "RUF002", "RUF003"]
62
+
63
+ [tool.ruff.lint.per-file-ignores]
64
+ "tests/*" = ["S", "E501", "B905"]
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ # The gate: lint, format, then the tests.
3
+ set -euo pipefail
4
+ cd "$(dirname "${BASH_SOURCE[0]}")/.."
5
+ uv sync --locked
6
+ .venv/bin/ruff check src tests
7
+ .venv/bin/ruff format --check src tests
8
+ .venv/bin/python -m pytest "$@"
@@ -0,0 +1,29 @@
1
+ """Canonical EOD market-data CSV store, exchange calendars, split guards, and providers."""
2
+
3
+ from . import calendar, fx_backfill, providers, splits, store, universe
4
+ from .providers.base import GapFillProvider, ProviderRegistry
5
+ from .store import HISTORY_COLS, read_history_df, series_columns, series_matrix, upsert_series, write_history_df
6
+ from .universe import Security, UniverseConfig, load_universe
7
+
8
+ __version__ = "0.1.0"
9
+
10
+ __all__ = [
11
+ "HISTORY_COLS",
12
+ "GapFillProvider",
13
+ "ProviderRegistry",
14
+ "Security",
15
+ "UniverseConfig",
16
+ "__version__",
17
+ "calendar",
18
+ "fx_backfill",
19
+ "load_universe",
20
+ "providers",
21
+ "read_history_df",
22
+ "series_columns",
23
+ "series_matrix",
24
+ "splits",
25
+ "store",
26
+ "universe",
27
+ "upsert_series",
28
+ "write_history_df",
29
+ ]
@@ -0,0 +1,30 @@
1
+ """Atomic file writes and SHA-256 digests with no external dependencies."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import hashlib
6
+ import os
7
+ import tempfile
8
+ from pathlib import Path
9
+
10
+
11
+ def digest(path: str | Path) -> str:
12
+ """Return the hex SHA-256 digest of a file."""
13
+ return hashlib.sha256(Path(path).read_bytes()).hexdigest()
14
+
15
+
16
+ def atomic_write(path: str | Path, data: str | bytes) -> None:
17
+ """Write bytes or UTF-8 text atomically via same-directory temp file + fsync + replace."""
18
+ target = Path(path)
19
+ target.parent.mkdir(parents=True, exist_ok=True)
20
+ temp: Path | None = None
21
+ try:
22
+ with tempfile.NamedTemporaryFile(dir=target.parent, delete=False) as handle:
23
+ temp = Path(handle.name)
24
+ handle.write(data.encode("utf-8") if isinstance(data, str) else data)
25
+ handle.flush()
26
+ os.fsync(handle.fileno())
27
+ os.replace(temp, target)
28
+ finally:
29
+ if temp is not None:
30
+ temp.unlink(missing_ok=True)