Skip to content

Configuration API

Public author inputs parse once into AuthorInputs; resolution binds them to an operator configuration and retained market facts before parameters exist.

almanak.configuration.unresolved

The public author root, with connector-owned inputs and gateway-resolved facts.

These inputs are never strategy parameters. Supported connector bindings share this loader, which has no legacy-format fallback.

InventoryInput

Bases: Model

Owned cash a composed root declares; never spending authority.

diagnostic

diagnostic(
    source: Document, error, prefix=""
) -> ConfigurationError

Locate a validation or configuration failure in the author's own file.

author_field

author_field(location) -> str

A discriminated union inserts its connector tag, which the author never wrote.

public_root

public_root(value) -> bool

Public roots carry no execution block and identify every market chain by CAIP-2 text.

require_bindings

require_bindings(document: Document)

Every market names a canonical connector that has a public author binding.

inject_connectors

inject_connectors(document: Document) -> dict

Positions take the connector tag from their named market; the author never writes it.

read_inputs

read_inputs(
    path: Path,
    overrides=None,
    fields: frozenset[str] | None = None,
) -> InputDocument

The author inputs; fields names the strategy's typed parameter model's fields.

read_frozen_inputs

read_frozen_inputs(path: Path) -> InputDocument

A workspace's inputs as frozen in JSON; YAML would read 1e-05 back as a string.

require_one_allocation_per_fund

require_one_allocation_per_fund(inputs: AuthorInputs)

The DEX connectors' own per-fund rule, refused here before any resolution.

known_assets

known_assets(
    inputs: AuthorInputs, value
) -> tuple[AssetType, ...]

The position assets the author file names; pool coins need resolution.

require_composed_inventory

require_composed_inventory(inputs: AuthorInputs)

Composed inventory states every fund asset; check the ones known before resolution.

require_chain_support

require_chain_support(inputs: AuthorInputs)

Offline checks refuse a market chain its connector never declared, in any mode.

unknown_reference

unknown_reference(kind, value, choices, field)

Report local-name typos without selecting a replacement automatically.

almanak.configuration.parameters

Construct complete parameters only from matching, replay-checked resolution.

admit_new_positions

admit_new_positions(document: InputDocument, result)

Preflight for a new run only: connector refusals that need the resolved reads.

Retained parameters (resume, exit) and backtests never pass through here, so a check added later cannot strand a deployment whose parameters are already frozen.

check_resolved_positions

check_resolved_positions(document, reader, markets)

Connector checks that need the market's resolved reads, not only its frozen facts.

grouped_positions

grouped_positions(
    document, markets
) -> dict[ConnectorId, dict[str, list]]

Resolved positions grouped by the connector of their named market.

fork_rescope

fork_rescope(groups, fixture)

Positions move to the generated fixture chains; targets keep their origin identity.

assemble

assemble(
    document, groups, accounts, metadata, gas
) -> Model

Build one authoritative parameter instance across all named markets.

resolved_inventory

resolved_inventory(document, accounts, metadata)

Resolve shared owned cash once, using verified precision and bound fund scope.

resolved_metadata

resolved_metadata(document, markets, symbols=None)

Verified precision per asset, named by the author or else by the token itself.

Backtest inputs resolve against those same parameters and explicit operator provider bindings.

almanak.configuration.backtest_inputs

Public backtest settings: syntax-checked inputs that resolve with verified parameters.

Historical provider bindings come from the operator configuration, never from the author's backtest file, so retained runs carry no provider identity.

BacktestInputs

Bases: Model

anchors

anchors(
    inputs: AuthorInputs,
) -> tuple[AnchorSelection, ...]

One anchor per account chain: the last block at the window start.

resolve_backtest

resolve_backtest(
    document: BacktestDocument,
    parameters: Model,
    history: tuple[HistoryBinding, ...],
    vendors: tuple[VendorBinding, ...] = (),
)

The settings wire of whichever connector the resolved parameters name.

refuse_strategy_prices

refuse_strategy_prices(
    document: Document, value, prefix="data"
)

Only the strategy declares a pool price series; a backtest never repeats one.

A single strategy price (an Aave V4 economic input) may still be listed here, and must then equal the strategy's declaration.

bind_vendor_access

bind_vendor_access(
    document: BacktestDocument,
    wire: dict,
    available: tuple[VendorBinding, ...],
)

Bind only author-selected vendors to operator-owned access settings.

aave_wire

aave_wire(
    document: BacktestDocument, parameters, history
) -> dict

Aave V4 keeps the flat fund identity and models no separate gas payer.

connector_wire

connector_wire(
    document: BacktestDocument, parameters, history
) -> dict

Every other connector carries a simulation profile and its own gas payers.

composed_wire

composed_wire(
    document: BacktestDocument, parameters, history
) -> dict

A composed run pairs one data policy, one cost policy and one model per connector.

refuse_payers

refuse_payers(document: BacktestDocument)

Aave V4 simulates one account identity, so its inputs carry no payer.

payer_wire

payer_wire(document, name, payer, parameters) -> dict

A payer keeps the same deterministic identity as a hypothetical fund.

Runtime artifacts use the resolved parameter codecs. Archived author fixtures are private evidence inputs under scripts/legacy_configuration/; they are not an SDK configuration API.