tarf_monte_carlo 3.66 → 3.67
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/tarf_monte_carlo/tarf_monte_carlo.c +6 -19
- data/lib/tarf_monte_carlo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4eaec9a6c923daa279367d27ae6d5c7739d54a8d6581395b887429907a028792
|
4
|
+
data.tar.gz: 91f799dc24f730b68afdd7977cf5dbdca20e3d0d9973d3b3eb78ce044a898d81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 148485ef218f78f3bcda485866fbcb65197e47d052aab4c2266fd4df2512029b79c0ba1fcedc148a0d330444644539fadbef797b2dfaf6524e8586fb580bb0e4
|
7
|
+
data.tar.gz: fbdef2214f7d80d306b9ace4e007aa49787145fa9b0962d1a11fd0ae836797a231988ea454c979f13f8ed92ad1fcd1995839f4fa1ffea5f6178eb1d134cf39fb
|
@@ -212,7 +212,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
212
212
|
// first create a 1-D array of pointers, and then, for each array entry, create another 1-D array.
|
213
213
|
//
|
214
214
|
double **metrics;
|
215
|
-
double pffm[SCount];
|
216
215
|
if (barrier_variations(KType)){
|
217
216
|
metrics = ( double** ) malloc( BARRIER_DP * sizeof(double*) );
|
218
217
|
for( metric = 0; metric < BARRIER_DP; metric++ ) {
|
@@ -236,9 +235,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
236
235
|
// run simulations loop
|
237
236
|
for( sim_count = 0; sim_count < SCount; sim_count += 2 ) {
|
238
237
|
// initial spot rate for each iteration would be current spot rate
|
239
|
-
pffm[sim_count] = 0;
|
240
|
-
pffm[sim_count+1] = 0;
|
241
|
-
|
242
238
|
double Spot = S, Spot_dash = S;
|
243
239
|
double sim[NL], sim_pos[NL], sim_neg[NL], sim_dash[NL], sim_dash_pos[NL], sim_dash_neg[NL];
|
244
240
|
|
@@ -559,13 +555,13 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
559
555
|
}
|
560
556
|
} else if(KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP){
|
561
557
|
if(knockedLeg2 >= 0){
|
562
|
-
sim_pos[NL-1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array +
|
558
|
+
sim_pos[NL-1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg2 ) ), sim[NL-1], dir_sign);
|
563
559
|
} else if(knockedLeg >= 0) {
|
564
560
|
double equivalent_notional = *( Ns_array + knockedLeg );
|
565
561
|
sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
|
566
562
|
}
|
567
563
|
if(knockedLeg2_dash >= 0){
|
568
|
-
sim_dash_pos[NL-1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array +
|
564
|
+
sim_dash_pos[NL-1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg2 ) ), sim_dash[NL-1], dir_sign);
|
569
565
|
} else if(knockedLeg_dash >= 0) {
|
570
566
|
double equivalent_notional = *( Ns_array + knockedLeg_dash );
|
571
567
|
sim_dash_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg_dash) ) ), sim_dash[NL-1], cp_sign, dir_sign, equivalent_notional);
|
@@ -585,12 +581,10 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
585
581
|
double equivalent_notional = *( Ns_array + knockedLeg );
|
586
582
|
sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
|
587
583
|
} else {
|
588
|
-
|
589
|
-
sim_pos[knockedLeg2] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[knockedLeg2], dir_sign);
|
584
|
+
sim_pos[knockedLeg2] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg2 ) ), sim[knockedLeg2], dir_sign);
|
590
585
|
}
|
591
586
|
} else if(knockedLeg2 >= 0){
|
592
|
-
|
593
|
-
sim_pos[knockedLeg2] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[knockedLeg2], dir_sign);
|
587
|
+
sim_pos[knockedLeg2] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg2 ) ), sim[knockedLeg2], dir_sign);
|
594
588
|
} else if(knockedLeg >= 0) {
|
595
589
|
double equivalent_notional = *( Ns_array + knockedLeg );
|
596
590
|
sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
|
@@ -601,10 +595,10 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
601
595
|
double equivalent_notional = *( Ns_array + knockedLeg_dash );
|
602
596
|
sim_dash_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg_dash) ) ), sim_dash[NL-1], cp_sign, dir_sign, equivalent_notional);
|
603
597
|
} else {
|
604
|
-
sim_dash_pos[knockedLeg2_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array +
|
598
|
+
sim_dash_pos[knockedLeg2_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg2_dash ) ), sim_dash[knockedLeg2_dash], dir_sign);
|
605
599
|
}
|
606
600
|
} else if(knockedLeg2_dash >= 0){
|
607
|
-
sim_dash_pos[knockedLeg2_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array +
|
601
|
+
sim_dash_pos[knockedLeg2_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg2_dash ) ), sim_dash[knockedLeg2_dash], dir_sign);
|
608
602
|
} else if(knockedLeg_dash >= 0) {
|
609
603
|
double equivalent_notional = *( Ns_array + knockedLeg_dash );
|
610
604
|
sim_dash_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg_dash) ) ), sim_dash[NL-1], cp_sign, dir_sign, equivalent_notional);
|
@@ -845,19 +839,12 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
845
839
|
}
|
846
840
|
}
|
847
841
|
|
848
|
-
VALUE pffm_metrics = rb_ary_new();
|
849
|
-
for(metric = 0; metric < SCount; metric++) {
|
850
|
-
rb_ary_push(pffm_metrics, DBL2NUM(pffm[metric]));
|
851
|
-
}
|
852
|
-
|
853
|
-
|
854
842
|
// rb_p(rb_str_new2("Generating output hash"));
|
855
843
|
VALUE final_pvs = rb_hash_new();
|
856
844
|
rb_hash_aset(final_pvs, rb_str_new2("positive_pv"), DBL2NUM( pvs_pos_sum / SCount ));
|
857
845
|
rb_hash_aset(final_pvs, rb_str_new2("negative_pv"), DBL2NUM( pvs_neg_sum / SCount ));
|
858
846
|
rb_hash_aset(final_pvs, rb_str_new2("total_pv"), DBL2NUM( (pvs_neg_sum + pvs_pos_sum) / SCount ));
|
859
847
|
rb_hash_aset(final_pvs, rb_str_new2("metrics"), final_metrics);
|
860
|
-
rb_hash_aset(final_pvs, rb_str_new2("testing"), pffm_metrics);
|
861
848
|
|
862
849
|
//
|
863
850
|
// free your arrays from memory once you're done using them
|