我发现“CPR”是一种基于债券不同方面的功能。
我们目前的公式是这样的:
SELECT All
a.[CUSIP NUMBER],
CPR,
a.[POOL PREFIX],
a.[POOL NUMBER],
a.[POOL TYPE],
a.[CURRENT MM],
a.[CURRENT YY],
a.[ISSUE MM],
a.[ISSUE DD],
a.[ISSUE YY],
a.[MATURITY MM],
a.[MATURITY DD],
a.[MATURITY YY],
a.[SELLER NAME],
a.[SELLER STREET],
a.[SELLER CITY],
a.[SELLER STATE],
a.[SELLER ZIP],
a.[ORIGINAL WA COUPON],
a.[SD SECURITY TYPE],
a.[SD INTEREST RATE],
a.[SD POOL PREFIX],
a.[SD POOL NUMBER],
a.[CURRENT WA COUPON],
a.[CURRENT BALANCE],
a.[ORIGINAL WA MATURITY],
a.[CURRENT WA MATURITY],
a.[PASS THRU RATE],
a.[CURRENT FACTOR],
b.[CURRENT FACTOR] as AprilFactor,
b.[ORIGINAL BALANCE],
MonthlyRate,
Payment,
InterestPayment,
Principle,
ScheduledFace,
PreviousFace,
ScheduledFactor,
SMM
INTO March2013CPR
FROM dbo.mbs022013 a
JOIN dbo.mbs032013 b ON a.[CUSIP NUMBER] = b.[CUSIP NUMBER]
CROSS APPLY (Select (a.[PASS THRU RATE]*.01)/12) CA(MonthlyRate)
CROSS APPLY (Select (a.[CURRENT BALANCE] * ((MonthlyRate)/((1-(1/power(1+ MonthlyRate, a.[CURRENT WA MATURITY]))))))) CA2(Payment)
Cross Apply (Select a.[CURRENT BALANCE] * MonthlyRate) CA3 (InterestPayment)
Cross Apply (Select Payment - InterestPayment) CA4 (Principle)
Cross Apply (Select a.[ORIGINAL BALANCE] * a.[CURRENT FACTOR]) CA5 (PreviousFace)
CROSS APPLY (Select PreviousFace - Principle) CA6(ScheduledFace)
Cross Apply (Select ScheduledFace/a.[ORIGINAL BALANCE]) CA7 (ScheduledFactor)
Cross Apply (Select 100 * (1-(b.[CURRENT FACTOR]/ScheduledFactor))) CA8(SMM)
Cross Apply (Select (1-(power(1-SMM/100,12)))*100) CA9 (CPR)
WHERE a.[CURRENT WA MATURITY] != 0 and a.[CURRENT BALANCE] != 0
我们通过交叉应用计算,以便我们可以将整个投资组合发布到一个新表中,其中包含每个债券的 CPR 值。这个函数已经工作了几个月的数据,但是这个月它只是返回:
Msg 8117, Level 16, State 1, Line 49
Operand data type varchar is invalid for multiply operator.
这是计算 March 的函数。三月文件使用二月文件和三月文件中的信息。但是,我认为这两个文件都没有问题,因为该函数对于使用一月和二月数据的二月文件和使用四月和三月数据的四月文件是正确的。
第 49 行是这样的行:
Cross Apply (Select a.[ORIGINAL BALANCE] * a.[CURRENT FACTOR]) CA5 (PreviousFace)
任何想法如何解决?:-D
更新:
以下是一些示例数据:
CUSIP NUMBER Original Balance Current Factor Pass Thru Rate Current Balance
31416HAB1 00000325972000 0.19556008 04.500 00000063747109
31416HAB1 00003749061700 0.11487645 05.000 00000430678890
31416HAC9 00002164121900 0.15490762 05.500 00000335238974
31416HAD7 00000274716900 0.22204878 06.000 00000061000552
31416HAE5 00018198400200 0.10905233 06.000 00001984577976
当前的 WA 成熟度范围为 0-360。