22 lines
1022 B
Python
22 lines
1022 B
Python
from __future__ import annotations
|
|
from dataclasses import dataclass
|
|
from datetime import datetime
|
|
from deltaforge.dsl import SharedSignals, PlanDelta, LocalArbProblem
|
|
|
|
|
|
def reconcile(signals: SharedSignals, problems: list[LocalArbProblem], plan: PlanDelta) -> PlanDelta:
|
|
# Very lightweight cross-venue coherence check.
|
|
# Ensure that for delta-hedge style plans, net delta sums close to zero (delta-neutral) as a toy constraint.
|
|
net = sum(plan.delta.values()) if plan and plan.delta else 0.0
|
|
if abs(net) > 1e-6:
|
|
# Adjust plan by distributing remaining delta to the first asset if possible
|
|
if plan.delta:
|
|
first = next(iter(plan.delta))
|
|
plan.delta[first] = plan.delta[first] - net
|
|
else:
|
|
plan.delta = {"default": -net}
|
|
# Attach a lightweight audit tag
|
|
plan.safety_tags = plan.safety_tags if hasattr(plan, 'safety_tags') else []
|
|
plan.safety_tags.append("reconciled-by-curator-at-{}".format(datetime.utcnow().isoformat()))
|
|
return plan
|