Tuesday, March 27, 2012

Advice on calculating coupon dates?

I am wondering if anyone has approached this problem before. I'm looking for
advice more than code, but either would be appreciated.
Bonds periodically pay you a "coupon". Typically they do so on anniverseries
of their first coupon date (which we store) or last coupon date (maturity),
some number of times a year (typically 2, 4 or 6 times). I would like to run
a query that shows every bond that is going to pay a coupon within a certain
time, say one week on either side of today, or even just "today" would be
useful.
It would seem that I could potentially calculate this with some clever
"slicing" of the dates. For instance, if the coupon pays every month I could
substitute the month of the test date (July for instance) into the first/last
coupon date and get something reasonable. However this would only work if the
coupon is _this_ month - perhaps the closest one is at the end of last month?
Nor do I see an easy way to handle the non-monthly (or yearly) cases.
Any advice?
Maury
"Maury Markowitz" <MauryMarkowitz@.discussions.microsoft.com> wrote in
message news:C585A270-C0A5-452B-85AC-56A8EFB4A2DA@.microsoft.com...
>I am wondering if anyone has approached this problem before. I'm looking
>for
> advice more than code, but either would be appreciated.
> Bonds periodically pay you a "coupon". Typically they do so on
> anniverseries
> of their first coupon date (which we store) or last coupon date
> (maturity),
> some number of times a year (typically 2, 4 or 6 times). I would like to
> run
> a query that shows every bond that is going to pay a coupon within a
> certain
> time, say one week on either side of today, or even just "today" would be
> useful.
> It would seem that I could potentially calculate this with some clever
> "slicing" of the dates. For instance, if the coupon pays every month I
> could
> substitute the month of the test date (July for instance) into the
> first/last
> coupon date and get something reasonable. However this would only work if
> the
> coupon is _this_ month - perhaps the closest one is at the end of last
> month?
> Nor do I see an easy way to handle the non-monthly (or yearly) cases.
> Any advice?
Break the problem into two problems. For every bond, calculate and store
ahead of time its cupon payment schedule.
create table BondCuponPayment
(
BondID int not null,
CuponDate DateTime not null,
constraint pk_BondPayment primary key (BondID, CuponDate),
Amount decimal(13,2)
)
Then you can run simple queries to retrieve upcoming cupon payments.
David
|||"David Browne" wrote:

> Break the problem into two problems. For every bond, calculate and store
> ahead of time its cupon payment schedule.
I didn't want to do this because it could potentially be an unlimited number
of bonds. So then I "got smart" and did another query on all the things that
we recently had a trade in. That was only 35, which seemed to be OK, it took
aboput 4 seconds.
But then on a lark I just did it for everything in the database. It took 0
seconds.
Sigh. Outsmarted myself again...
Maury

No comments:

Post a Comment