1 PACKAGE XTR_MM_FORMULAS AS
2 /* $Header: xtrmmfls.pls 120.1 2005/06/29 11:18:53 rjose ship $ */
3
4 /*--------------------------------------------------------------------------
5 BLACK_OPTION_PRICE Calculates the price/sensitivities of the interest rate option price using Blacks Formula.(Hull's 4th Edition p.540, p.317)
6
7 black_opt_in_rec_typ:
8 IN: P_PRINCIPAL num
9 P_INT_RATE num
10 P_FORWARD_RATE num
11 P_T1 num
12 P_T2 num
13 P_T2_INT_RATE num
14 P_VOLATILITY num
15 black_opt_out_rec_typ:
16 OUT: P_CAPLET_PRICE num
17 P_FLOORLET_PRICE num
18 P_ND1 num
19 P_ND2 num
20 P_ND1_A num
21 P_ND2_A num
22
23 Assumption: Annual Basis = 360
24 Continuous interest rate is required
25
26 Call XTR_RATE_CONVERSION.rate_conversion to convert day counts and/or between compounded and simple interest rates.
27
28 P_PRINCIPAL = the principal amount from which the interest rate is calculated
29 P_INT_RATE = strike price = interest rate for the deal
30 P_FORWARD_RATE = market forward rate for the period of the deal
31 P_T1 = number of days to the start date when the deal becomes effective.
32 P_T2 = number of days to the end date when the deal matures
33 p_T2_INT_RATE = current interest rate until the maturity date
34 P_VOLATILITY = volatility of interest rate per annum
35 P_CAPLET_PRICE = interest rate collars
36 P_FLOORLET_PRICE = interest rate floors(CAPLET_PRICE = FLOORLET_PRICE + SWAP_VALUE)
37 P_ND1/2 = cumulative normal probability distribution value = N(x) in Black Formula
38 P_ND1/2_A = N'(x) in Black Formula
39 --------------------------------------------------------------------------*/
40 -- modified fhu 6/20/01
41 TYPE black_opt_in_rec_type is RECORD (p_principal NUMBER,
42 p_int_rate NUMBER,
43 p_forward_rate NUMBER,
44 p_t1 NUMBER,
45 p_t2 NUMBER,
46 p_t2_int_rate NUMBER,
47 p_volatility NUMBER);
48
49 TYPE black_opt_out_rec_type is RECORD (p_caplet_price NUMBER,
50 p_floorlet_price NUMBER,
51 p_nd1 NUMBER,
52 p_nd2 NUMBER,
53 p_nd1_a NUMBER,
54 p_nd2_a NUMBER);
55
56
57 /*---------------------------------------------------------------------------
58 --addition by prafiuly 02/01/01
59 --Find Cumulative Normal Distribution,precision up to 6 decimal places
60 --from Hull's Fourth Edition p.252
61 cum_normdist_in_rec_type:
62 p_d1 = the value of d1 from Black's formula
63 p_d2 = the value of d2 from Black's formula
64 cum_normdist_out_rec_type:
65 p_n_d1 = the cumulative normal distribution given p_d1
66 p_n_d2 = the cumulative normal distribution given p_d2
67 p_n_d1_a
68 p_n_d2_a
69 ----------------------------------------------------------------------------*/
70 TYPE cum_normdist_in_rec_type is RECORD (p_d1 NUMBER,
71 p_d2 NUMBER);
72
73 TYPE cum_normdist_out_rec_type is RECORD (p_n_d1 NUMBER,
74 p_n_d2 NUMBER,
75 p_n_d1_a NUMBER,
76 p_n_d2_a NUMBER);
77
78
79
80 --
81 -- Calculates the value of $1 after DAY_COUNT period given the
82 -- ANNUAL_BASIS and Annual Rate (RATE).
83 --
84 -- * P_RATE = the annual rate.
85 -- * P_DAY_COUNT = the number of days for which the GROWTH_FACTOR
86 -- is calculated
87 -- * P_ANNUAL_BASIS = number of days in a year where the RATE and the
88 -- DAY_COUNT are based on
89 -- * P_GROWTH_FAC = the value of $1 after DAY_COUNT period given the
90 -- ANNUAL_BASIS and Annual Rate (RATE).
91 --
92 PROCEDURE growth_factor(p_rate IN NUMBER,
93 p_day_count IN NUMBER,
94 p_annual_basis IN NUMBER,
95 p_growth_fac IN OUT NOCOPY NUMBER);
96
97
98
99 --
100 -- Calculates the PRESENT_VALUE given the discount rate as inputs.
101 --
102 -- * P_FUTURE_VALUE = the amount at maturity (i.e. Maturity Amount in
103 -- Discounted Securities Calculator HLD).
104 -- * P_DISCOUNT_RATE = the return in a discounted security as an
105 -- annualized percentage of the future amount.
106 -- * P_PRESENT_VALUE = the fair value of the discounted security.
107 -- * P_DAY_COUNT = number of days between the PRESENT_VALUE date and
108 -- FUTURE_VALUE date. (For example: DAY_COUNT = Maturity Date -
109 -- Settlement Date in Discounted Securities Calculator HLD).
110 -- * P_ANNUAL_BASIS = number of days in a year where the RATE and the
111 -- DAY_COUNT are based on.
112 --
113 -- ######################################################################
114 -- # #
115 -- # WARNING!!!!! The procedure should never be called directly, please #
116 -- # call xtr_mm_covers.present_value instead. #
117 -- # #
118 -- ######################################################################
119 --
120 PROCEDURE present_value_discount_rate(p_future_value IN NUMBER,
121 p_discount_rate IN NUMBER,
122 p_day_count IN NUMBER,
123 p_annual_basis IN NUMBER,
124 p_present_value IN OUT NOCOPY NUMBER);
125
126
127
128
129 --
130 -- Calculates the PRESENT_VALUE given the yield rate as inputs.
131 --
132 -- * P_FUTURE_VALUE = the amount at maturity
133 -- * P_YIELD_RATE = the return in a discounted security as an
134 -- annualized percentage of the current amount.
135 -- * P_PRESENT_VALUE = the fair value of the discounted security.
136 -- * P_DAY_COUNT = number of days between the PRESENT_VALUE date
137 -- and FUTURE_VALUE date.
138 -- * P_ANNUAL_BASIS = number of days in a year where the RATE and
139 -- the DAY_COUNT are based on.
140 --
141 -- ######################################################################
142 -- # #
143 -- # WARNING!!!!! The procedure should never be called directly, please #
144 -- # call xtr_mm_covers.present_value instead. #
145 -- # #
146 -- ######################################################################
147 --
148 PROCEDURE present_value_yield_rate(p_future_value IN NUMBER,
149 p_yield_rate IN NUMBER,
150 p_day_count IN NUMBER,
151 p_annual_basis IN NUMBER,
152 p_present_value IN OUT NOCOPY NUMBER);
153
154
155
156 --
157 -- * P_FUTURE_VALUE = the amount at maturity (i.e. Maturity Amount in
158 -- Discounted Securities Calculator HLD).
159 -- * P_YIELD_RATE = the return in a discounted security as an annualized
160 -- percentage of the current amount.
161 -- * P_PRESENT_VALUE = the fair value of the discounted security.
162 -- * P_DAY_COUNT = number of days between the PRESENT_VALUE date and
163 -- FUTURE_VALUE date. (For example: DAY_COUNT = Maturity Date - Settlement
164 -- Date in Discounted Securities Calculator HLD).
165 -- * P_ANNUAL_BASIS = number of days in a year where the RATE and the
166 -- DAY_COUNT are based on.
167 --
168 -- ######################################################################
169 -- # #
170 -- # WARNING!!!!! The procedure should never be called directly, please #
171 -- # call xtr_mm_covers.future_value instead. #
172 -- # #
173 -- ######################################################################
174 --
175 PROCEDURE future_value_yield_rate(p_present_value IN NUMBER,
176 p_yield_rate IN NUMBER,
177 p_day_count IN NUMBER,
178 p_annual_basis IN NUMBER,
179 p_future_value IN OUT NOCOPY NUMBER);
180
181
182
183 --
184 -- Calculates the FUTURE_VALUE given the discount rate as inputs.
185 --
186 -- * P_FUTURE_VALUE = the amount at maturity
187 -- * P_PRESENT_VALUE = the fair value of the discounted security.
188 -- * P_DISCOUNT_RATE = the return in a discounted security as an annualized
189 -- percentage of the future amount.
190 -- * P_DAY_COUNT = number of days between the PRESENT_VALUE date and
191 -- FUTURE_VALUE date.
192 -- * P_ANNUAL_BASIS = number of days in a year where the RATE and the
193 -- DAY_COUNT are based on.
194 --
195 -- ######################################################################
196 -- # #
197 -- # WARNING!!!!! The procedure should never be called directly, please #
198 -- # call xtr_mm_covers.present_value instead. #
199 -- # #
200 -- ######################################################################
201 --
202 PROCEDURE future_value_discount_rate(p_present_value IN NUMBER,
203 p_discount_rate IN NUMBER,
204 p_day_count IN NUMBER,
205 p_annual_basis IN NUMBER,
206 p_future_value IN OUT NOCOPY NUMBER);
207
208
209 --
210 -- Calculates FRA Price (=Contract Rate) as defined in FRA Calculator HLD
211 --
212 --
213 -- * p_t = number of days from today to start date
214 -- * P_T1 = number of days from today to maturity date
215 -- * P_Rt = annual interest rate for maturity t days
216 -- * P_RT1 = annual interest rate for maturity T1 days
217 -- *** Assumed: Rt and RT1 have the same day count basis.
218 -- * p_year_basis = number of days in a year the interest rate is based on.
219 -- * p_fra_rate = fair contract rate of FRA (forward interest rate covering
220 -- from the Start Date to the Maturity Date).
221 --
222 PROCEDURE fra_price(p_t IN NUMBER,
223 p_T1 IN NUMBER,
224 p_Rt IN NUMBER,
225 p_Rt1 IN NUMBER,
226 p_year_basis IN NUMBER,
227 p_fra_rate IN OUT NOCOPY NUMBER);
228
229
230 --
231 -- Calculates the FRA Settlement Amount in FRA Calculator when the input
232 -- parameter is set to 'Discount'.
233 --
234 -- * P_FRA_PRICE = fra_rate = fair contract rate of FRA (forward interest
235 -- rate covering from the Start Date to the Maturity Date of the contract).
236 -- * P_SETTLEMENT_RATE = current market annual interest rate.
237 -- * P_FACE_VALUE = notional principal amount of FRA.
238 -- * P_DAY_COUNT = number of days between the Settlement Date to Maturity Date.
239 -- * P_ANNUAL_BASIS = number of days in a year the SETTLEMENT_RATE and
240 -- DAY_COUNT are based on.
241 -- * P_SETTLEMENT_AMOUNT = absolute profit or loss amount
242 --
243 -- ######################################################################
244 -- # #
245 -- # WARNING!!!!! The procedure should never be called directly, please #
246 -- # call xtr_mm_covers.fra_settlement_amount instead. #
247 -- # #
248 -- ######################################################################
249 --
250 PROCEDURE fra_settlement_amount_discount(
251 p_fra_price IN NUMBER,
252 p_settlement_rate IN NUMBER,
253 p_face_value IN NUMBER,
254 p_day_count IN NUMBER,
255 p_annual_basis IN NUMBER,
256 p_settlement_amount IN OUT NOCOPY NUMBER);
257
258
259
260 --
261 -- Calculates the FRA Settlement Amount in FRA Calculator when the input
262 -- parameter is set to 'Yield'.
263 --
264 -- * P_FRA_PRICE = fra_rate = fair contract rate of FRA (forward interest
265 -- rate covering from the Start Date to the Maturity Date of the contract).
266 -- * P_SETTLEMENT_RATE = current market annual interest rate.
267 -- * P_FACE_VALUE = notional principal amount of FRA.
268 -- * P_DAY_COUNT = number of days between the Settlement Date to Maturity Date.
269 -- * P_ANNUAL_BASIS = number of days in a year the SETTLEMENT_RATE and
270 -- DAY_COUNT are based on.
271 -- * P_SETTLEMENT_AMOUNT = absolute profit or loss amount
272 --
273 -- ######################################################################
274 -- # #
275 -- # WARNING!!!!! The procedure should never be called directly, please #
276 -- # call xtr_mm_covers.fra_settlement_amount instead. #
277 -- # #
278 -- ######################################################################
279 --
280 PROCEDURE fra_settlement_amount_yield(p_fra_price IN NUMBER,
281 p_settlement_rate IN NUMBER,
282 p_face_value IN NUMBER,
283 p_day_count IN NUMBER,
284 p_annual_basis IN NUMBER,
285 p_settlement_amount IN OUT NOCOPY NUMBER);
286
287
288
289 --
290 -- Calculates the price of a generic option.
291 --
292 -- * time_in_days = time left to maturity in days
293 -- * int_rate = annual risk free interest rate.
294 -- * market_price = the current market price of the commodity
295 -- * strike_price = the strike price agreed in the option.
296 -- * vol = volatility
297 -- * l_call_price = theoretical fair value of the call.
298 -- * L_put_price = theoretical fair value of the put
299 -- * l_delta_call/put = delta of the call/put
300 -- * l_theta_call/put = theta of the call/put
301 -- * l_rho_call/put = rho of the call/put
302 -- * l_gamma = gamma
303 -- * l_vega = vega
304 --
305 -- gamma, theta, delta, vega are sensitivity measurements of the model
306 -- relatives to its different variables and explained extensively in Hull's
307 -- Option, Future, and Other Derivatives.
308 --
309 PROCEDURE bs_option_price(time_in_days IN NUMBER,
310 int_rate IN NUMBER,
311 market_price IN NUMBER,
312 strike_price IN NUMBER,
313 vol IN NUMBER,
314 l_delta_call IN OUT NOCOPY NUMBER,
315 l_delta_put IN OUT NOCOPY NUMBER,
316 l_theta_call IN OUT NOCOPY NUMBER,
317 l_theta_put IN OUT NOCOPY NUMBER,
318 l_rho_call IN OUT NOCOPY NUMBER,
319 l_rho_put IN OUT NOCOPY NUMBER,
320 l_gamma IN OUT NOCOPY NUMBER,
321 l_vega IN OUT NOCOPY NUMBER,
322 l_call_price IN OUT NOCOPY NUMBER,
323 l_put_price IN OUT NOCOPY NUMBER);
324
325
326
327 --
328 -- Calculates the cashflow given the coupon rate.
329 --
330 -- * PRINCIPAL_AMOUNT = the face value from which the cash flows are generated.
331 -- * P_RATE is the annual coupon rate.
332 -- * P_DAY_COUNT = number of days from the spot date/current date to the cash
333 -- flow payment date. (For example: DAY_COUNT = Maturity Date - Spot Date,
334 -- in IRS HLD).
335 -- * P_ANNUAL_BASIS = number of days in a year from which the DAY_COUNT and
336 -- RATE are based on.
337 --
338 PROCEDURE coupon_cashflow(p_principal_amount IN NUMBER,
339 p_rate IN NUMBER,
340 p_day_count IN NUMBER,
341 p_annual_basis IN NUMBER,
345
342 p_cashflow_value IN OUT NOCOPY NUMBER);
343
344
346 --
347 -- Calculates the present value given the discount factor.
348 --
349 -- * P_DISCOUNT_FACTOR = a number between 0 and 1 that is use to calculate
350 -- the present value as a function of interest rate.
351 -- * P_FUTURE_VALUE = the amount at maturity.
352 -- * P_PRESENT_VALUE = the fair value of the discounted security.
353 --
354 PROCEDURE present_value_discount_factor(p_discount_factor IN NUMBER,
355 p_future_value IN NUMBER,
356 p_present_value IN OUT NOCOPY NUMBER);
357
358
359 --
360 -- addition by prafiuly 12/18/2000
361 -- BLACK_OPTION_PRICE Calculates the price of the interest rate option
362 -- price using Blacks Formula.(Hull's 4th Edition p.540)
363
364
365 -- modified by fhu 6/12/01
366 PROCEDURE black_option_price(p_in_rec IN black_opt_in_rec_type,
367 p_out_rec IN OUT NOCOPY black_opt_out_rec_type);
368
369 --addition by prafiuly 02/01/01
370 --Find Cumulative Normal Distribution,precision up to 6 decimal places
371 --from Hull's Fourth Edition p.252
372 --
373 PROCEDURE cumulative_norm_distribution (
374 p_in_rec IN cum_normdist_in_rec_type,
375 p_out_rec IN OUT NOCOPY cum_normdist_out_rec_type);
376
377
378 --
379 -- Calculates FRA Price (=Contract Rate) for compounded interest where
380 -- t2-t1 >= N
381 -- as defined in Market Data Curves HLD
382 --
383 --
384 -- * p_t = number of days from today to start date
385 -- * P_T1 = number of days from today to maturity date
386 -- * P_Rt = annual interest rate for maturity t days
387 -- * P_RT1 = annual interest rate for maturity T1 days
388 -- *** Assumed: Rt and RT1 have the same day count basis.
389 -- * p_year_basis = number of days in a year the interest rate is based on.
390 -- * p_fra_rate = fair contract rate of FRA (forward interest rate covering
391 -- from the Start Date to the Maturity Date).
392 --
393 PROCEDURE fra_price_long(p_t IN NUMBER,
394 p_T1 IN NUMBER,
395 p_Rt IN NUMBER,
396 p_Rt1 IN NUMBER,
397 p_year_basis IN NUMBER,
398 p_fra_rate IN OUT NOCOPY NUMBER);
399
400
401 --
402 -- Calculates FRA Price (=Contract Rate) using discount factor as input rates
403 -- as defined in Market Data Curves HLD
404 --
405 --
406 -- * p_t = number of days from today to start date
407 -- * P_T1 = number of days from today to maturity date
408 -- * P_Rt = discount factor for maturity t days
409 -- * P_RT1 = discount factor for maturity T1 days
410 -- *** Assumed: Rt and RT1 have the same day count basis.
411 -- * p_year_basis = number of days in a year the interest rate is based on.
412 -- * p_fra_rate = fair contract rate of FRA (forward interest rate covering
413 -- from the Start Date to the Maturity Date).
414 --
415 PROCEDURE fra_price_df(p_t IN NUMBER,
416 p_T1 IN NUMBER,
417 p_Rt IN NUMBER,
418 p_Rt1 IN NUMBER,
419 p_year_basis IN NUMBER,
420 p_fra_rate IN OUT NOCOPY NUMBER);
421
422
423
424 END;
425
426
427
428