tarf_monte_carlo 3.34 → 3.35

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: 6ba6dd94cb23ba87cba4dfe1247ff41902d8644efacbbbf1b712ea7d61cc8341
4
- data.tar.gz: da934c46905408ad6bc80694e4b2644535078437fd347c8f986aa9eb71c777b0
3
+ metadata.gz: d99188553bdf78de85d726474f7397e49f3195ef802cedf1800dd8a462b50584
4
+ data.tar.gz: 6e0bb8b0ef4078cfc547def074f4fb6ac04ee6ea7a89db777f6158367552d659
5
5
  SHA512:
6
- metadata.gz: b08cf5f89f3776766cb26d99fdad66b67f2783312ce9489f9ae934ffc359601261b80f9f0f9a2bbb19fd346f8230a3934ce6080ea0b4d755b3bbba34bbc7f1e2
7
- data.tar.gz: b016ab0298d3041ab725d37a3a7aa74be2f8fbe33d510c2f6ef1dd55298d1d1209694234a227b028ed01d50009c112a15ebeaf5a07b2edce43e3e098bc01e23f
6
+ metadata.gz: d302c75c2917d824ff3938fdd996594062dd50fd6a6814f98b7955de32f7cb53f35ae928578b56e705c54579a107b7757e9650c595cf0b515566dcd2361d2eed
7
+ data.tar.gz: e98d7a04f2b99fc9b77cf19f5e0417316505142b67965810c7bcb41d95e12ca8fe7f4e3ff474b3e6f0029251bf4056a7c9cc5a5520c8f4b08fa76dc556ce7b3a
@@ -90,13 +90,11 @@ double european_payoff(double strike, double spot, int cp_sign, int dir_sign, do
90
90
  }
91
91
 
92
92
  double get_equivalent_notional(int conversion_sign, double notional, float rate){
93
- double eq = (conversion_sign == 1) ? (notional / rate) : notional;
94
- return eq;
93
+ return (conversion_sign == 1) ? (notional / rate) : notional;
95
94
  }
96
95
 
97
96
  double get_equivalent_rebate(int conversion_sign, double rebate, float rate){
98
- double eq = (conversion_sign == 1) ? (rebate * rate) : rebate;
99
- return eq;
97
+ return (conversion_sign == 1) ? (rebate * rate) : rebate;
100
98
  }
101
99
 
102
100
  // main method for running monte carlo simulation from sidekiq worker/outside method
@@ -195,7 +193,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
195
193
  // first create a 1-D array of pointers, and then, for each array entry, create another 1-D array.
196
194
  //
197
195
  double **metrics;
198
- double data[SCount];
199
196
  metrics = ( double** ) malloc( DATAPOINTS * sizeof(double*) );
200
197
  for( metric = 0; metric < DATAPOINTS; metric++ ) {
201
198
  metrics[metric] = ( double* ) malloc( NL * sizeof(double) );
@@ -208,9 +205,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
208
205
  // run simulations loop
209
206
  for( sim_count = 0; sim_count < SCount; sim_count += 2 ) {
210
207
  // initial spot rate for each iteration would be current spot rate
211
- data[sim_count] = 0;
212
- data[sim_count + 1] = 0;
213
-
214
208
  double Spot = S, Spot_dash = S;
215
209
  double sim[NL], sim_pos[NL], sim_neg[NL], sim_dash[NL], sim_dash_pos[NL], sim_dash_neg[NL];
216
210
 
@@ -397,7 +391,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
397
391
  if(KType == FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE){
398
392
  if(knockedLeg >= 0){
399
393
  double equivalent_notional = get_equivalent_notional(conversion_sign, ( *( Ns_array + knockedLeg ) ), sim[NL-1]);
400
- data[sim_count] = equivalent_notional;
401
394
  sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
402
395
  }
403
396
  else{
@@ -405,7 +398,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
405
398
  }
406
399
  if(knockedLeg_dash >= 0 ){
407
400
  double equivalent_notional = get_equivalent_notional(conversion_sign, ( *( Ns_array + knockedLeg_dash ) ), sim_dash[NL-1]);
408
- data[sim_count + 1] = equivalent_notional;
409
401
  sim_dash_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg_dash) ) ), sim_dash[NL-1], cp_sign, dir_sign, equivalent_notional);
410
402
  }
411
403
  else{
@@ -592,14 +584,14 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
592
584
  //
593
585
  // rb_p(rb_str_new2("Converting metrics"));
594
586
  VALUE final_metrics = rb_ary_new();
595
- for(metric = 0; metric < SCount; metric++) {
596
- // VALUE leg_metrics = rb_ary_new();
587
+ for(metric = 0; metric < DATAPOINTS; metric++) {
588
+ VALUE leg_metrics = rb_ary_new();
597
589
 
598
- // for(leg = 0; leg < NL; leg++) {
599
- // rb_ary_push( leg_metrics, DBL2NUM( metrics[metric][leg] ) );
600
- // }
590
+ for(leg = 0; leg < NL; leg++) {
591
+ rb_ary_push( leg_metrics, DBL2NUM( metrics[metric][leg] ) );
592
+ }
601
593
 
602
- rb_ary_push(final_metrics, data[metric]);
594
+ rb_ary_push(final_metrics, leg_metrics);
603
595
  }
604
596
 
605
597
  // 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.34"
6
+ VERSION = "3.35"
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.34'
4
+ version: '3.35'
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-05 00:00:00.000000000 Z
11
+ date: 2020-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler