tarf_monte_carlo 3.4 → 3.5
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 +18 -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: 67b1ad29c02a6eaa79c27b2bcd092d8d58736de856228479553c01275c74aa23
|
4
|
+
data.tar.gz: a0f8a59cc28cec075cdaf3181aa41df49068efa7ef53613fb840d7582f91194d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71691b20d4de8c2c218280998dbd67a2c89d829001b46181186560ed15f8e644b1cc6e9c83b737c4f59e77adfe22e65bc34f2184d9e8d9f1f4d59efff8a2193e
|
7
|
+
data.tar.gz: c8b637dfab5f1153e02bd61ff4e48742cd15507fd3dba45af07bad6a63224ce962ed8afbc88011d241cb82a919f94901fd76fbaa6a8e6f192beb3518c2fa8888
|
@@ -77,13 +77,14 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
77
77
|
int leg, sim_count, metric, point_pos = 0;
|
78
78
|
double pvs_pos_sum = 0.0, pvs_neg_sum = 0.0;
|
79
79
|
|
80
|
-
int SCount
|
81
|
-
int MCType
|
82
|
-
int NL
|
83
|
-
int BS
|
84
|
-
double K
|
85
|
-
int KType
|
86
|
-
double S
|
80
|
+
int SCount = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("scount")) ) * 2;
|
81
|
+
int MCType = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("mc_type")) );
|
82
|
+
int NL = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("legs_count")) );
|
83
|
+
int BS = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("buy_sell")) );
|
84
|
+
double K = NUM2DBL( rb_hash_aref(MCInputs, rb_str_new2("knockout")) );
|
85
|
+
int KType = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("knockout_type")) );
|
86
|
+
double S = NUM2DBL( rb_hash_aref(MCInputs, rb_str_new2("spot_rate")) );
|
87
|
+
int Ko_compare_mult = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("multiplier")) );
|
87
88
|
|
88
89
|
// assign leg specific attributes
|
89
90
|
double *pvs_pos = ( double* ) malloc( SCount * sizeof(double) );
|
@@ -201,13 +202,14 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
201
202
|
if( sim[leg] >= 0.0 ) {
|
202
203
|
// knock out condition
|
203
204
|
double temp_payoff = sim[leg] * ( *( Ns_array + leg ) );
|
205
|
+
double temp_payoff_ko_ccy = temp_payoff * pow( *( Xs_array + leg ), Ko_compare_mult );
|
204
206
|
|
205
|
-
if(
|
206
|
-
sim_pos[leg] = ko_so_far;
|
207
|
+
if( temp_payoff_ko_ccy > ko_so_far ) {
|
208
|
+
sim_pos[leg] = ko_so_far * pow( *( Xs_array + leg ), Ko_compare_mult );
|
207
209
|
ko_so_far = 0.0;
|
208
|
-
} else if(
|
210
|
+
} else if( temp_payoff_ko_ccy <= ko_so_far ) {
|
209
211
|
sim_pos[leg] = temp_payoff; // take the payoff in +ve's
|
210
|
-
ko_so_far -=
|
212
|
+
ko_so_far -= temp_payoff_ko_ccy; // update the knock out
|
211
213
|
}
|
212
214
|
} else {
|
213
215
|
sim_neg[leg] = sim[leg] * ( *( Ls_array + leg ) ) * ( *( Ns_array + leg ) );
|
@@ -219,13 +221,14 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
219
221
|
if( sim_dash[leg] >= 0.0 ) {
|
220
222
|
// knock out condition
|
221
223
|
double temp_payoff_dash = sim_dash[leg] * ( *( Ns_array + leg ) );
|
224
|
+
double temp_payoff_ko_ccy = temp_payoff_dash * pow( *( Xs_array + leg ), Ko_compare_mult );
|
222
225
|
|
223
|
-
if(
|
224
|
-
sim_dash_pos[leg] = ko_so_far_dash;
|
226
|
+
if( temp_payoff_ko_ccy > ko_so_far_dash ) {
|
227
|
+
sim_dash_pos[leg] = ko_so_far_dash * pow( *( Xs_array + leg ), Ko_compare_mult );
|
225
228
|
ko_so_far_dash = 0.0;
|
226
|
-
} else if(
|
229
|
+
} else if( temp_payoff_ko_ccy <= ko_so_far_dash ) {
|
227
230
|
sim_dash_pos[leg] = temp_payoff_dash; // take the payoff in +ve's
|
228
|
-
ko_so_far_dash -=
|
231
|
+
ko_so_far_dash -= temp_payoff_ko_ccy; // update the knock out
|
229
232
|
}
|
230
233
|
} else {
|
231
234
|
sim_dash_neg[leg] = sim_dash[leg] * ( *( Ls_array + leg ) ) * ( *( Ns_array + leg ) );
|
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.5'
|
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-04-
|
11
|
+
date: 2020-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|