30 lines
911 B
Python
30 lines
911 B
Python
import datetime
|
|
|
|
import pytest
|
|
|
|
from idea159_arbsphere_federated_cross.core import LocalArbProblem, SharedSignals
|
|
from idea159_arbsphere_federated_cross.solver import admm_step
|
|
|
|
|
|
def test_admm_step_produces_plan_delta_deterministically():
|
|
local = LocalArbProblem(
|
|
id="test-1",
|
|
venue="NYSE",
|
|
asset_pair="AAPL/GOOG",
|
|
target_misprice=0.5,
|
|
max_exposure=10000.0,
|
|
latency_budget_ms=100,
|
|
)
|
|
signals = SharedSignals(version=1, price_delta=0.05, cross_venue_corr=0.9, liquidity=50000.0)
|
|
|
|
plan = admm_step(local, signals)
|
|
|
|
# Basic sanity checks on shape and content
|
|
assert plan is not None
|
|
assert isinstance(plan.actions, list)
|
|
assert len(plan.actions) == 1
|
|
act = plan.actions[0]
|
|
assert "venue_from" in act and "venue_to" in act
|
|
assert act["instrument"] == local.asset_pair
|
|
assert plan.timestamp <= datetime.datetime.utcnow()
|