tarf_monte_carlo 3.12 → 3.13
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/.gitignore +0 -0
- data/ext/tarf_monte_carlo/tarf_monte_carlo.c +17 -15
- 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: bf901445c70d80f370053ffa90ba2cc6fb3e12b9ad7c372777cae63b92ceecdb
|
4
|
+
data.tar.gz: 04331203b779e146db0e48a7eb9d1a0452c31aee17311c5f3c863d2104bc080b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b912836d2d1a64d62c9b1d394be9ca89c5dbeb245312ce18d9490751bf61fd1fc9ade361a60446d1a0b1df7928882e5e4d0691b0e8c7528733f9bdfc49ccf6b2
|
7
|
+
data.tar.gz: '08248d29944ff3fb8981d7bda9506bd056869575e54cb1ec6aa3be403b945cbe1b11c6bcb1cc42193f5617330d1be6633f4f1c2ab331cd2cc70d4cf455ef7df1'
|
data/.gitignore
CHANGED
File without changes
|
@@ -124,11 +124,18 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
124
124
|
vs_array[leg] = NUM2DBL( rb_ary_entry(vs, leg) );
|
125
125
|
bs_array[leg] = NUM2DBL( rb_ary_entry(bs, leg) );
|
126
126
|
DFs_array[leg] = NUM2DBL( rb_ary_entry(DFs, leg) );
|
127
|
-
|
127
|
+
}
|
128
|
+
// extra tarf structures
|
129
|
+
if ( KType == PIVOT_POINTS ) {
|
130
|
+
for (leg = 0; leg < NL; ++leg) {
|
128
131
|
Ps_array[leg] = NUM2DBL( rb_ary_entry(Ps, leg) );
|
129
|
-
}
|
132
|
+
}
|
133
|
+
} else if ( KType == COLLAR_POINTS ) {
|
134
|
+
for (leg = 0; leg < NL; ++leg) {
|
130
135
|
CFs_array[leg] = NUM2DBL( rb_ary_entry(CFs, leg) );
|
131
|
-
}
|
136
|
+
}
|
137
|
+
} else if ( KType == DUAL_STRIKE_POINTS ) {
|
138
|
+
for (leg = 0; leg < NL; ++leg) {
|
132
139
|
LSts_array[leg] = NUM2DBL( rb_ary_entry(LSts, leg) );
|
133
140
|
USts_array[leg] = NUM2DBL( rb_ary_entry(USts, leg) );
|
134
141
|
}
|
@@ -186,20 +193,16 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
186
193
|
profit_loss_dash = ( Spot_dash - ( *( Xs_array + leg ) ) );
|
187
194
|
} else if ( BS == SELL ) {
|
188
195
|
if ( KType == PIVOT_POINTS ) {
|
189
|
-
if (
|
190
|
-
profit_loss = *( Xs_array + leg ) - Spot;
|
191
|
-
} else if ( Spot > *( Xs_array + leg ) && Spot >= *( Ps_array + leg ) ) {
|
192
|
-
profit_loss = *( Xs_array + leg ) - Spot;
|
193
|
-
} else {
|
196
|
+
if ( *( Xs_array + leg ) < Spot && Spot < *( Ps_array + leg ) ) {
|
194
197
|
profit_loss = 0.0;
|
198
|
+
} else {
|
199
|
+
profit_loss = ( ( *( Xs_array + leg ) ) - Spot );
|
195
200
|
}
|
196
201
|
// dash
|
197
|
-
if (
|
198
|
-
profit_loss_dash = *( Xs_array + leg ) - Spot_dash;
|
199
|
-
} else if ( Spot_dash > *( Xs_array + leg ) && Spot_dash >= *( Ps_array + leg ) ) {
|
200
|
-
profit_loss_dash = *( Xs_array + leg ) - Spot_dash;
|
201
|
-
} else {
|
202
|
+
if ( *( Xs_array + leg ) < Spot_dash && Spot_dash < *( Ps_array + leg ) ) {
|
202
203
|
profit_loss_dash = 0.0;
|
204
|
+
} else {
|
205
|
+
profit_loss_dash = ( ( *( Xs_array + leg ) ) - Spot_dash );
|
203
206
|
}
|
204
207
|
} else {
|
205
208
|
// profit if spot is lower than market price
|
@@ -229,7 +232,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
229
232
|
}
|
230
233
|
}
|
231
234
|
// legs loop end
|
232
|
-
|
233
235
|
// start from the Knock value
|
234
236
|
double ko_so_far = K, ko_so_far_dash = K;
|
235
237
|
if( KType == ABSOLUTE ) {
|
@@ -272,7 +274,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
272
274
|
}
|
273
275
|
}
|
274
276
|
}
|
275
|
-
} else if( KType == POINTS ) {
|
277
|
+
} else if( KType == POINTS || KType == PIVOT_POINTS || KType == COLLAR_POINTS || KType == DUAL_STRIKE_POINTS ) {
|
276
278
|
for( leg = 0; leg < NL; ++leg ) {
|
277
279
|
// simulation normal
|
278
280
|
if ( ko_so_far > 0.0 ) {
|