tarf_monte_carlo 3.4 → 3.5

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: f90742330d3f80592bdce28e973cddc0e5f3e4f33a3eaa95c2e779a4d0d7e0f8
4
- data.tar.gz: 9f9fc72f4678623c133b6920fd93f02a0712dbf7e59a889356c30766733c5f1f
3
+ metadata.gz: 67b1ad29c02a6eaa79c27b2bcd092d8d58736de856228479553c01275c74aa23
4
+ data.tar.gz: a0f8a59cc28cec075cdaf3181aa41df49068efa7ef53613fb840d7582f91194d
5
5
  SHA512:
6
- metadata.gz: 10e15c3d7b598cf89ea2c2ae7f58df77415b3563697f82a87c18d7544783e8974cc35e416d254ba78eae79d9265572de7e06c56ea39c8f89bcc131e6999d3b82
7
- data.tar.gz: ecac211c54170175bfd6b469719dfc65349f3506854d7c5275e48b9087b44e8452a291ac3727d8babf094a16c1a9453233fe57f7cb6ae7e018e2526c07f2f18b
6
+ metadata.gz: 71691b20d4de8c2c218280998dbd67a2c89d829001b46181186560ed15f8e644b1cc6e9c83b737c4f59e77adfe22e65bc34f2184d9e8d9f1f4d59efff8a2193e
7
+ data.tar.gz: c8b637dfab5f1153e02bd61ff4e48742cd15507fd3dba45af07bad6a63224ce962ed8afbc88011d241cb82a919f94901fd76fbaa6a8e6f192beb3518c2fa8888
@@ -77,13 +77,14 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
77
77
  int leg, sim_count, metric, point_pos = 0;
78
78
  double pvs_pos_sum = 0.0, pvs_neg_sum = 0.0;
79
79
 
80
- int SCount = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("scount")) ) * 2;
81
- int MCType = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("mc_type")) );
82
- int NL = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("legs_count")) );
83
- int BS = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("buy_sell")) );
84
- double K = NUM2DBL( rb_hash_aref(MCInputs, rb_str_new2("knockout")) );
85
- int KType = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("knockout_type")) );
86
- double S = NUM2DBL( rb_hash_aref(MCInputs, rb_str_new2("spot_rate")) );
80
+ int SCount = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("scount")) ) * 2;
81
+ int MCType = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("mc_type")) );
82
+ int NL = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("legs_count")) );
83
+ int BS = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("buy_sell")) );
84
+ double K = NUM2DBL( rb_hash_aref(MCInputs, rb_str_new2("knockout")) );
85
+ int KType = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("knockout_type")) );
86
+ double S = NUM2DBL( rb_hash_aref(MCInputs, rb_str_new2("spot_rate")) );
87
+ int Ko_compare_mult = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("multiplier")) );
87
88
 
88
89
  // assign leg specific attributes
89
90
  double *pvs_pos = ( double* ) malloc( SCount * sizeof(double) );
@@ -201,13 +202,14 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
201
202
  if( sim[leg] >= 0.0 ) {
202
203
  // knock out condition
203
204
  double temp_payoff = sim[leg] * ( *( Ns_array + leg ) );
205
+ double temp_payoff_ko_ccy = temp_payoff * pow( *( Xs_array + leg ), Ko_compare_mult );
204
206
 
205
- if( temp_payoff > ko_so_far ) {
206
- sim_pos[leg] = ko_so_far;
207
+ if( temp_payoff_ko_ccy > ko_so_far ) {
208
+ sim_pos[leg] = ko_so_far * pow( *( Xs_array + leg ), Ko_compare_mult );
207
209
  ko_so_far = 0.0;
208
- } else if( temp_payoff <= ko_so_far ) {
210
+ } else if( temp_payoff_ko_ccy <= ko_so_far ) {
209
211
  sim_pos[leg] = temp_payoff; // take the payoff in +ve's
210
- ko_so_far -= temp_payoff; // update the knock out
212
+ ko_so_far -= temp_payoff_ko_ccy; // update the knock out
211
213
  }
212
214
  } else {
213
215
  sim_neg[leg] = sim[leg] * ( *( Ls_array + leg ) ) * ( *( Ns_array + leg ) );
@@ -219,13 +221,14 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
219
221
  if( sim_dash[leg] >= 0.0 ) {
220
222
  // knock out condition
221
223
  double temp_payoff_dash = sim_dash[leg] * ( *( Ns_array + leg ) );
224
+ double temp_payoff_ko_ccy = temp_payoff_dash * pow( *( Xs_array + leg ), Ko_compare_mult );
222
225
 
223
- if( temp_payoff_dash > ko_so_far_dash ) {
224
- sim_dash_pos[leg] = ko_so_far_dash;
226
+ if( temp_payoff_ko_ccy > ko_so_far_dash ) {
227
+ sim_dash_pos[leg] = ko_so_far_dash * pow( *( Xs_array + leg ), Ko_compare_mult );
225
228
  ko_so_far_dash = 0.0;
226
- } else if( temp_payoff_dash <= ko_so_far_dash ) {
229
+ } else if( temp_payoff_ko_ccy <= ko_so_far_dash ) {
227
230
  sim_dash_pos[leg] = temp_payoff_dash; // take the payoff in +ve's
228
- ko_so_far_dash -= temp_payoff_dash; // update the knock out
231
+ ko_so_far_dash -= temp_payoff_ko_ccy; // update the knock out
229
232
  }
230
233
  } else {
231
234
  sim_dash_neg[leg] = sim_dash[leg] * ( *( Ls_array + leg ) ) * ( *( Ns_array + leg ) );
@@ -3,5 +3,5 @@
3
3
  # gem yank tarf_monte_carlo -v 2.3
4
4
 
5
5
  module TarfMonteCarlo
6
- VERSION = "3.4"
6
+ VERSION = "3.5"
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.4'
4
+ version: '3.5'
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-04-02 00:00:00.000000000 Z
11
+ date: 2020-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler