hypercall_db/traits/
catalog.rs1use anyhow::Result;
7use rust_decimal::Decimal;
8
9#[derive(Debug, Clone)]
11pub struct MarketCatalogState {
12 pub underlying: String,
13 pub expiry: i64,
14 pub ref_price_at_listing: Decimal,
15 pub listed_at: i64,
16 pub listing_policy_version: i32,
17 pub last_extension_at: Option<i64>,
18 pub last_extension_ref_price: Option<Decimal>,
19}
20
21#[derive(Debug, Clone)]
23pub struct CatalogInstrument {
24 pub id: String,
25 pub underlying: String,
26 pub strike: Decimal,
27 pub expiry: i64,
28 pub option_type: String,
29}
30
31#[async_trait::async_trait]
33pub trait CatalogReader: Send + Sync {
34 async fn get_market_catalog_state(
36 &self,
37 underlying: &str,
38 expiry: i64,
39 ) -> Result<Option<MarketCatalogState>>;
40
41 async fn get_instruments_for_settlement(
43 &self,
44 underlying: &str,
45 expiry: i64,
46 ) -> Result<Vec<CatalogInstrument>>;
47
48 async fn get_distinct_strikes(&self, underlying: &str, expiry: i64) -> Result<Vec<Decimal>>;
50
51 async fn get_markets_for_underlying(&self, underlying: &str) -> Result<Vec<(String, i64)>>;
53
54 async fn get_instruments_count(&self, underlying: &str, expiry: i64) -> Result<i32>;
56
57 async fn market_exists(&self, underlying: &str, expiry: i64) -> Result<bool>;
59
60 async fn instrument_exists(&self, symbol: &str) -> Result<bool>;
62}
63
64#[async_trait::async_trait]
66pub trait CatalogWriter: CatalogReader {
67 async fn upsert_market_catalog_state(&self, state: &MarketCatalogState) -> Result<()>;
72
73 async fn update_trading_mode_for_underlying(
75 &self,
76 underlying: &str,
77 trading_mode: &str,
78 ) -> Result<()>;
79}