tarf_monte_carlo 3.14 → 3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/tarf_monte_carlo/tarf_monte_carlo.c +73 -4
- 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: 0f33686b3c3246f31356eb1f1cc2161bb1a23a87f305b4a34e370d6c59584180
|
4
|
+
data.tar.gz: 3576f3fdb01ab53522ee92926d7536994551cc97503a9497c894b904c06582aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
190
|
-
|
191
|
-
|
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
|
-
|
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 );
|
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
|
+
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-
|
11
|
+
date: 2020-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|