pub trait AffinityRecorder: Send + Sync {
// Required method
fn record_trade<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
strategy: &'life1 str,
asset: &'life2 str,
pnl: f64,
is_winner: bool,
rr_ratio: Option<f64>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
A type-erased interface for recording a realized trade outcome into the strategy-affinity tracker.
Stored in JanusState so the API module’s position-close handler can
feed outcomes back into affinity learning in real time without
janus-core (or janus-api) depending on janus-strategies — the
concrete tracker lives in the forward service’s TradingPipeline, which
installs an adapter via set_affinity_recorder.
Mirrors the LogLevelController pattern.
§Thread Safety
Implementations must be Send + Sync because JanusState is shared
across Tokio tasks. The method is async + &self so the adapter can
acquire the concrete tracker’s own (async) lock internally.
Required Methods§
Sourcefn record_trade<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
strategy: &'life1 str,
asset: &'life2 str,
pnl: f64,
is_winner: bool,
rr_ratio: Option<f64>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn record_trade<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
strategy: &'life1 str,
asset: &'life2 str,
pnl: f64,
is_winner: bool,
rr_ratio: Option<f64>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Record a closed trade for (strategy, asset).
pnl: realized P&L in quote currency (signed).is_winner: whether the trade closed in profit.rr_ratio: realized risk-reward ratio, when known.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".