tarf_monte_carlo 3.59 → 3.60
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 +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: 3e84d65efa37c58059ce27ed5c949cf99d734804ae813840e7da6b46694394af
|
4
|
+
data.tar.gz: 54943b6268ddf6ee4f4f7ac72d4dc3fe9f8abbee1176b159fee6c35428ac106e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c49d6bed204c1e80f618c828dabc12febd6576c5b2e663bc3b36de24eda39c5f4d1783006ddf7996865809cb7174acaa4ed28fd353ebcef78505e1f305e75380
|
7
|
+
data.tar.gz: 5d520f207257d87a69bb9675fc3e6e36853378a0aef16c5f146a94ec2387f1de7bac75081266325a97728c80f5df8045328a2cd32599b076510d215f826c0e8a
|
@@ -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 payoffmet[SCount];
|
214
215
|
double **metrics;
|
215
216
|
if (barrier_variations(KType)){
|
216
217
|
metrics = ( double** ) malloc( BARRIER_DP * sizeof(double*) );
|
@@ -235,6 +236,8 @@ 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
|
+
payoffmet[sim_count] = 0;
|
240
|
+
payoffmet[sim_count + 1] = 0;
|
238
241
|
double Spot = S, Spot_dash = S;
|
239
242
|
double sim[NL], sim_pos[NL], sim_neg[NL], sim_dash[NL], sim_dash_pos[NL], sim_dash_neg[NL];
|
240
243
|
|
@@ -746,6 +749,8 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
746
749
|
pvs_neg[sim_count] = sim_neg_sum;
|
747
750
|
pvs_neg[sim_count + 1] = sim_dash_neg_sum;
|
748
751
|
|
752
|
+
payoffmet[sim_count] = sim_pos_sum;
|
753
|
+
payoffmet[sim_count + 1] = sim_dash_pos_sum;
|
749
754
|
|
750
755
|
if (barrier_variations(KType)){
|
751
756
|
if ((point_pos < DATAPOINTS) && (sim_count % INTERVAL) == 0){
|
@@ -821,12 +826,20 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
821
826
|
}
|
822
827
|
}
|
823
828
|
|
829
|
+
|
830
|
+
VALUE py_final_metrics = rb_ary_new();
|
831
|
+
for(metric = 0; metric < SCount; metric++) {
|
832
|
+
VALUE leg_metrics = rb_ary_new();
|
833
|
+
|
834
|
+
rb_ary_push(py_final_metrics, payoffmet[metric]);
|
835
|
+
}
|
824
836
|
// rb_p(rb_str_new2("Generating output hash"));
|
825
837
|
VALUE final_pvs = rb_hash_new();
|
826
838
|
rb_hash_aset(final_pvs, rb_str_new2("positive_pv"), DBL2NUM( pvs_pos_sum / SCount ));
|
827
839
|
rb_hash_aset(final_pvs, rb_str_new2("negative_pv"), DBL2NUM( pvs_neg_sum / SCount ));
|
828
840
|
rb_hash_aset(final_pvs, rb_str_new2("total_pv"), DBL2NUM( (pvs_neg_sum + pvs_pos_sum) / SCount ));
|
829
841
|
rb_hash_aset(final_pvs, rb_str_new2("metrics"), final_metrics);
|
842
|
+
rb_hash_aset(final_pvs, rb_str_new2("payoffmetrics"), py_final_metrics);
|
830
843
|
|
831
844
|
//
|
832
845
|
// free your arrays from memory once you're done using them
|