public bool GetFirstYearFactor(DateTime dtDate, out double pVal) { short iTolWeight; short iAnuWeight; DateTime dtTmpEndDate; DateTime dtTmpStartDate; IBAFiscalYear FY; bool hr; pVal = 0.0; if (m_pObjCalendar == null) { throw new Exception("Avg Convention not initialized."); } if (dtDate <= DateTime.MinValue) { throw new Exception("Avg Convention not initialized."); } if (!(hr = m_pObjCalendar.GetFiscalYear(dtDate, out FY))) { return(false); } dtTmpStartDate = FY.YRStartDate; dtTmpEndDate = FY.YREndDate; FY.GetTotalFiscalYearPeriodWeights(out iTolWeight); FY.GetTotalAnnualPeriodWeights(out iAnuWeight); pVal = 0.5 * iTolWeight / iAnuWeight; return(true); }
public bool GetFirstYearFactor(DateTime dtDate, out double pVal) { short iTolWeight; short iAnuWeight; DateTime dtTmpEndDate; DateTime dtTmpStartDate; DateTime dtMidDate; IBAFiscalYear FY; bool hr; pVal = 0.0; if (m_pObjCalendar == null) { throw new Exception("Avg Convention not initialized."); } if (dtDate <= DateTime.MinValue) { throw new Exception("Avg Convention not initialized."); } if (!(hr = m_pObjCalendar.GetFiscalYear(dtDate, out FY))) { return(false); } dtTmpStartDate = FY.YRStartDate; dtTmpEndDate = FY.YREndDate; FY.GetTotalFiscalYearPeriodWeights(out iTolWeight); FY.GetTotalAnnualPeriodWeights(out iAnuWeight); FY.GetMidYearDate(out dtMidDate); if (dtDate < dtMidDate) { //if the PIS is in the first half of the year, then 100% pVal = (double)(iTolWeight) / iAnuWeight; } else { //if( the PIS is in the second half of the year, then no disposed pVal = 0; } return(true); }