37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Dict
|
|
|
|
from .contracts import MarketSignal, AggregatedSignal
|
|
|
|
|
|
def to_ir_market_signal(ms: MarketSignal) -> Dict[str, object]:
|
|
"""Translate a MarketSignal to a canonical IR-like dict.
|
|
|
|
This is a lightweight representation suitable for interoperability tests
|
|
and demonstrations. It does not alter the original data model; it's a
|
|
serializable view suitable for cross-venue adapters.
|
|
"""
|
|
return {
|
|
"local_context": {
|
|
"venue": ms.venue_id,
|
|
"instrument": ms.symbol,
|
|
"timestamp": ms.timestamp.isoformat(),
|
|
"features": ms.features,
|
|
"version": ms.version,
|
|
}
|
|
}
|
|
|
|
|
|
def to_ir_aggregated_signal(agg: AggregatedSignal) -> Dict[str, object]:
|
|
"""Translate an AggregatedSignal to a canonical IR-like dict."""
|
|
return {
|
|
"aggregated": {
|
|
"venues": agg.venues,
|
|
"feature_vector": agg.feature_vector,
|
|
"privacy_budget_used": agg.privacy_budget_used,
|
|
"nonce": agg.nonce,
|
|
"merkle_proof": agg.merkle_proof,
|
|
}
|
|
}
|