feat: add allocation backtest evidence
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""Contracts for administrator-run advisory allocation backtests."""
|
||||
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
||||
|
||||
|
||||
class AllocationBacktestQuery(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid", frozen=True)
|
||||
|
||||
started_on: date
|
||||
ended_on: date
|
||||
profile_risk_level: int = Field(ge=1, le=5)
|
||||
return_target_lower_pct: Decimal = Field(ge=Decimal("0"), le=Decimal("100"))
|
||||
max_drawdown_pct: Decimal = Field(ge=Decimal("0"), le=Decimal("100"))
|
||||
liquidity_requirement: str
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_range(self) -> "AllocationBacktestQuery":
|
||||
if self.ended_on <= self.started_on:
|
||||
raise ValueError("ended_on must be after started_on")
|
||||
if (self.ended_on - self.started_on).days > 1825:
|
||||
raise ValueError("backtest range must not exceed five years")
|
||||
if self.liquidity_requirement not in {
|
||||
"daily", "within_7_days", "within_30_days", "over_30_days"
|
||||
}:
|
||||
raise ValueError("unknown liquidity requirement")
|
||||
return self
|
||||
Reference in New Issue
Block a user