tarf_monte_carlo 3.2.1 → 3.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03bf86914a9a49bf1e131da2f8e0d7f68c74045468ac37b4d1512d02d9314dd6
4
- data.tar.gz: eeb37d954cccbd49685804b31aae18df4e26df1b7f3b645c76693d620c37c1f7
3
+ metadata.gz: 952162cf5265bbbe96f76316c5b3e4622136bc8a92f687e20ab06a02b2bd722a
4
+ data.tar.gz: bae272fc02f0f90e3a71ae7f7be76d2946a8f220a98b2e9400f52c11911dcea8
5
5
  SHA512:
6
- metadata.gz: 21f5c9487dd9534ef219b00636993d2df6c2282e5249589fafe282990a81fe74a3dc77dfa0f3861cfd75dde25df3929479b1a5331ded3099791bf43b8c466002
7
- data.tar.gz: 1c5d90afdd841e6a2238eac32c9b930ada776c4c17ad8d8a16ffd1d4f4e972cfd51a735a7d07cca35fc86e2f76c9a90912154d75501ad8f6aabbbdedd422ece3
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:"));
@@ -3,5 +3,5 @@
3
3
  # gem yank tarf_monte_carlo -v 2.3
4
4
 
5
5
  module TarfMonteCarlo
6
- VERSION = "3.2.1"
6
+ VERSION = "3.2.5"
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tarf_monte_carlo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vivek Routh