tarf_monte_carlo 3.57 → 3.62
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 -15
- 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: 774a60220745dc9096b8d91dd54d01a7053bc78a3f3b70fcc631e9c451d59ede
|
4
|
+
data.tar.gz: d2a4bbf7986e338fdec318e7a0045fb92ceb86e9a7b276ad1bdfd8ae0a38d53f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f01816bea5fc7b19ecc9ee8c8d7ebb5179e63e1042c676a2aafcb04d68dac922f8c1bfbe6b71676d7a74aeffc4107a571340fdf442eafcb8c552cb803cefeaa
|
7
|
+
data.tar.gz: 7fdd0048cf2e8acbe0322da4f0618de813dc7de0245a2a30fc3f9b88b92138983e7239a6cc146eaafa2c03633250e461ab1abb654a28eed1321983c522f23d82
|
@@ -66,7 +66,6 @@ VALUE cTarfMonteCarlo = Qnil;
|
|
66
66
|
// Prototype for the initialization method - Ruby calls this, not you
|
67
67
|
void Init_tarf_monte_carlo();
|
68
68
|
double european_payoff(double, double, int, int, double);
|
69
|
-
double get_equivalent_notional(int, double, float);
|
70
69
|
double get_equivalent_rebate(int, double, float, int);
|
71
70
|
bool barrier_variations(int);
|
72
71
|
bool double_barrier_variations(int);
|
@@ -99,10 +98,6 @@ double european_payoff(double strike, double spot, int cp_sign, int dir_sign, do
|
|
99
98
|
return (diff * notional * dir_sign);
|
100
99
|
}
|
101
100
|
|
102
|
-
double get_equivalent_notional(int conversion_sign, double notional, float rate){
|
103
|
-
return (conversion_sign == 1) ? (notional / rate) : notional;
|
104
|
-
}
|
105
|
-
|
106
101
|
double get_equivalent_rebate(int conversion_sign, double rebate, float rate, int dir_sign){
|
107
102
|
double total = (conversion_sign == 1) ? (rebate * rate) : rebate;
|
108
103
|
return (dir_sign * total);
|
@@ -453,14 +448,14 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
453
448
|
double ko_so_far = K, ko_so_far_dash = K;
|
454
449
|
if(KType == FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE || KType == FX_AMERICAN_BARRIER_WINDOW_KNOCKIN){
|
455
450
|
if(knockedLeg >= 0){
|
456
|
-
double equivalent_notional =
|
451
|
+
double equivalent_notional = *( Ns_array + knockedLeg );
|
457
452
|
sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
|
458
453
|
}
|
459
454
|
else{
|
460
455
|
sim_pos[NL-1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[NL-1], dir_sign);
|
461
456
|
}
|
462
457
|
if(knockedLeg_dash >= 0 ){
|
463
|
-
double equivalent_notional =
|
458
|
+
double equivalent_notional = *( Ns_array + knockedLeg_dash );
|
464
459
|
sim_dash_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg_dash) ) ), sim_dash[NL-1], cp_sign, dir_sign, equivalent_notional);
|
465
460
|
}
|
466
461
|
else{
|
@@ -502,6 +497,12 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
502
497
|
sim_dash_pos[legIndex_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim_dash[legIndex_dash], dir_sign);
|
503
498
|
}
|
504
499
|
}
|
500
|
+
if ((point_pos < DATAPOINTS) && (sim_count % INTERVAL) == 0){
|
501
|
+
metrics[0][point_pos] = sim[NL-1];
|
502
|
+
metrics[1][point_pos] = *( Xs_array + 0 );
|
503
|
+
metrics[0][point_pos+1] = sim_dash[NL-1];
|
504
|
+
metrics[1][point_pos+1] = *( Xs_array + 0 );
|
505
|
+
}
|
505
506
|
} else if(KType == FX_AMERICAN_BARRIER_BINARY_OUT_DISCRETE || KType == FX_AMERICAN_BARRIER_BINARY_CALLPUT_OUT_DISCRETE){
|
506
507
|
if(knockedLeg == -1){
|
507
508
|
int itm = true;
|
@@ -528,17 +529,23 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
528
529
|
sim_dash_pos[NL - 1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim_dash[NL - 1], dir_sign);
|
529
530
|
}
|
530
531
|
}
|
532
|
+
if ((point_pos < DATAPOINTS) && (sim_count % INTERVAL) == 0){
|
533
|
+
metrics[0][point_pos] = sim[NL-1];
|
534
|
+
metrics[1][point_pos] = *( Xs_array + 0 );
|
535
|
+
metrics[0][point_pos+1] = sim_dash[NL-1];
|
536
|
+
metrics[1][point_pos+1] = *( Xs_array + 0 );
|
537
|
+
}
|
531
538
|
} else if(KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP){
|
532
539
|
if(knockedLeg2 >= 0){
|
533
540
|
sim_pos[NL-1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[NL-1], dir_sign);
|
534
541
|
} else if(knockedLeg >= 0) {
|
535
|
-
double equivalent_notional =
|
542
|
+
double equivalent_notional = *( Ns_array + knockedLeg );
|
536
543
|
sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
|
537
544
|
}
|
538
545
|
if(knockedLeg2_dash >= 0){
|
539
546
|
sim_dash_pos[NL-1] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim_dash[NL-1], dir_sign);
|
540
547
|
} else if(knockedLeg_dash >= 0) {
|
541
|
-
double equivalent_notional =
|
548
|
+
double equivalent_notional = *( Ns_array + knockedLeg_dash );
|
542
549
|
sim_dash_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg_dash) ) ), sim_dash[NL-1], cp_sign, dir_sign, equivalent_notional);
|
543
550
|
}
|
544
551
|
|
@@ -553,7 +560,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
553
560
|
} else if(KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_KI){
|
554
561
|
if(knockedLeg >= 0 && knockedLeg2 >= 0){
|
555
562
|
if(knockedLeg < knockedLeg2){
|
556
|
-
double equivalent_notional =
|
563
|
+
double equivalent_notional = *( Ns_array + knockedLeg );
|
557
564
|
sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
|
558
565
|
} else {
|
559
566
|
sim_pos[knockedLeg2] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[knockedLeg2], dir_sign);
|
@@ -561,13 +568,13 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
561
568
|
} else if(knockedLeg2 >= 0){
|
562
569
|
sim_pos[knockedLeg2] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim[knockedLeg2], dir_sign);
|
563
570
|
} else if(knockedLeg >= 0) {
|
564
|
-
double equivalent_notional =
|
571
|
+
double equivalent_notional = *( Ns_array + knockedLeg );
|
565
572
|
sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
|
566
573
|
}
|
567
574
|
|
568
575
|
if(knockedLeg_dash >= 0 && knockedLeg2_dash >= 0){
|
569
576
|
if(knockedLeg_dash < knockedLeg2_dash){
|
570
|
-
double equivalent_notional =
|
577
|
+
double equivalent_notional = *( Ns_array + knockedLeg_dash );
|
571
578
|
sim_dash_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg_dash) ) ), sim_dash[NL-1], cp_sign, dir_sign, equivalent_notional);
|
572
579
|
} else {
|
573
580
|
sim_dash_pos[knockedLeg2_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim_dash[knockedLeg2_dash], dir_sign);
|
@@ -575,7 +582,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
575
582
|
} else if(knockedLeg2_dash >= 0){
|
576
583
|
sim_dash_pos[knockedLeg2_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + 0 ) ), sim_dash[knockedLeg2_dash], dir_sign);
|
577
584
|
} else if(knockedLeg_dash >= 0) {
|
578
|
-
double equivalent_notional =
|
585
|
+
double equivalent_notional = *( Ns_array + knockedLeg_dash );
|
579
586
|
sim_dash_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg_dash) ) ), sim_dash[NL-1], cp_sign, dir_sign, equivalent_notional);
|
580
587
|
}
|
581
588
|
|
@@ -592,14 +599,14 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
592
599
|
sim_pos[knockedLeg] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg ) ), sim[knockedLeg], dir_sign);
|
593
600
|
}
|
594
601
|
else{
|
595
|
-
double equivalent_notional =
|
602
|
+
double equivalent_notional = *( Ns_array + 0 );
|
596
603
|
sim_pos[NL-1] = european_payoff(( *( Xs_array + 0 ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
|
597
604
|
}
|
598
605
|
if(knockedLeg_dash >= 0 ){
|
599
606
|
sim_dash_pos[knockedLeg_dash] = get_equivalent_rebate(rebate_conversion_sign, ( *( Rebate_array + knockedLeg_dash ) ), sim[knockedLeg_dash], dir_sign);
|
600
607
|
}
|
601
608
|
else{
|
602
|
-
double equivalent_notional =
|
609
|
+
double equivalent_notional = *( Ns_array + 0 );
|
603
610
|
sim_dash_pos[NL-1] = european_payoff(( *( Xs_array + 0 ) ), sim_dash[NL-1], cp_sign, dir_sign, equivalent_notional);
|
604
611
|
}
|
605
612
|
|
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.62'
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|