tarf_monte_carlo 3.19 → 3.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/tarf_monte_carlo/tarf_monte_carlo.c +7 -5
- 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: 82676c437016c3396bd0732ee1d20db01a0d4fea1243b3a4555a3b746024874b
|
4
|
+
data.tar.gz: 774bf6b5cd0f5193c23477bd190aa88d538ae8f5977151e4129928ec13775354
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f51579af9e3911d5a23324af39aee42d877e7067d86cf2781889de751fb49fff7df31be62acc450aaed89c7bf85d3f0759c34fb94de6445c47f4392226623e3b
|
7
|
+
data.tar.gz: fdaff8bcd7ec29be4c0478cad38fe3469baea9ce657262c6e5422967968ccd7a463da96a477cc27bcc9906b5245a28707afac62cb4d1a93c29b9f73a51b25386
|
@@ -81,7 +81,7 @@ VALUE method_box_muller( VALUE self ) {
|
|
81
81
|
VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
82
82
|
VALUE MCInputs = rb_ary_shift(args);
|
83
83
|
// rb_p(rb_str_new2("MC Inputs:"));
|
84
|
-
|
84
|
+
rb_p(MCInputs);
|
85
85
|
|
86
86
|
// seed value for rand() function
|
87
87
|
srand( time(0) );
|
@@ -114,6 +114,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
114
114
|
double *CFs_array = ( double* ) malloc( NL * sizeof(double) );
|
115
115
|
double *LSts_array = ( double* ) malloc( NL * sizeof(double) );
|
116
116
|
double *USts_array = ( double* ) malloc( NL * sizeof(double) );
|
117
|
+
double *TempNs_array = ( double* ) malloc( NL * sizeof(double) );
|
117
118
|
|
118
119
|
VALUE Ls = rb_hash_aref(MCInputs, rb_str_new2("leverage_ratios") );
|
119
120
|
VALUE Ts = rb_hash_aref(MCInputs, rb_str_new2("expiration_times") );
|
@@ -135,6 +136,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
135
136
|
vs_array[leg] = NUM2DBL( rb_ary_entry(vs, leg) );
|
136
137
|
bs_array[leg] = NUM2DBL( rb_ary_entry(bs, leg) );
|
137
138
|
DFs_array[leg] = NUM2DBL( rb_ary_entry(DFs, leg) );
|
139
|
+
TempNs_array[leg] = *(Ns_array + leg);
|
138
140
|
}
|
139
141
|
// extra tarf structures
|
140
142
|
if ( KType == PIVOT_POINTS || KType == PIVOT_ABSOLUTE || KType == PIVOT_LEGS ) {
|
@@ -211,13 +213,12 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
211
213
|
}
|
212
214
|
|
213
215
|
if (ConvertNotional == 1){
|
214
|
-
if(Spot < *( Ps_array + leg )){
|
215
|
-
Ns_array[leg] = *(
|
216
|
+
if(Spot < *( Ps_array + leg ) || Spot_dash < *( Ps_array + leg )){
|
217
|
+
Ns_array[leg] = *(TempNs_array + leg) / *( LSts_array + leg );
|
216
218
|
} else {
|
217
|
-
Ns_array[leg] = *(
|
219
|
+
Ns_array[leg] = *(TempNs_array + leg) / *( USts_array + leg );
|
218
220
|
}
|
219
221
|
}
|
220
|
-
rb_p(Ns_array[leg]);
|
221
222
|
|
222
223
|
// dash
|
223
224
|
if ( Spot_dash < *( LSts_array + leg ) ) {
|
@@ -366,6 +367,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
366
367
|
} else if( KType == POINTS || KType == PIVOT_POINTS || KType == COLLAR_POINTS || KType == DOUBLE_STRIKE_POINTS ) {
|
367
368
|
for( leg = 0; leg < NL; ++leg ) {
|
368
369
|
// simulation normal
|
370
|
+
rb_p(DBL2NUM(*(Ns_array + leg )));
|
369
371
|
if ( ko_so_far > 0.0 ) {
|
370
372
|
if( sim[leg] >= 0.0 ) {
|
371
373
|
// knock out condition
|