Config¶
Frozen Pydantic configuration model for the Basanos engine.
tinycta.config
¶
Configuration model for the Basanos engine.
Config
¶
Bases: BaseModel
Configuration for correlation-aware position optimization (Basanos engine).
Example
from pydantic import ValidationError from tinycta.config import Config cfg = Config(vola=32, corr=64, clip=4.2, shrink=0.5) cfg.vola, cfg.corr, cfg.clip, cfg.shrink (32, 64, 4.2, 0.5)
The model is frozen, so a validated config cannot drift after construction:
try: ... cfg.vola = 16 ... except ValidationError: ... print("frozen") frozen
corr must not be shorter than vola — a correlation window below the
volatility window is numerically unstable:
try: ... Config(vola=64, corr=32, clip=4.2, shrink=0.5) ... except ValidationError: ... print("corr must be >= vola") corr must be >= vola
Windows are strictly positive, shrink lies in [0, 1], and unknown
keys are rejected rather than silently ignored:
for bad in ({"vola": 0}, {"shrink": 1.5}, {"typo": 1}): ... kwargs = {"vola": 32, "corr": 64, "clip": 4.2, "shrink": 0.5} | bad ... try: ... Config(**kwargs) ... except ValidationError: ... print("rejected", sorted(bad)) rejected ['vola'] rejected ['shrink'] rejected ['typo']
Source code in src/tinycta/config.py
corr_greater_than_vola(v, info)
classmethod
¶
Enforce corr >= vola for numerical stability.