-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c01a036
commit 8787fcb
Showing
14 changed files
with
245 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/// This is Black Scholes Merton PDE solver using finite difference method | ||
/// $ \frac{\partial V}{\partial t} + \frac{1}{2}\sigma^2 S^2 \frac{\partial^2 V}{\partial S^2} + rS\frac{\partial V}{\partial S} - rV = 0 $ | ||
/// $ V(S,T) = max(S-K,0) $ | ||
/// $ V(0,t) = 0 $ | ||
/// $ V(S,t) \rightarrow S $ as $ S \rightarrow \infty $ | ||
///https://de.wikipedia.org/wiki/Thomas-Algorithmus | ||
// pub fn blackscholes_pde(spot:f64,strike:f64,rate:f64,volatility:f64,time_to_maturity:f64,steps:u64,option_type:OptionType) -> f64{ | ||
// let mut grid = Grid::new(spot,strike,rate,volatility,time_to_maturity,steps,option_type); | ||
// grid.solve(); | ||
// let value = grid.get_value(); | ||
// value | ||
// } | ||
// pub struct Grid { | ||
// spot: f64, | ||
// strike: f64, | ||
// rate: f64, | ||
// dividend: f64, | ||
// //volatility:f64, | ||
// time_to_maturity: f64, | ||
// spot_steps: u64, | ||
// time_steps: u64 | ||
// } | ||
// impl Grid{ | ||
// pub fn payoff(&self,spot:f64) -> f64{ | ||
// let payoff = (spot - self.strike).max(0.0); | ||
// payoff | ||
// } | ||
// pub fn build_grid(&self) -> Vec<Vec<f64>>{ | ||
// let mut grid:Array2<f64> = Array2::zeros((self.time_steps as usize,self.spot_steps as usize)); | ||
// //let mut grid = vec![vec![0.0;self.spot_steps as usize];self.time_steps as usize]; | ||
// for i in 0..self.spot_steps as usize{ | ||
// grid[0][i] = self.payoff(i as f64); | ||
// } | ||
// grid | ||
// } | ||
// } | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{"asset":"IR", | ||
"contracts" : [ | ||
{ | ||
"action":"PV", | ||
"pricer":"Analytical", | ||
"asset":"IR", | ||
"rate_data":{ | ||
"instrument": "Deposit", | ||
"currency": "USD", | ||
"start_date": "0M", | ||
"maturity_date":"1M", | ||
"valuation_date": "0M", | ||
"notional": 1000000, | ||
"fix_rate": 0.055, | ||
"day_count": "A360", | ||
"business_day_adjustment": 0 | ||
} | ||
}, | ||
{ | ||
"action":"PV", | ||
"pricer":"Analytical", | ||
"asset":"IR", | ||
"rate_data":{ | ||
"instrument": "Deposit", | ||
"currency": "USD", | ||
"start_date": "0M", | ||
"maturity_date":"3M", | ||
"valuation_date": "0M", | ||
"notional": 1000000, | ||
"fix_rate": 0.05, | ||
"day_count": "A360", | ||
"business_day_adjustment": 0 | ||
} | ||
}, | ||
{ | ||
"action":"PV", | ||
"pricer":"Analytical", | ||
"asset":"IR", | ||
"rate_data":{ | ||
"instrument": "FRA", | ||
"currency": "USD", | ||
"start_date": "3M", | ||
"maturity_date":"6M", | ||
"valuation_date": "0M", | ||
"notional": 1000000, | ||
"fix_rate": 0.06, | ||
"day_count": "A360", | ||
"business_day_adjustment": 0 | ||
} | ||
}, | ||
{ | ||
"action":"PV", | ||
"pricer":"Analytical", | ||
"asset":"IR", | ||
"rate_data":{ | ||
"instrument": "FRA", | ||
"currency": "USD", | ||
"start_date": "6M", | ||
"maturity_date":"9M", | ||
"valuation_date": "0M", | ||
"notional": 1000000, | ||
"fix_rate": 0.065, | ||
"day_count": "A360", | ||
"business_day_adjustment": 0 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.