34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
import json
|
|
import pytest
|
|
|
|
from exprove.contracts import LocalExecutionTask, SharedMarketContext, PlanDelta, GraphOfContracts
|
|
|
|
|
|
def test_local_execution_task_serialization():
|
|
task = LocalExecutionTask(
|
|
task_id="t1",
|
|
instrument="AAPL",
|
|
venue="VENUE1",
|
|
objective="VWAP",
|
|
constraints={"max_ticks": 5},
|
|
)
|
|
|
|
as_dict = task.to_dict()
|
|
assert as_dict["task_id"] == "t1"
|
|
assert as_dict["instrument"] == "AAPL"
|
|
|
|
|
|
def test_shared_market_context_and_plan_delta_roundtrip():
|
|
ctx = SharedMarketContext(signals={"depth": 10}, version=1, contract_id="c1")
|
|
# Create a deterministic delta via helper (imported inline for test simplicity)
|
|
from exprove.contracts import compute_delta
|
|
delta = compute_delta(LocalExecutionTask("t2", "MSFT", "VENUE2", "VWAP", {}), ctx)
|
|
assert isinstance(delta, PlanDelta)
|
|
assert delta.contract_id == "c1"
|
|
assert delta.timestamp == 0.0
|
|
|
|
|
|
def test_graph_of_contracts_serialization():
|
|
g = GraphOfContracts(registry={"adapterA": {"version": "1.0"}})
|
|
assert "adapterA" in g.registry
|