Skip to main content

hypercall/
types.rs

1use hypercall_engine::fee::FeeConfig;
2
3pub use hypercall_margin::types::{
4    Account, MarginDetails, OptionContract, OptionType, Position, Scenario, ScenarioType,
5};
6
7#[derive(Clone)]
8pub struct Config {
9    pub scenarios: Vec<Scenario>,
10    pub risk_free_rate: f64,
11    pub base_volatility: f64,
12    pub base_skew: f64,
13    pub base_excess_kurtosis: f64,
14    pub delta_threshold: f64,
15    pub strike_match_tolerance: f64,
16    pub expiry_match_tolerance_years: f64,
17    pub fee_config: FeeConfig,
18    pub allow_standard_margin_shorts: bool,
19}
20
21#[cfg(feature = "test-utils")]
22pub fn standard_test_scenarios() -> Vec<Scenario> {
23    vec![
24        Scenario {
25            scenario_type: ScenarioType::SpotChange,
26            value: 0.15,
27        },
28        Scenario {
29            scenario_type: ScenarioType::SpotChange,
30            value: -0.15,
31        },
32        Scenario {
33            scenario_type: ScenarioType::VolChange,
34            value: 0.25,
35        },
36        Scenario {
37            scenario_type: ScenarioType::VolChange,
38            value: -0.25,
39        },
40    ]
41}
42
43impl Config {
44    pub fn portfolio_margin_config(&self) -> hypercall_margin::PortfolioMarginConfig {
45        hypercall_margin::PortfolioMarginConfig::from_legacy_config(
46            self.risk_free_rate,
47            self.base_volatility,
48            self.base_skew,
49            self.base_excess_kurtosis,
50            self.delta_threshold,
51            self.strike_match_tolerance,
52            self.expiry_match_tolerance_years,
53        )
54    }
55}