2 # This file is part of SMR.
4 # SMR is free software: you can redistribute it and/or modify it under the
5 # terms of the GNU General Public License as published by the Free Software
6 # Foundation, either version 3 of the License, or (at your option) any later
9 # SMR is distributed in the hope that it will be useful, but WITHOUT ANY
10 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License along with
14 # SMR. If not, see <http://www.gnu.org/licenses/>.
18 # Mandatory methods for mixing into Security typemodels.
20 # This just makes the methods present, it does NOT implement them. Its up to
21 # the typemodels to implement something that produces a result.
22 module Smr::Extensions::SecurityTypemodelMandatoryMethods
25 # static definition of whats provided
26 MANDATORY_TYPE_METHODS = [
27 :describe, :is_expired?,
28 :current_yield, :yield_to_call, :yield_to_maturity,
29 :shares, :cashflow, :cashflow_this_year, :has_subannual_payments?,
34 # Human readable String describing the typemodel.
40 # Number of tradable units in existance.
46 # Current Yield. Based on last known Quote unless some other Quote is given.
47 def current_yield(quote=false)
52 # Yield to next Call. Based on last known Quote unless some other Quote is given.
53 def yield_to_call(quote=false)
58 # Yield to final Maturity. Based on last known Quote unless some other Quote is given.
59 def yield_to_maturity(quote=false)
64 # Tell whether the Security is expired at given :date by inspection information known
66 def is_expired?(date=Time.now)
71 # Returns Smr::CashflowStream.
72 def cashflow(options={:start_date=>false, :end_date=>false, :amount=>false, :type=>:none, :item_link=>false})
77 # Tell whether multiple payments can be expected within a fiscal year.
78 def has_subannual_payments?
83 # Interest accrued since last payment prior given :date.
84 def accrued_interest(date=Time.now)