66 lines
1.7 KiB
Python
66 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from .primitives import LocalProblem, SharedVariables, PlanDelta, DualVariables, PrivacyBudget, AuditLog, GraphOfContractsRegistry, TimeRounds
|
|
|
|
|
|
def sample_local_problem() -> LocalProblem:
|
|
return LocalProblem(
|
|
id="lp-demo",
|
|
domain="equities",
|
|
assets=["AAPL", "MSFT"],
|
|
objective="minimize expected cost",
|
|
constraints={"max_risk": 0.05},
|
|
)
|
|
|
|
|
|
def sample_shared_variables() -> SharedVariables:
|
|
return SharedVariables(
|
|
forecasts={"AAPL": 150.0, "MSFT": 300.0},
|
|
priors={"AAPL": 149.5, "MSFT": 299.5},
|
|
version=1,
|
|
)
|
|
|
|
|
|
def sample_plan_delta() -> PlanDelta:
|
|
return PlanDelta(
|
|
delta={"action": "rebalance", "targets": {"AAPL": 100}},
|
|
timestamp=0.0,
|
|
author="toy-simulator",
|
|
contract_id="lp-demo",
|
|
signature=None,
|
|
)
|
|
|
|
|
|
def sample_dual_variables() -> DualVariables:
|
|
return DualVariables(lambda_latency=0.0, lambda_fees=0.0)
|
|
|
|
|
|
def sample_privacy_budget() -> PrivacyBudget:
|
|
return PrivacyBudget(budget=1.0, expiry=None)
|
|
|
|
|
|
def sample_audit_log() -> AuditLog:
|
|
import time
|
|
return AuditLog(entry="demo", signer="toy-signer", timestamp=time.time(), contract_id="lp-demo", version=1)
|
|
|
|
|
|
def sample_registry() -> GraphOfContractsRegistry:
|
|
reg = GraphOfContractsRegistry()
|
|
reg.register("adapter-demo", "v0.1")
|
|
return reg
|
|
|
|
|
|
def sample_time_rounds() -> TimeRounds:
|
|
return TimeRounds(round_id="tr-1", start_ts=0.0, end_ts=3600.0)
|
|
|
|
|
|
__all__ = [
|
|
"sample_local_problem",
|
|
"sample_shared_variables",
|
|
"sample_plan_delta",
|
|
"sample_dual_variables",
|
|
"sample_privacy_budget",
|
|
"sample_audit_log",
|
|
"sample_registry",
|
|
]
|