tarf_monte_carlo 3.34 → 3.35
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 +8 -16
- 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: d99188553bdf78de85d726474f7397e49f3195ef802cedf1800dd8a462b50584
|
4
|
+
data.tar.gz: 6e0bb8b0ef4078cfc547def074f4fb6ac04ee6ea7a89db777f6158367552d659
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d302c75c2917d824ff3938fdd996594062dd50fd6a6814f98b7955de32f7cb53f35ae928578b56e705c54579a107b7757e9650c595cf0b515566dcd2361d2eed
|
7
|
+
data.tar.gz: e98d7a04f2b99fc9b77cf19f5e0417316505142b67965810c7bcb41d95e12ca8fe7f4e3ff474b3e6f0029251bf4056a7c9cc5a5520c8f4b08fa76dc556ce7b3a
|
@@ -90,13 +90,11 @@ double european_payoff(double strike, double spot, int cp_sign, int dir_sign, do
|
|
90
90
|
}
|
91
91
|
|
92
92
|
double get_equivalent_notional(int conversion_sign, double notional, float rate){
|
93
|
-
|
94
|
-
return eq;
|
93
|
+
return (conversion_sign == 1) ? (notional / rate) : notional;
|
95
94
|
}
|
96
95
|
|
97
96
|
double get_equivalent_rebate(int conversion_sign, double rebate, float rate){
|
98
|
-
|
99
|
-
return eq;
|
97
|
+
return (conversion_sign == 1) ? (rebate * rate) : rebate;
|
100
98
|
}
|
101
99
|
|
102
100
|
// main method for running monte carlo simulation from sidekiq worker/outside method
|
@@ -195,7 +193,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
195
193
|
// first create a 1-D array of pointers, and then, for each array entry, create another 1-D array.
|
196
194
|
//
|
197
195
|
double **metrics;
|
198
|
-
double data[SCount];
|
199
196
|
metrics = ( double** ) malloc( DATAPOINTS * sizeof(double*) );
|
200
197
|
for( metric = 0; metric < DATAPOINTS; metric++ ) {
|
201
198
|
metrics[metric] = ( double* ) malloc( NL * sizeof(double) );
|
@@ -208,9 +205,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
208
205
|
// run simulations loop
|
209
206
|
for( sim_count = 0; sim_count < SCount; sim_count += 2 ) {
|
210
207
|
// initial spot rate for each iteration would be current spot rate
|
211
|
-
data[sim_count] = 0;
|
212
|
-
data[sim_count + 1] = 0;
|
213
|
-
|
214
208
|
double Spot = S, Spot_dash = S;
|
215
209
|
double sim[NL], sim_pos[NL], sim_neg[NL], sim_dash[NL], sim_dash_pos[NL], sim_dash_neg[NL];
|
216
210
|
|
@@ -397,7 +391,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
397
391
|
if(KType == FX_AMERICAN_BARRIER_KNOCKIN_DISCRETE){
|
398
392
|
if(knockedLeg >= 0){
|
399
393
|
double equivalent_notional = get_equivalent_notional(conversion_sign, ( *( Ns_array + knockedLeg ) ), sim[NL-1]);
|
400
|
-
data[sim_count] = equivalent_notional;
|
401
394
|
sim_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg) ) ), sim[NL-1], cp_sign, dir_sign, equivalent_notional);
|
402
395
|
}
|
403
396
|
else{
|
@@ -405,7 +398,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
405
398
|
}
|
406
399
|
if(knockedLeg_dash >= 0 ){
|
407
400
|
double equivalent_notional = get_equivalent_notional(conversion_sign, ( *( Ns_array + knockedLeg_dash ) ), sim_dash[NL-1]);
|
408
|
-
data[sim_count + 1] = equivalent_notional;
|
409
401
|
sim_dash_pos[NL-1] = european_payoff(( *( Xs_array + (knockedLeg_dash) ) ), sim_dash[NL-1], cp_sign, dir_sign, equivalent_notional);
|
410
402
|
}
|
411
403
|
else{
|
@@ -592,14 +584,14 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
592
584
|
//
|
593
585
|
// rb_p(rb_str_new2("Converting metrics"));
|
594
586
|
VALUE final_metrics = rb_ary_new();
|
595
|
-
for(metric = 0; metric <
|
596
|
-
|
587
|
+
for(metric = 0; metric < DATAPOINTS; metric++) {
|
588
|
+
VALUE leg_metrics = rb_ary_new();
|
597
589
|
|
598
|
-
|
599
|
-
|
600
|
-
|
590
|
+
for(leg = 0; leg < NL; leg++) {
|
591
|
+
rb_ary_push( leg_metrics, DBL2NUM( metrics[metric][leg] ) );
|
592
|
+
}
|
601
593
|
|
602
|
-
rb_ary_push(final_metrics,
|
594
|
+
rb_ary_push(final_metrics, leg_metrics);
|
603
595
|
}
|
604
596
|
|
605
597
|
// rb_p(rb_str_new2("Generating output hash"));
|
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.35'
|
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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|