Skip to main content

hypercall_runtime_api/boundary/
market_inputs.rs

1use std::collections::HashMap;
2
3use hypercall_types::api_models::Instrument;
4use hypercall_types::Greeks;
5use rust_decimal::Decimal;
6
7#[async_trait::async_trait]
8pub trait GreeksCacheReader: Send + Sync {
9    async fn get_greeks(&self, symbol: &str) -> anyhow::Result<Greeks>;
10    async fn get_theoretical_price(&self, symbol: &str) -> anyhow::Result<f64>;
11    async fn get_theoretical_mark(&self, symbol: &str) -> anyhow::Result<f64>;
12    async fn get_iv(&self, symbol: &str) -> anyhow::Result<f64>;
13    async fn get_bulk_iv(&self, symbols: &[String]) -> HashMap<String, f64>;
14    async fn get_all_iv_snapshot(&self) -> HashMap<String, f64>;
15    async fn get_all_spot_prices_snapshot(&self) -> HashMap<String, f64>;
16    async fn get_all_prev_day_prices_snapshot(&self) -> HashMap<String, f64>;
17    async fn get_spot_price(&self, underlying: &str) -> Option<f64>;
18    async fn get_settlement_price(&self, underlying: &str, expiry_timestamp: i64) -> Option<f64>;
19    async fn get_quote_side_ivs_from_prices(
20        &self,
21        symbol: &str,
22        best_bid: Option<f64>,
23        best_ask: Option<f64>,
24    ) -> anyhow::Result<(Option<f64>, Option<f64>)>;
25    async fn has_symbol(&self, symbol: &str) -> bool;
26    fn get_configured_underlyings(&self) -> Vec<String>;
27    async fn get_spot_price_staleness(&self) -> HashMap<String, Option<f64>>;
28    async fn get_unhealthy_oracles(&self) -> Vec<String>;
29    #[cfg(feature = "test-utils")]
30    async fn set_spot_price_for_testing(&self, underlying: &str, price: f64) -> bool;
31    #[cfg(feature = "test-utils")]
32    async fn set_theoretical_iv_for_testing(&self, symbol: &str, iv: f64);
33}
34
35#[async_trait::async_trait]
36pub trait InstrumentsCacheReader: Send + Sync {
37    async fn get_by_symbol(&self, symbol: &str) -> Option<Instrument>;
38    fn allows_rfq(&self, symbol: &str) -> bool;
39    async fn get_by_underlying_and_expiry(&self, underlying: &str, expiry: u64) -> Vec<Instrument>;
40    async fn get_by_instrument_id(&self, instrument_id: i32) -> Option<Instrument>;
41    async fn get_all(&self) -> Vec<Instrument>;
42    async fn len(&self) -> usize;
43    async fn reload_from_db(&self, db: &dyn hypercall_db::BootstrapReader) -> anyhow::Result<()>;
44}
45
46#[async_trait::async_trait]
47pub trait MarketStatsCacheReader: Send + Sync {
48    async fn get_all_stats(&self) -> HashMap<String, (Decimal, Decimal)>;
49}