Skip to content

cointoss.ingest

ingest

Ingest: where Observations are constructed, and so where ADR-0004's FIGI attempt is enforced.

cointoss.instrument cannot compel a FIGI attempt -- it is pure and takes the outcome as given -- so the invariant lives here, at the only place an Observation is built from outside data. It holds two paths in. Pinning a typed ticker (issue #14): a researcher types a symbol against a source, and it is resolved to an Instrument once, at edit time, per ADR-0007. And the daily market sweep, sweep, which turns one CoinGecko markets listing into Instruments, membership and bars. figi_attempts, pin_with_attempt and anchor_with_attempt split pinning and retrying around one batched FIGI call, for the stock sweep (cointoss.stocks), which also runs the unresolved retry for stocks. hold puts a traded Instrument into portfolio-held, whose Inclusions are priced from their own Price Sources: a coin by the sweep, even outside its listing, and a stock by cointoss.stock_bars (#41).

It sits apart from its neighbours because it is the one layer that combines them: it makes a network call, which cointoss.instrument and cointoss.universe must not; it applies identity rules, which cointoss.store must not; and it writes through the store, which the source adapters must not.

The resolution policy, in order, following ADR-0004:

  • A FIGI hit for a symbol that exactly one unresolved Instrument held, at that source on that date, is that Instrument's retry: the references are attached to it through InstrumentRegistry.anchor rather than minting a numbered second one.
  • Any other FIGI hit is put through the registry, which matches by External Reference or mints. The result is persisted and the member pinned to it.
  • A FIGI answer naming several distinct anchors is flagged for review. Picking one would guess, and minting from the symbol would ignore evidence that the ticker is contested.
  • Otherwise -- no match, an OpenFIGI outage, or a scope with no FIGI exchange to ask -- the ticker is first looked up in the Ticker History already held, as that source spelled it on that date, and pinned if exactly one Instrument held it.
  • Failing that the Observation goes through the registry's symbol-keyed last resort, which mints an Instrument flagged unresolved (or joins one already minted that way), and the member is pinned to it. An outage is recorded as NOT_ATTEMPTED and a miss as NOT_FOUND; both put the Instrument in the registry's unresolved queue, which retry_resolution works one Instrument at a time.
  • Anything the registry flags for review, or a symbol two Instruments hold at once, leaves the member stored unresolved, and the edit still succeeds.

A symbol typed against CoinGecko that reaches the registry also carries the coin's CoinGecko id as a provider External Reference, the one the sweep identifies coins by. Without it a coin pinned before its first sweep could not be matched by that sweep -- a FIGI-anchored Instrument is out of reach of the symbol tier -- and crypto.native.btc_2 would be minted beside it. See _coingecko_coin for how a symbol several coins share is decided.

FigiAttempt = tuple[FigiResolution, tuple[ExternalReference, ...]] | IdentityResult module-attribute

The outcome of one FIGI attempt and the References it supplies, or a flagged result.

DEFAULT_TOP_N = 250 module-attribute

How many coins a sweep lists by default: one full markets page.

DEFAULT_BAR_WINDOW = timedelta(hours=3) module-attribute

How long after 00:00 UTC a listing's price still stands for that date's 00:00 price.

SweepTooNarrow

Bases: ValueError

The listing asked for is narrower than a Definition's exit rank, so members would vanish.

Source code in src/cointoss/ingest.py
class SweepTooNarrow(ValueError):
    """The listing asked for is narrower than a Definition's exit rank, so members would vanish."""

SweepReport

Bases: BaseModel

What one sweep did, for a caller to log or report.

skipped maps a CoinGecko coin id to why no Instrument was named for it; failed maps a Definition name to why its membership was not recorded. Neither aborts the sweep. runs are the Evaluation Runs in the order the Definitions were named, including one already recorded by an earlier sweep the same day.

listed counts the coins of the markets listing, and unlisted the coins fetched by id beside it because a Definition includes them. bars counts the bars written. bars_kept counts coins whose bar for the day was already stored and was left as it was. bars_skipped_late means the sweep ran after the bar window, so it wrote no bars at all.

Source code in src/cointoss/ingest.py
class SweepReport(BaseModel):
    """What one sweep did, for a caller to log or report.

    `skipped` maps a CoinGecko coin id to why no Instrument was named for it; `failed` maps a
    Definition name to why its membership was not recorded. Neither aborts the sweep. `runs`
    are the Evaluation Runs in the order the Definitions were named, including one already
    recorded by an earlier sweep the same day.

    `listed` counts the coins of the `markets` listing, and `unlisted` the coins fetched by id
    beside it because a Definition includes them. `bars` counts the bars written. `bars_kept`
    counts coins whose bar for the day was already stored and was left as it was.
    `bars_skipped_late` means the sweep ran after the bar window, so it wrote no bars at all.
    """

    model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

    at: datetime
    listed: int
    unlisted: int
    minted: int
    matched: int
    superseded: int
    skipped: dict[str, str]
    bars: int
    bars_kept: int
    bars_skipped_late: bool
    restatements: int
    runs: tuple[EvaluationRun, ...]
    failed: dict[str, str]

    @property
    def day(self) -> date:
        """The UTC date the sweep recorded membership and bars for."""
        return as_utc(self.at).date()

day property

The UTC date the sweep recorded membership and bars for.

figi_job(source, symbol, scope=None)

The OpenFIGI mapping request for a symbol typed against a source, if one can be formed.

Yahoo spells a share class with a hyphen where OpenFIGI uses a slash.

>>> figi_job(Source.YAHOO, "brk-b").model_dump(exclude_none=True)
{'idType': 'TICKER', 'idValue': 'BRK/B', 'exchCode': 'US'}
>>> figi_job(Source.COINGECKO, "btc").model_dump(exclude_none=True)
{'idType': 'TICKER', 'idValue': 'BTC', 'marketSecDes': 'Curncy'}
>>> figi_job(Source.YAHOO, "7203", scope="jp") is None
True
Source code in src/cointoss/ingest.py
def figi_job(source: Source, symbol: str, scope: str | None = None) -> MappingJob | None:
    """The OpenFIGI mapping request for a symbol typed against a source, if one can be formed.

    Yahoo spells a share class with a hyphen where OpenFIGI uses a slash.

    >>> figi_job(Source.YAHOO, "brk-b").model_dump(exclude_none=True)
    {'idType': 'TICKER', 'idValue': 'BRK/B', 'exchCode': 'US'}
    >>> figi_job(Source.COINGECKO, "btc").model_dump(exclude_none=True)
    {'idType': 'TICKER', 'idValue': 'BTC', 'marketSecDes': 'Curncy'}
    >>> figi_job(Source.YAHOO, "7203", scope="jp") is None
    True
    """
    return _figi_job_for(_SOURCE_TYPE[source], symbol, scope)

figi_request(instrument)

The FIGI attempt a retry of instrument makes, from its type, scope and display symbol.

Source code in src/cointoss/ingest.py
def figi_request(instrument: Instrument) -> tuple[InstrumentType, MappingJob | None]:
    """The FIGI attempt a retry of `instrument` makes, from its type, scope and display symbol."""
    return instrument.type, _figi_job_for(instrument.type, instrument.symbol, instrument.scope)

figi_attempts(figi, requests) async

The FIGI outcome of each request, in order, from one batched mapping call.

A request with no job -- a scope with no FIGI exchange to ask -- is NOT_ATTEMPTED, and an answer naming several anchors is flagged for review.

Source code in src/cointoss/ingest.py
async def figi_attempts(
    figi: OpenFigiClient, requests: Sequence[tuple[InstrumentType, MappingJob | None]]
) -> list[FigiAttempt]:
    """The FIGI outcome of each request, in order, from one batched mapping call.

    A request with no job -- a scope with no FIGI exchange to ask -- is `NOT_ATTEMPTED`, and an
    answer naming several anchors is flagged for review.
    """
    asked = [job for _, job in requests if job is not None]
    answers = iter(await figi.map_identifiers(asked) if asked else [])
    attempts: list[FigiAttempt] = []
    for instrument_type, job in requests:
        if job is None:
            attempts.append((FigiResolution.NOT_ATTEMPTED, ()))
        else:
            attempts.append(_attempt_from(instrument_type, job, next(answers)))
    return attempts

retry_resolution(store, instrument_id, at, *, figi=None) async

Retry the FIGI attempt for one stored Instrument, anchoring it on a hit.

The unit of work for the unresolved retry runner. The request is formed from the Instrument's type, scope and display symbol, and a hit is attached through InstrumentRegistry.anchor, which flags contrary evidence rather than acting on it. Returns None when OpenFIGI still has no single answer to give -- a miss, an outage, or a scope with no FIGI exchange -- and nothing is written. An unknown id raises KeyError.

Source code in src/cointoss/ingest.py
async def retry_resolution(
    store: Store,
    instrument_id: InstrumentId,
    at: date,
    *,
    figi: OpenFigiClient | None = None,
) -> IdentityResult | None:
    """Retry the FIGI attempt for one stored Instrument, anchoring it on a hit.

    The unit of work for the unresolved retry runner. The request is formed from the
    Instrument's type, scope and display symbol, and a hit is attached through
    `InstrumentRegistry.anchor`, which flags contrary evidence rather than acting on it. Returns
    None when OpenFIGI still has no single answer to give -- a miss, an outage, or a scope with
    no FIGI exchange -- and nothing is written. An unknown id raises `KeyError`.
    """
    registry = store.load_registry()
    (attempt,) = await figi_attempts(
        figi or OpenFigiClient(), [figi_request(registry.get(instrument_id))]
    )
    return anchor_with_attempt(store, instrument_id, at, attempt, registry=registry)

anchor_with_attempt(store, instrument_id, at, attempt, *, registry=None)

retry_resolution for a FIGI attempt already made, as figi_attempts makes them.

Lets a runner retry many Instruments from one batched mapping call. registry must hold what the store holds; without one it is loaded.

Source code in src/cointoss/ingest.py
def anchor_with_attempt(
    store: Store,
    instrument_id: InstrumentId,
    at: date,
    attempt: FigiAttempt,
    *,
    registry: InstrumentRegistry | None = None,
) -> IdentityResult | None:
    """`retry_resolution` for a FIGI attempt already made, as `figi_attempts` makes them.

    Lets a runner retry many Instruments from one batched mapping call. `registry` must hold
    what the store holds; without one it is loaded.
    """
    registry = registry or store.load_registry()
    target = registry.get(instrument_id)
    if isinstance(attempt, IdentityResult):
        return attempt
    resolution, references = attempt
    if resolution is not FigiResolution.RESOLVED:
        return None
    obs = Observation(
        type=target.type,
        symbol=target.symbol,
        scope=target.scope,
        observed_at=at,
        source=target.identity_source,
        references=references,
        figi_resolution=resolution,
    )
    result = registry.anchor(target.id, obs)
    _persist(store, registry, result)
    return result

resolve_typed_symbol(store, source, symbol, at, *, scope=None, figi=None, coingecko=None, coingecko_id=None) async

Resolve a symbol typed against a source on a date, persisting whatever it establishes.

Builds the Observation, makes the FIGI attempt, and resolves it by the policy in the module docstring. Returns None when no Instrument can be named, which is a result rather than an error.

For a CoinGecko symbol that is not already found in the Ticker History, the coin's CoinGecko id is looked up and recorded on the Observation; coingecko_id names the coin outright when the symbol is shared. It is only valid against CoinGecko.

Source code in src/cointoss/ingest.py
async def resolve_typed_symbol(
    store: Store,
    source: Source,
    symbol: str,
    at: date,
    *,
    scope: str | None = None,
    figi: OpenFigiClient | None = None,
    coingecko: CoinGeckoClient | None = None,
    coingecko_id: str | None = None,
) -> InstrumentId | None:
    """Resolve a symbol typed against a source on a date, persisting whatever it establishes.

    Builds the `Observation`, makes the FIGI attempt, and resolves it by the policy in the module
    docstring. Returns None when no Instrument can be named, which is a result rather than an
    error.

    For a CoinGecko symbol that is not already found in the Ticker History, the coin's CoinGecko
    id is looked up and recorded on the Observation; `coingecko_id` names the coin outright
    when the symbol is shared. It is only valid against CoinGecko.
    """
    if coingecko_id is not None and source is not Source.COINGECKO:
        raise ValueError(f"a CoinGecko id names a coin, not a symbol typed against {source}")
    instrument_type = _SOURCE_TYPE[source]
    scope = scope or _DEFAULT_SCOPE[instrument_type]
    (attempt,) = await figi_attempts(
        figi or OpenFigiClient(), [(instrument_type, figi_job(source, symbol, scope))]
    )
    named = _held_or_observation(store, source, symbol, scope, at, attempt)
    if not isinstance(named, Observation):
        return named
    if source is Source.COINGECKO:
        named = await _with_coingecko_id(named, coingecko or CoinGeckoClient(), coingecko_id)
    return _pinned(store, named)

pin_with_attempt(store, source, symbol, at, attempt, *, scope=None, registry=None)

resolve_typed_symbol for a FIGI attempt already made, as figi_attempts makes them.

Lets a sweep pin many symbols from one batched mapping call, by the same policy. Not for CoinGecko, whose symbols also need the coin's CoinGecko id looked up. registry must hold what the store holds; without one it is loaded.

Source code in src/cointoss/ingest.py
def pin_with_attempt(
    store: Store,
    source: Source,
    symbol: str,
    at: date,
    attempt: FigiAttempt,
    *,
    scope: str | None = None,
    registry: InstrumentRegistry | None = None,
) -> InstrumentId | None:
    """`resolve_typed_symbol` for a FIGI attempt already made, as `figi_attempts` makes them.

    Lets a sweep pin many symbols from one batched mapping call, by the same policy. Not for
    CoinGecko, whose symbols also need the coin's CoinGecko id looked up. `registry` must hold
    what the store holds; without one it is loaded.
    """
    if source is Source.COINGECKO:
        raise ValueError("a CoinGecko symbol is pinned through resolve_typed_symbol")
    scope = scope or _DEFAULT_SCOPE[_SOURCE_TYPE[source]]
    named = _held_or_observation(store, source, symbol, scope, at, attempt)
    if not isinstance(named, Observation):
        return named
    return _pinned(store, named, registry)

pin_member(store, name, role, source, symbol, at, *, scope=None, figi=None, coingecko=None, coingecko_id=None) async

Add a typed ticker to a Universe Definition, pinned to an Instrument if it resolves.

The edit is one new revision, dated at, naming the role's field as changed. It is recorded whether or not resolution succeeds: an unresolved member is still a change to the member set, and a cold registry delays membership rather than blocking the edit. Re-adding a ticker already standing in the same role from the same source changes nothing and makes no FIGI call.

Source code in src/cointoss/ingest.py
async def pin_member(
    store: Store,
    name: str,
    role: MemberRole,
    source: Source,
    symbol: str,
    at: date,
    *,
    scope: str | None = None,
    figi: OpenFigiClient | None = None,
    coingecko: CoinGeckoClient | None = None,
    coingecko_id: str | None = None,
) -> UniverseMemberRecord:
    """Add a typed ticker to a Universe Definition, pinned to an Instrument if it resolves.

    The edit is one new revision, dated `at`, naming the role's field as changed. It is
    recorded whether or not resolution succeeds: an unresolved member is still a change to the
    member set, and a cold registry delays membership rather than blocking the edit. Re-adding
    a ticker already standing in the same role from the same source changes nothing and makes
    no FIGI call.
    """
    definition = store.require_universe(name)
    for member in store.load_universe_members(name):
        if _stands_as(member, definition.revision, role, source, symbol):
            return member
    instrument_id = await resolve_typed_symbol(
        store,
        source,
        symbol,
        at,
        scope=scope,
        figi=figi,
        coingecko=coingecko,
        coingecko_id=coingecko_id,
    )
    revised = _with_member(definition, at, role, instrument_id)
    record = UniverseMemberRecord(
        role=role,
        source=source,
        symbol_as_typed=symbol,
        instrument_id=instrument_id,
        added_in_revision=revised.revision,
    )
    store.save_universe(revised, [record])
    return record

hold(store, instrument_id, source, symbol, at)

Include a traded Instrument in portfolio-held, so the sweep or the stock sweep prices it.

The Definition is created on first use with the Instrument as its one Inclusion and no rank rule. An Instrument already included changes nothing, so trading it again adds no revision. source and symbol are what the trade named it by, recorded as the member's provenance.

Source code in src/cointoss/ingest.py
def hold(store: Store, instrument_id: InstrumentId, source: Source, symbol: str, at: date) -> None:
    """Include a traded Instrument in `portfolio-held`, so the sweep or the stock sweep prices it.

    The Definition is created on first use with the Instrument as its one Inclusion and no rank
    rule. An Instrument already included changes nothing, so trading it again adds no revision.
    `source` and `symbol` are what the trade named it by, recorded as the member's provenance.
    """
    record = UniverseMemberRecord(
        role=MemberRole.INCLUSION,
        source=source,
        symbol_as_typed=symbol,
        instrument_id=instrument_id,
    )
    definition = store.load_universe(PORTFOLIO_HELD)
    if definition is None:
        parameters = UniverseParameters(inclusions=frozenset({instrument_id}))
        store.save_universe(UniverseDefinition.create(PORTFOLIO_HELD, parameters, at), [record])
        return
    if instrument_id in definition.parameters.inclusions:
        return
    revised = _with_member(definition, at, MemberRole.INCLUSION, instrument_id)
    store.save_universe(
        revised, [record.model_copy(update={"added_in_revision": revised.revision})]
    )

check_listing_width(top_n, exit_ranks)

Refuse a listing of top_n coins that stops short of the widest exit rank.

>>> check_listing_width(120, [120, None, 12])
>>> check_listing_width(119, [120])
Traceback (most recent call last):
...
cointoss.ingest.SweepTooNarrow: top_n 119 is narrower than exit rank 120
Source code in src/cointoss/ingest.py
def check_listing_width(top_n: int, exit_ranks: Iterable[int | None]) -> None:
    """Refuse a listing of `top_n` coins that stops short of the widest exit rank.

    >>> check_listing_width(120, [120, None, 12])
    >>> check_listing_width(119, [120])
    Traceback (most recent call last):
    ...
    cointoss.ingest.SweepTooNarrow: top_n 119 is narrower than exit rank 120
    """
    widest = max((rank or 0 for rank in exit_ranks), default=0)
    if top_n < widest:
        raise SweepTooNarrow(f"top_n {top_n} is narrower than exit rank {widest}")

sweep(store, at, definitions, *, top_n=DEFAULT_TOP_N, bar_window=DEFAULT_BAR_WINDOW, coingecko=None) async

Turn one CoinGecko markets listing into Instruments, membership and bars for a day.

at is the moment of the sweep, when the listing is fetched. Its UTC date is the date everything is recorded for, and it stamps the bars' fetched_at and the Runs' run_at.

A day's bar is the price at its 00:00 UTC, which is what CoinGecko labels its own daily point with, and a listing's current_price is that price only when fetched soon after midnight. So bars are written only when at is within bar_window of the day's 00:00 UTC, and are then final, not Provisional. A later sweep still resolves Instruments and records membership, and reports bars_skipped_late; the day's bars are left for a backfill. Nor is a bar already stored for the day from CoinGecko overwritten: a re-sweep's later price is not a new vintage of the 00:00 price, and overwriting it would file a false Restatement.

The top top_n coins are listed by market cap, paging as needed. Each coin is one Observation whose FIGI attempt is recorded NOT_ATTEMPTED -- the crypto FIGI request is unverified and must not gate the sweep; retry_resolution takes these up later -- carrying its CoinGecko id as a provider External Reference, so a coin already held is matched through a ticker change rather than reminted. Every coin gets native scope, as a CoinGecko symbol typed for pinning does.

An Inclusion stands whatever its rank, so a coin a named Definition includes but the listing left out is fetched by its CoinGecko id and gets its bar and its Ticker History as a listed coin does. It is not ranked: it cannot enter a band from outside the listing.

Each named Definition is evaluated against CoinGecko's own market_cap_rank, not the listing position, which the API does not keep equal to it; a coin with no rank, or not listed, is absent. A Definition is evaluated once per day: when a Run for the day is already stored, it is returned rather than evaluated again, since a moved market would otherwise put two memberships on one date. The Definitions are named by the caller rather than read from the store, because a Definition dropped from configuration stays stored. top_n must reach the widest exit rank among them, or SweepTooNarrow is raised before anything is fetched; an unknown name raises UnknownUniverse.

A coin whose Observation cannot be formed, or that the registry flags for review, is logged and skipped. A Definition whose membership the store refuses for this date is logged and reported in failed.

Source code in src/cointoss/ingest.py
async def sweep(
    store: Store,
    at: datetime,
    definitions: Iterable[str],
    *,
    top_n: int = DEFAULT_TOP_N,
    bar_window: timedelta = DEFAULT_BAR_WINDOW,
    coingecko: CoinGeckoClient | None = None,
) -> SweepReport:
    """Turn one CoinGecko `markets` listing into Instruments, membership and bars for a day.

    `at` is the moment of the sweep, when the listing is fetched. Its UTC date is the date
    everything is recorded for, and it stamps the bars' `fetched_at` and the Runs' `run_at`.

    A day's bar is the price at its 00:00 UTC, which is what CoinGecko labels its own daily
    point with, and a listing's `current_price` is that price only when fetched soon after
    midnight. So bars are written only when `at` is within `bar_window` of the day's 00:00 UTC,
    and are then final, not Provisional. A later sweep still resolves Instruments and records
    membership, and reports `bars_skipped_late`; the day's bars are left for a backfill. Nor is
    a bar already stored for the day from CoinGecko overwritten: a re-sweep's later price is not
    a new vintage of the 00:00 price, and overwriting it would file a false Restatement.

    The top `top_n` coins are listed by market cap, paging as needed. Each coin is one
    `Observation` whose FIGI attempt is recorded `NOT_ATTEMPTED` -- the crypto FIGI request is
    unverified and must not gate the sweep; `retry_resolution` takes these up later -- carrying
    its CoinGecko `id` as a provider External Reference, so a coin already held is matched
    through a ticker change rather than reminted. Every coin gets `native` scope, as a
    CoinGecko symbol typed for pinning does.

    An Inclusion stands whatever its rank, so a coin a named Definition includes but the listing
    left out is fetched by its CoinGecko id and gets its bar and its Ticker History as a listed
    coin does. It is not ranked: it cannot enter a band from outside the listing.

    Each named Definition is evaluated against CoinGecko's own `market_cap_rank`, not the
    listing position, which the API does not keep equal to it; a coin with no rank, or not
    listed, is absent. A Definition is evaluated once per day: when a Run for the day is already
    stored, it is returned rather than evaluated again, since a moved market would otherwise
    put two memberships on one date. The Definitions are named by the caller rather than read
    from the store, because a Definition dropped from configuration stays stored. `top_n` must
    reach the widest exit rank among them, or `SweepTooNarrow` is raised before anything is
    fetched; an unknown name raises `UnknownUniverse`.

    A coin whose Observation cannot be formed, or that the registry flags for review, is logged
    and skipped. A Definition whose membership the store refuses for this date is logged and
    reported in `failed`.
    """
    moment = as_utc(at)
    day = moment.date()
    loaded = [store.require_universe(name) for name in definitions]
    check_listing_width(top_n, (d.parameters.exit_rank for d in loaded))

    client = coingecko or CoinGeckoClient()
    listing = await _list_markets(client, top_n)
    unlisted = await _unlisted_inclusions(client, store, loaded, listing)
    identified, outcomes, skipped = _identify_listing(store, [*listing, *unlisted], day)

    ranks: dict[InstrumentId, int] = {}
    for coin in listing:
        instrument_id = identified.get(coin.id)
        if instrument_id is not None and coin.market_cap_rank is not None:
            ranks[instrument_id] = min(
                coin.market_cap_rank, ranks.get(instrument_id, coin.market_cap_rank)
            )

    runs: list[EvaluationRun] = []
    failed: dict[str, str] = {}
    for definition in loaded:
        try:
            runs.append(_evaluate_once_a_day(store, definition, ranks, day, moment))
        except EntryOrder as exc:
            log.warning("sweep %s: %s not recorded: %s", day, definition.name, exc)
            failed[definition.name] = str(exc)

    late = moment - datetime.combine(day, time(), UTC) > bar_window
    bars: list[Bar] = []
    kept = 0
    if late:
        log.warning("sweep %s: at %s, after the %s bar window; no bars", day, moment, bar_window)
    else:
        bars = _bars([*listing, *unlisted], identified, moment)
        already_priced = store.instruments_with_bars(Source.COINGECKO, day)
        kept = sum(bar.instrument_id in already_priced for bar in bars)
        bars = [bar for bar in bars if bar.instrument_id not in already_priced]
    restated = store.upsert_bars(bars)
    return SweepReport(
        at=moment,
        listed=len(listing),
        unlisted=len(unlisted),
        minted=outcomes.count(Outcome.MINTED),
        matched=outcomes.count(Outcome.MATCHED),
        superseded=outcomes.count(Outcome.SUPERSEDED),
        skipped=skipped,
        bars=len(bars),
        bars_kept=kept,
        bars_skipped_late=late,
        restatements=len(restated),
        runs=tuple(runs),
        failed=failed,
    )