tarf_monte_carlo 3.68 → 3.69
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 +14 -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: a09821b8f49b2435d5faac86b35b58e9514de07dcf70200c99d9fe8c2a496cd1
|
|
4
|
+
data.tar.gz: 6f19dd72e7a81ba7ed41f8e40e29a57965acf4e4b5ee78cb1fb2f931d5ae3270
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3fb2c088e7cd659ebae7db0b3dadb0ddac9e58661ca70383df086ff550f1e7387f384c29f66f216d13b9e0b6f073770521db72815544ac1aa401ac84476a8b93
|
|
7
|
+
data.tar.gz: c686b6a2e6a347ffcb62a293f7b1b39beafae1755b31ab4d9a540b1b8f0b9ce16a3b0ae00ec43447214b4247229d58ea15ae996ee5467205432be179f9fccdb9
|
|
@@ -211,6 +211,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
211
211
|
//
|
|
212
212
|
// first create a 1-D array of pointers, and then, for each array entry, create another 1-D array.
|
|
213
213
|
//
|
|
214
|
+
double testing[SCount];
|
|
214
215
|
double **metrics;
|
|
215
216
|
if (barrier_variations(KType)){
|
|
216
217
|
metrics = ( double** ) malloc( BARRIER_DP * sizeof(double*) );
|
|
@@ -234,6 +235,10 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
234
235
|
|
|
235
236
|
// run simulations loop
|
|
236
237
|
for( sim_count = 0; sim_count < SCount; sim_count += 2 ) {
|
|
238
|
+
|
|
239
|
+
testing[sim_count] = -1;
|
|
240
|
+
testing[sim_count+1] = -1;
|
|
241
|
+
|
|
237
242
|
// initial spot rate for each iteration would be current spot rate
|
|
238
243
|
double Spot = S, Spot_dash = S;
|
|
239
244
|
double sim[NL], sim_pos[NL], sim_neg[NL], sim_dash[NL], sim_dash_pos[NL], sim_dash_neg[NL];
|
|
@@ -576,6 +581,9 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
576
581
|
metrics[3][point_pos+1] = knockedLeg_dash;
|
|
577
582
|
}
|
|
578
583
|
} else if(KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_KI){
|
|
584
|
+
testing[sim_count] = knockedLeg2;
|
|
585
|
+
testing[sim_count + 1] = knockedLeg2_dash;
|
|
586
|
+
|
|
579
587
|
if(knockedLeg >= 0 && knockedLeg2 >= 0){
|
|
580
588
|
if(knockedLeg < knockedLeg2){
|
|
581
589
|
double equivalent_notional = *( Ns_array + knockedLeg );
|
|
@@ -839,12 +847,18 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
839
847
|
}
|
|
840
848
|
}
|
|
841
849
|
|
|
850
|
+
VALUE testing_data = rb_ary_new();
|
|
851
|
+
for(metric = 0; metric < SCount; metric++) {
|
|
852
|
+
rb_ary_push(testing_data, DBL2NUM(testing[metric]));
|
|
853
|
+
}
|
|
854
|
+
|
|
842
855
|
// rb_p(rb_str_new2("Generating output hash"));
|
|
843
856
|
VALUE final_pvs = rb_hash_new();
|
|
844
857
|
rb_hash_aset(final_pvs, rb_str_new2("positive_pv"), DBL2NUM( pvs_pos_sum / SCount ));
|
|
845
858
|
rb_hash_aset(final_pvs, rb_str_new2("negative_pv"), DBL2NUM( pvs_neg_sum / SCount ));
|
|
846
859
|
rb_hash_aset(final_pvs, rb_str_new2("total_pv"), DBL2NUM( (pvs_neg_sum + pvs_pos_sum) / SCount ));
|
|
847
860
|
rb_hash_aset(final_pvs, rb_str_new2("metrics"), final_metrics);
|
|
861
|
+
rb_hash_aset(final_pvs, rb_str_new2("testing"), testing_data);
|
|
848
862
|
|
|
849
863
|
//
|
|
850
864
|
// free your arrays from memory once you're done using them
|