bond_calculator 0.0.2
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/.gitignore +17 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +7 -0
- data/README.md +78 -0
- data/Rakefile +13 -0
- data/bin/console +10 -0
- data/bond_calculator.gemspec +30 -0
- data/doc/BondCalculator.html +140 -0
- data/doc/BondCalculator/BaseCalculator.html +480 -0
- data/doc/BondCalculator/Bond.html +693 -0
- data/doc/BondCalculator/SpreadToBenchmark.html +567 -0
- data/doc/BondCalculator/SpreadToCurve.html +475 -0
- data/doc/_index.html +143 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +492 -0
- data/doc/file.README.html +133 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +133 -0
- data/doc/js/app.js +248 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +155 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/bond_calculator.rb +7 -0
- data/lib/bond_calculator/base_calculator.rb +37 -0
- data/lib/bond_calculator/bond.rb +48 -0
- data/lib/bond_calculator/spread_to_benchmark.rb +77 -0
- data/lib/bond_calculator/spread_to_curve.rb +64 -0
- data/lib/bond_calculator/version.rb +5 -0
- data/test/bond_calculator/base_calculator_test.rb +31 -0
- data/test/bond_calculator/bond_calculator_test.rb +9 -0
- data/test/bond_calculator/bond_test.rb +24 -0
- data/test/bond_calculator/spread_to_benchmark_test.rb +33 -0
- data/test/bond_calculator/spread_to_curve_test.rb +37 -0
- data/test/fixtures/c1.csv +4 -0
- data/test/fixtures/c2.csv +14 -0
- data/test/test_helper.rb +7 -0
- metadata +191 -0
@@ -0,0 +1,475 @@
|
|
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: BondCalculator::SpreadToCurve
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.9
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "BondCalculator::SpreadToCurve";
|
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 (S)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../BondCalculator.html" title="BondCalculator (module)">BondCalculator</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">SpreadToCurve</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: BondCalculator::SpreadToCurve
|
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="BaseCalculator.html" title="BondCalculator::BaseCalculator (class)">BaseCalculator</a></span></span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next"><span class='object_link'><a href="BaseCalculator.html" title="BondCalculator::BaseCalculator (class)">BaseCalculator</a></span></li>
|
78
|
+
|
79
|
+
<li class="next">BondCalculator::SpreadToCurve</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/bond_calculator/spread_to_curve.rb</dd>
|
100
|
+
</dl>
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
<h2>Overview</h2><div class="docstring">
|
105
|
+
<div class="discussion">
|
106
|
+
|
107
|
+
<p>Class that handle the calculation of the spread to curve</p>
|
108
|
+
|
109
|
+
<p>Since the corporate bond term is not exactly the same as its benchmark
|
110
|
+
term, we use linear interpolation to calculate the spread to the curve.</p>
|
111
|
+
|
112
|
+
|
113
|
+
</div>
|
114
|
+
</div>
|
115
|
+
<div class="tags">
|
116
|
+
|
117
|
+
|
118
|
+
</div>
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
123
|
+
<ul class="summary">
|
124
|
+
|
125
|
+
<li class="public ">
|
126
|
+
<span class="summary_signature">
|
127
|
+
|
128
|
+
<a href="#bonds-instance_method" title="#bonds (instance method)">#<strong>bonds</strong> ⇒ Object </a>
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
</span>
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
<span class="note title readonly">readonly</span>
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
<span class="summary_desc"><div class='inline'>
|
148
|
+
<p>Returns the value of attribute bonds.</p>
|
149
|
+
</div></span>
|
150
|
+
|
151
|
+
</li>
|
152
|
+
|
153
|
+
|
154
|
+
</ul>
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
<h2>
|
161
|
+
Instance Method Summary
|
162
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
163
|
+
</h2>
|
164
|
+
|
165
|
+
<ul class="summary">
|
166
|
+
|
167
|
+
<li class="public ">
|
168
|
+
<span class="summary_signature">
|
169
|
+
|
170
|
+
<a href="#calculate-instance_method" title="#calculate (instance method)">#<strong>calculate</strong> ⇒ Hash </a>
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
</span>
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
<span class="summary_desc"><div class='inline'>
|
185
|
+
<p>Execute the bussines rule to calculate the spread to curve.</p>
|
186
|
+
</div></span>
|
187
|
+
|
188
|
+
</li>
|
189
|
+
|
190
|
+
|
191
|
+
<li class="public ">
|
192
|
+
<span class="summary_signature">
|
193
|
+
|
194
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(bond_file_path) ⇒ <void> </a>
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
</span>
|
199
|
+
|
200
|
+
|
201
|
+
<span class="note title constructor">constructor</span>
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
211
|
+
|
212
|
+
</li>
|
213
|
+
|
214
|
+
|
215
|
+
</ul>
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="BaseCalculator.html" title="BondCalculator::BaseCalculator (class)">BaseCalculator</a></span></h3>
|
228
|
+
<p class="inherited"><span class='object_link'><a href="BaseCalculator.html#bonds_by_type-instance_method" title="BondCalculator::BaseCalculator#bonds_by_type (method)">#bonds_by_type</a></span>, <span class='object_link'><a href="BaseCalculator.html#csv_to_bonds-instance_method" title="BondCalculator::BaseCalculator#csv_to_bonds (method)">#csv_to_bonds</a></span></p>
|
229
|
+
<div id="constructor_details" class="method_details_list">
|
230
|
+
<h2>Constructor Details</h2>
|
231
|
+
|
232
|
+
<div class="method_details first">
|
233
|
+
<h3 class="signature first" id="initialize-instance_method">
|
234
|
+
|
235
|
+
#<strong>initialize</strong>(bond_file_path) ⇒ <tt><void></tt>
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
</h3><div class="docstring">
|
242
|
+
<div class="discussion">
|
243
|
+
|
244
|
+
|
245
|
+
</div>
|
246
|
+
</div>
|
247
|
+
<div class="tags">
|
248
|
+
<p class="tag_title">Parameters:</p>
|
249
|
+
<ul class="param">
|
250
|
+
|
251
|
+
<li>
|
252
|
+
|
253
|
+
<span class='name'>bond_file_path</span>
|
254
|
+
|
255
|
+
|
256
|
+
<span class='type'>(<tt>File</tt>)</span>
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
—
|
261
|
+
<div class='inline'>
|
262
|
+
<p>Csv curve file path</p>
|
263
|
+
</div>
|
264
|
+
|
265
|
+
</li>
|
266
|
+
|
267
|
+
</ul>
|
268
|
+
|
269
|
+
|
270
|
+
</div><table class="source_code">
|
271
|
+
<tr>
|
272
|
+
<td>
|
273
|
+
<pre class="lines">
|
274
|
+
|
275
|
+
|
276
|
+
18
|
277
|
+
19
|
278
|
+
20</pre>
|
279
|
+
</td>
|
280
|
+
<td>
|
281
|
+
<pre class="code"><span class="info file"># File 'lib/bond_calculator/spread_to_curve.rb', line 18</span>
|
282
|
+
|
283
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_bond_file_path'>bond_file_path</span><span class='rparen'>)</span>
|
284
|
+
<span class='ivar'>@bonds</span> <span class='op'>=</span> <span class='id identifier rubyid_csv_to_bonds'>csv_to_bonds</span><span class='lparen'>(</span><span class='id identifier rubyid_bond_file_path'>bond_file_path</span><span class='rparen'>)</span>
|
285
|
+
<span class='kw'>end</span></pre>
|
286
|
+
</td>
|
287
|
+
</tr>
|
288
|
+
</table>
|
289
|
+
</div>
|
290
|
+
|
291
|
+
</div>
|
292
|
+
|
293
|
+
<div id="instance_attr_details" class="attr_details">
|
294
|
+
<h2>Instance Attribute Details</h2>
|
295
|
+
|
296
|
+
|
297
|
+
<span id=""></span>
|
298
|
+
<div class="method_details first">
|
299
|
+
<h3 class="signature first" id="bonds-instance_method">
|
300
|
+
|
301
|
+
#<strong>bonds</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
</h3><div class="docstring">
|
308
|
+
<div class="discussion">
|
309
|
+
|
310
|
+
<p>Returns the value of attribute bonds</p>
|
311
|
+
|
312
|
+
|
313
|
+
</div>
|
314
|
+
</div>
|
315
|
+
<div class="tags">
|
316
|
+
|
317
|
+
|
318
|
+
</div><table class="source_code">
|
319
|
+
<tr>
|
320
|
+
<td>
|
321
|
+
<pre class="lines">
|
322
|
+
|
323
|
+
|
324
|
+
13
|
325
|
+
14
|
326
|
+
15</pre>
|
327
|
+
</td>
|
328
|
+
<td>
|
329
|
+
<pre class="code"><span class="info file"># File 'lib/bond_calculator/spread_to_curve.rb', line 13</span>
|
330
|
+
|
331
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_bonds'>bonds</span>
|
332
|
+
<span class='ivar'>@bonds</span>
|
333
|
+
<span class='kw'>end</span></pre>
|
334
|
+
</td>
|
335
|
+
</tr>
|
336
|
+
</table>
|
337
|
+
</div>
|
338
|
+
|
339
|
+
</div>
|
340
|
+
|
341
|
+
|
342
|
+
<div id="instance_method_details" class="method_details_list">
|
343
|
+
<h2>Instance Method Details</h2>
|
344
|
+
|
345
|
+
|
346
|
+
<div class="method_details first">
|
347
|
+
<h3 class="signature first" id="calculate-instance_method">
|
348
|
+
|
349
|
+
#<strong>calculate</strong> ⇒ <tt>Hash</tt>
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
</h3><div class="docstring">
|
356
|
+
<div class="discussion">
|
357
|
+
|
358
|
+
<p>Execute the bussines rule to calculate the spread to curve</p>
|
359
|
+
|
360
|
+
|
361
|
+
</div>
|
362
|
+
</div>
|
363
|
+
<div class="tags">
|
364
|
+
|
365
|
+
<p class="tag_title">Returns:</p>
|
366
|
+
<ul class="return">
|
367
|
+
|
368
|
+
<li>
|
369
|
+
|
370
|
+
|
371
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
—
|
376
|
+
<div class='inline'>
|
377
|
+
<p>:bond_name</p>
|
378
|
+
</div>
|
379
|
+
|
380
|
+
</li>
|
381
|
+
|
382
|
+
<li>
|
383
|
+
|
384
|
+
|
385
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
—
|
390
|
+
<div class='inline'>
|
391
|
+
<p>:spread_to_curve</p>
|
392
|
+
</div>
|
393
|
+
|
394
|
+
</li>
|
395
|
+
|
396
|
+
</ul>
|
397
|
+
|
398
|
+
</div><table class="source_code">
|
399
|
+
<tr>
|
400
|
+
<td>
|
401
|
+
<pre class="lines">
|
402
|
+
|
403
|
+
|
404
|
+
25
|
405
|
+
26
|
406
|
+
27
|
407
|
+
28
|
408
|
+
29
|
409
|
+
30
|
410
|
+
31
|
411
|
+
32
|
412
|
+
33
|
413
|
+
34
|
414
|
+
35
|
415
|
+
36
|
416
|
+
37
|
417
|
+
38
|
418
|
+
39
|
419
|
+
40
|
420
|
+
41
|
421
|
+
42
|
422
|
+
43
|
423
|
+
44
|
424
|
+
45
|
425
|
+
46
|
426
|
+
47
|
427
|
+
48
|
428
|
+
49</pre>
|
429
|
+
</td>
|
430
|
+
<td>
|
431
|
+
<pre class="code"><span class="info file"># File 'lib/bond_calculator/spread_to_curve.rb', line 25</span>
|
432
|
+
|
433
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_calculate'>calculate</span>
|
434
|
+
<span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
435
|
+
<span class='id identifier rubyid_corps'>corps</span> <span class='op'>=</span> <span class='id identifier rubyid_bonds_by_type'>bonds_by_type</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>corporate</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='ivar'>@bonds</span><span class='rparen'>)</span>
|
436
|
+
<span class='id identifier rubyid_govs'>govs</span> <span class='op'>=</span> <span class='id identifier rubyid_bonds_by_type'>bonds_by_type</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>government</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='ivar'>@bonds</span><span class='rparen'>)</span>
|
437
|
+
|
438
|
+
<span class='id identifier rubyid_corps'>corps</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_corp'>corp</span><span class='op'>|</span>
|
439
|
+
<span class='id identifier rubyid_upper_bond'>upper_bond</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
440
|
+
<span class='id identifier rubyid_lower_bond'>lower_bond</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
441
|
+
|
442
|
+
<span class='id identifier rubyid_govs'>govs</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_gov'>gov</span><span class='op'>|</span>
|
443
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_corp'>corp</span><span class='period'>.</span><span class='id identifier rubyid_term_years'>term_years</span> <span class='op'><=</span> <span class='id identifier rubyid_gov'>gov</span><span class='period'>.</span><span class='id identifier rubyid_term_years'>term_years</span>
|
444
|
+
<span class='id identifier rubyid_lower_bond'>lower_bond</span> <span class='op'>=</span> <span class='id identifier rubyid_gov'>gov</span>
|
445
|
+
<span class='kw'>break</span>
|
446
|
+
<span class='kw'>else</span>
|
447
|
+
<span class='id identifier rubyid_upper_bond'>upper_bond</span> <span class='op'>=</span> <span class='id identifier rubyid_gov'>gov</span>
|
448
|
+
<span class='kw'>end</span>
|
449
|
+
<span class='kw'>end</span>
|
450
|
+
|
451
|
+
<span class='id identifier rubyid_spread_to_curve'>spread_to_curve</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_corp'>corp</span><span class='period'>.</span><span class='id identifier rubyid_yield_percent'>yield_percent</span> <span class='op'>-</span> <span class='id identifier rubyid_yield_on_curve'>yield_on_curve</span><span class='lparen'>(</span><span class='id identifier rubyid_corp'>corp</span><span class='comma'>,</span> <span class='id identifier rubyid_lower_bond'>lower_bond</span><span class='comma'>,</span> <span class='id identifier rubyid_upper_bond'>upper_bond</span><span class='rparen'>)</span><span class='rparen'>)</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>
|
452
|
+
<span class='id identifier rubyid_response'>response</span> <span class='op'><<</span> <span class='lbrace'>{</span> <span class='label'>bond_name:</span> <span class='id identifier rubyid_corp'>corp</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='label'>spread_to_curve:</span> <span class='id identifier rubyid_spread_to_curve'>spread_to_curve</span> <span class='rbrace'>}</span>
|
453
|
+
<span class='kw'>end</span>
|
454
|
+
<span class='id identifier rubyid_print_response'>print_response</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
|
455
|
+
|
456
|
+
<span class='id identifier rubyid_response'>response</span>
|
457
|
+
<span class='kw'>end</span></pre>
|
458
|
+
</td>
|
459
|
+
</tr>
|
460
|
+
</table>
|
461
|
+
</div>
|
462
|
+
|
463
|
+
</div>
|
464
|
+
|
465
|
+
</div>
|
466
|
+
|
467
|
+
<div id="footer">
|
468
|
+
Generated on Mon Sep 25 23:31:15 2017 by
|
469
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
470
|
+
0.9.9 (ruby-2.4.0).
|
471
|
+
</div>
|
472
|
+
|
473
|
+
</div>
|
474
|
+
</body>
|
475
|
+
</html>
|