merton.scenarios.base

Scenario ABC and shared result container.

Classes

ScenarioResult

The output of applying a Scenario to a Firm.

Scenario

Base class for any deterministic firm-level scenario.

CompositeScenario

Apply a sequence of scenarios left-to-right.

Module Contents

class merton.scenarios.base.ScenarioResult[source]

The output of applying a Scenario to a Firm.

Carries the stressed firm together with structured metadata describing what was changed and why, which downstream reporting / audit tooling surfaces back to the user. Keeping the metadata in a typed container — rather than as free-form dict in user code — makes scenario stacks debuggable: every transformation leaves a trace.

firm: merton.core.firm.Firm[source]
scenario: str[source]
parameters: dict[str, Any][source]
description: str = ''[source]
class merton.scenarios.base.Scenario[source]

Bases: abc.ABC

Base class for any deterministic firm-level scenario.

Concrete subclasses must implement apply(), which takes a Firm and returns a ScenarioResult.

Subclasses are expected to expose a name attribute; we deliberately do not declare it on the base class as a class-level default, because that would inject a default value into dataclass subclasses and force every later field to also have a default.

abstractmethod apply(firm: merton.core.firm.Firm, **kwargs: Any) ScenarioResult[source]

Return a stressed copy of firm with scenario metadata attached.

class merton.scenarios.base.CompositeScenario[source]

Bases: Scenario

Apply a sequence of scenarios left-to-right.

The first scenario’s output feeds the second, etc. parameters and description accumulate into a stacked record so report tooling can show the full chain.

scenarios: list[Scenario][source]
name: str = 'composite'[source]
apply(firm: merton.core.firm.Firm, **kwargs: Any) ScenarioResult[source]

Return a stressed copy of firm with scenario metadata attached.