Skip to main content

market-data

Market-data producer for MyOpenFund. It fetches daily prices, corporate actions and identifiers through pluggable source adapters, keeps every raw answer in an immutable archive, maps provider symbols to opaque instruments, and writes look-ahead-free batches into open-data-store, whose recipes then serve point-in-time index membership, prices and total returns for backtests. It also loads a history export in a public file format, and ships the acceptance computations that check a backtest universe for look-ahead and survivorship bias.

Principles

  • Bring your own source. The repo ships code: adapters, a source registry, the history-file loader. It ships no data. You use your own provider accounts and keys (environment variables, never logged, never in an error message).
  • Your data, your terms. Prices are fetched for your own use, with your own keys. Every source carries descriptive licence flags (see Licences); nothing here enforces them, no row is dropped, hidden or refused because of one. What you do with the data is your responsibility.
  • Look-ahead-free. Every fact carries the time it became known (known_at), from the exchange calendar (session close in UTC) or the fetch time of a correction. Dated rows from a private export are keyed by opaque tokens; their labels are published only as identifier observations known at load time.

Install

From PyPI (Python 3.11 or later):

pip install myopenfund-market-data

This pulls myopenfund-open-data-store[writer,recipes] 0.4.x.

Try it: prices in a notebook (none profile)

With your own free Tiingo key in TIINGO_API_KEY:

from datetime import date
from market_data.api import prices

prices(["AAPL", "MSFT"], date(2024, 1, 2), date(2024, 3, 28))  # raw daily closes
prices(["MSFT"], date(2024, 1, 2), date(2024, 3, 28), adjust="total_return")

Nothing is stored: the data is fetched with your key, built in memory and returned to you (only Tiingo's quota state is kept, see MOF_MARKET_STATE_DIR). Inputs are the source's own symbols (Tiingo writes a class share with a hyphen, as XXX-B). Rows are keyed by an in-memory id (live:tiingo:MSFT, not a store instrument id) and your input. source="massive" uses MASSIVE_API_KEY instead, within that plan's history window; api_key= passes a key directly.

With adjust="total_return", the store's recipes build a total-return index (base 1.0 on the first session of the range with a price) from raw closes and corporate actions, with the recipe's flags. Vendor-adjusted prices are never used.

On a store (profile="server"), inputs may be tickers (plain, or qualified by their exchange: "SAP GY"), ISINs, CIKs, FIGIs or instrument ids (mof:...), resolved through the latest mapping on the requested range's end, then its start, then today: a reused ticker names whoever held it then, a delisted company is found by its ticker over its life. A label naming several instruments raises AmbiguousInstrumentError, whose candidates (and message) list each one's qualified tickers, name, ISIN, composite FIGI and life, so the caller can ask which one; never a silent pick. The answer is keyed by instrument_id only and read as known at as_of (only the requested instruments' series are read). Every source is read; where two sources hold one instrument, pass precedence=["my_export", "massive"] (the first source with a row wins per session; see "Your own data" for the default); source= keeps one source only. Errors are ApiError subclasses (MissingKeyError, UnknownInstrumentError, AmbiguousInstrumentError, AmbiguousSourceError, NoDataError). See the docstring of market_data.api.

Environment variables

Variable Used by Meaning
TIINGO_API_KEY Tiingo adapter, prices() Your Tiingo key. Required for Tiingo.
MASSIVE_API_KEY Massive adapter, prices(source="massive") Your Massive key. Required for Massive.
OPENFIGI_API_KEY map --openfigi, map --listings Optional. Without it the resolver stays within OpenFIGI's keyless quota (25 requests a minute, 10 jobs per request); with it, 250 and 100.
MOF_MARKET_ADAPTERS CLI Comma-separated source codes of the adapters allowed (e.g. massive,tiingo). Unset: none. Others are never imported.
MOF_MARKET_ARCHIVE CLI Root of the raw archive (default for --archive). No default; must not be inside a git checkout.
MOF_MARKET_REPORTS CLI Private directory for run records and reports (default for --reports). Required by every --write and by report. Must not be inside a git checkout.
MOF_MARKET_TOKEN_SALT load-history Secret salt (at least 16 bytes) for the opaque tokens of a history file. Keep it on the store host.
MOF_MARKET_MANUAL_MAPPING map Optional path to a reviewed CSV (source_code, source_symbol, instrument_id or composite_figi, valid_date, valid_to, link_reason) that overrides the automatic mapping for the series it names. Private.
MOF_MARKET_VOLUME_ROUNDING Massive and Tiingo adapters How a decimal (fractional-share) volume becomes the store's whole-share volume: nearest (default, ties to even), floor, or reject (the row is kept out as bad_volume, the behaviour before 0.1.2). The raw archive keeps the exact value. Pick it once per store: a rebuild under another rule conflicts with published rows.
MOF_MARKET_STATE_DIR Tiingo adapter Where the provider quota state is kept across runs (off disables it). Default: the user cache directory + myopenfund/market-data.
OPEN_DATA_STORE_DATA_ROOT CLI, prices(profile="server") The store's data root; batches are dropped in its landing/ (default for --landing).
OPEN_DATA_STORE_CATALOG CLI, prices(profile="server") The store's catalogue (published identifiers, coverage reads).

Other open-data-store variables (publisher, catalogue tuning) are documented in its README.

Operator commands (server profile)

market-data <command> runs on the store host. Every command is a dry run unless --write: it computes what it can and writes nothing (fetch lists the requests it would make and the quota they would spend). Each prints one summary line (counts, never a label) and exits 0 (ok), 1 (degraded; 0 with --allow-degraded) or 2 (error, or a usage error refused before any work). Common flags: --write, --allow-degraded, --archive, --reports, and --landing for the commands that land batches. --source takes the adapters shipped here (massive, tiingo); an adapter from your own package is driven through the Python API (market_data.pipeline).

The order of a run, the publisher (open-data-store's publish_pending) landing the batches between the steps that read the store:

  1. declare --from-manifest DIR --write and declare --installed CODE... --write, publish (a store's first sources batch must be approved; every landing also writes its own);
  2. load-history --write (once per export), map --write --no-existing (the first mapping), publish;
  3. fetch --write (symbols, prices, actions: as many as the plan allows), map --write (reads the published identifiers), publish, build --source ... --write (restricted to the published mapping), publish;
  4. index-reference --export DIR --public-changes FILE... --write, publish (after map, before report; rerun it each quarter, see below);
  5. report --index CODE --write (with --precedence my_export massive once a provider overlaps the history: two sources for one instrument and session refuse a coverage without it).

The raw archive (MOF_MARKET_ARCHIVE) must sit on a local filesystem that supports hard links (each answer is written to a temp file, then linked into place, never overwritten): not a share mounted without hard-link support. Fetch a session once the provider has published it: a session fetched right after its close may come back empty and is logged as fetched; while no member has a price that day the store's coverage counts the session session_not_published, never a delisting; fetch it again later (report --index without --as-of leaves out a session not closed yet).

Load a history file (format below); --previous-snapshots restates snapshots already published, --max-non-session-share sets the tripwire for dates that are not exchange-local:

market-data load-history --dir /private/exports/2026-11 --write

Fetch into the raw archive (--kind prices|actions|symbols; --date D or --from D --to D; --symbols for a per-symbol fetch, else the whole market where the source offers it):

market-data fetch --source massive --kind prices --date 2026-11-20 --write

Map provider symbols to instruments (defaults: the newest history load's observations and spans, plus the archived symbols and prices of every allowed adapter, and the identifiers already published; --no-existing is required for a first mapping, --openfigi asks OpenFIGI; --listings asks OpenFIGI the exchange of each instrument without one, by its composite FIGI, and adds its exchange-qualified ticker: once per instrument, a re-run asks nothing more):

market-data map --openfigi --write
market-data map --listings --write

A history file's labels (ticker, ISIN, name...) of a delisted listing are dated to its life (first to last quote), never open next to a later reuse of its ticker. A series mapped by the reviewed manual file keeps the labels its own composite FIGI gives when the review maps it to that instrument (a venue cut of one company); otherwise none.

Build prices, corporate_actions and fetch_log batches from the archive of one source, restricted to its mapped universe (--identifiers PARQUET instead of the store's; --all-symbols for every archived symbol):

market-data build --source massive --write

Merge the newest piece of each step into <run_id>-report.json / .md, with the store's coverage of one index (--as-of, --precedence, --snapshot-precedence, --staleness-days, --max-missing-share, --min-delisting-gap-sessions; defaults are the store recipes'). Without --index the report is degraded (coverage_not_run):

market-data report --index sp500 --as-of 2026-11-20T22:00:00+00:00 --write

Publish the index reference data of a history export's indices (--export DIR, the export load-history read). --public-changes FILE... takes one or more CSV files of public dated changes, with the header index_code,change,ticker,name,effective_date,reason,reference,evidence_source (change is add or remove). Each row is confirmed only when exactly one member of the matching month-end snapshot transition fits its ticker, then its name; a row that fits none or several stays unconfirmed and is counted, not published. Rows giving the same change of the same member with the same normalised date (twice, or on the review's Friday and on its effective Monday) confirm once, the others are counted as public_duplicates; the same member with two distinct dates is a conflict and stays unconfirmed. The snapshot counts (snapshot_adds, snapshot_removes, transitions_unconfirmed) are by export member id, so a member whose id changes (a rename, a venue change) counts as a remove and an add: they overstate the undated changes. --horizon-years N (default 2) is how many calendar years past today the review calendar is projected:

market-data index-reference --export /private/exports/2026-11 \
    --public-changes /private/changes/2026-q3.csv --horizon-years 2 --write

It publishes two contracts, both declared with origin operator (--write declares them before landing): index_calendar (source index_rules: the review and rebalance events the rules give, with the verified dates and exceptions applied) and index_changes (source index_public: the confirmed changes, keyed by token, never by raw member id). reason and reference are never published. They stay, with the raw member ids and the unconfirmed counts, in the private run directory under MOF_MARKET_REPORTS: keep it off any shared path and out of any git checkout. An identical rerun writes no row.

Rerun it each quarter, with the new public changes. A projected event that keeps its date keeps its key (index, event type, effective date): it is restated with a later known_at (status projected to rule or verified) and nothing is retired. A calendar retirement row (is_active = false) is written only for a published active event of index_rules whose index is one of this run's ruled indices, whose effective date is inside this run's range (1 January of the first snapshot year to 31 December of the load year + --horizon-years), and whose key is no longer in the new output, that is when a projection moves or disappears. An event outside that range (a shorter --horizon-years than the previous run, or an earlier year) or of another index is left as it is.

The changes are retired the same way: a published active index_public change of this export's snapshot_source_code and of one of the export's indices that is not in the new confirmed set gets a retirement row. So a run must be given the complete set of public changes (every file, every quarter so far): a file left out retires the changes it confirmed. An index absent from a later export keeps its rows.

Retirement needs the store to be configured (OPEN_DATA_STORE_DATA_ROOT and OPEN_DATA_STORE_CATALOG both set), because the previous rows are read from it; without them no previous rows are read and nothing is retired.

A dry run (no --write) reads the store's previous rows and declarations, when a store is configured, exactly as a write does.

The package data (verified review dates and exceptions) is extended by editing the two CSVs under src/market_data/data/index_calendar/. Each exceptions row must move one rule event (its rule_effective_date is the rule's effective date for that index and event type) and have last_old_session before effective_date; index_calendar.validate_exceptions() checks it, and the calendar refuses a row that moves nothing.

Once published, market_data.pipeline.store_coverage(membership_dates="reference") reads the membership dates from this reference data, and the acceptance module's equal_weight_index(rebalance="calendar", calendar=<the parent index's index_calendar rows>) rebalances on its review sessions.

See market-data <command> --help and the docstrings of market_data.cli and market_data.pipeline.

Daily job

market-data daily runs the whole daily cycle in one command, for a cron or a container. Like every operator command it is a dry run unless --write:

market-data daily --check            # validate the configuration and the environment, change nothing
market-data daily                    # dry run: plans and computes, writes nothing
market-data daily --write            # the real run
market-data daily --write --allow-degraded

Exit codes: 0 ok, 1 degraded (0 with --allow-degraded), 2 error or a usage or configuration error refused before any work. The run prints one summary line (counts, never a label).

Run order, in outline. Preconditions first (the daily source declared, a published mapping for it, the market contracts approved, a readable exceptions file). Batches left by an interrupted run are published first, after a catalogue dump (one dump per run, before its first publish; old dumps are pruned at the end). Then the sessions to do are worked out from the store's prices; more than MOF_DAILY_MAX_CATCHUP_SESSIONS is an error (a manual catch-up is needed), never a silent quota spend. The daily source is fetched (prices per session, corporate actions, symbol lists when stale), mapped, published, built and published. A first verdict is computed; Tiingo is then asked for the unexplained gaps within its budget, with its own mapping rows, build and publish, and a final verdict closes the run. A --write run holds a job lock (<MOF_MARKET_REPORTS>/.daily.lock): a second --write run started while one is active exits 2 at once (and sends no alert: the active run alerts for itself). A dry run or --check takes no lock.

Checked sessions and retries. The verdict checks the sessions to do plus the last MOF_DAILY_GAP_RETRY_SESSIONS sessions before them, never before the first session priced in the read window; for each checked index, only the sessions from its first snapshot on (a newly added index is younger, not empty). Of those retried sessions, only the ones holding a session_not_published cell (no daily-source price at all for that session) are asked again from Massive; every other gap goes to Tiingo, within its budget. When a run's map changes the published Massive mapping (a symbol mapped late), the Massive build covers the whole checked window, so the symbol's archived sessions are built too; rows already published are skipped by the publisher.

OpenFIGI. The map asks at most MOF_DAILY_OPENFIGI_MAX_JOBS jobs a run. Every current member's ticker (mapped or not) takes a member share of at least one and at most half the cap (cap // 2), rotated night after night; every other job (the unmapped tickers and the mapped tickers priced tonight) shares the remaining slots in one rotated pool; slots the pool leaves unused go back to the members. Jobs not sent stay unresolved this night.

Provider failures. A provider call that fails (Massive or Tiingo answering an error, a 429 or a transport error still failing after the adapter's retries, an unusable answer, Tiingo's own quota refusal, an OpenFIGI failure) does not stop the run: the archived data is used, the run goes on and ends degraded with the reason provider_error; the report's notes name the source and step (provider_error_<source>_<step>). A refused key, a failed dump, publish or store read, and any other exception are errors (exit 2).

First watched night. A member lacking a price before the junction (the export's last session to the daily source's first) may make the first dry run show session_not_published cells and the first --write ask Massive for a few earlier sessions; this resolves itself.

A dry run (no --write) prints one summary line (the plan and the verdict on what is stored) and writes nothing: no report, no notification.

Parameters. Every setting is an environment variable with a default; leave a variable unset to take the default (a variable set but empty is an error for those that have one).

Variable Default Rule Meaning
MOF_DAILY_PUBLICATION_DELAY_MIN 120 integer minutes >= 0 Minutes after a session's close before the job treats the provider as having published it.
MOF_DAILY_PUBLICATION_GRACE_SESSIONS 1 integer >= 0 Latest sessions whose missing prices are tolerated as not yet published rather than a gap.
MOF_DAILY_MAX_CATCHUP_SESSIONS 20 integer >= 1 Most sessions one run catches up after a missed run.
MOF_DAILY_ACTIONS_LOOKBACK_DAYS 10 integer >= 0 Days back the corporate-actions fetch re-reads, to pick up corrections.
MOF_DAILY_ACTIONS_LOOKAHEAD_DAYS 30 integer >= 0 Days ahead the corporate-actions fetch reads (announced events).
MOF_DAILY_SYMBOLS_MAX_AGE_DAYS 7 integer >= 1 Age in days after which the provider symbol lists are fetched again.
MOF_DAILY_OPENFIGI_MAX_JOBS 100 integer >= 0 Most OpenFIGI jobs one run may spend on mapping (0 disables the lookup).
MOF_DAILY_MAX_BATCH_ROWS 500000 integer >= 1 Most rows in one landed batch; larger builds are split.
MOF_DAILY_GAP_RETRY_SESSIONS 10 integer >= 0 Sessions back in which a price gap is fetched again.
MOF_DAILY_TIINGO_MAX_SYMBOLS 25 integer >= 0 Most Tiingo per-symbol fetches in one run (0 disables).
MOF_DAILY_TIINGO_MONTHLY_RESERVE 100 integer in 0..500 Tiingo monthly quota kept unspent (0..500).
MOF_DAILY_VERDICT_UNIVERSE indices one of: indices, all_mapped Universe of the coverage verdict: indices or all_mapped.
MOF_DAILY_VERDICT_INDICES SPX NDX space-separated, non-empty Index codes judged when the universe is indices (space-separated).
MOF_DAILY_PRICE_PRECEDENCE empty space-separated source codes Price source order, first wins. Empty: derived from the declarations (file sources, then adapters in MOF_MARKET_ADAPTERS order).
MOF_DAILY_SNAPSHOT_PRECEDENCE empty space-separated source codes Index-snapshot source order. Empty: derived from the declarations.
MOF_DAILY_MAX_SNAPSHOT_AGE_DAYS 35 integer in 1..44 (below the recipe's 45) Oldest membership snapshot the run accepts, in 1..44 (the recipe's own limit is 45).
MOF_DAILY_JUMP_THRESHOLD 0.5 finite number > 0 Relative close-to-close move above which a price is flagged as a jump.
MOF_DAILY_JUNCTION_MAX_GAP 0.25 finite number > 0 Largest relative gap tolerated where two sources' series are joined.
MOF_DAILY_PUBLISH_LOCK_RETRIES 6 integer >= 0 Times the publish step retries when the publisher lock is held.
MOF_DAILY_PUBLISH_LOCK_WAIT_S 300 finite number > 0 Seconds between those retries.
MOF_DAILY_DUMP_RETENTION_DAYS 30 integer >= 1 Days the catalogue dumps are kept.
MOF_DAILY_NTFY_MAX_NAMES 5 integer >= 0 Most names listed in a notification (0: counts only).
MOF_MARKET_EXCEPTIONS unset path Reviewed exceptions file (below). Unset: no exceptions. The NAS recipe sets it.
NTFY_URL unset text Notification endpoint, treated as a secret and never printed. Unset: no notification. The NAS recipe sets it.

The precedence variables list source codes, such as private_history massive tiingo. Source codes are those of your declarations; a deployment sets them explicitly.

Exceptions file. A private CSV, only read by the job, that explains a missing price of an index member. Columns, in order: instrument_id, session_from, session_to, reason (one of halted, delisted, acquired, not_traded, provider_missing, other), evidence, verified_by, verified_at, recheck_by. Dates are ISO (YYYY-MM-DD). A malformed file is an error that lists each problem by row and column, never the cell content.

Report. Each --write run writes daily-<run_id>-report.json (complete) and daily-<run_id>-report.md (short summary) into MOF_MARKET_REPORTS. They hold no private token. The JSON holds the outcome and reasons; counts (cells per class) and counts_by_session (session -> class -> cells); the gaps (non-ok cells: instrument id, session, class, public ticker); the issues (quality issues on member cells: instrument id, session, issue, ticker); members_unresolved (member symbols of the checked snapshots that map to no instrument, counted per checked session: degrading, reason members_unresolved); calls (fetches per provider, i.e. archived fetch results, plus openfigi_jobs, the OpenFIGI jobs sent; the map step line shows the same sent count as openfigi_jobs and the jobs offered as openfigi_offered); the publish counts, the compositions, the precedence, the fallback plan, the notes, the step lines and run (wall-clock seconds and the process's peak_rss_mib).

Notification. With --write, a short message goes to NTFY_URL after each run with its status and counts, naming at most MOF_DAILY_NTFY_MAX_NAMES instruments: the tickers of missing and unmapped cells, and only those when there are any, else those of the other non-ok cells. A failure outside the run's own report (the configuration, the job lock unavailable, the report not written) sends a best-effort urgent message naming the error type only.

Deployment. The container image and a NAS recipe (compose file, .env.example, schedule) are under deploy/nas/; see its README. The image runs market-data daily --write on DAILY_CRON, default 30 3 * * 2-6 with TZ=Europe/Paris (03:30 Tuesday to Saturday), to confirm from the publication probes. OPENFIGI_API_KEY is optional in the CLI (the NAS recipe requires it).

History-file format

The door for anyone with their own data: a directory loaded by load-history (market_data.adapters.file). Tables are Parquet (preferred) or CSV (UTF-8, comma separator, header line), possibly split into parts (prices_daily_part001.parquet); dates YYYY-MM-DD; . as decimal separator; empty means unknown (never -, N/A or #N/A, which are refused). Prices must be raw, unadjusted.

File Columns Required
manifest.json or manifest.csv (key,value) export_time (ISO 8601 with offset), adjustment (must be none), dates_timezone (must be exchange), dividends (gross or net), source_description; optional fields, notes, per_share_basis_default (old_share or new_share: the basis of a cash amount whose row leaves per_share_basis empty) yes, every key but the optional ones
securities (one row per member_id) member_id, name, figi, composite_figi, share_class_figi, isin, country, exchange_code, security_type, price_currency, status, delisting_date, delisting_reason, last_ticker yes; member_id, name (the rest best effort)
index_snapshots date, index, member_id, weight date, index, member_id
prices_daily member_id, date, close, volume, currency, optional open, high, low member_id, date, close, volume (values may be empty), currency; for every member over its whole listed life
corporate_actions member_id, action_type, source_action_type, announce_date, ex_date, record_date, pay_date, amount, currency, ratio_old, ratio_new, spinoff_member_id, optional per_share_basis (old_share or new_share: is a cash amount per share before or after a split on the same ex-date) optional file; member_id, source_action_type, ex_date
total_return_index member_id, date, tr_index optional file (a vendor control series)

At least one of index_snapshots and prices_daily is required. An exchange code (from securities.exchange_code, else the second word of member_id) picks the calendar of a member; US codes map to XNYS by default. A cash action the total-return recipe could never apply (no currency, or no per_share_basis on the ex-date of a split or stock dividend of the same member) is still loaded but counted, and degrades the run (unusable_cash_actions). The loader replaces every member_id by an opaque token (MOF_MARKET_TOKEN_SALT) in every dated row, and refuses a malformed file with a list of every problem (file, column, row; never a cell's content).

Acceptance computations

market_data.acceptance holds pure functions over the store recipes' outputs (membership_intervals of one index, total_return, sessions), to check a backtest universe on your data. None of them reports a clean result on missing evidence:

  • equal_weight_index(intervals, tr, sessions, rebalance="quarterly", company_groups=...): an equal-weight index (per company when company_groups [instrument_id, company_id] groups share lines), rebalanced monthly or quarterly (rebalance_months, default January, April, July, October) on membership as known at each date. Members leaving between rebalances are sold at their last total-return level; exit_proceeds keeps the proceeds in cash (default) or reinvests them pro rata. A member with no usable level at a rebalance (none yet, or older than max_stale_sessions) is skipped and counted (on_missing="skip", default) or refused ("raise"). The result holds levels and one rebalances row per date (members, bought, skipped, stale, carried). annual_fee for an ETF comparison.
  • truncation_check(build_fn, as_of): your build_fn(as_of, truncate=...) builds the series twice, once after removing every fact known after as_of from its inputs (truncate=True) and once from everything available now; the check lists the sessions up to as_of that differ (empty: no look-ahead). It proves only what your build_fn does: one that ignores truncate always passes. Take as_of at or after a session close; comparing no session raises.
  • compare_series(a, b, tolerance=...): our series vs a vendor's (maximum difference, sessions over tolerance, annualised tracking difference); it does not pass on fewer than min_sessions (default 2) common sessions, and says why in reason.
  • survivors_only_delta(...): the same index on today's members only, and the annualised return that bias would add. The point-in-time index raises on a member without total return (full_on_missing="raise", default: skipping a dead name would hide the bias measured); the survivors index skips (survivors_on_missing="skip"); both skipped counts are returned.

Their docstrings state every rule and parameter.

Adapters

What --source and load-history read:

Adapter What Command
massive Massive (formerly Polygon.io) daily US prices, dividends, splits, tickers; free Stocks Basic plan, 5 requests a minute, 2 years of history fetch / build --source massive
tiingo Tiingo end-of-day prices with dividends and splits, per symbol; free plan (50 requests an hour, 1,000 a day, 500 symbols a month) fetch / build --source tiingo
history file the format above (source code: your manifest's source_code) load-history

Quotas are respected, never worked around: requests are spaced, retries are bounded, and a limit may be set lower, never higher.

Sources this package registers (licence, terms, flags) under the open_data_store.sources entry point: see Licences. A history file's source is declared by its own manifest, not here.

Writing an adapter in your own package

Implement the market_data.adapters.base.Adapter protocol (source_code, info, fetch, parse), register a SourceInfo for your source under the open_data_store.sources entry point, and declare the adapter under the market_data.adapters entry point (name = source code, value = a zero-argument callable returning the adapter). Then add its code to MOF_MARKET_ADAPTERS.

Optional class attribute corroborates_delisting (default False when absent): set it to True only when your source's mapping windows end at an export date, as the history file's do (a dead member's last price ends its window, the export date ends its fetch-log row). The coverage then reads an ok/empty fetch past a symbol's last window as a corroborated delisting (quality.fetch_coverage rule 6, its corroborating_sources; pipeline.corroborating_codes reads the attribute, pipeline.store_coverage takes the codes). A live provider keeps False (Massive and Tiingo do): one empty answer for the next session (a halt, a late publication) or a renamed ticker is not a delisting.

[project.entry-points."market_data.adapters"]
my_source = "my_package.adapter:make_adapter"

[project.entry-points."open_data_store.sources"]
my_package = "my_package.sources:sources"

Compliance checklist (adapters merged in this repo)

  • Link to the source's terms
  • Official or documented endpoint
  • Quota respected (rate limiter, backoff)
  • Licence declared in the source registry
  • No header or browser spoofing
  • Terms flags (redistribution, public_display, ml_training) filled in from the terms

Anything else lives in your own package, under your responsibility.

Your own data

A history file (format above) is declared by its manifest.json (or manifest.csv). Besides the keys listed there, it names its source:

Key Meaning
source_code required: the code your rows carry (lowercase letters, digits, _)
licence required: a short text, e.g. the name of your agreement
terms_url optional: link to the terms
attribution optional: text to credit when you share
redistribution, public_display, ml_training optional flags: true/yes/1, false/no/0 (in manifest.json also a JSON true/false), or empty (not stated)

A minimal synthetic manifest.json:

{
  "export_time": "2026-11-01T00:00:00+00:00",
  "adjustment": "none",
  "dates_timezone": "exchange",
  "dividends": "gross",
  "source_description": "Synthetic example export",
  "source_code": "my_export",
  "licence": "My own research licence",
  "terms_url": "https://example.com/terms",
  "attribution": "",
  "redistribution": "false",
  "public_display": "false",
  "ml_training": "no"
}

Every landing writes a sources batch declaring the sources of its rows, and no row of a market contract lands without its source declared. To declare without loading anything:

market-data declare --from-manifest /private/exports/2026-11 --write
market-data declare --installed massive tiingo --write

--installed takes codes that installed packages register (the open_data_store.sources entry point); both are dry runs without --write (a dry run reads the store when it is configured and says which declarations would land and which are already published). On an existing store, follow "Upgrading an existing store" below before the next map, report, build or read.

Precedence. No reader filters by source. Where several sources hold one instrument, the first source with a row wins per session: by default file sources (your history files) first, then the adapters in MOF_MARKET_ADAPTERS order, unlisted sources last. Two unlisted file sources on one instrument raise AmbiguousSourceError: pass precedence=[...] to market_data.api.prices or --precedence to the CLI steps that take it (the MCP server reads the same order from its MOF_MARKET_PRECEDENCE setting) to say which wins, or source= to keep one. The declarations behind that default order are read as they stand now, whatever as_of: a reproducible as-of backtest passes an explicit precedence.

Corporate actions across sources. prices(..., adjust="total_return") takes actions_from: with "winning_source" (the default) a source's corporate actions count only on the sessions where its prices win (conventions differ across sources), and every session where an action of another source was dropped carries the flag action_of_other_source_dropped in flags. A price-only history winning over a provider then shows the provider's split as a flagged drop, not a silent one. actions_from="any" counts every action of the instrument's series, resolved per ex-date in the same precedence (the previous behaviour).

Licences

Every source declares three descriptive flags: redistribution, public_display, ml_training (true, false, or not stated). They are information for you and for open-data-store's licence report. They are never enforced: no code path drops, hides or refuses a row because of a flag, and a deployment serves what it holds. Checking each provider's current terms, and what you may do with the data (share, publish, train on it), is your responsibility. The code in this repository is MIT licensed; the data you fetch is not.

Sources this package registers:

Source Licence Redistribution Public display ML training
massive Massive terms of service, personal use no no no
tiingo Tiingo terms of service, personal use no no no
openfigi OpenFIGI terms of service (attribution: OpenFIGI) yes yes not stated
sec SEC EDGAR public data (attribution: SEC EDGAR) yes yes not stated
manual your reviewed manual mapping (origin operator) not stated not stated not stated

Upgrading (breaking changes)

  • FileHistory no longer takes a source code: the manifest names it (source_code).
  • Manifest keys source_code and licence are now required (see Your own data).
  • build_mapping and link_issuers have new signatures: the source codes come from the declarations, not from a fixed constant.
  • prices(..., allowed_restricted=...) is removed, and so is RestrictedSourceError.
  • CLI --allowed-restricted is removed (report).
  • HISTORY_SOURCE is removed: no source name is special in library code.
  • A source's corporate actions follow the sessions where its prices win (actions_from="winning_source"; actions_from="any" keeps the previous behaviour, see Precedence).
  • map, report --index and pipeline.store_coverage refuse a store holding rows of a source code nobody declares (UndeclaredSourceError); readers (prices) still read such rows.

Upgrading an existing store

A store written by an earlier release holds rows and no sources rows. Before the next map, report, build or read, approve the sources contract, then declare and publish:

  1. The manifest's source_code must be exactly the code your published rows already carry. The history file's tokens derive from that code: another code orphans every published row and mapping (they would be re-minted under new tokens).

  2. Declare and publish first, before the next map, report, build or read:

    market-data declare --from-manifest /private/exports/2026-11 --write
    market-data declare --installed massive openfigi manual --write
    open-data-store publish
    

    Until then map stops with UndeclaredSourceError (dry run included) and sends nothing to OpenFIGI.

  3. --installed must list every other code that has rows in the store (labels placed by the previous release can sit under openfigi, sec, manual or an adapter's code). List them per market table with the reader's role (lake_reader):

    from open_data_store.reader import Store
    from open_data_store.reader.api import UnknownDataset
    
    MARKET = ("prices", "corporate_actions", "index_snapshots", "vendor_total_return",
              "instrument_identifiers", "fetch_log")
    with Store.open() as store:  # the reader's environment
        held = set()
        for name in MARKET:
            try:
                published = store.is_published(name)
            except UnknownDataset:  # a contract this store never approved
                continue
            if published:
                sql = f"SELECT DISTINCT source_code FROM lake.facts.{name}_v1"
                held |= {code for (code,) in store.con.cursor().execute(sql).fetchall()}
    print(sorted(held))  # e.g. ['massive', 'manual', 'openfigi', 'my_export']
    

    Your manifest declares your own code; pass the others to --installed (here massive openfigi manual).

  4. Check the result: every code held has a declaration.

    from open_data_store.sources import describe_sources
    
    with Store.open() as store:
        declared = describe_sources(store, present=held)
    assert None not in declared.values(), [c for c, i in declared.items() if i is None]
    

Then map and build run as before: nothing is re-emitted, and a second run lands no new sources vintage.

What never goes in this repository

  • A private export, or anything derived from it: member lists, dead-name lists, their FIGIs, manual mapping rows, tokens, mapping reports.
  • Run records and reports (MOF_MARKET_REPORTS), the raw archive (MOF_MARKET_ARCHIVE), store data: all on private paths outside any git checkout.
  • Keys and the token salt.

Tests use synthetic fixtures only.

Development

python3 -m venv .venv && . .venv/bin/activate && pip install -e ".[dev]"
ruff check src tests && ruff format --check src tests
pytest -q -W error

Releases: the release workflow publishes to PyPI by trusted publishing (tag vX.Y.Z, or Run workflow with target pypi or testpypi) once the pypi environment's reviewer approves. Its guard (scripts/check-no-direct-references.sh) fails the build while pyproject.toml pins a dependency by git URL, and checks the built wheel's Requires-Dist again. The workflow then creates the tag vX.Y.Z and the GitHub Release with the repository secret RELEASE_TOKEN, a fine-grained personal access token with Contents and Workflows read/write on this repository: the workflow's own token may not create a tag once main changed a file under .github/workflows/ (an automated GitHub Actions bump, for instance). Without the secret, or when it cannot read the repository, the run stops before publishing; there is no fallback to the workflow's token. A tag pushed with that token starts the workflow again; the release writes a mark in the tag annotation and that second run skips every job. The PyPI upload skips files already there: if PyPI got the package but the tag is missing, re-run the failed job or run the workflow again; if the tag exists but the Release is missing, re-run only the failed github-release job (a new run stops at the existing tag).

MIT licensed.

Metadata

Release files for myopenfund-market-data 0.2.0

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

Source distribution (sdist)

Source distribution for myopenfund-market-data 0.2.0
File Size Uploaded Provenance Actions
myopenfund_market_data-0.2.0.tar.gz 417.2 kB With provenance Details for myopenfund_market_data-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for myopenfund-market-data 0.2.0
File Interpreter ABI Platform Actions
myopenfund_market_data-0.2.0-py3-none-any.whl Python 3 none any Details for myopenfund_market_data-0.2.0-py3-none-any.whl

Total release size: 662.9 kB

Release files / myopenfund_market_data-0.2.0.tar.gz

Download URL myopenfund_market_data-0.2.0.tar.gz
Size 417.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4977e5852761a7426c5d11aa51168cbfa89c23ec98e5ec6ec390031e1868c82e
BLAKE2b-256 checksum
How to use checksums
eea9365384da79bf5fe055f8304d61843e2315abf1d029ae6694b57db5b313cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / myopenfund_market_data-0.2.0-py3-none-any.whl

Download URL myopenfund_market_data-0.2.0-py3-none-any.whl
Size 245.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f9f30dc8794a66d626134c73ed4280d0cb44f6a9bfa92f987e84b6365196b49
BLAKE2b-256 checksum
How to use checksums
c14dbd8da7270c955eb0a975dd3985ac17521bdcfaf81170d9a2f1354bfd1be9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Security for myopenfund-market-data 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for myopenfund_market_data-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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