option_lab 0.1.0
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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +139 -0
- data/.yard/hooks/before_generate.rb +7 -0
- data/.yardopts +11 -0
- data/Gemfile +26 -0
- data/LICENSE.txt +21 -0
- data/README.md +180 -0
- data/Rakefile +44 -0
- data/docs/OptionLab/BinomialTree.html +1271 -0
- data/docs/OptionLab/BjerksundStensland.html +2022 -0
- data/docs/OptionLab/BlackScholes.html +2388 -0
- data/docs/OptionLab/Engine.html +1716 -0
- data/docs/OptionLab/Models/AmericanModelInputs.html +937 -0
- data/docs/OptionLab/Models/ArrayInputs.html +463 -0
- data/docs/OptionLab/Models/BaseModel.html +223 -0
- data/docs/OptionLab/Models/BinomialModelInputs.html +1161 -0
- data/docs/OptionLab/Models/BlackScholesInfo.html +967 -0
- data/docs/OptionLab/Models/BlackScholesModelInputs.html +851 -0
- data/docs/OptionLab/Models/ClosedPosition.html +445 -0
- data/docs/OptionLab/Models/EngineData.html +2523 -0
- data/docs/OptionLab/Models/EngineDataResults.html +435 -0
- data/docs/OptionLab/Models/Inputs.html +2241 -0
- data/docs/OptionLab/Models/LaplaceInputs.html +777 -0
- data/docs/OptionLab/Models/Option.html +736 -0
- data/docs/OptionLab/Models/Outputs.html +1753 -0
- data/docs/OptionLab/Models/PoPOutputs.html +645 -0
- data/docs/OptionLab/Models/PricingResult.html +848 -0
- data/docs/OptionLab/Models/Stock.html +583 -0
- data/docs/OptionLab/Models/TreeVisualization.html +688 -0
- data/docs/OptionLab/Models.html +251 -0
- data/docs/OptionLab/Plotting.html +548 -0
- data/docs/OptionLab/Support.html +2884 -0
- data/docs/OptionLab/Utils.html +619 -0
- data/docs/OptionLab.html +133 -0
- data/docs/_index.html +376 -0
- data/docs/class_list.html +54 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +503 -0
- data/docs/file.LICENSE.html +70 -0
- data/docs/file.README.html +263 -0
- data/docs/file_list.html +64 -0
- data/docs/frames.html +22 -0
- data/docs/index.html +263 -0
- data/docs/js/app.js +344 -0
- data/docs/js/full_list.js +242 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +1974 -0
- data/docs/top-level-namespace.html +110 -0
- data/examples/american_options.rb +163 -0
- data/examples/covered_call.rb +76 -0
- data/lib/option_lab/binomial_tree.rb +238 -0
- data/lib/option_lab/bjerksund_stensland.rb +276 -0
- data/lib/option_lab/black_scholes.rb +323 -0
- data/lib/option_lab/engine.rb +492 -0
- data/lib/option_lab/models.rb +768 -0
- data/lib/option_lab/plotting.rb +182 -0
- data/lib/option_lab/support.rb +471 -0
- data/lib/option_lab/utils.rb +107 -0
- data/lib/option_lab/version.rb +5 -0
- data/lib/option_lab.rb +134 -0
- data/option_lab.gemspec +43 -0
- metadata +207 -0
@@ -0,0 +1,688 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: OptionLab::Models::TreeVisualization
|
8
|
+
|
9
|
+
— OptionLab Documentation
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
pathId = "OptionLab::Models::TreeVisualization";
|
19
|
+
relpath = '../../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../../_index.html">Index (T)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../../OptionLab.html" title="OptionLab (module)">OptionLab</a></span></span> » <span class='title'><span class='object_link'><a href="../Models.html" title="OptionLab::Models (module)">Models</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">TreeVisualization</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: OptionLab::Models::TreeVisualization
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName"><span class='object_link'><a href="BaseModel.html" title="OptionLab::Models::BaseModel (class)">BaseModel</a></span></span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next"><span class='object_link'><a href="BaseModel.html" title="OptionLab::Models::BaseModel (class)">BaseModel</a></span></li>
|
78
|
+
|
79
|
+
<li class="next">OptionLab::Models::TreeVisualization</li>
|
80
|
+
|
81
|
+
</ul>
|
82
|
+
<a href="#" class="inheritanceTree">show all</a>
|
83
|
+
|
84
|
+
</dd>
|
85
|
+
</dl>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<dl>
|
98
|
+
<dt>Defined in:</dt>
|
99
|
+
<dd>lib/option_lab/models.rb</dd>
|
100
|
+
</dl>
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
<h2>Overview</h2><div class="docstring">
|
105
|
+
<div class="discussion">
|
106
|
+
<p>Binomial tree visualization data</p>
|
107
|
+
|
108
|
+
|
109
|
+
</div>
|
110
|
+
</div>
|
111
|
+
<div class="tags">
|
112
|
+
|
113
|
+
|
114
|
+
</div>
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
119
|
+
<ul class="summary">
|
120
|
+
|
121
|
+
<li class="public ">
|
122
|
+
<span class="summary_signature">
|
123
|
+
|
124
|
+
<a href="#exercise_flags-instance_method" title="#exercise_flags (instance method)">#<strong>exercise_flags</strong> ⇒ Object </a>
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
</span>
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute exercise_flags.</p>
|
142
|
+
</div></span>
|
143
|
+
|
144
|
+
</li>
|
145
|
+
|
146
|
+
|
147
|
+
<li class="public ">
|
148
|
+
<span class="summary_signature">
|
149
|
+
|
150
|
+
<a href="#option_values-instance_method" title="#option_values (instance method)">#<strong>option_values</strong> ⇒ Object </a>
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
</span>
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute option_values.</p>
|
168
|
+
</div></span>
|
169
|
+
|
170
|
+
</li>
|
171
|
+
|
172
|
+
|
173
|
+
<li class="public ">
|
174
|
+
<span class="summary_signature">
|
175
|
+
|
176
|
+
<a href="#parameters-instance_method" title="#parameters (instance method)">#<strong>parameters</strong> ⇒ Object </a>
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
</span>
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute parameters.</p>
|
194
|
+
</div></span>
|
195
|
+
|
196
|
+
</li>
|
197
|
+
|
198
|
+
|
199
|
+
<li class="public ">
|
200
|
+
<span class="summary_signature">
|
201
|
+
|
202
|
+
<a href="#stock_prices-instance_method" title="#stock_prices (instance method)">#<strong>stock_prices</strong> ⇒ Object </a>
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
</span>
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute stock_prices.</p>
|
220
|
+
</div></span>
|
221
|
+
|
222
|
+
</li>
|
223
|
+
|
224
|
+
|
225
|
+
</ul>
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
<h2>
|
232
|
+
Instance Method Summary
|
233
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
234
|
+
</h2>
|
235
|
+
|
236
|
+
<ul class="summary">
|
237
|
+
|
238
|
+
<li class="public ">
|
239
|
+
<span class="summary_signature">
|
240
|
+
|
241
|
+
<a href="#diagram_data-instance_method" title="#diagram_data (instance method)">#<strong>diagram_data</strong> ⇒ Object </a>
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
</span>
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
<span class="summary_desc"><div class='inline'><p>Get data for rendering a tree diagram.</p>
|
256
|
+
</div></span>
|
257
|
+
|
258
|
+
</li>
|
259
|
+
|
260
|
+
|
261
|
+
<li class="public ">
|
262
|
+
<span class="summary_signature">
|
263
|
+
|
264
|
+
<a href="#get_node-instance_method" title="#get_node (instance method)">#<strong>get_node</strong>(step, node) ⇒ Object </a>
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
</span>
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
279
|
+
|
280
|
+
</li>
|
281
|
+
|
282
|
+
|
283
|
+
<li class="public ">
|
284
|
+
<span class="summary_signature">
|
285
|
+
|
286
|
+
<a href="#to_csv-instance_method" title="#to_csv (instance method)">#<strong>to_csv</strong> ⇒ Object </a>
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
</span>
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
<span class="summary_desc"><div class='inline'><p>Export tree data to CSV format.</p>
|
301
|
+
</div></span>
|
302
|
+
|
303
|
+
</li>
|
304
|
+
|
305
|
+
|
306
|
+
</ul>
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
<div id="constructor_details" class="method_details_list">
|
312
|
+
<h2>Constructor Details</h2>
|
313
|
+
|
314
|
+
<p class="notice">This class inherits a constructor from <span class='object_link'><a href="BaseModel.html#initialize-instance_method" title="OptionLab::Models::BaseModel#initialize (method)">OptionLab::Models::BaseModel</a></span></p>
|
315
|
+
|
316
|
+
</div>
|
317
|
+
|
318
|
+
<div id="instance_attr_details" class="attr_details">
|
319
|
+
<h2>Instance Attribute Details</h2>
|
320
|
+
|
321
|
+
|
322
|
+
<span id="exercise_flags=-instance_method"></span>
|
323
|
+
<div class="method_details first">
|
324
|
+
<h3 class="signature first" id="exercise_flags-instance_method">
|
325
|
+
|
326
|
+
#<strong>exercise_flags</strong> ⇒ <tt>Object</tt>
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
</h3><div class="docstring">
|
333
|
+
<div class="discussion">
|
334
|
+
<p>Returns the value of attribute exercise_flags.</p>
|
335
|
+
|
336
|
+
|
337
|
+
</div>
|
338
|
+
</div>
|
339
|
+
<div class="tags">
|
340
|
+
|
341
|
+
|
342
|
+
</div><table class="source_code">
|
343
|
+
<tr>
|
344
|
+
<td>
|
345
|
+
<pre class="lines">
|
346
|
+
|
347
|
+
|
348
|
+
713
|
349
|
+
714
|
350
|
+
715</pre>
|
351
|
+
</td>
|
352
|
+
<td>
|
353
|
+
<pre class="code"><span class="info file"># File 'lib/option_lab/models.rb', line 713</span>
|
354
|
+
|
355
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_exercise_flags'>exercise_flags</span>
|
356
|
+
<span class='ivar'>@exercise_flags</span>
|
357
|
+
<span class='kw'>end</span></pre>
|
358
|
+
</td>
|
359
|
+
</tr>
|
360
|
+
</table>
|
361
|
+
</div>
|
362
|
+
|
363
|
+
|
364
|
+
<span id="option_values=-instance_method"></span>
|
365
|
+
<div class="method_details ">
|
366
|
+
<h3 class="signature " id="option_values-instance_method">
|
367
|
+
|
368
|
+
#<strong>option_values</strong> ⇒ <tt>Object</tt>
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
</h3><div class="docstring">
|
375
|
+
<div class="discussion">
|
376
|
+
<p>Returns the value of attribute option_values.</p>
|
377
|
+
|
378
|
+
|
379
|
+
</div>
|
380
|
+
</div>
|
381
|
+
<div class="tags">
|
382
|
+
|
383
|
+
|
384
|
+
</div><table class="source_code">
|
385
|
+
<tr>
|
386
|
+
<td>
|
387
|
+
<pre class="lines">
|
388
|
+
|
389
|
+
|
390
|
+
713
|
391
|
+
714
|
392
|
+
715</pre>
|
393
|
+
</td>
|
394
|
+
<td>
|
395
|
+
<pre class="code"><span class="info file"># File 'lib/option_lab/models.rb', line 713</span>
|
396
|
+
|
397
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_option_values'>option_values</span>
|
398
|
+
<span class='ivar'>@option_values</span>
|
399
|
+
<span class='kw'>end</span></pre>
|
400
|
+
</td>
|
401
|
+
</tr>
|
402
|
+
</table>
|
403
|
+
</div>
|
404
|
+
|
405
|
+
|
406
|
+
<span id="parameters=-instance_method"></span>
|
407
|
+
<div class="method_details ">
|
408
|
+
<h3 class="signature " id="parameters-instance_method">
|
409
|
+
|
410
|
+
#<strong>parameters</strong> ⇒ <tt>Object</tt>
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
</h3><div class="docstring">
|
417
|
+
<div class="discussion">
|
418
|
+
<p>Returns the value of attribute parameters.</p>
|
419
|
+
|
420
|
+
|
421
|
+
</div>
|
422
|
+
</div>
|
423
|
+
<div class="tags">
|
424
|
+
|
425
|
+
|
426
|
+
</div><table class="source_code">
|
427
|
+
<tr>
|
428
|
+
<td>
|
429
|
+
<pre class="lines">
|
430
|
+
|
431
|
+
|
432
|
+
713
|
433
|
+
714
|
434
|
+
715</pre>
|
435
|
+
</td>
|
436
|
+
<td>
|
437
|
+
<pre class="code"><span class="info file"># File 'lib/option_lab/models.rb', line 713</span>
|
438
|
+
|
439
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_parameters'>parameters</span>
|
440
|
+
<span class='ivar'>@parameters</span>
|
441
|
+
<span class='kw'>end</span></pre>
|
442
|
+
</td>
|
443
|
+
</tr>
|
444
|
+
</table>
|
445
|
+
</div>
|
446
|
+
|
447
|
+
|
448
|
+
<span id="stock_prices=-instance_method"></span>
|
449
|
+
<div class="method_details ">
|
450
|
+
<h3 class="signature " id="stock_prices-instance_method">
|
451
|
+
|
452
|
+
#<strong>stock_prices</strong> ⇒ <tt>Object</tt>
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
|
458
|
+
</h3><div class="docstring">
|
459
|
+
<div class="discussion">
|
460
|
+
<p>Returns the value of attribute stock_prices.</p>
|
461
|
+
|
462
|
+
|
463
|
+
</div>
|
464
|
+
</div>
|
465
|
+
<div class="tags">
|
466
|
+
|
467
|
+
|
468
|
+
</div><table class="source_code">
|
469
|
+
<tr>
|
470
|
+
<td>
|
471
|
+
<pre class="lines">
|
472
|
+
|
473
|
+
|
474
|
+
713
|
475
|
+
714
|
476
|
+
715</pre>
|
477
|
+
</td>
|
478
|
+
<td>
|
479
|
+
<pre class="code"><span class="info file"># File 'lib/option_lab/models.rb', line 713</span>
|
480
|
+
|
481
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_stock_prices'>stock_prices</span>
|
482
|
+
<span class='ivar'>@stock_prices</span>
|
483
|
+
<span class='kw'>end</span></pre>
|
484
|
+
</td>
|
485
|
+
</tr>
|
486
|
+
</table>
|
487
|
+
</div>
|
488
|
+
|
489
|
+
</div>
|
490
|
+
|
491
|
+
|
492
|
+
<div id="instance_method_details" class="method_details_list">
|
493
|
+
<h2>Instance Method Details</h2>
|
494
|
+
|
495
|
+
|
496
|
+
<div class="method_details first">
|
497
|
+
<h3 class="signature first" id="diagram_data-instance_method">
|
498
|
+
|
499
|
+
#<strong>diagram_data</strong> ⇒ <tt>Object</tt>
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
</h3><div class="docstring">
|
506
|
+
<div class="discussion">
|
507
|
+
<p>Get data for rendering a tree diagram</p>
|
508
|
+
|
509
|
+
|
510
|
+
</div>
|
511
|
+
</div>
|
512
|
+
<div class="tags">
|
513
|
+
|
514
|
+
|
515
|
+
</div><table class="source_code">
|
516
|
+
<tr>
|
517
|
+
<td>
|
518
|
+
<pre class="lines">
|
519
|
+
|
520
|
+
|
521
|
+
724
|
522
|
+
725
|
523
|
+
726
|
524
|
+
727
|
525
|
+
728
|
526
|
+
729
|
527
|
+
730
|
528
|
+
731
|
529
|
+
732
|
530
|
+
733
|
531
|
+
734
|
532
|
+
735
|
533
|
+
736
|
534
|
+
737
|
535
|
+
738
|
536
|
+
739
|
537
|
+
740
|
538
|
+
741
|
539
|
+
742
|
540
|
+
743
|
541
|
+
744
|
542
|
+
745
|
543
|
+
746
|
544
|
+
747</pre>
|
545
|
+
</td>
|
546
|
+
<td>
|
547
|
+
<pre class="code"><span class="info file"># File 'lib/option_lab/models.rb', line 724</span>
|
548
|
+
|
549
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_diagram_data'>diagram_data</span>
|
550
|
+
<span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
551
|
+
|
552
|
+
<span class='comment'># Process each step in the tree
|
553
|
+
</span> <span class='id identifier rubyid_stock_prices'>stock_prices</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='period'>.</span><span class='id identifier rubyid_times'>times</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_step'>step</span><span class='op'>|</span>
|
554
|
+
<span class='id identifier rubyid_step_data'>step_data</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
555
|
+
|
556
|
+
<span class='comment'># Process each node in the current step
|
557
|
+
</span> <span class='lparen'>(</span><span class='id identifier rubyid_step'>step</span> <span class='op'>+</span> <span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_times'>times</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_node'>node</span><span class='op'>|</span>
|
558
|
+
<span class='id identifier rubyid_step_data'>step_data</span> <span class='op'><<</span> <span class='lbrace'>{</span>
|
559
|
+
<span class='label'>stock_price:</span> <span class='id identifier rubyid_stock_prices'>stock_prices</span><span class='lbracket'>[</span><span class='id identifier rubyid_step'>step</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_node'>node</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_round'>round</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span><span class='comma'>,</span>
|
560
|
+
<span class='label'>option_value:</span> <span class='id identifier rubyid_option_values'>option_values</span><span class='lbracket'>[</span><span class='id identifier rubyid_step'>step</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_node'>node</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_round'>round</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span><span class='comma'>,</span>
|
561
|
+
<span class='label'>exercise:</span> <span class='id identifier rubyid_exercise_flags'>exercise_flags</span><span class='lbracket'>[</span><span class='id identifier rubyid_step'>step</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_node'>node</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
562
|
+
<span class='rbrace'>}</span>
|
563
|
+
<span class='kw'>end</span>
|
564
|
+
|
565
|
+
<span class='id identifier rubyid_data'>data</span> <span class='op'><<</span> <span class='id identifier rubyid_step_data'>step_data</span>
|
566
|
+
<span class='kw'>end</span>
|
567
|
+
|
568
|
+
<span class='lbrace'>{</span>
|
569
|
+
<span class='label'>tree:</span> <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span>
|
570
|
+
<span class='label'>parameters:</span> <span class='id identifier rubyid_parameters'>parameters</span><span class='comma'>,</span>
|
571
|
+
<span class='rbrace'>}</span>
|
572
|
+
<span class='kw'>end</span></pre>
|
573
|
+
</td>
|
574
|
+
</tr>
|
575
|
+
</table>
|
576
|
+
</div>
|
577
|
+
|
578
|
+
<div class="method_details ">
|
579
|
+
<h3 class="signature " id="get_node-instance_method">
|
580
|
+
|
581
|
+
#<strong>get_node</strong>(step, node) ⇒ <tt>Object</tt>
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
|
586
|
+
|
587
|
+
</h3><table class="source_code">
|
588
|
+
<tr>
|
589
|
+
<td>
|
590
|
+
<pre class="lines">
|
591
|
+
|
592
|
+
|
593
|
+
715
|
594
|
+
716
|
595
|
+
717
|
596
|
+
718
|
597
|
+
719
|
598
|
+
720
|
599
|
+
721</pre>
|
600
|
+
</td>
|
601
|
+
<td>
|
602
|
+
<pre class="code"><span class="info file"># File 'lib/option_lab/models.rb', line 715</span>
|
603
|
+
|
604
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_get_node'>get_node</span><span class='lparen'>(</span><span class='id identifier rubyid_step'>step</span><span class='comma'>,</span> <span class='id identifier rubyid_node'>node</span><span class='rparen'>)</span>
|
605
|
+
<span class='lbrace'>{</span>
|
606
|
+
<span class='label'>stock_price:</span> <span class='id identifier rubyid_stock_prices'>stock_prices</span><span class='lbracket'>[</span><span class='id identifier rubyid_step'>step</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_node'>node</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
607
|
+
<span class='label'>option_value:</span> <span class='id identifier rubyid_option_values'>option_values</span><span class='lbracket'>[</span><span class='id identifier rubyid_step'>step</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_node'>node</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
608
|
+
<span class='label'>exercise:</span> <span class='id identifier rubyid_exercise_flags'>exercise_flags</span><span class='lbracket'>[</span><span class='id identifier rubyid_step'>step</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_node'>node</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
609
|
+
<span class='rbrace'>}</span>
|
610
|
+
<span class='kw'>end</span></pre>
|
611
|
+
</td>
|
612
|
+
</tr>
|
613
|
+
</table>
|
614
|
+
</div>
|
615
|
+
|
616
|
+
<div class="method_details ">
|
617
|
+
<h3 class="signature " id="to_csv-instance_method">
|
618
|
+
|
619
|
+
#<strong>to_csv</strong> ⇒ <tt>Object</tt>
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
|
624
|
+
|
625
|
+
</h3><div class="docstring">
|
626
|
+
<div class="discussion">
|
627
|
+
<p>Export tree data to CSV format</p>
|
628
|
+
|
629
|
+
|
630
|
+
</div>
|
631
|
+
</div>
|
632
|
+
<div class="tags">
|
633
|
+
|
634
|
+
|
635
|
+
</div><table class="source_code">
|
636
|
+
<tr>
|
637
|
+
<td>
|
638
|
+
<pre class="lines">
|
639
|
+
|
640
|
+
|
641
|
+
750
|
642
|
+
751
|
643
|
+
752
|
644
|
+
753
|
645
|
+
754
|
646
|
+
755
|
647
|
+
756
|
648
|
+
757
|
649
|
+
758
|
650
|
+
759
|
651
|
+
760
|
652
|
+
761
|
653
|
+
762</pre>
|
654
|
+
</td>
|
655
|
+
<td>
|
656
|
+
<pre class="code"><span class="info file"># File 'lib/option_lab/models.rb', line 750</span>
|
657
|
+
|
658
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_csv'>to_csv</span>
|
659
|
+
<span class='id identifier rubyid_csv'>csv</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Step,Node,StockPrice,OptionValue,Exercise\n</span><span class='tstring_end'>"</span></span>
|
660
|
+
|
661
|
+
<span class='comment'># Process each step in the tree
|
662
|
+
</span> <span class='id identifier rubyid_stock_prices'>stock_prices</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='period'>.</span><span class='id identifier rubyid_times'>times</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_step'>step</span><span class='op'>|</span>
|
663
|
+
<span class='comment'># Process each node in the current step
|
664
|
+
</span> <span class='lparen'>(</span><span class='id identifier rubyid_step'>step</span> <span class='op'>+</span> <span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_times'>times</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_node'>node</span><span class='op'>|</span>
|
665
|
+
<span class='id identifier rubyid_csv'>csv</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_step'>step</span><span class='embexpr_end'>}</span><span class='tstring_content'>,</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_node'>node</span><span class='embexpr_end'>}</span><span class='tstring_content'>,</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_stock_prices'>stock_prices</span><span class='lbracket'>[</span><span class='id identifier rubyid_step'>step</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_node'>node</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>,</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option_values'>option_values</span><span class='lbracket'>[</span><span class='id identifier rubyid_step'>step</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_node'>node</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>,</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_exercise_flags'>exercise_flags</span><span class='lbracket'>[</span><span class='id identifier rubyid_step'>step</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_node'>node</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span>
|
666
|
+
<span class='kw'>end</span>
|
667
|
+
<span class='kw'>end</span>
|
668
|
+
|
669
|
+
<span class='id identifier rubyid_csv'>csv</span>
|
670
|
+
<span class='kw'>end</span></pre>
|
671
|
+
</td>
|
672
|
+
</tr>
|
673
|
+
</table>
|
674
|
+
</div>
|
675
|
+
|
676
|
+
</div>
|
677
|
+
|
678
|
+
</div>
|
679
|
+
|
680
|
+
<div id="footer">
|
681
|
+
Generated on Sun Apr 27 16:09:34 2025 by
|
682
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
683
|
+
0.9.37 (ruby-3.3.3).
|
684
|
+
</div>
|
685
|
+
|
686
|
+
</div>
|
687
|
+
</body>
|
688
|
+
</html>
|