tarf_monte_carlo 3.56 → 3.57

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: e049edbb4b08e73240bcefcb197f9f29d9d7491c6dba1d4c97130af405cfbfcf
4
- data.tar.gz: 92ff0b4ad25f0e871ccbaa6e14f62e5eaabbe1500b9a7724bda47bd09839ee23
3
+ metadata.gz: 37cf728f754098494cffed6ce0f9f8c3dde4e593702a748cdc8bca2d1c5182cd
4
+ data.tar.gz: 76e9c21b88d3ecb5925c525420fc704fcf8e8cf992b2db3bd9f4367c1d20396c
5
5
  SHA512:
6
- metadata.gz: 4d2514c2a003eb7d117519e3c17e4d68bc00dec97ffc4bb2ac3498076b80612c15df901d94faee6087552876ba050899fe0d7beeee7b62bbd192777f4f9888e8
7
- data.tar.gz: 71fa095eb08d47d02335e63d4800b20c9714215aaa17d3993567ff7d2ae861acbae22499490ae852727018908a36da319eaec08e1a1413ad00a4e8a4774bf20d
6
+ metadata.gz: fb5a2d931a8ea07cf8fa49b2ca4ef2341474fbf59431b2fb16c8188df43018c146fd70dbb0f907ce921657b01aca8c4e35600ded2075e5bd16d2435619565671
7
+ data.tar.gz: 490bacf7090a637d5c3b9f54176c80d5419f13f5b8e4320634977bc1815b3f8430dca1072c347b07b268cdec0fc152959e7d4d2f4d459dc0a3c6164516ffb5b5
@@ -49,6 +49,8 @@
49
49
  #define FX_AMERICAN_BARRIER_KIKO_UNTIL_KI 18
50
50
  #define FX_AMERICAN_BARRIER_BINARY_IN_DISCRETE 19
51
51
  #define FX_AMERICAN_BARRIER_BINARY_OUT_DISCRETE 20
52
+ #define FX_AMERICAN_BARRIER_BINARY_CALLPUT_IN_DISCRETE 21
53
+ #define FX_AMERICAN_BARRIER_BINARY_CALLPUT_OUT_DISCRETE 22
52
54
 
53
55
  #define DATAPOINTS 200 // data for plotting
54
56
  #define BARRIER_DP 4 // data for plotting
@@ -107,7 +109,7 @@ double get_equivalent_rebate(int conversion_sign, double rebate, float rate, int
107
109
  }
108
110
 
109
111
  bool barrier_variations(int KType){
110
- return (KType == FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE || KType == FX_AMERICAN_BARRIER_KNOCKOUT_DISCRETE || KType == FX_AMERICAN_BARRIER_WINDOW_KNOCKIN || KType == FX_AMERICAN_BARRIER_WINDOW_KNOCKOUT || KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP || KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_KI || KType == FX_AMERICAN_BARRIER_BINARY_IN_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_OUT_DISCRETE);
112
+ return (KType == FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE || KType == FX_AMERICAN_BARRIER_KNOCKOUT_DISCRETE || KType == FX_AMERICAN_BARRIER_WINDOW_KNOCKIN || KType == FX_AMERICAN_BARRIER_WINDOW_KNOCKOUT || KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP || KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_KI || KType == FX_AMERICAN_BARRIER_BINARY_IN_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_OUT_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_CALLPUT_IN_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_CALLPUT_OUT_DISCRETE);
111
113
  }
112
114
 
113
115
  bool double_barrier_variations(int KType){
@@ -268,7 +270,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
268
270
  Spot = Spot * exp( drift + vSqrdt * eps );
269
271
  Spot_dash = Spot_dash * exp( drift + vSqrdt * eps_dash );
270
272
 
271
- if(KType == FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE || KType == FX_AMERICAN_BARRIER_KNOCKOUT_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_IN_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_OUT_DISCRETE){
273
+ if(KType == FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE || KType == FX_AMERICAN_BARRIER_KNOCKOUT_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_IN_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_OUT_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_CALLPUT_IN_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_CALLPUT_OUT_DISCRETE){
272
274
  profit_loss = Spot;
273
275
  profit_loss_dash = Spot_dash;
274
276
 
@@ -472,23 +474,59 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
472
474
  metrics[1][point_pos+1] = (knockedLeg_dash >= 0) ? ( *( Xs_array + (knockedLeg_dash) ) ) : 0;
473
475
  metrics[3][point_pos+1] = knockedLeg_dash;
474
476
  }
475
- } else if(KType == FX_AMERICAN_BARRIER_BINARY_IN_DISCRETE){
477
+ } else if(KType == FX_AMERICAN_BARRIER_BINARY_IN_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_CALLPUT_IN_DISCRETE){
476
478
  if(knockedLeg >= 0){
477
479
  int legIndex = (CP == 2) ? knockedLeg : (NL - 1);
478
- sim_pos[legIndex] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[legIndex], dir_sign);
480
+ int itm = true;
481
+ if (CP <= 1){
482
+ double tempPayOff = european_payoff(( *( Xs_array + legIndex ) ), sim[NL-1], cp_sign, dir_sign, 1);
483
+ if(tempPayOff == 0){
484
+ itm = false;
485
+ }
486
+ }
487
+ if (itm){
488
+ sim_pos[legIndex] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[legIndex], dir_sign);
489
+ }
479
490
  }
480
491
 
481
492
  if(knockedLeg_dash >= 0){
482
493
  int legIndex_dash = (CP == 2) ? knockedLeg_dash : (NL - 1);
483
- sim_dash_pos[legIndex_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim_dash[legIndex_dash], dir_sign);
494
+ int itm = true;
495
+ if (CP <= 1){
496
+ double tempPayOff = european_payoff(( *( Xs_array + legIndex_dash ) ), sim_dash[NL-1], cp_sign, dir_sign, 1);
497
+ if(tempPayOff == 0){
498
+ itm = false;
499
+ }
500
+ }
501
+ if (itm){
502
+ sim_dash_pos[legIndex_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim_dash[legIndex_dash], dir_sign);
503
+ }
484
504
  }
485
- } else if(KType == FX_AMERICAN_BARRIER_BINARY_OUT_DISCRETE){
505
+ } else if(KType == FX_AMERICAN_BARRIER_BINARY_OUT_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_CALLPUT_OUT_DISCRETE){
486
506
  if(knockedLeg == -1){
487
- sim_pos[NL - 1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[NL - 1], dir_sign);
507
+ int itm = true;
508
+ if (CP <= 1){
509
+ double tempPayOff = european_payoff(( *( Xs_array + 0 ) ), sim[NL-1], cp_sign, dir_sign, 1);
510
+ if(tempPayOff == 0){
511
+ itm = false;
512
+ }
513
+ }
514
+ if (itm){
515
+ sim_pos[NL - 1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[NL - 1], dir_sign);
516
+ }
488
517
  }
489
518
 
490
519
  if(knockedLeg_dash == -1){
491
- sim_dash_pos[NL - 1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim_dash[NL - 1], dir_sign);
520
+ int itm = true;
521
+ if (CP <= 1){
522
+ double tempPayOff = european_payoff(( *( Xs_array + 0 ) ), sim_dash[NL-1], cp_sign, dir_sign, 1);
523
+ if(tempPayOff == 0){
524
+ itm = false;
525
+ }
526
+ }
527
+ if (itm){
528
+ sim_dash_pos[NL - 1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim_dash[NL - 1], dir_sign);
529
+ }
492
530
  }
493
531
  } else if(KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP){
494
532
  if(knockedLeg2 >= 0){
@@ -3,5 +3,5 @@
3
3
  # gem yank tarf_monte_carlo -v 2.3
4
4
 
5
5
  module TarfMonteCarlo
6
- VERSION = "3.56"
6
+ VERSION = "3.57"
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.56'
4
+ version: '3.57'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vivek Routh