Skip to content

scenario

Module containing classes for managing financial scenarios.

Classes:

  • Scenario

    Represents a single scenario with financial data.

  • ScenarioBuilder

    Builder class for constructing a Scenario.

  • ScenarioManager

    Manage scenarios with functionalities to add, clear, and retrieve scenarios.

Scenario

Scenario(date: date)

Represents a single scenario with financial data.

Methods:

add_term_structure

add_term_structure(
    term_structure: YieldTermStructure,
) -> None

Add a term structure to the scenario.

ScenarioBuilder

ScenarioBuilder(date: date)

Builder class for constructing a Scenario.

Methods:

build

build() -> Scenario

Finalize the construction of the Scenario.

with_term_structure

with_term_structure(
    term_structure: YieldTermStructure,
) -> ScenarioBuilder

Add a term structure to the Scenario.

ScenarioManager

ScenarioManager()

Manage scenarios with functionalities to add, clear, and retrieve scenarios.

Methods:

add_scenario

add_scenario(date: date, scenario: Scenario) -> None

Add a scenario by date.

clear_scenarios

clear_scenarios() -> None

Clear all scenarios.

get_available_dates

get_available_dates() -> list[date]

Extract all dates from the treasury yields DataFrame.

get_historical_scenarios

get_historical_scenarios(
    start_date: date, end_date: date
) -> dict[date, Scenario]

Retrieve historical scenarios in a date range.

get_scenario

get_scenario(date: date) -> Scenario

Retrieve a scenario by date.

get_treasury_yields

get_treasury_yields() -> DataFrame

Retrieve the raw treasury yields data as a DataFrame.

has_scenario

has_scenario(date: date) -> bool

Check if a scenario exists for a given date.

load_data

load_data(source_type: str, source_path: str) -> None

Load data using DataLoader and build scenarios.