tarf_monte_carlo 3.32 → 3.33

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: 2fd5c07e07e1a0fa016c6f8137c1e2b964f031b7210dca898e4d1006c0781ff4
4
- data.tar.gz: 95210edd7247efc5785fec37c5c13cbe64f86a7509570382f19234174a021e4c
3
+ metadata.gz: f01c36b2c17eecf4dc3dae2cabe4e7eaecc613f70813de0f80bcfee81abd8005
4
+ data.tar.gz: e914b80b2b9c54f40e117aa65ada3caac54bfcc603114292d712b1d7eeb20e68
5
5
  SHA512:
6
- metadata.gz: b9da6d59b8810e6ff75ca95a02c66f59081dfc368bca41de0b809a6c14468b5c1935e07bcb3ba8108766b423177b43d454788fd62c44566747c2f2122a412626
7
- data.tar.gz: a954cdf5255f86459bae5c6c171b9232dfce4ec4fa13e1f1ef8d5ebfe18beac0defbcbb3ba6d33fbe05af28c889b28031139b60d5e2cac1fd4a468099c387d77
6
+ metadata.gz: 2d81d72be8b60152e95b2144961cb4529aebe67f07a9eda582897c0befb1ba595c96af7e4b3a856273de752d805650b8497eec0396469575c8bd04a7643dba97
7
+ data.tar.gz: b1000f8b7e734018cf5db0cdc60c467cd8792c43e4adec6da70950b6f3fd3de83c47a1a2fd7f8a39fb94b25edce659374bf78438f6690f8e5d6b11d82583f187
@@ -193,6 +193,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
193
193
  // first create a 1-D array of pointers, and then, for each array entry, create another 1-D array.
194
194
  //
195
195
  double **metrics;
196
+ double data[SCount];
196
197
  metrics = ( double** ) malloc( DATAPOINTS * sizeof(double*) );
197
198
  for( metric = 0; metric < DATAPOINTS; metric++ ) {
198
199
  metrics[metric] = ( double* ) malloc( NL * sizeof(double) );
@@ -205,6 +206,9 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
205
206
  // run simulations loop
206
207
  for( sim_count = 0; sim_count < SCount; sim_count += 2 ) {
207
208
  // initial spot rate for each iteration would be current spot rate
209
+ data[sim_count] = 0;
210
+ data[sim_count + 1] = 0;
211
+
208
212
  double Spot = S, Spot_dash = S;
209
213
  double sim[NL], sim_pos[NL], sim_neg[NL], sim_dash[NL], sim_dash_pos[NL], sim_dash_neg[NL];
210
214
 
@@ -391,6 +395,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
391
395
  if(KType == FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE){
392
396
  if(knockedLeg >= 0){
393
397
  double equivalent_notional = get_equivalent_notional(conversion_sign, ( *( Ns_array + knockedLeg ) ), sim[NL-1]);
398
+ data[sim_count] = equivalent_notional;
394
399
  sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
395
400
  }
396
401
  else{
@@ -398,6 +403,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
398
403
  }
399
404
  if(knockedLeg_dash >= 0 ){
400
405
  double equivalent_notional = get_equivalent_notional(conversion_sign, ( *( Ns_array + knockedLeg_dash ) ), sim_dash[NL-1]);
406
+ data[sim_count + 1] = equivalent_notional;
401
407
  sim_dash_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg_dash) ) ), sim_dash[NL-1], cp_sign, dir_sign, equivalent_notional);
402
408
  }
403
409
  else{
@@ -584,14 +590,14 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
584
590
  //
585
591
  // rb_p(rb_str_new2("Converting metrics"));
586
592
  VALUE final_metrics = rb_ary_new();
587
- for(metric = 0; metric < DATAPOINTS; metric++) {
588
- VALUE leg_metrics = rb_ary_new();
593
+ for(metric = 0; metric < SCount; metric++) {
594
+ // VALUE leg_metrics = rb_ary_new();
589
595
 
590
- for(leg = 0; leg < NL; leg++) {
591
- rb_ary_push( leg_metrics, DBL2NUM( metrics[metric][leg] ) );
592
- }
596
+ // for(leg = 0; leg < NL; leg++) {
597
+ // rb_ary_push( leg_metrics, DBL2NUM( metrics[metric][leg] ) );
598
+ // }
593
599
 
594
- rb_ary_push(final_metrics, leg_metrics);
600
+ rb_ary_push(final_metrics, data[metric]);
595
601
  }
596
602
 
597
603
  // rb_p(rb_str_new2("Generating output hash"));
@@ -3,5 +3,5 @@
3
3
  # gem yank tarf_monte_carlo -v 2.3
4
4
 
5
5
  module TarfMonteCarlo
6
- VERSION = "3.32"
6
+ VERSION = "3.33"
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tarf_monte_carlo
3
3
  version: !ruby/object:Gem::Version
4
- version: '3.32'
4
+ version: '3.33'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vivek Routh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-03 00:00:00.000000000 Z
11
+ date: 2020-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler