tarf_monte_carlo 3.14 → 3.15

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: d8d2906e29ad90b4dc0ff480eec64fed2a8d7aaca0e5933de6fa1d672185a38b
4
- data.tar.gz: d8afc4b56ea885bcd67299273ab887b2c97b6e73e6d218729a9e39b54433a240
3
+ metadata.gz: 0f33686b3c3246f31356eb1f1cc2161bb1a23a87f305b4a34e370d6c59584180
4
+ data.tar.gz: 3576f3fdb01ab53522ee92926d7536994551cc97503a9497c894b904c06582aa
5
5
  SHA512:
6
- metadata.gz: ae61b13786e7deb50903881364d793c96db0d453f34f54dd6dd4040a4eb3f86cfaeb6217be6433cbc8f9827c7ba12caabcfc2953edf3a18088a17eceda03fafc
7
- data.tar.gz: 546c462c9ccb5038e9ebb385aec5ccc1f66745d011d72f55c68afa9ec0a83847b0d8beea21bc531610453bd473e82e3a6792c0dc9138125247c32afd2228539d
6
+ metadata.gz: 27375bd106d3365323189a6d00ab4398b2d6d94d32fa82ed6ea69dc4d1f050a78d333ce4a694f8fd0a722f5c380b4e76ff946269b6b8cd5f29a02243120cf2d9
7
+ data.tar.gz: 5465e552c843af156e62bccbd1dbe34779c1f9e06f6596b2f142a817c4465299d635a8a1e8e4be0576e64ceae3f4017613209984aed02a2c0e4a2071425b9356
@@ -136,6 +136,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
136
136
  }
137
137
  } else if ( KType == DUAL_STRIKE_POINTS ) {
138
138
  for (leg = 0; leg < NL; ++leg) {
139
+ Ps_array[leg] = NUM2DBL( rb_ary_entry(Ps, leg) );
139
140
  LSts_array[leg] = NUM2DBL( rb_ary_entry(LSts, leg) );
140
141
  USts_array[leg] = NUM2DBL( rb_ary_entry(USts, leg) );
141
142
  }
@@ -186,11 +187,63 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
186
187
  Spot = Spot * exp( drift + vSqrdt * eps );
187
188
  Spot_dash = Spot_dash * exp( drift + vSqrdt * eps_dash );
188
189
 
189
- if ( BS == BUY ) {
190
- // profit if spot is higher than market price
191
- profit_loss = ( Spot - ( *( Xs_array + leg ) ) );
190
+ // Payoff of Dual strike points is independent of direction
191
+ if ( KType == DUAL_STRIKE_POINTS ) {
192
+ if ( Spot < *( LSts_array + leg ) ) {
193
+ profit_loss = Spot - (*( LSts_array + leg ));
194
+ } else if(Spot > *( USts_array + leg )){
195
+ profit_loss = (*( USts_array + leg ) - Spot);
196
+ } else if(Spot >= *( LSts_array + leg ) && (Spot < *(Ps_array + leg))) {
197
+ profit_loss = (*( LSts_array + leg )) - Spot;
198
+ } else {
199
+ profit_loss = Spot - (*( USts_array + leg ))
200
+ }
201
+ // dash
202
+ if ( Spot_dash < *( LSts_array + leg ) ) {
203
+ profit_loss_dash = Spot_dash - (*( LSts_array + leg ));
204
+ } else if(Spot_dash > *( USts_array + leg )){
205
+ profit_loss_dash = (*( USts_array + leg ) - Spot_dash);
206
+ } else if(Spot_dash >= *( LSts_array + leg ) && (Spot_dash < *(Ps_array + leg))) {
207
+ profit_loss_dash = (*( LSts_array + leg )) - Spot_dash;
208
+ } else {
209
+ profit_loss_dash = Spot_dash - (*( USts_array + leg ))
210
+ }
211
+ }
212
+ else if ( BS == BUY ) {
213
+ if ( KType == PIVOT_POINTS ) {
214
+ if ( *( Xs_array + leg ) > Spot && Spot > *( Ps_array + leg ) ) {
215
+ profit_loss = 0.0;
216
+ } else {
217
+ profit_loss = Spot - (*( Xs_array + leg ));
218
+ }
219
+ // dash
220
+ if ( *( Xs_array + leg ) > Spot_dash && Spot_dash > *( Ps_array + leg ) ) {
221
+ profit_loss_dash = 0.0;
222
+ } else {
223
+ profit_loss_dash = Spot_dash - (*( Xs_array + leg ));
224
+ }
225
+ } else if ( KType == COLLAR_POINTS ) {
226
+ if ( *( Xs_array + leg ) > Spot && Spot > *( CFs_array + leg ) ) {
227
+ profit_loss = 0.0;
228
+ } else if(Spot <= *( CFs_array + leg )){
229
+ profit_loss = Spot - (*( CFs_array + leg ));
230
+ } else {
231
+ profit_loss = Spot - (*( Xs_array + leg ));
232
+ }
233
+ // dash
234
+ if ( *( Xs_array + leg ) > Spot_dash && Spot_dash > *( CFs_array + leg ) ) {
235
+ profit_loss_dash = 0.0;
236
+ } else if(Spot_dash <= *( CFs_array + leg )){
237
+ profit_loss_dash = Spot_dash - (*( CFs_array + leg ));
238
+ } else {
239
+ profit_loss_dash = Spot_dash - (*( Xs_array + leg ));
240
+ }
241
+ } else {
192
242
  // profit if spot is higher than market price
193
- profit_loss_dash = ( Spot_dash - ( *( Xs_array + leg ) ) );
243
+ profit_loss = ( Spot - ( *( Xs_array + leg ) ) );
244
+ // profit if spot is higher than market price
245
+ profit_loss_dash = ( Spot_dash - ( *( Xs_array + leg ) ) );
246
+ }
194
247
  } else if ( BS == SELL ) {
195
248
  if ( KType == PIVOT_POINTS ) {
196
249
  if ( *( Xs_array + leg ) < Spot && Spot < *( Ps_array + leg ) ) {
@@ -204,6 +257,22 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
204
257
  } else {
205
258
  profit_loss_dash = ( ( *( Xs_array + leg ) ) - Spot_dash );
206
259
  }
260
+ } else if ( KType == COLLAR_POINTS ) {
261
+ if ( *( Xs_array + leg ) < Spot && Spot < *( CFs_array + leg ) ) {
262
+ profit_loss = 0.0;
263
+ } else if(Spot >= *( CFs_array + leg )){
264
+ profit_loss = ( ( *( CFs_array + leg ) ) - Spot );
265
+ } else {
266
+ profit_loss = ( ( *( Xs_array + leg ) ) - Spot );
267
+ }
268
+ // dash
269
+ if ( *( Xs_array + leg ) < Spot_dash && Spot_dash < *( CFs_array + leg ) ) {
270
+ profit_loss_dash = 0.0;
271
+ } else if(Spot_dash >= *( CFs_array + leg )){
272
+ profit_loss_dash = ( ( *( CFs_array + leg ) ) - Spot_dash );
273
+ } else {
274
+ profit_loss_dash = ( ( *( Xs_array + leg ) ) - Spot_dash );
275
+ }
207
276
  } else {
208
277
  // profit if spot is lower than market price
209
278
  profit_loss = ( ( *( Xs_array + leg ) ) - Spot );
@@ -1,7 +1,7 @@
1
1
  # gem build tarf_monte_carlo.gemspec
2
- # gem push -v tarf_monte_carlo-2.3.gem
2
+ # gem push -v tarf_monte_carlo-3.15.gem
3
3
  # gem yank tarf_monte_carlo -v 2.3
4
4
 
5
5
  module TarfMonteCarlo
6
- VERSION = "3.14"
6
+ VERSION = "3.15"
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.14'
4
+ version: '3.15'
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-09-15 00:00:00.000000000 Z
11
+ date: 2020-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler