Skip to content

Commit 44c5785

Browse files
committed
added npv of equity forward
1 parent 60cd2f8 commit 44c5785

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

src/equity/equity_forward.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,10 @@ impl Instrument for EquityForward {
7474
}
7575
}
7676

77+
impl EquityForward{
78+
pub fn delta(&self) -> f64 { 1.0 }
79+
pub fn gamma(&self) -> f64 { 0.0 }
80+
pub fn vega(&self) -> f64 { 0.0 }
81+
pub fn theta(&self) -> f64 { 0.0 }
82+
pub fn rho(&self) -> f64 { 0.0 }
83+
}

src/equity/handle_equity_contracts.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::core::traits::Instrument;
22
use crate::core::utils::{Contract,CombinedContract, ContractOutput};
3+
use crate::equity::equity_forward::EquityForward;
34
use crate::equity::vanila_option::EquityOption;
45
use crate::equity::equity_future::EquityFuture;
56
pub fn handle_equity_contract(data: &Contract) -> String {
@@ -41,6 +42,24 @@ pub fn handle_equity_contract(data: &Contract) -> String {
4142
};
4243
serde_json::to_string(&combined_).expect("Failed to generate output")
4344
}
45+
Some("Forward") => {
46+
let future = EquityForward::from_json(data);
47+
let contract_output = ContractOutput {
48+
pv: future.npv(),
49+
delta: future.delta(),
50+
gamma: future.gamma(),
51+
vega: future.vega(),
52+
theta: future.theta(),
53+
rho: future.rho(),
54+
error: None
55+
};
56+
println!("Equity Forward Price: {}", contract_output.pv);
57+
let combined_ = CombinedContract {
58+
contract: data.clone(),
59+
output: contract_output
60+
};
61+
serde_json::to_string(&combined_).expect("Failed to generate output")
62+
}
4463
_ => {
4564
panic!("Unsupported or missing product_type for asset EQ");
4665
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{"asset":"EQ",
2+
"contracts" : [
3+
{
4+
"action":"PV",
5+
"pricer":"Analytical",
6+
"asset":"EQ",
7+
"product_type": "Option",
8+
"payoff_type": "Vanilla",
9+
"market_data":{
10+
"underlying_price":100,
11+
"option_type":"C",
12+
"strike_price":100,
13+
"volatility":0.4,
14+
"risk_free_rate":0.06,
15+
"maturity":"2025-03-31",
16+
"dividend": 0.01
17+
}
18+
}]
19+
}

0 commit comments

Comments
 (0)