tarf_monte_carlo 3.63 → 3.68
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 +14 -14
- data/lib/tarf_monte_carlo/version.rb +1 -1
- 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: 2fa64303581fdfd8f57be13e97367ccd9c07d64bc7e4eeac8cdaa432d9c7dd71
|
4
|
+
data.tar.gz: 4b6851b1a03af9c991ad0b9d5396c78c81c88ab94c776191fe856d87699c8a1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da44ef843b722f1e2b2ef1b974c0b0d2d725a9a977a8748b72633fd7b55cf5749a8ea284efcb663923384440062038b5784214a58ad6ea280d3cffc19434c58c
|
7
|
+
data.tar.gz: 21318d9c0767bd83ba36ecab123b3189bef337b95c74726beb0e2c99ccc47cd8a356bbde7e14375dc102794dc79ba570b0034fb19c9a2800cc0bc84ac59eff92
|
@@ -283,14 +283,14 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
283
283
|
profit_loss_dash = Spot_dash;
|
284
284
|
|
285
285
|
// Both Until KI & Exp
|
286
|
-
if ( ((*(Barrier_array + leg) - *(Xs_array + leg)) * cp_sign
|
286
|
+
if ( (((*(Barrier_array + leg) - *(Xs_array + leg)) * cp_sign) <= 0) && (((*(Barrier2_array + leg) - *(Xs_array + leg)) * cp_sign) >= 0) ){
|
287
287
|
if ((knockedLeg == -1) && ((*(Barrier_array + leg) - Spot) * cp_sign >= 0)){ knockedLeg = leg; }
|
288
288
|
if ((knockedLeg2 == -1) && ((*(Barrier2_array + leg) - Spot) * cp_sign <= 0)){ knockedLeg2 = leg; }
|
289
289
|
|
290
290
|
if ((knockedLeg_dash == -1) && ((*(Barrier_array + leg) - Spot_dash) * cp_sign >= 0)){ knockedLeg_dash = leg; }
|
291
291
|
if ((knockedLeg2_dash == -1) && ((*(Barrier2_array + leg) - Spot_dash) * cp_sign <= 0)){ knockedLeg2_dash = leg; }
|
292
292
|
}
|
293
|
-
else if( ((*(Barrier_array + leg) - *(Xs_array + leg)) * cp_sign
|
293
|
+
else if( (((*(Barrier_array + leg) - *(Xs_array + leg)) * cp_sign) >= 0) && (((*(Barrier2_array + leg) - *(Xs_array + leg)) * cp_sign) <= 0) ){
|
294
294
|
if ((knockedLeg == -1) && ((*(Barrier_array + leg) - Spot) * cp_sign <= 0)){ knockedLeg = leg; }
|
295
295
|
if ((knockedLeg2 == -1) && ((*(Barrier2_array + leg) - Spot) * cp_sign >= 0)){ knockedLeg2 = leg; }
|
296
296
|
|
@@ -298,20 +298,20 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
298
298
|
if ((knockedLeg2_dash == -1) && ((*(Barrier2_array + leg) - Spot_dash) * cp_sign >= 0)){ knockedLeg2_dash = leg; }
|
299
299
|
}
|
300
300
|
// Only Until Exp
|
301
|
-
else if( (KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP) && ((*(Barrier_array + leg) - *(Xs_array + leg)) * cp_sign
|
301
|
+
else if( (KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP) && (((*(Barrier_array + leg) - *(Xs_array + leg)) * cp_sign) >= 0) && (((*(Barrier2_array + leg) - *(Barrier_array + leg)) * cp_sign) >= 0) ){
|
302
302
|
if ((knockedLeg == -1) && ((*(Barrier_array + leg) - Spot) * cp_sign <= 0)){ knockedLeg = leg; }
|
303
|
-
if ((knockedLeg2 == -1) && ((*(Barrier2_array + leg) - Spot) * cp_sign
|
303
|
+
if ((knockedLeg2 == -1) && ((*(Barrier2_array + leg) - Spot) * cp_sign <= 0)){ knockedLeg2 = leg; }
|
304
304
|
|
305
305
|
if ((knockedLeg_dash == -1) && ((*(Barrier_array + leg) - Spot_dash) * cp_sign <= 0)){ knockedLeg_dash = leg; }
|
306
|
-
if ((knockedLeg2_dash == -1) && ((*(Barrier2_array + leg) - Spot_dash) * cp_sign
|
306
|
+
if ((knockedLeg2_dash == -1) && ((*(Barrier2_array + leg) - Spot_dash) * cp_sign <= 0)){ knockedLeg2_dash = leg; }
|
307
307
|
}
|
308
308
|
|
309
|
-
else if( (KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP) && ((*(Barrier_array + leg) - *(Xs_array + leg)) * cp_sign
|
309
|
+
else if( (KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP) && (((*(Barrier_array + leg) - *(Xs_array + leg)) * cp_sign) <= 0) && (((*(Barrier2_array + leg) - *(Barrier_array + leg)) * cp_sign) <= 0) ){
|
310
310
|
if ((knockedLeg == -1) && ((*(Barrier_array + leg) - Spot) * cp_sign >= 0)){ knockedLeg = leg; }
|
311
|
-
if ((knockedLeg2 == -1) && ((*(Barrier2_array + leg) - Spot) * cp_sign
|
311
|
+
if ((knockedLeg2 == -1) && ((*(Barrier2_array + leg) - Spot) * cp_sign >= 0)){ knockedLeg2 = leg; }
|
312
312
|
|
313
313
|
if ((knockedLeg_dash == -1) && ((*(Barrier_array + leg) - Spot_dash) * cp_sign >= 0)){ knockedLeg_dash = leg; }
|
314
|
-
if ((knockedLeg2_dash == -1) && ((*(Barrier2_array + leg) - Spot_dash) * cp_sign
|
314
|
+
if ((knockedLeg2_dash == -1) && ((*(Barrier2_array + leg) - Spot_dash) * cp_sign >= 0)){ knockedLeg2_dash = leg; }
|
315
315
|
}
|
316
316
|
} else if(KType == FX_AMERICAN_BARRIER_WINDOW_KNOCKIN || KType == FX_AMERICAN_BARRIER_WINDOW_KNOCKOUT){
|
317
317
|
profit_loss = Spot;
|
@@ -555,13 +555,13 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
555
555
|
}
|
556
556
|
} else if(KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP){
|
557
557
|
if(knockedLeg2 >= 0){
|
558
|
-
sim_pos[NL-1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array +
|
558
|
+
sim_pos[NL-1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg2 ) ), sim[NL-1], dir_sign);
|
559
559
|
} else if(knockedLeg >= 0) {
|
560
560
|
double equivalent_notional = *( Ns_array + knockedLeg );
|
561
561
|
sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
|
562
562
|
}
|
563
563
|
if(knockedLeg2_dash >= 0){
|
564
|
-
sim_dash_pos[NL-1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array +
|
564
|
+
sim_dash_pos[NL-1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg2 ) ), sim_dash[NL-1], dir_sign);
|
565
565
|
} else if(knockedLeg_dash >= 0) {
|
566
566
|
double equivalent_notional = *( Ns_array + knockedLeg_dash );
|
567
567
|
sim_dash_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg_dash) ) ), sim_dash[NL-1], cp_sign, dir_sign, equivalent_notional);
|
@@ -581,10 +581,10 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
581
581
|
double equivalent_notional = *( Ns_array + knockedLeg );
|
582
582
|
sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
|
583
583
|
} else {
|
584
|
-
sim_pos[knockedLeg2] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array +
|
584
|
+
sim_pos[knockedLeg2] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg2 ) ), sim[knockedLeg2], dir_sign);
|
585
585
|
}
|
586
586
|
} else if(knockedLeg2 >= 0){
|
587
|
-
sim_pos[knockedLeg2] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array +
|
587
|
+
sim_pos[knockedLeg2] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg2 ) ), sim[knockedLeg2], dir_sign);
|
588
588
|
} else if(knockedLeg >= 0) {
|
589
589
|
double equivalent_notional = *( Ns_array + knockedLeg );
|
590
590
|
sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
|
@@ -595,10 +595,10 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
595
595
|
double equivalent_notional = *( Ns_array + knockedLeg_dash );
|
596
596
|
sim_dash_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg_dash) ) ), sim_dash[NL-1], cp_sign, dir_sign, equivalent_notional);
|
597
597
|
} else {
|
598
|
-
sim_dash_pos[knockedLeg2_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array +
|
598
|
+
sim_dash_pos[knockedLeg2_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg2_dash ) ), sim_dash[knockedLeg2_dash], dir_sign);
|
599
599
|
}
|
600
600
|
} else if(knockedLeg2_dash >= 0){
|
601
|
-
sim_dash_pos[knockedLeg2_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array +
|
601
|
+
sim_dash_pos[knockedLeg2_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg2_dash ) ), sim_dash[knockedLeg2_dash], dir_sign);
|
602
602
|
} else if(knockedLeg_dash >= 0) {
|
603
603
|
double equivalent_notional = *( Ns_array + knockedLeg_dash );
|
604
604
|
sim_dash_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg_dash) ) ), sim_dash[NL-1], cp_sign, dir_sign, equivalent_notional);
|
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.68'
|
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-
|
11
|
+
date: 2020-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|