Skip to content

Commit 9664b01

Browse files
committed
added input file
1 parent 6d9e300 commit 9664b01

File tree

4 files changed

+78
-10
lines changed

4 files changed

+78
-10
lines changed

derivatives/build/derivatives.exe

-23.8 MB
Binary file not shown.

derivatives/src/input/IR/ir1.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{"contracts" : [
2+
{
3+
"action":"PV",
4+
"pricer":"Analytical",
5+
"asset":"IR",
6+
"rate_data":{
7+
"instrument": "Deposit",
8+
"currency": "USD",
9+
"start_date": "0M",
10+
"maturity_date":"1M",
11+
"valuation_date": "0M",
12+
"notional": 1000000,
13+
"fix_rate": 0.055,
14+
"day_count": "A360",
15+
"business_day_adjustment": 0
16+
}
17+
},
18+
{
19+
"action":"PV",
20+
"pricer":"Analytical",
21+
"asset":"IR",
22+
"rate_data":{
23+
"instrument": "Deposit",
24+
"currency": "USD",
25+
"start_date": "0M",
26+
"maturity_date":"3M",
27+
"valuation_date": "0M",
28+
"notional": 1000000,
29+
"fix_rate": 0.05,
30+
"day_count": "A360",
31+
"business_day_adjustment": 0
32+
}
33+
},
34+
{
35+
"action":"PV",
36+
"pricer":"Analytical",
37+
"asset":"IR",
38+
"rate_data":{
39+
"instrument": "FRA",
40+
"currency": "USD",
41+
"start_date": "3M",
42+
"maturity_date":"6M",
43+
"valuation_date": "0M",
44+
"notional": 1000000,
45+
"fix_rate": 0.06,
46+
"day_count": "A360",
47+
"business_day_adjustment": 0
48+
}
49+
},
50+
{
51+
"action":"PV",
52+
"pricer":"Analytical",
53+
"asset":"IR",
54+
"rate_data":{
55+
"instrument": "FRA",
56+
"currency": "USD",
57+
"start_date": "6M",
58+
"maturity_date":"9M",
59+
"valuation_date": "0M",
60+
"notional": 1000000,
61+
"fix_rate": 0.065,
62+
"day_count": "A360",
63+
"business_day_adjustment": 0
64+
}
65+
}
66+
]
67+
}

derivatives/src/rates/utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ fn adjust_for_weekend(mut date: NaiveDate) -> NaiveDate {
3838
// Increment the date until it's not a weekend
3939
while is_holiday(date) || is_holiday(date) {
4040
date = date.succ();
41+
4142
}
4243
date
4344
}

derivatives/src/utils/parse_json.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ pub fn build_curve(mut file: &mut File,output_filename: &str)->() {
4545
ts.date.push(contract.get_maturity_date());
4646
ts.rate.push(contract.get_rate());
4747
}
48-
let mut dir = temp_dir();
49-
println!("dir {:?}",dir);
48+
let mut dir = std::path::PathBuf::from(output_filename);
49+
5050
dir.push("term_structure");
5151
let ts_dir = dir.as_path();
5252
if !ts_dir.exists() {
@@ -60,11 +60,11 @@ pub fn build_curve(mut file: &mut File,output_filename: &str)->() {
6060
}
6161
file.write_all(output.as_bytes()).expect("Failed to write to file");
6262

63-
let today = Local::today().naive_utc();
64-
let m = ts.interpolate_log_linear(today,NaiveDate::from_ymd(2024, 12, 12));
65-
println!("interpolated value {:?}",m);
66-
println!("Term Structure {:?}",ts);
67-
let mut deposit_test = rates::deposits::Deposit {
63+
//let today = Local::today().naive_utc();
64+
//let m = ts.interpolate_log_linear(today,NaiveDate::from_ymd(2024, 12, 12));
65+
//println!("interpolated value {:?}",m);
66+
//println!("Term Structure {:?}",ts);
67+
/*let mut deposit_test = rates::deposits::Deposit {
6868
start_date: today,
6969
maturity_date: NaiveDate::from_ymd(2024, 1, 17),
7070
valuation_date: today,
@@ -73,9 +73,9 @@ pub fn build_curve(mut file: &mut File,output_filename: &str)->() {
7373
day_count: rates::utils::DayCountConvention::Act360,
7474
business_day_adjustment: 0,
7575
term_structure: Some(ts.clone()),
76-
};
77-
println!("PV {:?}",deposit_test.get_pv(&ts));
78-
println!("Implied Rate {:?}",deposit_test.get_implied_rates());
76+
};*/
77+
//println!("PV {:?}",deposit_test.get_pv(&ts));
78+
//println!("Implied Rate {:?}",deposit_test.get_implied_rates());
7979

8080
}
8181
pub fn build_contracts(data: utils::Contract) -> Box<dyn Rates> {

0 commit comments

Comments
 (0)