Skip to main content

jgt-pricedb

The persistence layer of the next-generation Price Service: bars live in a database with an incremental, anchor-based refresh — CSV files become an export, not the source of truth.

Lineage: implementation of the PDSP specifications reverse-engineered from the Caishen .NET stack — caishen/rispecs/PDSP/ (specs 70–77) — translated into the jgt ecosystem's shapes.

Structural Tension

  • Current reality: price data as flat CSVs ($JGTPY_DATA/pds/<INSTR>_<TF>.csv); every refresh rewrites whole files and downstream recomputes whole series.
  • Desired state: a database-backed store where refresh finds the anchor (the single forming bar per series) and writes only forward; downstream learns which bar changed and computes incrementally.

Decisions

  • Periods are cut on the broker's trading session, not on UTC midnight (0.1.1). The feed publishes H4, D1, W1 and M1 bars on a 17:00 America/New_York boundary — 21:00Z in summer, 22:00Z in winter — so a UTC grid renamed 100% of them, silently. m1..H1 stay on UTC, where they measurably already were. The session is stated per market, resolved inside bar_key, and recorded on the series; tests/test_session_grid.py is the measurement, run against the real holdings. See rispecs/01-price-store.spec.md, The Session Grid.
  • Portable schema (SQLite for local-first dev, PostgreSQL for deployment); the anchor invariant is enforced by a partial unique index (UNIQUE(series_id) WHERE is_forming), not by application discipline.
  • No standalone importer. Backfill is the refresh engine's bootstrap path (PDSP spec 72, Algorithm C) fed by a source adapter. CsvSource reads the existing full/ CSVs through the exact same upsert path as BrokerSource live updates. The system can always rebuild itself from its own sources.
  • CSV compatibility export (PDSP spec 75 pattern, 0.1.2): consumers (jgtpy, jgtml, jgt-data-server) keep reading the same file paths while the database becomes authoritative underneath. The format is measured rather than assumed — quotes keep the double the feed published, the derived columns are quantized at display precision +1 and +2 (with builtin round, which is not the one pandas reaches for), and the line terminator belongs to the file being replaced. A holdings file read in and written back out is byte-for-byte itself: 89 of 89 live files, 13 instruments, all seven timeframes, 95 208 bars. See rispecs/03-csv-export.spec.md.
  • Redis pub/sub (already in the jgt-data-server stack) carries bar-completed events in Phase 4 — the role Rebus/MSMQ played in Caishen.
  • pyproject.toml with a static version — deliberately avoiding the setup.py circular-import pattern that blocks other jgt packages from installing in containers.

Phases

Phase Creates PDSP spec
1 Schema + store core + bootstrap-backfill through source adapters 70, 71, 72
2 Jobs (jgtpdb) replacing refresh_data.sh — shipped as jgtpricedb-util 72, 74
3 CSV export bridge — DB authoritative, downstream untouched (0.1.2) 75
4 Redis events → incremental IDS/CDS recompute 73, 77
5 Serving from DB; indicator tables; strategy layer (SpiderDb heir) 76

Layout

  • rispecs/ — jgt-native specifications (the buildable truth; start here)
  • src/jgtpricedb/ — the library
  • docker-compose.yml — optional Postgres for deployment; SQLite needs nothing
  • ../jgt-pricedb-util/ — the sibling package (jgtpricedb-util): the jobs an operator runs against a store — bootstrap, refresh, a bounded forming-bar loop, an OANDA fetch on this session grid, and the freshness and relabel probes. This repository is the store; that one is the steward.

Release files for jgtpricedb 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jgtpricedb 0.1.2
File Size Uploaded
jgtpricedb-0.1.2.tar.gz 127.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jgtpricedb 0.1.2
File Interpreter ABI Platform
jgtpricedb-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 178.1 kB

Release files / jgtpricedb-0.1.2.tar.gz

Download URL jgtpricedb-0.1.2.tar.gz
Size 127.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b009b87254e4bb5323e1df27a05666f2e0717f50f0f798ff676a77d229e37a4b
BLAKE2b-256 checksum
How to use checksums
d8d02f1827d8e311140c9edaa9aa6f02b685ba3bc2f9bea12cb9e46e3d08e505
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Release files / jgtpricedb-0.1.2-py3-none-any.whl

Download URL jgtpricedb-0.1.2-py3-none-any.whl
Size 50.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b4bfe28fd9fdf747cd1a31d6b961f442054de81093607d20d825ae9bc90fae9a
BLAKE2b-256 checksum
How to use checksums
a0fb20b0549ab9b3c95dd352a9e8a76aa55fa262d6abc208698a214499d62fb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Release history Release notifications | RSS feed

0.2.1

2 release files

0.2.0

2 release files

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page