tarf_monte_carlo 3.67 → 4.01
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 +9 -9
- 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: dcb28d2f1c3f662185c981ea526e2281824674db223f1a985fb21b8d561aaac2
|
4
|
+
data.tar.gz: 9dbb8ab79cac6ddd06c9ae051c9be9bf0d3165c40e4264d27dbb370ae3f7d348
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: babd0341ce343a1d262bbfcfd31e066d6e0f50639e2303f77faa98732a600398fea02f80417754c460b974fc919d81f5f21f1f61e66b230c691d601a4ab723c8
|
7
|
+
data.tar.gz: 022d7afcd71ce6f2fcd9db1faa973a2031ac002b21d4220d9ac532a4e7def7e480adab1de19cd9373e6e0c61fbc45947470947a75377fa3fc4e73f4ed5aac51d
|
@@ -43,8 +43,8 @@
|
|
43
43
|
|
44
44
|
#define FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE 13
|
45
45
|
#define FX_AMERICAN_BARRIER_KNOCKOUT_DISCRETE 14
|
46
|
-
#define
|
47
|
-
#define
|
46
|
+
#define FX_AMERICAN_BARRIER_DOUBLE_KNOCKIN 15
|
47
|
+
#define FX_AMERICAN_BARRIER_DOUBLE_KNOCKOUT 16
|
48
48
|
#define FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP 17
|
49
49
|
#define FX_AMERICAN_BARRIER_KIKO_UNTIL_KI 18
|
50
50
|
#define FX_AMERICAN_BARRIER_BINARY_IN_DISCRETE 19
|
@@ -104,11 +104,11 @@ double get_equivalent_rebate(int conversion_sign, double rebate, float rate, int
|
|
104
104
|
}
|
105
105
|
|
106
106
|
bool barrier_variations(int KType){
|
107
|
-
return (KType == FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE || KType == FX_AMERICAN_BARRIER_KNOCKOUT_DISCRETE || KType ==
|
107
|
+
return (KType == FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE || KType == FX_AMERICAN_BARRIER_KNOCKOUT_DISCRETE || KType == FX_AMERICAN_BARRIER_DOUBLE_KNOCKIN || KType == FX_AMERICAN_BARRIER_DOUBLE_KNOCKOUT || KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP || KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_KI || KType == FX_AMERICAN_BARRIER_BINARY_IN_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_OUT_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_CALLPUT_IN_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_CALLPUT_OUT_DISCRETE);
|
108
108
|
}
|
109
109
|
|
110
110
|
bool double_barrier_variations(int KType){
|
111
|
-
return (KType ==
|
111
|
+
return (KType == FX_AMERICAN_BARRIER_DOUBLE_KNOCKIN || KType == FX_AMERICAN_BARRIER_DOUBLE_KNOCKOUT || KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP || KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_KI);
|
112
112
|
}
|
113
113
|
// main method for running monte carlo simulation from sidekiq worker/outside method
|
114
114
|
VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
@@ -313,7 +313,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
313
313
|
if ((knockedLeg_dash == -1) && ((*(Barrier_array + leg) - Spot_dash) * cp_sign >= 0)){ knockedLeg_dash = leg; }
|
314
314
|
if ((knockedLeg2_dash == -1) && ((*(Barrier2_array + leg) - Spot_dash) * cp_sign >= 0)){ knockedLeg2_dash = leg; }
|
315
315
|
}
|
316
|
-
} else if(KType ==
|
316
|
+
} else if(KType == FX_AMERICAN_BARRIER_DOUBLE_KNOCKIN || KType == FX_AMERICAN_BARRIER_DOUBLE_KNOCKOUT){
|
317
317
|
profit_loss = Spot;
|
318
318
|
profit_loss_dash = Spot_dash;
|
319
319
|
|
@@ -464,7 +464,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
464
464
|
// legs loop end
|
465
465
|
// start from the Knock value
|
466
466
|
double ko_so_far = K, ko_so_far_dash = K;
|
467
|
-
if(KType == FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE || KType ==
|
467
|
+
if(KType == FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE || KType == FX_AMERICAN_BARRIER_DOUBLE_KNOCKIN){
|
468
468
|
if(knockedLeg >= 0){
|
469
469
|
double equivalent_notional = *( Ns_array + knockedLeg );
|
470
470
|
sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
|
@@ -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[
|
558
|
+
sim_pos[knockedLeg2] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg2 ) ), sim[knockedLeg2], 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[
|
564
|
+
sim_dash_pos[knockedLeg2_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg2 ) ), sim_dash[knockedLeg2_dash], 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);
|
@@ -612,7 +612,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
612
612
|
metrics[1][point_pos+1] = (knockedLeg_dash >= 0) ? ( *( Xs_array + (knockedLeg_dash) ) ) : 0;
|
613
613
|
metrics[3][point_pos+1] = knockedLeg_dash;
|
614
614
|
}
|
615
|
-
} else if(KType == FX_AMERICAN_BARRIER_KNOCKOUT_DISCRETE || KType ==
|
615
|
+
} else if(KType == FX_AMERICAN_BARRIER_KNOCKOUT_DISCRETE || KType == FX_AMERICAN_BARRIER_DOUBLE_KNOCKOUT){
|
616
616
|
if(knockedLeg >= 0){
|
617
617
|
sim_pos[knockedLeg] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg ) ), sim[knockedLeg], dir_sign);
|
618
618
|
}
|