manage bookmarks, bugfixes
[smr.git] / gui / lib / smr / extensions / security_typemodel_mandatory_methods.rb
blob82d5018460209eec72c3a2343a18073eceda98d1
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
7 # version.
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
24     ##
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?,
30         :accrued_interest,
31     ]
33     ##
34     # Human readable String describing the typemodel.
35     def describe
36         ''
37     end
39     ##
40     # Number of tradable units in existance.
41     def shares
42         0
43     end
45     ##
46     # Current Yield. Based on last known Quote unless some other Quote is given.
47     def current_yield(quote=false)
48         false
49     end
51     ##
52     # Yield to next Call. Based on last known Quote unless some other Quote is given.
53     def yield_to_call(quote=false)
54         false
55     end
57     ##
58     # Yield to final Maturity. Based on last known Quote unless some other Quote is given.
59     def yield_to_maturity(quote=false)
60         false
61     end
63     ##
64     # Tell whether the Security is expired at given :date by inspection information known
65     # by the type model.
66     def is_expired?(date=Time.now)
67         false
68     end
70     ##
71     # Returns Smr::CashflowStream.
72     def cashflow(options={:start_date=>false, :end_date=>false, :amount=>false, :type=>:none, :item_link=>false})
73         Array.new
74     end
76     ##
77     # Tell whether multiple payments can be expected within a fiscal year.
78     def has_subannual_payments?
79         false
80     end
82     ##
83     # Interest accrued since last payment prior given :date.
84     def accrued_interest(date=Time.now)
85         0
86     end
88 end