Cache-first market bar archive: fetch from Polygon (or others), store 1m bars, return any timeframe. No pandas required for callers.
Project description
Barvault
Cache-first market bar archive: fetch from Polygon (or other providers), store 1-minute bars in S3 or local, return any timeframe. Callers can use plain Python (datetime, list[dict]) — no pandas required.
- deterministic archive reads (stable ordering + explicit boundary semantics)
- a single golden source stored in the archive: 1-minute bars
- stateless configuration (no module globals, no env lookups at import-time)
Install (Poetry)
poetry install
Quick usage
from __future__ import annotations
from datetime import datetime, timezone
from market_data import ArchiveConfig, MarketDataClient, PolygonConfig
cfg = ArchiveConfig.s3(bucket="public-market-data-truth-trader", prefix="md-archive")
client = MarketDataClient(cfg, polygon=PolygonConfig(api_key="YOUR_POLYGON_KEY"))
records = client.get_bars_records(
["AAPL"],
start=datetime(2025, 1, 2, 14, 30, tzinfo=timezone.utc),
end=datetime(2025, 1, 2, 15, 30, tzinfo=timezone.utc),
timeframe="5min",
)
print(records[:2])
Fetch + cache (Polygon) + return any timeframe
The archive’s golden source is always 1-minute bars. MarketDataClient will:
- read what’s already in the archive for
[start, end) - detect missing expected minutes (using the provided calendar)
- fetch missing data from Polygon
- write 1m bars back to the archive (merge + de-dupe)
- return 1m or any derived timeframe (resampled from 1m)
from __future__ import annotations
from market_data import ArchiveConfig, MarketDataClient, PolygonConfig
# Local archive:
# cfg = ArchiveConfig.local(root="/tmp/md-archive")
#
# S3 archive:
cfg = ArchiveConfig.s3(bucket="public-market-data-truth-trader", prefix="md-archive")
client = MarketDataClient(
cfg,
polygon=PolygonConfig(api_key="YOUR_POLYGON_KEY"),
)
# Always returns data for [start,end) (start inclusive, end exclusive).
bars_1m = client.get_bars(
["AAPL", "MSFT"],
start="2025-01-02T14:30:00Z",
end="2025-01-02T15:30:00Z",
timeframe="1min",
)
# Derived timeframe (resampled from 1m):
bars_5m = client.get_bars(
["AAPL"],
start="2025-01-02T14:30:00Z",
end="2025-01-02T15:30:00Z",
timeframe="5min",
)
# If you don't want to work with pandas DataFrames, use plain Python records:
records_5m = client.get_bars_records(
["AAPL"],
start="2025-01-02T14:30:00Z",
end="2025-01-02T15:30:00Z",
timeframe="5min",
)
Timeframe notes:
- Use pandas-compatible offset strings like
"5min","1h","1D". - Do not use
"1m"to mean 1 minute — in pandas"m"means months.
Design constraints
import market_datamust not start servers, read env vars, or require credentials- all configuration is passed via constructors/args (
ArchiveConfig, provider constructors, etc.) - only 1m is accepted by the writer; higher timeframes are derived from 1m (never written)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file truthtrader-0.1.0.tar.gz.
File metadata
- Download URL: truthtrader-0.1.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0524cf7bbc5110efb42793c48aa93f361ac0c37c37ed49b0676fa620c4e1675d
|
|
| MD5 |
e2d030087f73b61be861d0c0d428bda9
|
|
| BLAKE2b-256 |
a7da5d1d963f40dfe714ab2eebfa0981dcd044779fa2ccd164ce2e752b226cba
|
Provenance
The following attestation bundles were made for truthtrader-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on meetorman/barvault
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
truthtrader-0.1.0.tar.gz -
Subject digest:
0524cf7bbc5110efb42793c48aa93f361ac0c37c37ed49b0676fa620c4e1675d - Sigstore transparency entry: 871165900
- Sigstore integration time:
-
Permalink:
meetorman/barvault@934fbec54ffa4c6b93ed8725e586498595707118 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/meetorman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@934fbec54ffa4c6b93ed8725e586498595707118 -
Trigger Event:
push
-
Statement type:
File details
Details for the file truthtrader-0.1.0-py3-none-any.whl.
File metadata
- Download URL: truthtrader-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
450ee895c95843e891c4f63e0b9060e2dce093af5f1c371d1637617cce432de2
|
|
| MD5 |
77c7b2f42f89b325421475a74357f049
|
|
| BLAKE2b-256 |
c311cce83dee33243cfb2e067cbdbc7ca790a182c3995d7ee6c7b7833b1a22e0
|
Provenance
The following attestation bundles were made for truthtrader-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on meetorman/barvault
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
truthtrader-0.1.0-py3-none-any.whl -
Subject digest:
450ee895c95843e891c4f63e0b9060e2dce093af5f1c371d1637617cce432de2 - Sigstore transparency entry: 871165903
- Sigstore integration time:
-
Permalink:
meetorman/barvault@934fbec54ffa4c6b93ed8725e586498595707118 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/meetorman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@934fbec54ffa4c6b93ed8725e586498595707118 -
Trigger Event:
push
-
Statement type: