private void GetDiscountingDates(BondCashflow cashflow, TEDFuture future, out DateTime startDate, out DateTime endDate)
 {
     int iED = future.No;
     if (cashflow.FlowDate < future.Maturity)
     {
         startDate = cashflow.FlowDate;
         endDate = mTEDFutures[iED - 1].Maturity;
     }
     else if (iED > mFirstTED)
     {
         startDate = future.Maturity;
         endDate = mTEDFutures[iED - 1].Maturity;
     }
     else
     {
         startDate = future.Maturity;
         endDate = mSettlement;
     }
 }
        private void DiscountCashflow(BondCashflow cashflow)
        {
            if (cashflow.FlowDate > mSettlement)
            {
                for (int iED = mFirstTED; iED < mTEDFutures.Length; iED++)
                {
                    DateTime startDate = DateTime.MinValue;
                    DateTime endDate = DateTime.MaxValue;
                    GetDiscountingDates(cashflow, mTEDFutures[iED], out startDate, out endDate);

                    cashflow.Amount *= GetTEDDiscountFactor(iED - 1, startDate, endDate);

                    if (cashflow.FlowDate < mTEDFutures[iED].Maturity)
                    {
                        return;
                    }
                }
                SLog.log.Error("Error calculating ED hedges - the strip is too short!");
                throw new Exception("Error calculating ED hedges - the strip is too short!");
            }
        }
        private void CalculateWeights(BondCashflow cashflow)
        {
            if (cashflow.FlowDate > mSettlement)
            {
                for (int iED = mFirstTED; iED < mTEDFutures.Length; ++iED)
                {
                    DateTime startDate = DateTime.MinValue;
                    DateTime endDate = DateTime.MaxValue;
                    GetDiscountingDates(cashflow, mTEDFutures[iED], out startDate, out endDate);

                    mTEDFutures[iED - 1].Weight += cashflow.Amount * (startDate - endDate).TotalDays / 360.0 * GetTEDDiscountFactor(iED - 1, startDate, endDate) / 25.0;

                    if (cashflow.FlowDate < mTEDFutures[iED].Maturity)
                    {
                        return;
                    }
                }
                SLog.log.Error("Error calculating ED hedges - the strip is too short!");
                throw new Exception("Error calculating ED hedges - the strip is too short!");
            }
        }
        private void CreateCashflows(DateTime settleDate, DateTime maturity, decimal coupon)
        {
          var cashflows = BondCashFlowsCalculator.GenerateBondCashFlows(settleDate, maturity, Convert.ToDouble(coupon),
            CarbonDataSource.GetPersistedInstance(), ThrowBehavior.Throw);

            // get cashflows from FinCAD
            //var cashflows = aaBond_strip_cfWrapper.CalculateCashflowStrip(settleDate, maturity, coupon);
          var numCashflows = cashflows.Count;
            mCashflows = new BondCashflow[numCashflows];
            for (int c = 0; c < numCashflows; ++c)
            {
                mCashflows[c] = new BondCashflow
                {
                    FlowDate = cashflows[c].Key,
                    Amount = cashflows[c].Value
                };
            }
        }