Skip to content

mostlyrightmd/mostlyright-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

814 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

mostlyright

The public-data SDK for quants, ML pipelines, and AI agents.

PyPI version PyPI downloads npm version npm downloads Python versions License: MIT Docs

mostlyright is a Python + TypeScript SDK for quants, ML engineers, and AI agents — one direct, schema-versioned interface to every public data source that matters. Today's adapters ship weather data (live METAR/ASOS, forecasts, GHCNh climate history, NWS CLI text products) and prediction-market settlements (Kalshi NHIGH/NLOW, Polymarket discovery + settlement, Kalshi + Polymarket trades). Next: SEC filings (EDGAR), equities structured data, Federal Reserve series (FRED), court filings, FDA approvals — anywhere the data is public, we ship the adapter. Local-first: no hosted backend, no API key for the public-data layer, byte-equivalent reproducibility from research to backtest, and leakage-free training pairs for ML pipelines.


Install

# Python
pip install 'mostlyrightmd[research]'

# TypeScript / Node
pnpm add mostlyright

Python 3.11+. Node 18+. No API key required for any package below.

Quickstart

# Python
import mostlyright

df = mostlyright.research("KNYC", "2025-01-06", "2025-01-12")
print(df.head())
# pandas DataFrame: one row per LST settlement date
# Columns: date, station, cli_high_f, cli_low_f, obs_high_f, obs_low_f,
#          obs_mean_f, obs_count, fcst_*, market_close_utc
// TypeScript
import { research } from "mostlyright";

const rows = await research("KNYC", "2025-01-06", "2025-01-12");
console.log(rows[0]);
// ReadonlyArray<PairsRow>: same schema as Python, JSON-serializable

First call writes a parquet (Python) or JSON-envelope (Node) cache to ~/.mostlyright/cache/. Subsequent calls in the same window are local-only — no network.

Full quickstart with concepts at https://mostlyright.md/docs/sdk/.

Packages

Python (PyPI)

Package Description Downloads Status
mostlyrightmd Core types, schemas, validators, the research() join, and snapshot primitives. Imports as mostlyright. monthly downloads stable
mostlyrightmd-weather Weather data fetchers — live METAR (AWC), ASOS archive (IEM), historical observations (GHCNh), and NWS climate text products (CLI). Direct public-API access. monthly downloads stable
mostlyrightmd-markets Prediction-market data — Kalshi NHIGH/NLOW weather-contract resolvers, Polymarket discovery + settlement, and Kalshi + Polymarket trade history. monthly downloads stable
mostlyrightmd-edgar SEC filings (10-K, 10-Q, 8-K) — direct EDGAR full-text + facts access. n/a planned
mostlyrightmd-equities Equities structured data — fundamentals, corporate actions, normalized XBRL pulls. n/a planned
mostlyrightmd-fred Federal Reserve economic data (FRED series, observations, releases). n/a planned
mostlyrightmd-courts Court filings — federal (PACER) and state dockets, opinions, party data. n/a planned
mostlyrightmd-fda FDA approvals — drug + medical-device clearance records, post-market events. n/a planned

TypeScript (npm)

Package Description Downloads Status
mostlyright Meta package — one import { research } from "mostlyright" for weather data + prediction-market settlements + the core join. monthly downloads stable
@mostlyrightmd/core Core types, schemas, validators, temporal-safety primitives, and the research() join. monthly downloads stable
@mostlyrightmd/weather Weather data fetchers — live METAR (AWC), ASOS archive (IEM), historical observations (GHCNh), and NWS climate text products (CLI). monthly downloads stable
@mostlyrightmd/markets Prediction-market data — Kalshi NHIGH/NLOW weather-contract resolvers, Polymarket discovery + settlement, and Kalshi + Polymarket trade history. monthly downloads stable
@mostlyrightmd/edgar SEC filings (10-K, 10-Q, 8-K) — direct EDGAR full-text + facts access. n/a planned
@mostlyrightmd/equities Equities structured data — fundamentals, corporate actions, normalized XBRL pulls. n/a planned
@mostlyrightmd/fred Federal Reserve economic data (FRED series, observations, releases). n/a planned
@mostlyrightmd/courts Court filings — federal (PACER) and state dockets, opinions, party data. n/a planned
@mostlyrightmd/fda FDA approvals — drug + medical-device clearance records, post-market events. n/a planned

What you can build

Backtest prediction-market settlements

Pull joined climate + observation rows for a settlement window, compare against contract spec, and produce a deterministic settlement decision.

import mostlyright
from mostlyright.markets.catalog import kalshi_nhigh

# 1. What does the contract settle on?
contract = kalshi_nhigh.resolve("KHIGHNYC", date(2025, 1, 15))
# 2. Pull the data that decides it.
df = mostlyright.research(contract.settlement_station, "2025-01-15", "2025-01-15")
# 3. Apply the threshold and decide.

Train models with train/infer source parity

research() stamps a source identity on every row. The validator catches train/infer mismatches at load time, instead of silently corrupting predictions in production.

from mostlyright.mode2 import research_by_source
from mostlyright.core import validate_dataframe

train = research_by_source("KNYC", "iem.archive", "2024-01-01", "2024-12-31")
# Validator pins the schema's expected source. SourceMismatchError fires if
# you accidentally route a Mode 1 (fused AWC+IEM+GHCNh) DataFrame through a
# Mode 2 (iem.archive only) schema.
validate_dataframe(train, schema_id="schema.observation.v1")

Feed AI agents structured public data

Every response carries a stable schema.*.v1 URI and serializes to JSON-Schema-validated shapes. Drop responses into MCP tool outputs or OpenAI/Anthropic function-call returns without re-shaping.

import { research } from "mostlyright";
import { validateRows } from "@mostlyrightmd/core/validator";

const rows = await research("KNYC", "2025-01-06", "2025-01-12");
const result = validateRows(rows, "schema.observation.v1");
// result.audit_log carries the schema URI + source identity + row count
// — ready to pass through to an agent's tool-call response.

Why mostlyright

  • No hosted backend. Direct calls to public APIs (NOAA, NWS, IEM, Kalshi, Polymarket). No proxy. No vendor account. No rate-limited tier.
  • Local-first cache. Parquet (Python) or JSON envelope (Node) at ~/.mostlyright/cache/. Byte-stable across runs — deterministic backtests.
  • Schema-versioned outputs. Every response carries a stable schema.*.v1 URI. Train/infer source mismatches fail loudly instead of silently corrupting models.
  • Python + TypeScript peers. Same research() shape, byte-equivalent on the parity fixtures. Use whichever runtime your stack prefers.
  • MIT licensed. Use it commercially. Fork it. Ship it.

Documentation

Contributing

Bug reports, feature requests, and pull requests are welcome. See CONTRIBUTING.md for the development workflow (fork → branch → PR) and the test gate. See CODE_OF_CONDUCT.md for community guidelines.

For security issues, see SECURITY.md — do not file public issues for vulnerabilities; email vu@mostlyright.md instead.

License

MIT. See LICENSE.

Acknowledgements

mostlyright calls the following public APIs directly. We are grateful for the work that makes weather and market data accessible at the public-API layer:

  • NOAA Aviation Weather Center (AWC) — live METAR feeds
  • Iowa State University Iowa Environmental Mesonet (IEM) — ASOS archive + CLI text products
  • NOAA National Centers for Environmental Information (NCEI) — GHCNh historical observations
  • National Weather Service (NWS) — climate data products (CLI) and forecast model outputs
  • Open-Meteo — multi-provider forecast aggregation (added Phase 20). 36 models across NCEP / ECMWF / DWD / Météo-France / Asia / Oceania / Europe / GEM Canada. Leakage-safe via per-cycle endpoint + conservative issued_at lower bound. See docs/forecast-sources.md.
  • Kalshi + Polymarket — public prediction-market metadata + settlement feeds

About

Local-first Python + TypeScript SDK for public data — one interface for quants, ML pipelines, and AI agents. Adapters ship weather (METAR, ASOS, GHCNh, NWS CLI) + prediction-market settlements (Kalshi, Polymarket) today. SEC filings (EDGAR), Federal Reserve (FRED), court filings, FDA approvals, and equities structured data are next.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors