tarf_monte_carlo 3.65 → 3.66

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 707623dec4f74afcf22546eb4e00d1eac103b8f09f9b876b485496f8ee720588
4
- data.tar.gz: f882ae037b74ec0823880a030d71d59f617f8b93ffaaa6d3630078c73e9ceb9e
3
+ metadata.gz: 1398b6cb4be3ea51154d3da07ab8db53b46e32ea5340688de66f25583834141d
4
+ data.tar.gz: 73320e683ceb04104c1cc1803a3b753b104ddd7c150314f86c2408abf77558b2
5
5
  SHA512:
6
- metadata.gz: b11a35791403e6999b76ed1a2501d252a3960ccce81fb918119d87453859e15dd1462d2aaa459bba213ec164bf7b0e518d4ed56d93a5823398351722ece66f06
7
- data.tar.gz: e5ae1f9e36514c594aa5b29bced3861a17d7f66951f8c8ba0ae20dfd93ff7c00e5f45b0faff6ed86fcb8d6d5324788072078f866986ce2dc1405e74f63c457cd
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
@@ -3,5 +3,5 @@
3
3
  # gem yank tarf_monte_carlo -v 2.3
4
4
 
5
5
  module TarfMonteCarlo
6
- VERSION = "3.65"
6
+ VERSION = "3.66"
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.65'
4
+ version: '3.66'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vivek Routh