tarf_monte_carlo 3.47 → 3.49

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: a69379430c97fbbf86b791e49a7564c7504a21fa73f3ea44ede3ec1d3a876bc6
4
- data.tar.gz: 3fcd6ef1020d223148c3279c80694c007373f933f434ee48258a62938188c130
3
+ metadata.gz: 92ba4ec2f8c25a6704d3e7388a8a3e243ff51693b8ea1966d57b67b42d09514f
4
+ data.tar.gz: f80d07fdca106e815b442561331e1cfce8a7772e5e8b9bfb830cf6b043432fcd
5
5
  SHA512:
6
- metadata.gz: 55528c53ec418a966b6e8e405ba177038e097993ac5a532bb99c4bfbc8d32048eea25ca8893749207c0ccb6e950ff0fdff6a573e99ccd71a5d627e40b3204a87
7
- data.tar.gz: fd79143e72702699469613433aeffcc7fe75fa001c69a6f759582bb72059ba8847862eea11357dc365d73acf06e34a0362d3e09518ac08a865cc0480da13e3ed
6
+ metadata.gz: 944741bc4e48a44ecd97d09e36a316bb2eba4b78a6d2bbd2e645699b5e595008e443f88e78e841844ef6765af80b45a9a47144978e8628048699787a8859ee9b
7
+ data.tar.gz: a03e00f6749dcdc4358370b1d49056032b9d97ff4293208633045dddeb970fea0b9be734037383734a117f13dce003d5fa851e734a6b725cd72f4908a47b6e9f
@@ -43,6 +43,8 @@
43
43
 
44
44
  #define FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE 13
45
45
  #define FX_AMERICAN_BARRIER_KNOCKOUT_DISCRETE 14
46
+ #define FX_AMERICAN_BARRIER_WINDOW_KNOCKIN 15
47
+ #define FX_AMERICAN_BARRIER_WINDOW_KNOCKOUT 16
46
48
 
47
49
  #define DATAPOINTS 200 // data for plotting
48
50
  #define BARRIER_DP 4 // data for plotting
@@ -143,6 +145,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
143
145
  double *USts_array = ( double* ) malloc( NL * sizeof(double) );
144
146
  double *TempNs_array = ( double* ) malloc( NL * sizeof(double) );
145
147
  double *Barrier_array = ( double* ) malloc( NL * sizeof(double) );
148
+ double *Barrier2_array = ( double* ) malloc( NL * sizeof(double) );
146
149
  double *Rebate_array = ( double* ) malloc( NL * sizeof(double) );
147
150
 
148
151
  VALUE Ls = rb_hash_aref(MCInputs, rb_str_new2("leverage_ratios") );
@@ -157,6 +160,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
157
160
  VALUE LSts = rb_hash_aref(MCInputs, rb_str_new2("lower_strikes") );
158
161
  VALUE USts = rb_hash_aref(MCInputs, rb_str_new2("upper_strikes") );
159
162
  VALUE Brs = rb_hash_aref(MCInputs, rb_str_new2("barriers") );
163
+ VALUE Brs2 = rb_hash_aref(MCInputs, rb_str_new2("barriers2") );
160
164
  VALUE Rbts = rb_hash_aref(MCInputs, rb_str_new2("rebates") );
161
165
 
162
166
  for (leg = 0; leg < NL; ++leg) {
@@ -189,6 +193,8 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
189
193
  Barrier_array[leg] = NUM2DBL( rb_ary_entry(Brs, leg) );
190
194
  Rebate_array[leg] = NUM2DBL( rb_ary_entry(Rbts, leg) );
191
195
  }
196
+ } else if(KType == FX_AMERICAN_BARRIER_WINDOW_KNOCKIN || KType == FX_AMERICAN_BARRIER_WINDOW_KNOCKOUT){
197
+ Barrier2_array[leg] = NUM2DBL( rb_ary_entry(Brs2, leg) );
192
198
  }
193
199
 
194
200
  //
@@ -204,7 +210,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
204
210
  }
205
211
  }
206
212
  }
207
- else{
213
+ else{
208
214
  metrics = ( double** ) malloc( DATAPOINTS * sizeof(double*) );
209
215
  for( metric = 0; metric < DATAPOINTS; metric++ ) {
210
216
  metrics[metric] = ( double* ) malloc( NL * sizeof(double) );
@@ -262,6 +268,16 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
262
268
  if(knockedLeg_dash == -1 && knockin_dash >= 0){
263
269
  knockedLeg_dash = leg;
264
270
  }
271
+ } else if(KType == FX_AMERICAN_BARRIER_WINDOW_KNOCKIN || KType == FX_AMERICAN_BARRIER_WINDOW_KNOCKOUT){
272
+ profit_loss = Spot;
273
+ profit_loss_dash = Spot_dash;
274
+
275
+ if(knockedLeg == -1 && (Spot <= *(Barrier_array + leg) || Spot >= *(Barrier2_array + leg))){
276
+ knockedLeg = leg;
277
+ }
278
+ if(knockedLeg_dash == -1 && (Spot_dash <= *(Barrier_array + leg) || Spot_dash >= *(Barrier2_array + leg))){
279
+ knockedLeg_dash = leg;
280
+ }
265
281
  } else if ( KType == DOUBLE_STRIKE_POINTS || KType == DOUBLE_STRIKE_ABSOLUTE || KType == DOUBLE_STRIKE_LEGS ) {
266
282
  if ( Spot < *( LSts_array + leg ) ) {
267
283
  profit_loss = Spot - (*( LSts_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.47"
6
+ VERSION = "3.49"
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.47'
4
+ version: '3.49'
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-06 00:00:00.000000000 Z
11
+ date: 2020-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubygems_version: 3.0.8
143
+ rubygems_version: 3.0.6
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Monte Carlo Simulation.