tarf_monte_carlo 3.59 → 3.60

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 384c19cb2b52b6b7f0cd0b03f0128fc6401c2455286aa206770233781685a41c
4
- data.tar.gz: 63d22411c3a1a438f679a8ce421fea26e9b6ad8bc5f479eb66532f9b3087c652
3
+ metadata.gz: 3e84d65efa37c58059ce27ed5c949cf99d734804ae813840e7da6b46694394af
4
+ data.tar.gz: 54943b6268ddf6ee4f4f7ac72d4dc3fe9f8abbee1176b159fee6c35428ac106e
5
5
  SHA512:
6
- metadata.gz: b17e9cc3e33b5c21bb5a2e9ab8dcb8912e0bed6522279066a903ca315a3d2b5ca8c3666b5b1687fd63f2060f297b3a0e1e2e4a312c2268bb0e31bb896c88e4e3
7
- data.tar.gz: 4ac2992778ce44b6a7add5db8dec950ee8ad86ac140f80e064054f3871720a470e66e936eafe424d892e8082c4fe57ffae28df4a05ffa35c92539388fb7a7922
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
@@ -3,5 +3,5 @@
3
3
  # gem yank tarf_monte_carlo -v 2.3
4
4
 
5
5
  module TarfMonteCarlo
6
- VERSION = "3.59"
6
+ VERSION = "3.60"
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tarf_monte_carlo
3
3
  version: !ruby/object:Gem::Version
4
- version: '3.59'
4
+ version: '3.60'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vivek Routh