tarf_monte_carlo 3.20 → 3.25
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 +22 -4
- data/lib/tarf_monte_carlo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b578a4483961831037817279e8d1f3d6fe7e55e4312b51ccac26e757e520996
|
|
4
|
+
data.tar.gz: 7ce9ff317c5f1383499ec18c50be613ec4b9955be99101e9c0aa9b7385c67874
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e9735f0cac81ddcbe4af47ed5f36daeafa57a3bac7c7d88e5d9bee9bc8dd951810054b6bbeb6e34fdc670cdce21ce13360f22665e6856fc307e84bf71401f110
|
|
7
|
+
data.tar.gz: 2580760d17c4f660431a26e3d7afd018da399eb75691f4e0ff08017b872fe371849b2c76b280de675fddb3df2dcd8b45401281bbedf342997ad1a822443eaf3b
|
|
@@ -114,6 +114,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
114
114
|
double *CFs_array = ( double* ) malloc( NL * sizeof(double) );
|
|
115
115
|
double *LSts_array = ( double* ) malloc( NL * sizeof(double) );
|
|
116
116
|
double *USts_array = ( double* ) malloc( NL * sizeof(double) );
|
|
117
|
+
double *TempNs_array = ( double* ) malloc( NL * sizeof(double) );
|
|
117
118
|
|
|
118
119
|
VALUE Ls = rb_hash_aref(MCInputs, rb_str_new2("leverage_ratios") );
|
|
119
120
|
VALUE Ts = rb_hash_aref(MCInputs, rb_str_new2("expiration_times") );
|
|
@@ -135,6 +136,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
135
136
|
vs_array[leg] = NUM2DBL( rb_ary_entry(vs, leg) );
|
|
136
137
|
bs_array[leg] = NUM2DBL( rb_ary_entry(bs, leg) );
|
|
137
138
|
DFs_array[leg] = NUM2DBL( rb_ary_entry(DFs, leg) );
|
|
139
|
+
TempNs_array[leg] = *(Ns_array + leg);
|
|
138
140
|
}
|
|
139
141
|
// extra tarf structures
|
|
140
142
|
if ( KType == PIVOT_POINTS || KType == PIVOT_ABSOLUTE || KType == PIVOT_LEGS ) {
|
|
@@ -211,10 +213,10 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
211
213
|
}
|
|
212
214
|
|
|
213
215
|
if (ConvertNotional == 1){
|
|
214
|
-
if(Spot < *( Ps_array + leg )){
|
|
215
|
-
Ns_array[leg] = *(
|
|
216
|
+
if(Spot < *( Ps_array + leg ) || Spot_dash < *( Ps_array + leg )){
|
|
217
|
+
Ns_array[leg] = *(TempNs_array + leg) / *( LSts_array + leg );
|
|
216
218
|
} else {
|
|
217
|
-
Ns_array[leg] = *(
|
|
219
|
+
Ns_array[leg] = *(TempNs_array + leg) / *( USts_array + leg );
|
|
218
220
|
}
|
|
219
221
|
}
|
|
220
222
|
|
|
@@ -246,6 +248,10 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
246
248
|
profit_loss = 0.0;
|
|
247
249
|
} else if(Spot <= *( CFs_array + leg )){
|
|
248
250
|
profit_loss = Spot - (*( CFs_array + leg ));
|
|
251
|
+
|
|
252
|
+
if (ConvertNotional == 1){
|
|
253
|
+
Ns_array[leg] = *(TempNs_array + leg) / *( CFs_array + leg );
|
|
254
|
+
}
|
|
249
255
|
} else {
|
|
250
256
|
profit_loss = Spot - (*( Xs_array + leg ));
|
|
251
257
|
}
|
|
@@ -254,6 +260,10 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
254
260
|
profit_loss_dash = 0.0;
|
|
255
261
|
} else if(Spot_dash <= *( CFs_array + leg )){
|
|
256
262
|
profit_loss_dash = Spot_dash - (*( CFs_array + leg ));
|
|
263
|
+
|
|
264
|
+
if (ConvertNotional == 1){
|
|
265
|
+
Ns_array[leg] = *(TempNs_array + leg) / *( CFs_array + leg );
|
|
266
|
+
}
|
|
257
267
|
} else {
|
|
258
268
|
profit_loss_dash = Spot_dash - (*( Xs_array + leg ));
|
|
259
269
|
}
|
|
@@ -281,6 +291,10 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
281
291
|
profit_loss = 0.0;
|
|
282
292
|
} else if(Spot >= *( CFs_array + leg )){
|
|
283
293
|
profit_loss = ( ( *( CFs_array + leg ) ) - Spot );
|
|
294
|
+
|
|
295
|
+
if (ConvertNotional == 1){
|
|
296
|
+
Ns_array[leg] = *(TempNs_array + leg) / *( CFs_array + leg );
|
|
297
|
+
}
|
|
284
298
|
} else {
|
|
285
299
|
profit_loss = ( ( *( Xs_array + leg ) ) - Spot );
|
|
286
300
|
}
|
|
@@ -289,6 +303,10 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
289
303
|
profit_loss_dash = 0.0;
|
|
290
304
|
} else if(Spot_dash >= *( CFs_array + leg )){
|
|
291
305
|
profit_loss_dash = ( ( *( CFs_array + leg ) ) - Spot_dash );
|
|
306
|
+
|
|
307
|
+
if (ConvertNotional == 1){
|
|
308
|
+
Ns_array[leg] = *(TempNs_array + leg) / *( CFs_array + leg );
|
|
309
|
+
}
|
|
292
310
|
} else {
|
|
293
311
|
profit_loss_dash = ( ( *( Xs_array + leg ) ) - Spot_dash );
|
|
294
312
|
}
|
|
@@ -325,7 +343,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
325
343
|
if( KType == ABSOLUTE || KType == PIVOT_ABSOLUTE || KType == COLLAR_ABSOLUTE || KType == DOUBLE_STRIKE_ABSOLUTE ) {
|
|
326
344
|
for( leg = 0; leg < NL; ++leg ) {
|
|
327
345
|
// simulation normal
|
|
328
|
-
rb_p(*(Ns_array +leg ));
|
|
329
346
|
if( ko_so_far > 0.0 ) {
|
|
330
347
|
if( sim[leg] >= 0.0 ) {
|
|
331
348
|
// knock out condition
|
|
@@ -366,6 +383,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
|
366
383
|
} else if( KType == POINTS || KType == PIVOT_POINTS || KType == COLLAR_POINTS || KType == DOUBLE_STRIKE_POINTS ) {
|
|
367
384
|
for( leg = 0; leg < NL; ++leg ) {
|
|
368
385
|
// simulation normal
|
|
386
|
+
// rb_p(DBL2NUM(*(Ns_array + leg )));
|
|
369
387
|
if ( ko_so_far > 0.0 ) {
|
|
370
388
|
if( sim[leg] >= 0.0 ) {
|
|
371
389
|
// knock out condition
|