Class: Rupee::FixedIncome
- Defined in:
- lib/rupee/fixed_income.rb
Overview
A basic fixed income security that allows the user to specify cash flows, discount curves, payout curves, calendars, currencies, daycounts, roll day conventions, etc.
Instance Attribute Summary collapse
-
#accrual_dates ⇒ Object
readonly
The dates on which accruals start and end.
-
#business_day ⇒ Object
The security’s business day convention.
-
#calendar ⇒ Object
The calendar used for determining holidays.
-
#currency ⇒ Object
The security’s currency.
-
#day_count ⇒ Object
The day count convention for determining payment and accrual dates.
-
#first_coupon ⇒ Object
readonly
The date of the first coupon payment, if the security has irregular cash flows.
-
#frequency ⇒ Object
The frequency of payment periods.
-
#last_coupon ⇒ Object
readonly
The date of the last coupon payment, if the security has irregular cash flows.
-
#maturity ⇒ Object
readonly
The maturity date of the security.
-
#payment_dates ⇒ Object
readonly
The dates on which payments occur.
-
#periods ⇒ Object
readonly
The periods in years between accrual dates.
-
#settlement ⇒ Object
readonly
The settlement or issuance date of the security.
-
#start_date ⇒ Object
readonly
The start date for accruals.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ FixedIncome
constructor
Build a custom security.
Methods inherited from Security
Constructor Details
#initialize(opts = {}) ⇒ FixedIncome
Build a custom security
Configuration options
-
:business_day
- The security’s business day convention, used to determine when the next business day is relative to the calendar in use (default is :modified_following)-
:actual
- The actual day, regardless of whether it’s a business day -
:following
- The following business day -
:modified_following
- The following business day unless it occurs in the following month, in which case use the previous business day -
:modified_previous
- The previous business day unless it occurs in the previous month, in which case use the following business day -
:previous
- The previous business day
-
-
:calendar
- The calendar to use for determining holidays and days off (default is:us
)-
:us
- The US Federal Reserve Calendar -
:japan
- The Japanese calendar
-
-
:currency
- (default is:usd
)-
:eur
or:euro
- The euro -
:jpy
or:yen
- The Japanese yen -
:gbp
or:pound
- The British pound sterling -
:usd
or:dollar
- The US dollar
-
-
:day_count
- (default is:thirty_360
)-
:thirty_360
- 30/360 -
:thirty_e_360
- 30E/360 -
:thirty_e_360_isda
- 30E/360 ISDA -
:thirty_e_plus_360
- 30E+/360 -
:act_360
- Act/360 -
:act_365
- Act/365 -
:act_act
- Act/Act
-
For example, the following security types can be created (although not currently priced or anything useful like that):
require "rupee"
# A typical pay-fixed bond
bond = Rupee::FixedIncome.new
# A typical yen LIBOR security
bond = Rupee::FixedIncome.new :calendar => :japan, :currency => :yen,
:day_count => :act_365
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/rupee/fixed_income.rb', line 81 def initialize(opts = {}) opts = { :business_day => :modified_following, :calendar => :us, :currency => :usd, :day_count => :thirty_360, :first_coupon => nil, :frequency => [6, :months], # hands off Rails monkey-patching :last_coupon => nil, :maturity => Date.today.next_year, :settlement => Date.today, :start_date => nil }.merge opts self.business_day = opts[:business_day] self.calendar = opts[:calendar] self.currency = opts[:currency] self.day_count = opts[:day_count] self.frequency = opts[:frequency] @first_coupon = opts[:first_coupon] @last_coupon = opts[:last_coupon] @maturity = opts[:maturity] @settlement = opts[:settlement] @start_date = opts[:start_date] build_dates end |
Instance Attribute Details
#accrual_dates ⇒ Object (readonly)
The dates on which accruals start and end
7 8 9 |
# File 'lib/rupee/fixed_income.rb', line 7 def accrual_dates @accrual_dates end |
#business_day ⇒ Object
The security’s business day convention
9 10 11 |
# File 'lib/rupee/fixed_income.rb', line 9 def business_day @business_day end |
#calendar ⇒ Object
The calendar used for determining holidays
11 12 13 |
# File 'lib/rupee/fixed_income.rb', line 11 def calendar @calendar end |
#currency ⇒ Object
The security’s currency
13 14 15 |
# File 'lib/rupee/fixed_income.rb', line 13 def currency @currency end |
#day_count ⇒ Object
The day count convention for determining payment and accrual dates
15 16 17 |
# File 'lib/rupee/fixed_income.rb', line 15 def day_count @day_count end |
#first_coupon ⇒ Object (readonly)
The date of the first coupon payment, if the security has irregular cash flows
18 19 20 |
# File 'lib/rupee/fixed_income.rb', line 18 def first_coupon @first_coupon end |
#frequency ⇒ Object
The frequency of payment periods
20 21 22 |
# File 'lib/rupee/fixed_income.rb', line 20 def frequency @frequency end |
#last_coupon ⇒ Object (readonly)
The date of the last coupon payment, if the security has irregular cash flows
23 24 25 |
# File 'lib/rupee/fixed_income.rb', line 23 def last_coupon @last_coupon end |
#maturity ⇒ Object (readonly)
The maturity date of the security
25 26 27 |
# File 'lib/rupee/fixed_income.rb', line 25 def maturity @maturity end |
#payment_dates ⇒ Object (readonly)
The dates on which payments occur
27 28 29 |
# File 'lib/rupee/fixed_income.rb', line 27 def payment_dates @payment_dates end |
#periods ⇒ Object (readonly)
The periods in years between accrual dates
29 30 31 |
# File 'lib/rupee/fixed_income.rb', line 29 def periods @periods end |
#settlement ⇒ Object (readonly)
The settlement or issuance date of the security
31 32 33 |
# File 'lib/rupee/fixed_income.rb', line 31 def settlement @settlement end |
#start_date ⇒ Object (readonly)
The start date for accruals
33 34 35 |
# File 'lib/rupee/fixed_income.rb', line 33 def start_date @start_date end |