Exemple #1
0
        /// <summary>
        /// IRH7,IRZ9 (90 day futures)
        ///
        /// IBH8,IBU9 (30 day futures)
        /// </summary>
        /// <returns></returns>
        /// <param name="referenceDate">
        /// if 2000, IRZ8 is futures that expires in December 2008.
        /// if 2010, IRZ8 is futures that expires in December 2018.
        /// </param>
        public override DateTime GetLastTradingDay(DateTime referenceDate)
        {
            //FuturesPrefixImmMonthCodeAndYear futuresPrefixImmMonthCodeAndYear = BreakCodeIntoPrefixAndYear(futuresCode);
            var month = (int)LastTradingDayHelper.ParseToCode(CodeAndExpiryMonth.ImmMonthCode);
            //  Expiration - 3rd (3) Wednesday (3) of month.
            //
            //DateTime unadjustedExpirationDate = DateHelper.nthWeekday(2, 5, month, referenceYear + futuresPrefixImmMonthCodeAndYear.Year);
            DateTime unadjustedExpirationDate;

            if (CodeAndExpiryMonth.Year < referenceDate.Year % 10)
            {
                int realYear = referenceDate.Year - (referenceDate.Year % 10) + CodeAndExpiryMonth.Year + 10;
                unadjustedExpirationDate = RuleHelper.GetNthDayInMonth(month, 3, 3, realYear, 0, 0);
            }
            else
            {
                int realYear = referenceDate.Year - (referenceDate.Year % 10) + CodeAndExpiryMonth.Year;
                unadjustedExpirationDate = RuleHelper.GetNthDayInMonth(month, 3, 3, realYear, 0, 0);
            }
            return(unadjustedExpirationDate);
        }
Exemple #2
0
 /// <summary>
 /// Gets the date rules.
 /// </summary>
 /// <param name="year">The year.</param>
 /// <returns></returns>
 protected override List <DateTime> DateRules(int year)
 {
     return(ValidMeetingMonths.Select(month => RuleHelper.GetNthDayInMonth(month, 1, 3, year, 0, 0)).ToList());
 }
Exemple #3
0
        /// <summary>
        /// Gets the last trading day.
        /// </summary>
        /// <param name="month">The month.</param>
        /// <param name="year">The year.</param>
        /// <returns></returns>
        public override DateTime GetLastTradingDay(int month, int year)
        {
            var significantDate = RuleHelper.GetNthDayInMonth(month, 3, 3, year, 0, 0);

            return(significantDate);
        }