Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. vector<float>
  2. RichardRollPrepayment::ComputingCPR(
  3. float maturity,
  4. float settledTime,
  5. float frequencyPreYear,
  6. float couponRate,
  7. vector<float> mortgageRate
  8. )
  9. {
  10. vector<float> cprVector(ceil((maturity-settledTime) * frequencyPreYear));
  11. float seasonality[] = {
  12. .94, .76, .73, .96, .98, .92, .99, 1.1, 1.18, 1.21, 1.23, .97
  13. };
  14. int seasoning = int(settledTime) * 12;
  15.  
  16. for (int i = 0; i < cprVector.size(); i++) {
  17.  
  18. if (seasoning < 30) {
  19. cprVector[i] =
  20. (.2406 - .1389 * atan(5.952*(1.089 - couponRate/mortgageRate[i])))
  21. * (seasoning/30) * seasonality[seasoning%12];
  22.  
  23. seasoning++;
  24. }
  25.  
  26. else {
  27. cprVector[i] =
  28. (.2406 - .1389 * atan(5.952*(1.089 - couponRate/mortgageRate[i])))
  29. * 1 * seasonality[seasoning%12];
  30.  
  31. seasoning++;
  32. }
  33. }
  34.  
  35. return cprVector;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement