Road Map¶
Where cointoss is, where it is going, and what has to be decided before it gets there. Updated
as directions change. Decisions that survive belong in docs/adr/; vocabulary belongs in
CONTEXT.md. This file holds the parts that are still moving.
Last updated: 2026-11-28, at 61ab18a.
Where we are¶
Ten ADRs. 477 tests, lint clean. Released as v0.0.1 and v0.0.2 on PyPI. The persistence layer (issue #5, ADR-0007, 0008 and 0009) is built: identity, Universe Definitions, membership intervals, Evaluation Runs, matrix entries and price history all persist, and every read folds supersession.
Two instances run on one host as systemd --user units (#23), each sweeping CoinGecko daily:
| Instance | Unit | Code | Bars since |
|---|---|---|---|
| dev | cointoss |
this checkout's .venv |
2026-10-01 |
| int | cointoss-int |
the released package (uv tool) |
2026-10-06 |
Both are backed up daily by a timer in the deployment repo (net00), which calls cointoss backup
where the build has it (#24); cointoss restore puts a backup into a stopped instance. Auth is woodglue's AuthStore (0.0.9): a built-in admin User
whose bearer token cointoss token prints; no Identity Provider is configured yet.
Built¶
| Module | What it owns |
|---|---|
cointoss.instrument |
Instrument identity. Immutable {type}.{scope}.{symbol} ids, resolution by External Reference, supersession, Ticker History. ADR-0004. |
cointoss.series |
UniverseSeries and ExposureSeries over lythonic value types. Step lookup, whole values per date. ADR-0003. |
cointoss.risk |
RiskModel with a revision log, CovarianceSeries declared and never recomputed. Exact-date lookup. ADR-0005. |
cointoss.sources.openfigi |
OpenFIGI v3 batch mapping, paced to the rate limit, a 429 optionally sent again (#39). Uncached, deliberately. ADR-0006. |
cointoss.sources.yahoofinance |
get_info, get_prices, batched get_prices_batch (#40), lookup, and each industry's top and fastest-growing companies (industry_listings, #38), and the industries themselves (industries, #42). Cached. |
cointoss.sources.coingecko |
Coin list, markets, detail, OHLC, market chart. Cached. |
cointoss.universe |
UniverseDefinition with a revision log, Inclusions and Exclusions, pure evaluation of a rank band or a Listing Rule (#38). ADR-0007. |
cointoss.prices |
Bar, CorporateAction, Restatement, source mapping, split-aware restatement detection. ADR-0009. |
cointoss.store |
The only module that touches SQL. Eighteen tables, enforced pragmas, SchemaVersion with migrations. Membership by date or Instrument, bars resolved through Price Sources and dated by the session closed (Session Offset). Schema version 3 stores each Universe Definition revision's rule kind (#38). ADR-0008. |
cointoss.portfolio |
Portfolio owned by a User, single-leg Trade voided rather than deleted, PortfolioPosition derived on read with average cost (#32). Stored as Portfolio and Trade, schema version 2. ADR-0001. |
cointoss.datasets |
Datasets read through frame (#27, ADR-0010): instruments, industries (#42), bars, returns, membership, changes, runs, and the owned trades, positions and portfolio_value, each holding only the caller's Portfolios and valued at resolved closes (#34). load into pandas for the explorer. |
cointoss.ingest |
Pinning a typed ticker: the mandatory FIGI attempt, resolve or mint, retrying an unresolved Instrument. ADR-0004. The daily market sweep (#19): CoinGecko markets to Instruments, membership and the day's bars with market cap, written only within the bar window after 00:00 UTC and never over a bar already stored. An Inclusion the listing leaves out is fetched by its CoinGecko id (#33). |
cointoss.backfill |
History backfill (#26): every coin ever a member gets a bar for each date with no stored one, from CoinGecko market_chart (90 to 365 days) and, for a coin whose Yahoo pair (a hand-kept ticker, {SYMBOL}-USD, or a suffixed ticker Yahoo search lists, #36) agrees with CoinGecko within 3% in median over 30 sessions, from Yahoo period="max" before today UTC. An accepted pair is a Yahoo External Reference and Ticker History; nothing stored is overwritten. ADR-0009. Then stock bars, through cointoss.stock_bars (#40). |
cointoss.stocks |
The stock sweep (#39): Yahoo's industry lists into yahoo-industries membership, once per US session. Tickers pinned by Ticker History at yahoo, else through one batched FIGI call minting stock.us.*; then every unresolved stock's FIGI attempt retried. A golden FIGI file of 19 tricky tickers replays offline. Each stock's Yahoo sector and industry into the yahoo-industry Exposure Series, appended only on change (#42). Then the stocks' bars (cointoss.stock_bars). |
cointoss.stock_bars |
Stock bars (#40): Yahoo period="max" for a stock with no bar, else a ten-day window reaching back to its latest bar, writing the sessions not stored; a new split or dividend in the window re-fetches and overwrites the whole history. Current members and standing Inclusions of every universe (#41), and former members with a bar in the last 30 days. Batched yf.download, run by the stock sweep and by backfill. |
cointoss.config |
Universe Declarations in config, reconciled into stored Universe Definitions (#20). Settings: the data directory (--data-dir, COINTOSS_HOME, ~/.local/share/cointoss), its cointoss.db and optional cointoss.yaml with top_n and bar_window_hours (#21). |
cointoss.app |
The CointossApp namespace fragment (#21): a sweep node on a daily cron trigger, idempotent within a UTC day and serialised by a lock file, a backfill node on its own daily trigger an hour later, taking the lock for each write, a stock_sweep node on a weekday trigger after the US close (#39), and read nodes members, changes, bars, universes_of, runs, universes served over woodglue JSON-RPC. Portfolio writes create_portfolio, add_trade, void_trade behind the portfolio Role's call cointoss.portfolio Grant, owner-only, a traded Instrument held in portfolio-held (#33). |
cointoss.cli |
The cointoss command (#22): init writes cointoss.yaml, woodglue.yaml and the store, idempotently, and with --systemd the systemd --user unit; sweep runs today's sweep through the fragment's node, with no date to choose; backfill [--days N] runs the backfill node; sweep-stocks [--force] runs the stock sweep, and init reports a missing stock trigger (#39); status and token. init --unit, --port and --schedule let instances run side by side (#23). portfolio create, trade add and trade void call the portfolio writes over JSON-RPC with a bearer token, against the local instance or any --url (#33). |
Not built¶
Everything that makes it a system rather than a library:
- Missed days have no membership. A day the machine was down for is never swept, so it has no Evaluation Run or membership; the daily backfill (#26) fills its bars, and those of a sweep later than the bar window, but membership is not backfilled (ADR-0008 amendment).
- No crypto retry runner. The stock sweep retries every unresolved stock each run (#39); nothing runs the unresolved retry queue for crypto.
- No returns. Nothing turns prices into returns, so no covariance can be computed; the only way one enters the system today is a vendor import.
- No Portfolio Snapshot. Positions and value are derived on read from the Trades (#34);
PortfolioSnapshotis deferred until replaying them is slow.
Direction¶
Stand up a running cointoss instance that accumulates market data on a schedule, maps it to stable Instrument identity, maintains universes per source, derives returns, and thereby has everything in place for portfolio tracking and risk estimation.
The shape of it:
Yahoo Finance ─┐ ┌─ UniverseSeries "yahoo-listed"
├─ ingest ─ Instrument ─┤
CoinGecko ─────┘ (FIGI-anchored) └─ UniverseSeries "coingecko-listed"
│
├─ price history ─ returns ─ CovarianceSeries
└─ Portfolio / Trade ─ Position ─ valuation
Nothing in that diagram is speculative about the parts already built — identity, universes and declared covariance exist and are tested. Storage is built too. What is missing is the plumbing that feeds it.
What a running instance needs¶
lythonic already supplies most of the machinery, which is worth knowing before designing any of it:
lythonic.stateis a SQLite ORM:DbModel,DbConfig,DbFile,Schema, alternative keys. This is the persistence answer; there is no need to choose a database.lythonic.compose.engineloads anEngineConfigfromlyth.yamland resolves three stores:cache.db,dags.db,triggers.db.lythonic.compose.namespaceregisters fragments and nodes, and applies cache config. Both source adapters are alreadyNamespaceFragments with@nsnode(tags=["api"]).lythonic.compose.triggerruns cron-scheduled polls against registered DAGs.lythonic.compose.dag_runnerexecutes DAGs with provenance.- woodglue serves it: apps, service, mount, CLI, UI.
So "run an instance" is mostly configuration and wiring, plus the genuinely new pieces: the ingest sweep and returns.
Proposed build order¶
Each step is independently useful and leaves the system working. Priority is a running instance early, because accumulated history is the one thing that cannot be produced later.
- Persistence for what exists. Done (#5).
cointoss.storeto ADR-0008, with a seeded property test keeping the store's diff-and-close honest againstUniverseSeries.append. - Universe Definitions. Done. ADR-0007's recipe, revision log, Inclusions and Exclusions, the pure evaluator, and pinning a typed ticker.
- Price storage. Done (#16). ADR-0009's Bars, Corporate Actions and Restatements.
- MVP: a running crypto instance (#18). Done, running since 2026-09-30. CoinGecko only. A daily sweep shortly after 00:00
UTC turns
marketsinto Instruments,cg-top-100membership (enter 100, exit 120, configurable) and the day's bars; a woodglue namespace serves it over JSON-RPC on 127.0.0.1;cointoss init,woodglue.yaml, cron triggers and asystemd --userunit keep it running. Tickets #19-#23; a second, integration instance runs the released package since 2026-10-06. - Next milestone: explorable data on int. Decided 2026-10-23. Three weeks of bars is too little to analyse, and the UI should not be tied to the datasets that exist today. In order:
- Backup and restore (#24). Done. Protects the history before anything else touches it.
- History backfill. Moved to step 6 and widened to Yahoo (#26).
- A generic dataset API (#27, ADR-0010). Done. On the cointoss namespace:
datasets()names each dataset, its columns and its params' JSON Schema,frame(dataset, params)returns it as a table. First datasets: instruments, bars, returns derived on read, membership, universe changes and runs. A new collection (Yahoo, portfolio) becomes a new dataset, not new UI code. - A Streamlit explorer (#28). Done. Served by woodglue at
/ui/explore/(kind: streamlit). It reads only through the dataset API with the viewer's Delegated Token, nevercointoss.db, and itsgrantslimit it to the read methods. Pick a dataset, filter, chart, pivot, download. - Google and GitHub sign-in on int (#29), with int staying tailnet-only: no Tailscale
Funnel. int is the Tailscale Service
svc:cointoss-int; guests are invited to the tailnet and granted only that Service on port 443, and Google or GitHub says who they are. Anyone who signs in becomes a User with no Roles (pending) until the admin approves or disables them. Registering the OAuth apps is manual;woodglue.yamlgets the providers,public_url, admission (anyone, with no default Roles) and roles. - Yahoo crypto bars. Decided 2026-10-30. Years of history for valuing a portfolio and for returns, beyond CoinGecko's 365-day window. In order:
- Session Offset on read (#31). Done. CoinGecko's bar stamped D+1 closes D; resolved
reads (
bars_for,member_bars, thebarsandreturnsdatasets) date each bar by the session it closes, so a per-date fallback splices like with like (ADR-0009 amendment). Reads of one source keep the stamped date. - History backfill (#26). Done. One
backfillfor both sources, filling only dates with no stored bar: CoinGeckomarket_chartfor its window, and Yahooperiod="max"for coins whose Yahoo pair (hand-kept,{SYMBOL}-USD, or found by search, #36) passes a price-agreement check against CoinGecko. Price Sources stay Yahoo first. On demand (cointoss backfill) and daily, on its own trigger an hour after the sweep; an existingwoodglue.yamlneeds the trigger added, whichinitreports. - Crypto portfolio. Decided 2026-10-30 (ADR-0001 amendment). Independent of step 6 until valuation. Single-leg trades with no cash leg, UTC timestamps, voided rather than deleted, average cost, each Portfolio owned by a User, USD only, no Snapshot yet. Real holdings live on int, so it ships in a release.
- Storage (#32). Done.
PortfolioandTradetables, positions on read. - Writes (#33). Done.
create_portfolio,add_tradeandvoid_tradeover JSON-RPC, each requiring woodglue's Required Actionwrite(#37), which theportfolioRole andadminhold and nocallGrant, the explorer's Delegated Token included, reaches; the caller owns what it creates and touches only its own.cointoss portfolio create,trade addandtrade voidare clients of them. A traded Instrument is an Inclusion ofportfolio-held, which the sweep evaluates and prices, fetching by CoinGecko id an Inclusion themarketslisting leaves out. - Datasets (#34). Done.
trades,positionsandportfolio_value, each the caller's own only: an owned Dataset is read for the Caller's User id, as a write is, and another User's Portfolio named in its params isNotFound. A position on D is valued at the closebarsshows for D; without one its close and value are null, and a Portfolio's value on that date is null with the unpriced positions counted, never a partial sum, and it has no row before its first Trade. The explorer chartsportfolio_valuewith no new UI code (ADR-0010 amendment). - Stocks from Yahoo's industry lists. Decided 2026-11-28 (ADR-0007 and ADR-0009 amendments). The universe exists to resolve tickers into Instruments and collect bars; ranking spaces and companies, and theme ETFs (Yahoo shows only an ETF's top ten holdings), wait. The curated, Inclusion-only stock universe is dropped. In order:
- Listing Rule (#38). Done. A second rule kind:
yahoo-industriesis the union of Yahoo's top (up to 50) and fastest-growing (5) companies in each of 145 industries, about 2,600 US tickers. Absent from every list means out; no hysteresis. - Stock sweep (#39). Done.
stock_sweepon its own trigger,weekday_stock_sweepat 22:30 UTC on weekdays, andcointoss sweep-stocks. Idempotent within a US session (the latest weekday whose 16:00 New York close has passed). Fetches outside the sweep lock and writes inside it. Resolves tickers through FIGI (no key needed; about ten minutes on a first run), retries unresolved stocks, and carries a golden-file FIGI test. - Stock bars (#40). Done.
period="max"for a new member, then a trailing ten-day window for current members and former members with a bar in the last 30 days, reaching back to a stock's latest bar after a longer downtime, so no gap forms whichever of the stock sweep andbackfillruns first. A new split or dividend in the window re-fetches and overwrites history. No exchange calendar. - Stocks in
portfolio-held(#41). Done. Each Inclusion priced from its own Price Sources, so a paper trade in any stock brings it in:add_tradeandcointoss trade add --source yahoopin a Yahoo ticker through FIGI, the CoinGecko sweep leaves a stock Inclusion alone, and stock bars cover every standing Inclusion, so the next stock sweep fetches its whole history before any sweep records it as a member. yahoo-industryExposure Series (#42). Done. Instruments against Yahoo's industries, each keyed{sector}/{industry}, as unscaled scores; the axis is the industries Yahoo had on the first run, and a listing outside it is logged and left out. An Instrument off every list keeps the industries it was last listed under, so boundary churn, which membership records already, appends nothing; an entry is appended only when a stock is listed for the first time or moves. TheindustriesDataset reads the entry in force on a date, filtered by sector or industry, so the explorer filters by industry with no new UI code.- Returns, stored. Whatever representation the estimator needs, beyond the derived-on-read dataset of step 5.
- The estimator. Closes ADR-0005's gap so a covariance can be computed rather than only imported.
- The FIGI mapping cache. ADR-0006's
(universe_name, as_of)key.
Settled in grilling¶
Storage, universes and price history were grilled on 2026-09-27 and closed. The reasoning lives in the ADRs; what follows is only the index, so nothing here is re-litigated from memory.
- Blob or table, and where the append boundary sits - ADR-0008. Different answers per Series type, and the value type stops being the storage unit.
- One database or several - ADR-0008. One
cointoss.db; split only if a backfill actually blocks. - Migrations - ADR-0008. cointoss's own
SchemaVersion, plus a durable/rebuildable split so only hand-authored tables ever need one. - Is a source universe a
UniverseSeries? - ADR-0007. The word covered two concepts. A Universe Definition is the recipe; a Universe Series is what it produced. - Adjusted or unadjusted - ADR-0009. The question was malformed: Yahoo's "unadjusted" OHLC is
already split-adjusted and raw is unobtainable. Splits leave returns invariant, so the worry was
misplaced; dividends do not, so
closeandadj_closeare both stored. - What is a bar, and vendor disagreement - ADR-0009. Session date in the venue's own calendar, keyed by source so disagreement is recorded rather than resolved.
Yahoo crypto bars and the crypto portfolio were grilled on 2026-10-30 and closed:
- CoinGecko and Yahoo crypto bars a day apart - ADR-0009 amendment. A Session Offset per source, applied on read; storage untouched.
- Linking a coin to its Yahoo pair - ADR-0009 amendment.
{SYMBOL}-USD, accepted on price agreement with CoinGecko, recorded as an External Reference. No FIGI involved. - Trades, voids, ownership, cost basis, cash - ADR-0001 amendment.
The stock universe was grilled on 2026-11-28 and closed:
- What builds a stock universe - ADR-0007 amendment. A Listing Rule over Yahoo's industry
lists, no hysteresis, plus
portfolio-held. - Stock bars, splits and dividends - ADR-0009 amendment. Full history once, a trailing window daily, overwrite on a Corporate Action; never-overwrite stays CoinGecko's.
Still open¶
- Where Streamlit is installed. int runs the released package as a
uv tool; Streamlit and pandas probably belong in an optional extra (cointoss[ui]) so the API-only install stays small. - Triage of pending Users (#29). int is tailnet-only, so only invited guests can reach it, and
anyone who signs in starts with no Roles. Docs and the Console stay on behind sign-in. woodglue
has no User status yet, so "pending" is inferred (a person with no Roles who is not disabled)
and triage happens through
wgl user; a status and a Console page are asked for in walnutgeek/woodglue#23. - Delisting versus absence. Absence from a source is not the same fact as a delisting, and nothing yet distinguishes them. ADR-0007 drops an instrument from membership either way. Step 8 sidesteps it for bars: a stock keeps its daily refetch until 30 days pass with no bar, so a delisted one stops by itself. Membership still cannot say which of the two happened.
- Screening spaces and ranking companies. Deferred 2026-11-28. Sketch from grilling: theme ETFs' holdings and Yahoo industries as Exposure Series; a space scored by its ETF's or industry index's price momentum computed from stored bars; vendor growth figures stored as dated snapshots, since none is point-in-time. Full ETF holdings need issuer CSVs.
- A fixed
daysformarket_chart. Mostly settled by #19: a CoinGecko bar is the date's first (00:00) point, so hourly and daily windows agree, except on the first day of an hourly window, which has no 00:00 point.cointoss.backfillrefuses fewer than 90 days and writes only days with a point at exactly 00:00 (#26). - Backfills.
record_membershiprefuses awhenearlier than the latest Evaluation Run, so evaluating a past date after a later one is not supported (ADR-0008 amendment). - Unfolded reads.
corporate_actions_for,restatements_forand the action lookup inupsert_barsdo not fold supersession;bars_forconsults only the Survivor's Price Sources. - A review queue for flagged identity. Registry flags, ambiguous FIGI answers and refused anchors are only logged.
save_universesilently discards Inclusion and Exclusion sets that arrive without member rows. Probably should raise.- Restatement noise. Tolerance is
1e-6relative. Since #40 a dividend dated after a bar explains itsadj_closefalling relative to an unchangedclose, so a stock's re-fetch after a dividend files nothing; the tolerance may still need loosening once real re-fetches run. - ADR-0008's schema block omits
ExposureEntry,CovarianceEntry,RiskModelandRiskModelRevision. - Full sweep versus incremental. What triggers each, and at what cadence the unresolved retry queue runs given OpenFIGI's coverage lag.
- Returns. Representation (
FrameData, aKeyedVectorper date, a new Series type, or something the estimator owns privately); stored or derived; simple or log; and what happens across a gap, a halt, or a chain split. - Lot-based tax accounting. ADR-0001 defers it with "lot as synthetic Instrument" as the sketch - worth testing against ADR-0004's grammar now that identity exists, since a synthetic instrument would need an Instrument Id and a Scope.
- Exact arithmetic. ADR-0008 stores prices as
floatbecauselythonic.stateregisters noDecimal. Fine for returns; revisit ifTradeaccounting ever needs a ledger.
Parked¶
Recorded so they are not rediscovered as new:
Issueras an entity, keyed by LEI. ADR-0004 defers it; grouping GOOG and GOOGL is anExposureSeriestoday. Revisit when fundamentals are ingested, since anExposureSerieshas nowhere to hang issuer attributes.- Correcting a declared covariance. ADR-0005 leaves a wrong covariance permanent, and
CovarianceSeries.correct()raises to make that surface. Revisit with a real instance of the problem. RiskModelversioning by minting new identities. Rejected for now in favour of the revision counter.- Bridged tokens and share classes are several Instruments each, grouped by an
ExposureSeriesrather than collapsed. InstrumentIdat matrix axes.lythonic.Universeis keyed bystr, so anInstrumentIddegrades to its string form exactly where the type safety would matter most. Fixing it properly means asking whetherUniverseshould be generic over its key type — a lythonic question, not a cointoss one.- Rule-based universe construction beyond market-cap rank. Screens on fundamentals, index constituents. Partly taken out of Parked 2026-11-28: ADR-0007 now offers a Listing Rule beside the rank band (step 8). Screens are still parked.
- Review queue for universe changes. Rule proposes, human approves. ADR-0007 notes it is
strictly buildable on top of what was decided, since
UniverseSeries.change()already yields the diff such a queue would show. - Bitemporal price history. ADR-0009 keeps one vintage plus
fetched_atand a Restatement log. Revisit if a restatement ever turns out to matter. - Exchange calendars. ADR-0009 stores no session time, so bars on one date are not contemporaneous across venues. A lead-lag correction needs a calendar table, not a bar column.