tarf_monte_carlo 3.15.2 → 3.15.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/tarf_monte_carlo/tarf_monte_carlo.c +22 -12
- data/lib/tarf_monte_carlo/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f59add36257db0337d6c1a72238af5d328892cb59959117797130e5b90b0f31
|
4
|
+
data.tar.gz: d78b75d035a82c487bdc15797e3589ff4c15f33f9180eea8f8d211b847c22fc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 675daf6c71ee357cc6eca37080acc93fa5211dc9737104c92ef0adc1c9d8bd8b61275d681fa64b1fd3da8832867b1f8e879eea8198d4b29dd06d1188eb645ba7
|
7
|
+
data.tar.gz: bbc2a4bfe53e589db3225c86bec1449adee93e2f9022f6b62775eca692b6a62a832988e627be1a0edf35478aa4a876a260735d1d0288eb3fac03023eaf3ae2c7
|
@@ -28,9 +28,19 @@
|
|
28
28
|
#define ABSOLUTE 1 // knockout by absolute
|
29
29
|
#define POINTS 2 // knockout by points
|
30
30
|
#define LEGS 3 // knockout by legs
|
31
|
+
|
31
32
|
#define PIVOT_POINTS 4
|
32
33
|
#define COLLAR_POINTS 5
|
33
|
-
#define
|
34
|
+
#define DOUBLE_STRIKE_POINTS 6
|
35
|
+
|
36
|
+
#define PIVOT_ABSOLUTE 7
|
37
|
+
#define COLLAR_ABSOLUTE 8
|
38
|
+
#define DOUBLE_STRIKE_ABSOLUTE 9
|
39
|
+
|
40
|
+
#define PIVOT_LEGS 10
|
41
|
+
#define COLLAR_LEGS 11
|
42
|
+
#define DOUBLE_STRIKE_LEGS 12
|
43
|
+
|
34
44
|
#define DATAPOINTS 200 // data for plotting
|
35
45
|
#define INTERVAL 50
|
36
46
|
#define SIM_LIMIT 196 // 196 + 4 = 200 simulations nedded
|
@@ -126,15 +136,15 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
126
136
|
DFs_array[leg] = NUM2DBL( rb_ary_entry(DFs, leg) );
|
127
137
|
}
|
128
138
|
// extra tarf structures
|
129
|
-
if ( KType == PIVOT_POINTS ) {
|
139
|
+
if ( KType == PIVOT_POINTS || KType == PIVOT_ABSOLUTE || KType == PIVOT_LEGS ) {
|
130
140
|
for (leg = 0; leg < NL; ++leg) {
|
131
141
|
Ps_array[leg] = NUM2DBL( rb_ary_entry(Ps, leg) );
|
132
142
|
}
|
133
|
-
} else if ( KType == COLLAR_POINTS ) {
|
143
|
+
} else if ( KType == COLLAR_POINTS || KType == COLLAR_ABSOLUTE || KType == COLLAR_LEGS ) {
|
134
144
|
for (leg = 0; leg < NL; ++leg) {
|
135
145
|
CFs_array[leg] = NUM2DBL( rb_ary_entry(CFs, leg) );
|
136
146
|
}
|
137
|
-
} else if ( KType ==
|
147
|
+
} else if ( KType == DOUBLE_STRIKE_POINTS || KType == DOUBLE_STRIKE_ABSOLUTE || KType == DOUBLE_STRIKE_LEGS) {
|
138
148
|
for (leg = 0; leg < NL; ++leg) {
|
139
149
|
Ps_array[leg] = NUM2DBL( rb_ary_entry(Ps, leg) );
|
140
150
|
LSts_array[leg] = NUM2DBL( rb_ary_entry(LSts, leg) );
|
@@ -188,7 +198,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
188
198
|
Spot_dash = Spot_dash * exp( drift + vSqrdt * eps_dash );
|
189
199
|
|
190
200
|
// Payoff of Dual strike points is independent of direction
|
191
|
-
if ( KType ==
|
201
|
+
if ( KType == DOUBLE_STRIKE_POINTS || KType == DOUBLE_STRIKE_ABSOLUTE || KType == DOUBLE_STRIKE_LEGS ) {
|
192
202
|
if ( Spot < *( LSts_array + leg ) ) {
|
193
203
|
profit_loss = Spot - (*( LSts_array + leg ));
|
194
204
|
} else if(Spot > *( USts_array + leg )){
|
@@ -209,7 +219,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
209
219
|
profit_loss_dash = (*( USts_array + leg )) - Spot_dash;
|
210
220
|
}
|
211
221
|
} else if ( BS == BUY ) {
|
212
|
-
if ( KType == PIVOT_POINTS ) {
|
222
|
+
if ( KType == PIVOT_POINTS || KType == PIVOT_ABSOLUTE || KType == PIVOT_LEGS ) {
|
213
223
|
if ( *( Xs_array + leg ) > Spot && Spot > *( Ps_array + leg ) ) {
|
214
224
|
profit_loss = 0.0;
|
215
225
|
} else {
|
@@ -221,7 +231,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
221
231
|
} else {
|
222
232
|
profit_loss_dash = Spot_dash - (*( Xs_array + leg ));
|
223
233
|
}
|
224
|
-
} else if ( KType == COLLAR_POINTS ) {
|
234
|
+
} else if ( KType == COLLAR_POINTS || KType == COLLAR_ABSOLUTE || KType == COLLAR_LEGS ) {
|
225
235
|
if ( *( Xs_array + leg ) > Spot && Spot > *( CFs_array + leg ) ) {
|
226
236
|
profit_loss = 0.0;
|
227
237
|
} else if(Spot <= *( CFs_array + leg )){
|
@@ -244,7 +254,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
244
254
|
profit_loss_dash = ( Spot_dash - ( *( Xs_array + leg ) ) );
|
245
255
|
}
|
246
256
|
} else if ( BS == SELL ) {
|
247
|
-
if ( KType == PIVOT_POINTS ) {
|
257
|
+
if ( KType == PIVOT_POINTS || KType == PIVOT_ABSOLUTE || KType == PIVOT_LEGS ) {
|
248
258
|
if ( *( Xs_array + leg ) < Spot && Spot < *( Ps_array + leg ) ) {
|
249
259
|
profit_loss = 0.0;
|
250
260
|
} else {
|
@@ -256,7 +266,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
256
266
|
} else {
|
257
267
|
profit_loss_dash = ( ( *( Xs_array + leg ) ) - Spot_dash );
|
258
268
|
}
|
259
|
-
} else if ( KType == COLLAR_POINTS ) {
|
269
|
+
} else if ( KType == COLLAR_POINTS || KType == COLLAR_ABSOLUTE || KType == COLLAR_LEGS ) {
|
260
270
|
if ( *( Xs_array + leg ) < Spot && Spot < *( CFs_array + leg ) ) {
|
261
271
|
profit_loss = 0.0;
|
262
272
|
} else if(Spot >= *( CFs_array + leg )){
|
@@ -302,7 +312,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
302
312
|
// legs loop end
|
303
313
|
// start from the Knock value
|
304
314
|
double ko_so_far = K, ko_so_far_dash = K;
|
305
|
-
if( KType == ABSOLUTE ) {
|
315
|
+
if( KType == ABSOLUTE || KType == PIVOT_ABSOLUTE || KType == COLLAR_ABSOLUTE || KType == DOUBLE_STRIKE_ABSOLUTE ) {
|
306
316
|
for( leg = 0; leg < NL; ++leg ) {
|
307
317
|
// simulation normal
|
308
318
|
if( ko_so_far > 0.0 ) {
|
@@ -342,7 +352,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
342
352
|
}
|
343
353
|
}
|
344
354
|
}
|
345
|
-
} else if( KType == POINTS || KType == PIVOT_POINTS || KType == COLLAR_POINTS || KType ==
|
355
|
+
} else if( KType == POINTS || KType == PIVOT_POINTS || KType == COLLAR_POINTS || KType == DOUBLE_STRIKE_POINTS ) {
|
346
356
|
for( leg = 0; leg < NL; ++leg ) {
|
347
357
|
// simulation normal
|
348
358
|
if ( ko_so_far > 0.0 ) {
|
@@ -376,7 +386,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
376
386
|
}
|
377
387
|
}
|
378
388
|
}
|
379
|
-
} else if( KType == LEGS ) {
|
389
|
+
} else if( KType == LEGS || KType == PIVOT_LEGS || KType == COLLAR_LEGS || KType == DOUBLE_STRIKE_LEGS ) {
|
380
390
|
for( leg = 0; leg < NL; ++leg ) {
|
381
391
|
// simulation normal
|
382
392
|
if ( ko_so_far > 0.0 ) {
|
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.15.
|
4
|
+
version: 3.15.3
|
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-
|
11
|
+
date: 2020-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|