///<summary> ///</summary> ///<param name="discount"></param> ///<param name="shift"></param> public void Populate(QuarterlyDiscounts discount, QuarterlyShifts shift) { var forward = new double[_maxTenor + 1]; var accumForward = new double[_maxTenor + 1]; var accumForwardTimesRate = new double[_maxTenor + 1]; var accumForwardTimesShiftedRate = new double[_maxTenor + 1]; accumForward[0] = 0; accumForwardTimesRate[0] = 0; accumForwardTimesShiftedRate[0] = 0; var w = new double[_maxTenor]; var h = new double[_maxTenor]; for (int i = 0; i < _maxExpiry; i++) { for (int j = 0; j < _maxTenor - i; j++) { //See "Engineering BGM" page 34 for explicit formula. Function definitions can be found in chapter 4. forward[j + 1] = RateAnalytics.ForwardContract(i + 1, i + j + 2, discount); accumForward[j + 1] = accumForward[j] + forward[j + 1]; accumForwardTimesRate[j + 1] = accumForwardTimesRate[j] + forward[j + 1] * RateAnalytics.CashForwardRate(i + j + 1, discount); accumForwardTimesShiftedRate[j + 1] = accumForwardTimesShiftedRate[j] + forward[j + 1] * RateAnalytics.ShiftedCashForwardRate(i + j + 1, discount, shift); h[j] = 0.25 * RateAnalytics.ShiftedCashForwardRate(i + j + 1, discount, shift) / (1 + 0.25 * RateAnalytics.CashForwardRate(i + j + 1, discount)); for (int k = 0; k < j + 1; k++) { w[k] = forward[k + 1] * RateAnalytics.ShiftedCashForwardRate(i + k + 1, discount, shift) / accumForwardTimesShiftedRate[j + 1]; _weights[i][j][k] = w[k] - h[k] * ((accumForwardTimesRate[j + 1] - accumForwardTimesRate[k]) / accumForwardTimesShiftedRate[j + 1] - (1 - accumForward[k] / accumForward[j + 1]) * accumForwardTimesRate[j + 1] / accumForwardTimesShiftedRate[j + 1]); } } } }