tarf_monte_carlo 3.2.1 → 3.2.5
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 +6 -7
- 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: 952162cf5265bbbe96f76316c5b3e4622136bc8a92f687e20ab06a02b2bd722a
|
4
|
+
data.tar.gz: bae272fc02f0f90e3a71ae7f7be76d2946a8f220a98b2e9400f52c11911dcea8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9516e88228e90b622d4d79e7d3e2a770ea13d645b703db2aeb5bffd135302fd6b91874043d193eddd46b6c2405ea319ec964cecbb431787332af29ed5d507e14
|
7
|
+
data.tar.gz: e2513d472eb9f93fe52dee7ff0f45fde7762db1a03d4bae5a79b73210a40e4c4b287574fc87f0e1c9b0f3eae1b98b385dce45e1f64705cb3ab26da9c7e83c642
|
@@ -30,6 +30,7 @@
|
|
30
30
|
#define LEGS 3 // knockout by legs
|
31
31
|
#define DATAPOINTS 200 // data for plotting
|
32
32
|
#define INTERVAL 50
|
33
|
+
#define SIM_LIMIT 96 // 96 + 4 = 100 simulations nedded
|
33
34
|
|
34
35
|
// Defining a space for information and references
|
35
36
|
// about the module to be stored internally
|
@@ -73,7 +74,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
73
74
|
srand( time(0) );
|
74
75
|
|
75
76
|
// initialize payoffs array
|
76
|
-
int leg, sim_count;
|
77
|
+
int leg, sim_count, metric, point_pos = 0;
|
77
78
|
double pvs_pos_sum = 0.0, pvs_neg_sum = 0.0;
|
78
79
|
|
79
80
|
int SCount = NUM2INT( rb_hash_aref(MCInputs, rb_str_new2("scount")) ) * 2;
|
@@ -116,18 +117,15 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
116
117
|
//
|
117
118
|
// first create a 1-D array of pointers, and then, for each array entry, create another 1-D array.
|
118
119
|
//
|
119
|
-
int metric;
|
120
120
|
double **metrics;
|
121
121
|
metrics = ( double** ) malloc( DATAPOINTS * sizeof(double*) );
|
122
122
|
for( metric = 0; metric < DATAPOINTS; metric++ ) {
|
123
123
|
metrics[metric] = ( double* ) malloc( NL * sizeof(double) );
|
124
|
-
|
125
|
-
for(metric = 0; metric < DATAPOINTS; metric++) {
|
124
|
+
|
126
125
|
for(leg = 0; leg < NL; leg++) {
|
127
126
|
metrics[metric][leg] = 0.0;
|
128
127
|
}
|
129
128
|
}
|
130
|
-
int point_pos = 0;
|
131
129
|
|
132
130
|
// run simulations loop
|
133
131
|
for( sim_count = 0; sim_count < SCount; sim_count += 2 ) {
|
@@ -179,7 +177,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
179
177
|
//
|
180
178
|
// Store spot and spot dash
|
181
179
|
//
|
182
|
-
if( (sim_count + 2) % INTERVAL == 0 ) {
|
180
|
+
if( point_pos <= SIM_LIMIT && (sim_count + 2) % INTERVAL == 0 ) {
|
183
181
|
rb_p(rb_str_new2("Leg:Spots"));
|
184
182
|
metrics[ point_pos ][ leg ] = Spot;
|
185
183
|
metrics[ point_pos + 2 ][ leg ] = Spot_dash;
|
@@ -300,7 +298,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
300
298
|
//
|
301
299
|
// store and send whichever payoff you want
|
302
300
|
//
|
303
|
-
if( (sim_count + 2) % INTERVAL == 0 ) {
|
301
|
+
if( point_pos <= SIM_LIMIT && (sim_count + 2) % INTERVAL == 0 ) {
|
304
302
|
rb_p(rb_str_new2("Leg:Payoffs"));
|
305
303
|
metrics[ point_pos + 1 ][ leg ] = sim_pos[leg];
|
306
304
|
metrics[ point_pos + 3 ][ leg ] = sim_dash_pos[leg];
|
@@ -320,6 +318,7 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
|
|
320
318
|
|
321
319
|
//
|
322
320
|
// increment metric storing point by 4
|
321
|
+
// Note: no limit condition here
|
323
322
|
//
|
324
323
|
if( (sim_count + 2) % INTERVAL == 0 ) {
|
325
324
|
rb_p(rb_str_new2("T:"));
|