tarf_monte_carlo 3.65 → 3.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/tarf_monte_carlo/tarf_monte_carlo.c +13 -0
- 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: 1398b6cb4be3ea51154d3da07ab8db53b46e32ea5340688de66f25583834141d
|
|
4
|
+
data.tar.gz: 73320e683ceb04104c1cc1803a3b753b104ddd7c150314f86c2408abf77558b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4af0d39d2b3e43b47060886282badc77ac70aa03bd4f9573e3cca13b45a245ecb14d99c34ced0b7d4a36b6d11384ea048a78a37e029267a6f482419a643b0dfa
|
|
7
|
+
data.tar.gz: 0b2952a5b59c8c56a5d3b570f540c508572384f000ff82b887a7fd5d254445a726e458c1b33b3836a7949682225a11d1d57219314d3bc43fbe19d696244d6619
|
|
@@ -212,6 +212,7 @@ 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];
|
|
215
216
|
if (barrier_variations(KType)){
|
|
216
217
|
metrics = ( double** ) malloc( BARRIER_DP * sizeof(double*) );
|
|
217
218
|
for( metric = 0; metric < BARRIER_DP; metric++ ) {
|
|
@@ -235,6 +236,9 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
235
236
|
// run simulations loop
|
|
236
237
|
for( sim_count = 0; sim_count < SCount; sim_count += 2 ) {
|
|
237
238
|
// initial spot rate for each iteration would be current spot rate
|
|
239
|
+
pffm[sim_count] = 0;
|
|
240
|
+
pffm[sim_count+1] = 0;
|
|
241
|
+
|
|
238
242
|
double Spot = S, Spot_dash = S;
|
|
239
243
|
double sim[NL], sim_pos[NL], sim_neg[NL], sim_dash[NL], sim_dash_pos[NL], sim_dash_neg[NL];
|
|
240
244
|
|
|
@@ -581,9 +585,11 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
581
585
|
double equivalent_notional = *( Ns_array + knockedLeg );
|
|
582
586
|
sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
|
|
583
587
|
} else {
|
|
588
|
+
pffm[sim_count] = knockedLeg2;
|
|
584
589
|
sim_pos[knockedLeg2] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[knockedLeg2], dir_sign);
|
|
585
590
|
}
|
|
586
591
|
} else if(knockedLeg2 >= 0){
|
|
592
|
+
pffm[sim_count] = knockedLeg2;
|
|
587
593
|
sim_pos[knockedLeg2] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[knockedLeg2], dir_sign);
|
|
588
594
|
} else if(knockedLeg >= 0) {
|
|
589
595
|
double equivalent_notional = *( Ns_array + knockedLeg );
|
|
@@ -839,12 +845,19 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
839
845
|
}
|
|
840
846
|
}
|
|
841
847
|
|
|
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
|
+
|
|
842
854
|
// rb_p(rb_str_new2("Generating output hash"));
|
|
843
855
|
VALUE final_pvs = rb_hash_new();
|
|
844
856
|
rb_hash_aset(final_pvs, rb_str_new2("positive_pv"), DBL2NUM( pvs_pos_sum / SCount ));
|
|
845
857
|
rb_hash_aset(final_pvs, rb_str_new2("negative_pv"), DBL2NUM( pvs_neg_sum / SCount ));
|
|
846
858
|
rb_hash_aset(final_pvs, rb_str_new2("total_pv"), DBL2NUM( (pvs_neg_sum + pvs_pos_sum) / SCount ));
|
|
847
859
|
rb_hash_aset(final_pvs, rb_str_new2("metrics"), final_metrics);
|
|
860
|
+
rb_hash_aset(final_pvs, rb_str_new2("testing"), pffm_metrics);
|
|
848
861
|
|
|
849
862
|
//
|
|
850
863
|
// free your arrays from memory once you're done using them
|