loaders
Loader protocol and ZipLoader for decoupled simulation data loading.
Classes:
-
Loader–Protocol for loading simulation data from any source.
-
SimulationData–Container for all data loaded by a loader.
-
ZipLoader–Loads simulation data from a zip archive (file path or in-memory buffer).
-
ZipLoaderConfig–Configuration for file names within a zip archive.
Loader
Bases: Protocol
Protocol for loading simulation data from any source.
Methods:
-
load–Load and return simulation data.
SimulationData
dataclass
SimulationData(
name: str,
start_date: date,
end_date: date,
instruments: list[Instrument],
positions: list[Position],
market_frames: dict[str, DataFrame],
balances: dict[str, float] = dict(),
valuations: dict[str, dict[str, float]] = dict(),
)
Container for all data loaded by a loader.
ZipLoader
ZipLoader(
*,
path: Path | str | None = None,
buffer: BytesIO | None = None,
instrument_registry: InstrumentRegistry,
config: ZipLoaderConfig | None = None,
)
Loads simulation data from a zip archive (file path or in-memory buffer).
Parameters:
-
(pathPath | str | None, default:None) –Path to a zip file on disk. Mutually exclusive with buffer.
-
(bufferBytesIO | None, default:None) –In-memory zip data. Mutually exclusive with path.
-
(instrument_registryInstrumentRegistry) –Registry used to construct instrument instances.
-
(configZipLoaderConfig | None, default:None) –Optional file-name configuration for the archive layout.
Methods:
-
load–Read the zip archive and return a populated SimulationData.
ZipLoaderConfig
dataclass
ZipLoaderConfig(
config_file: str = "config.json",
instruments_file: str = "instruments.json",
positions_file: str = "positions.json",
market_data_mapping: dict[str, str] = lambda: {
"yields": "yields.csv",
"benchmarks": "benchmarks.csv",
}(),
)
Configuration for file names within a zip archive.