tarf_monte_carlo 3.55 → 3.56

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: '06542868a0a9e3446d59880a36f2cc1f2d46c09ecf446c71fcad3ec235b08938'
4
- data.tar.gz: a6922adce8b10804cf0b7c09e837d91736863c7f97de606d1d7bd0ec2c80fe11
3
+ metadata.gz: e049edbb4b08e73240bcefcb197f9f29d9d7491c6dba1d4c97130af405cfbfcf
4
+ data.tar.gz: 92ff0b4ad25f0e871ccbaa6e14f62e5eaabbe1500b9a7724bda47bd09839ee23
5
5
  SHA512:
6
- metadata.gz: 6508270dcdc5a5958d2de0aec826a3141d0a315a72561798903315b9d0b37a49f960a9376e7b302f79a408996098cb13e715096fd123a0f536a15414d06c029a
7
- data.tar.gz: 8a6fb8e1a8554fbda71200c360db164ec4bf07953f672b7bd6982f4c2b7d394c7930dac88931f801a93438568e5976be490d31d25c334beb82d8748ca18d49d9
6
+ metadata.gz: 4d2514c2a003eb7d117519e3c17e4d68bc00dec97ffc4bb2ac3498076b80612c15df901d94faee6087552876ba050899fe0d7beeee7b62bbd192777f4f9888e8
7
+ data.tar.gz: 71fa095eb08d47d02335e63d4800b20c9714215aaa17d3993567ff7d2ae861acbae22499490ae852727018908a36da319eaec08e1a1413ad00a4e8a4774bf20d
@@ -47,6 +47,8 @@
47
47
  #define FX_AMERICAN_BARRIER_WINDOW_KNOCKOUT 16
48
48
  #define FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP 17
49
49
  #define FX_AMERICAN_BARRIER_KIKO_UNTIL_KI 18
50
+ #define FX_AMERICAN_BARRIER_BINARY_IN_DISCRETE 19
51
+ #define FX_AMERICAN_BARRIER_BINARY_OUT_DISCRETE 20
50
52
 
51
53
  #define DATAPOINTS 200 // data for plotting
52
54
  #define BARRIER_DP 4 // data for plotting
@@ -105,7 +107,7 @@ double get_equivalent_rebate(int conversion_sign, double rebate, float rate, int
105
107
  }
106
108
 
107
109
  bool barrier_variations(int KType){
108
- 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);
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);
109
111
  }
110
112
 
111
113
  bool double_barrier_variations(int KType){
@@ -129,6 +131,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
129
131
  int NL = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("legs_count")) );
130
132
  int BS = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("buy_sell")) );
131
133
  double K = NUM2DBL( rb_hash_aref(MCInputs, rb_str_new2("knockout")) );
134
+ int CP = NUM2DBL( rb_hash_aref(MCInputs, rb_str_new2("callput")) );
132
135
  int KType = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("knockout_type")) );
133
136
  double S = NUM2DBL( rb_hash_aref(MCInputs, rb_str_new2("spot_rate")) );
134
137
  int Ko_compare_mult = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("multiplier")) );
@@ -265,7 +268,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
265
268
  Spot = Spot * exp( drift + vSqrdt * eps );
266
269
  Spot_dash = Spot_dash * exp( drift + vSqrdt * eps_dash );
267
270
 
268
- if(KType == FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE || KType == FX_AMERICAN_BARRIER_KNOCKOUT_DISCRETE){
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){
269
272
  profit_loss = Spot;
270
273
  profit_loss_dash = Spot_dash;
271
274
 
@@ -469,6 +472,24 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
469
472
  metrics[1][point_pos+1] = (knockedLeg_dash >= 0) ? ( *( Xs_array + (knockedLeg_dash) ) ) : 0;
470
473
  metrics[3][point_pos+1] = knockedLeg_dash;
471
474
  }
475
+ } else if(KType == FX_AMERICAN_BARRIER_BINARY_IN_DISCRETE){
476
+ if(knockedLeg >= 0){
477
+ int legIndex = (CP == 2) ? knockedLeg : (NL - 1);
478
+ sim_pos[legIndex] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[legIndex], dir_sign);
479
+ }
480
+
481
+ if(knockedLeg_dash >= 0){
482
+ 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);
484
+ }
485
+ } else if(KType == FX_AMERICAN_BARRIER_BINARY_OUT_DISCRETE){
486
+ if(knockedLeg == -1){
487
+ sim_pos[NL - 1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[NL - 1], dir_sign);
488
+ }
489
+
490
+ 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);
492
+ }
472
493
  } else if(KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP){
473
494
  if(knockedLeg2 >= 0){
474
495
  sim_pos[NL-1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[NL-1], dir_sign);
@@ -3,5 +3,5 @@
3
3
  # gem yank tarf_monte_carlo -v 2.3
4
4
 
5
5
  module TarfMonteCarlo
6
- VERSION = "3.55"
6
+ VERSION = "3.56"
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.55'
4
+ version: '3.56'
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-10 00:00:00.000000000 Z
11
+ date: 2020-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler