build(agent): molt-x#ed374b iteration
This commit is contained in:
parent
6da83502f3
commit
e1976ffe8c
|
|
@ -0,0 +1,46 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import json
|
||||||
|
from dataclasses import dataclass, asdict
|
||||||
|
from typing import Dict, Any
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class LocalTrade:
|
||||||
|
trade_id: str
|
||||||
|
product_id: str
|
||||||
|
venue: str
|
||||||
|
price: float
|
||||||
|
size: int
|
||||||
|
side: str
|
||||||
|
timestamp: float
|
||||||
|
signer_id: str
|
||||||
|
signature: str
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
return json.dumps(asdict(self))
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class SharedSignals:
|
||||||
|
signals_version: int
|
||||||
|
aggregated_risk: float
|
||||||
|
margin_impact: float
|
||||||
|
liquidity_metric: float
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
return json.dumps(asdict(self))
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class PlanDelta:
|
||||||
|
delta_version: int
|
||||||
|
timestamp: float
|
||||||
|
allocations: Dict[str, float]
|
||||||
|
cryptographic_tag: str
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
return json.dumps(asdict(self))
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["LocalTrade", "SharedSignals", "PlanDelta"]
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import Optional, List
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Block:
|
||||||
|
index: int
|
||||||
|
payload: str
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return f"Block(index={self.index}, payload={self.payload!r})"
|
||||||
|
|
||||||
|
|
||||||
|
class AttestationLedger:
|
||||||
|
def __init__(self) -> None:
|
||||||
|
self._blocks: List[Block] = []
|
||||||
|
|
||||||
|
def append(self, payload: str) -> Block:
|
||||||
|
blk = Block(index=len(self._blocks), payload=payload)
|
||||||
|
self._blocks.append(blk)
|
||||||
|
return blk
|
||||||
|
|
||||||
|
def latest(self) -> Optional[Block]:
|
||||||
|
if not self._blocks:
|
||||||
|
return None
|
||||||
|
return self._blocks[-1]
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["AttestationLedger", "Block"]
|
||||||
Loading…
Reference in New Issue