17 using System.Collections.Generic;
32 Func<DateTime, DateTime> result;
39 throw new ArgumentException($
"Expiry function not implemented for {symbol} in FuturesExpiryFunctions.FuturesExpiryDictionary");
48 public static Dictionary<DateTime, DateTime>
DairyReportDates =
new Dictionary<DateTime, DateTime>()
50 {
new DateTime(2012, 3, 1),
new DateTime(2012, 4, 2) },
51 {
new DateTime(2012, 4, 1),
new DateTime(2012, 5, 2) },
52 {
new DateTime(2012, 5, 1),
new DateTime(2012, 5, 31) },
53 {
new DateTime(2012, 6, 1),
new DateTime(2012, 7, 5) },
54 {
new DateTime(2012, 7, 1),
new DateTime(2012, 8, 1) },
55 {
new DateTime(2012, 8, 1),
new DateTime(2012, 8, 29) },
56 {
new DateTime(2012, 9, 1),
new DateTime(2012, 10, 3) },
57 {
new DateTime(2012, 10, 1),
new DateTime(2012, 10, 31) },
58 {
new DateTime(2012, 11, 1),
new DateTime(2012, 12, 5) },
59 {
new DateTime(2012, 12, 1),
new DateTime(2013, 1, 3) },
60 {
new DateTime(2013, 1, 1),
new DateTime(2013, 1, 30) },
61 {
new DateTime(2013, 2, 1),
new DateTime(2013, 2, 27) },
62 {
new DateTime(2013, 3, 1),
new DateTime(2013, 4, 3) },
63 {
new DateTime(2013, 4, 1),
new DateTime(2013, 5, 1) },
64 {
new DateTime(2013, 5, 1),
new DateTime(2013, 6, 5) },
65 {
new DateTime(2013, 6, 1),
new DateTime(2013, 7, 3) },
66 {
new DateTime(2013, 7, 1),
new DateTime(2013, 7, 31) },
67 {
new DateTime(2013, 8, 1),
new DateTime(2013, 9, 5) },
68 {
new DateTime(2013, 9, 1),
new DateTime(2013, 10, 18) },
69 {
new DateTime(2013, 10, 1),
new DateTime(2013, 10, 30) },
70 {
new DateTime(2013, 11, 1),
new DateTime(2013, 12, 4) },
71 {
new DateTime(2013, 12, 1),
new DateTime(2014, 1, 2) },
72 {
new DateTime(2014, 1, 1),
new DateTime(2014, 2, 5) },
73 {
new DateTime(2014, 2, 1),
new DateTime(2014, 3, 5) },
74 {
new DateTime(2014, 3, 1),
new DateTime(2014, 4, 2) },
75 {
new DateTime(2014, 4, 1),
new DateTime(2014, 4, 30) },
76 {
new DateTime(2014, 5, 1),
new DateTime(2014, 6, 4) },
77 {
new DateTime(2014, 6, 1),
new DateTime(2014, 7, 2) },
78 {
new DateTime(2014, 7, 1),
new DateTime(2014, 7, 30) },
79 {
new DateTime(2014, 8, 1),
new DateTime(2014, 9, 4) },
80 {
new DateTime(2014, 9, 1),
new DateTime(2014, 10, 1) },
81 {
new DateTime(2014, 10, 1),
new DateTime(2014, 11, 5) },
82 {
new DateTime(2014, 11, 1),
new DateTime(2014, 12, 3) },
83 {
new DateTime(2014, 12, 1),
new DateTime(2014, 12, 31) },
84 {
new DateTime(2015, 1, 1),
new DateTime(2015, 2, 4) },
85 {
new DateTime(2015, 2, 1),
new DateTime(2015, 3, 4) },
86 {
new DateTime(2015, 3, 1),
new DateTime(2015, 4, 1) },
87 {
new DateTime(2015, 4, 1),
new DateTime(2015, 4, 29) },
88 {
new DateTime(2015, 5, 1),
new DateTime(2015, 6, 3) },
89 {
new DateTime(2015, 6, 1),
new DateTime(2015, 7, 1) },
90 {
new DateTime(2015, 7, 1),
new DateTime(2015, 8, 5) },
91 {
new DateTime(2015, 8, 1),
new DateTime(2015, 9, 2) },
92 {
new DateTime(2015, 9, 1),
new DateTime(2015, 9, 30) },
93 {
new DateTime(2015, 10, 1),
new DateTime(2015, 11, 4) },
94 {
new DateTime(2015, 11, 1),
new DateTime(2015, 12, 2) },
95 {
new DateTime(2015, 12, 1),
new DateTime(2015, 12, 30) },
96 {
new DateTime(2016, 1, 1),
new DateTime(2016, 2, 3) },
97 {
new DateTime(2016, 2, 1),
new DateTime(2016, 3, 2) },
98 {
new DateTime(2016, 3, 1),
new DateTime(2016, 3, 30) },
99 {
new DateTime(2016, 4, 1),
new DateTime(2016, 5, 4) },
100 {
new DateTime(2016, 5, 1),
new DateTime(2016, 6, 2) },
101 {
new DateTime(2016, 6, 1),
new DateTime(2016, 6, 29) },
102 {
new DateTime(2016, 7, 1),
new DateTime(2016, 8, 3) },
103 {
new DateTime(2016, 8, 1),
new DateTime(2016, 8, 31) },
104 {
new DateTime(2016, 9, 1),
new DateTime(2016, 10, 5) },
105 {
new DateTime(2016, 10, 1),
new DateTime(2016, 11, 2) },
106 {
new DateTime(2016, 11, 1),
new DateTime(2016, 11, 30) },
107 {
new DateTime(2016, 12, 1),
new DateTime(2017, 1, 5) },
108 {
new DateTime(2017, 1, 1),
new DateTime(2017, 2, 1) },
109 {
new DateTime(2017, 2, 1),
new DateTime(2017, 3, 1) },
110 {
new DateTime(2017, 3, 1),
new DateTime(2017, 4, 5) },
111 {
new DateTime(2017, 4, 1),
new DateTime(2017, 5, 3) },
112 {
new DateTime(2017, 5, 1),
new DateTime(2017, 6, 1) },
113 {
new DateTime(2017, 6, 1),
new DateTime(2017, 6, 28) },
114 {
new DateTime(2017, 7, 1),
new DateTime(2017, 8, 2) },
115 {
new DateTime(2017, 8, 1),
new DateTime(2017, 8, 30) },
116 {
new DateTime(2017, 9, 1),
new DateTime(2017, 10, 4) },
117 {
new DateTime(2017, 10, 1),
new DateTime(2017, 11, 1) },
118 {
new DateTime(2017, 11, 1),
new DateTime(2017, 11, 29) },
119 {
new DateTime(2017, 12, 1),
new DateTime(2018, 1, 4) },
120 {
new DateTime(2018, 1, 1),
new DateTime(2018, 1, 31) },
121 {
new DateTime(2018, 2, 1),
new DateTime(2018, 2, 28) },
122 {
new DateTime(2018, 3, 1),
new DateTime(2018, 4, 4) },
123 {
new DateTime(2018, 4, 1),
new DateTime(2018, 5, 2) },
124 {
new DateTime(2018, 5, 1),
new DateTime(2018, 5, 31) },
125 {
new DateTime(2018, 6, 1),
new DateTime(2018, 7, 5) },
126 {
new DateTime(2018, 7, 1),
new DateTime(2018, 8, 1) },
127 {
new DateTime(2018, 8, 1),
new DateTime(2018, 8, 29) },
128 {
new DateTime(2018, 9, 1),
new DateTime(2018, 10, 3) },
129 {
new DateTime(2018, 10, 1),
new DateTime(2018, 10, 31) },
130 {
new DateTime(2018, 11, 1),
new DateTime(2018, 12, 5) },
131 {
new DateTime(2018, 12, 1),
new DateTime(2019, 1, 3) },
132 {
new DateTime(2019, 1, 1),
new DateTime(2019, 1, 30) },
133 {
new DateTime(2019, 2, 1),
new DateTime(2019, 2, 27) },
134 {
new DateTime(2019, 3, 1),
new DateTime(2019, 4, 3) },
135 {
new DateTime(2019, 4, 1),
new DateTime(2019, 5, 1) },
136 {
new DateTime(2019, 5, 1),
new DateTime(2019, 6, 5) },
137 {
new DateTime(2019, 6, 1),
new DateTime(2019, 7, 3) },
138 {
new DateTime(2019, 7, 1),
new DateTime(2019, 7, 31) },
139 {
new DateTime(2019, 8, 1),
new DateTime(2019, 9, 5) },
140 {
new DateTime(2019, 9, 1),
new DateTime(2019, 10, 2) },
141 {
new DateTime(2019, 10, 1),
new DateTime(2019, 10, 30) },
142 {
new DateTime(2019, 11, 1),
new DateTime(2019, 12, 4) },
143 {
new DateTime(2019, 12, 1),
new DateTime(2020, 1, 2) },
144 {
new DateTime(2020, 1, 1),
new DateTime(2020, 2, 5) },
145 {
new DateTime(2020, 2, 1),
new DateTime(2020, 3, 4) },
146 {
new DateTime(2020, 3, 1),
new DateTime(2020, 4, 1) },
147 {
new DateTime(2020, 4, 1),
new DateTime(2020, 4, 29) },
148 {
new DateTime(2020, 5, 1),
new DateTime(2020, 6, 3) },
149 {
new DateTime(2020, 6, 1),
new DateTime(2020, 7, 1) },
150 {
new DateTime(2020, 7, 1),
new DateTime(2020, 8, 5) },
151 {
new DateTime(2020, 8, 1),
new DateTime(2020, 9, 2) },
152 {
new DateTime(2020, 9, 1),
new DateTime(2020, 9, 30) },
153 {
new DateTime(2020, 10, 1),
new DateTime(2020, 11, 4) },
154 {
new DateTime(2020, 11, 1),
new DateTime(2020, 12, 2) },
155 {
new DateTime(2020, 12, 1),
new DateTime(2020, 12, 30) },
156 {
new DateTime(2021, 1, 1),
new DateTime(2021, 2, 3) },
157 {
new DateTime(2021, 2, 1),
new DateTime(2021, 3, 3) },
158 {
new DateTime(2021, 3, 1),
new DateTime(2021, 3, 31) },
159 {
new DateTime(2021, 4, 1),
new DateTime(2021, 5, 5) },
160 {
new DateTime(2021, 5, 1),
new DateTime(2021, 6, 3) },
161 {
new DateTime(2021, 6, 1),
new DateTime(2021, 6, 30) },
162 {
new DateTime(2021, 7, 1),
new DateTime(2021, 8, 4) },
163 {
new DateTime(2021, 8, 1),
new DateTime(2021, 9, 1) },
164 {
new DateTime(2021, 9, 1),
new DateTime(2021, 9, 29) },
165 {
new DateTime(2021, 10, 1),
new DateTime(2021, 11, 3) },
166 {
new DateTime(2021, 11, 1),
new DateTime(2021, 12, 1) },
167 {
new DateTime(2021, 12, 1),
new DateTime(2022, 1, 5) },
168 {
new DateTime(2022, 1, 1),
new DateTime(2022, 2, 2) },
169 {
new DateTime(2022, 2, 1),
new DateTime(2022, 3, 2) },
170 {
new DateTime(2022, 3, 1),
new DateTime(2022, 3, 30) },
171 {
new DateTime(2022, 4, 1),
new DateTime(2022, 5, 4) },
172 {
new DateTime(2022, 5, 1),
new DateTime(2022, 6, 2) },
173 {
new DateTime(2022, 6, 1),
new DateTime(2022, 6, 29) },
174 {
new DateTime(2022, 7, 1),
new DateTime(2022, 8, 3) },
175 {
new DateTime(2022, 8, 1),
new DateTime(2022, 8, 31) },
176 {
new DateTime(2022, 9, 1),
new DateTime(2022, 10, 5) },
177 {
new DateTime(2022, 10, 1),
new DateTime(2022, 11, 2) },
178 {
new DateTime(2022, 11, 1),
new DateTime(2022, 11, 30) },
179 {
new DateTime(2022, 12, 1),
new DateTime(2023, 1, 5) },
188 {
new DateTime(2019, 6, 1),
new DateTime(2019, 5, 17) },
189 {
new DateTime(2019, 7, 1),
new DateTime(2019, 6, 15) },
190 {
new DateTime(2019, 8, 1),
new DateTime(2019, 7, 17) },
191 {
new DateTime(2019, 9, 1),
new DateTime(2019, 8, 16) },
192 {
new DateTime(2019, 10, 1),
new DateTime(2019, 9, 14) },
193 {
new DateTime(2019, 11, 1),
new DateTime(2019, 10, 17) },
194 {
new DateTime(2019, 12, 1),
new DateTime(2019, 11, 15) },
195 {
new DateTime(2020, 1, 1),
new DateTime(2019, 12, 14) },
196 {
new DateTime(2020, 2, 1),
new DateTime(2020, 1, 22) },
197 {
new DateTime(2020, 3, 1),
new DateTime(2020, 2, 21) },
198 {
new DateTime(2020, 4, 1),
new DateTime(2020, 3, 21) },
199 {
new DateTime(2020, 5, 1),
new DateTime(2020, 4, 21) },
200 {
new DateTime(2020, 6, 1),
new DateTime(2020, 5, 21) },
201 {
new DateTime(2020, 7, 1),
new DateTime(2020, 6, 23) },
202 {
new DateTime(2020, 8, 1),
new DateTime(2020, 7, 21) },
203 {
new DateTime(2020, 9, 1),
new DateTime(2020, 8, 21) },
204 {
new DateTime(2020, 10, 1),
new DateTime(2020, 9, 22) },
205 {
new DateTime(2020, 11, 1),
new DateTime(2020, 10, 21) },
206 {
new DateTime(2020, 12, 1),
new DateTime(2020, 11, 21) },
207 {
new DateTime(2021, 1, 1),
new DateTime(2020, 12, 22) },
208 {
new DateTime(2021, 2, 1),
new DateTime(2021, 1, 21) },
209 {
new DateTime(2021, 3, 1),
new DateTime(2021, 2, 23) },
210 {
new DateTime(2021, 4, 1),
new DateTime(2021, 3, 23) },
211 {
new DateTime(2021, 5, 1),
new DateTime(2021, 4, 21) },
212 {
new DateTime(2021, 6, 1),
new DateTime(2021, 5, 21) },
213 {
new DateTime(2021, 7, 1),
new DateTime(2021, 6, 22) },
214 {
new DateTime(2021, 8, 1),
new DateTime(2021, 7, 21) },
215 {
new DateTime(2021, 9, 1),
new DateTime(2021, 8, 21) },
216 {
new DateTime(2021, 10, 1),
new DateTime(2021, 9, 21) },
217 {
new DateTime(2021, 11, 1),
new DateTime(2021, 10, 21) },
218 {
new DateTime(2021, 12, 1),
new DateTime(2021, 11, 23) },
219 {
new DateTime(2022, 1, 1),
new DateTime(2021, 12, 21) },
220 {
new DateTime(2022, 2, 1),
new DateTime(2022, 1, 21) },
221 {
new DateTime(2022, 3, 1),
new DateTime(2022, 2, 23) },
222 {
new DateTime(2022, 4, 1),
new DateTime(2022, 3, 22) },
223 {
new DateTime(2022, 5, 1),
new DateTime(2022, 4, 21) },
224 {
new DateTime(2022, 6, 1),
new DateTime(2022, 5, 21) },
225 {
new DateTime(2022, 7, 1),
new DateTime(2022, 6, 21) },
226 {
new DateTime(2022, 8, 1),
new DateTime(2022, 7, 21) },
227 {
new DateTime(2022, 9, 1),
new DateTime(2022, 8, 23) },
228 {
new DateTime(2022, 10, 1),
new DateTime(2022, 9, 21) },
229 {
new DateTime(2022, 11, 1),
new DateTime(2022, 10, 21) },
230 {
new DateTime(2022, 12, 1),
new DateTime(2022, 11, 22) },
238 public static readonly Dictionary<Symbol, Func<DateTime, DateTime>>
FuturesExpiryDictionary =
new Dictionary<Symbol, Func<DateTime, DateTime>>()
297 return lastBusinessDay;
311 return lastBusinessDay;
334 var lastWednesday = (from dateRange in Enumerable.Range(1, DateTime.DaysInMonth(time.Year, time.Month))
335 where
new DateTime(time.Year, time.Month, dateRange).DayOfWeek == DayOfWeek.Wednesday
336 select
new DateTime(time.Year, time.Month, dateRange)).Last();
348 time = time.AddMonths(1);
353 return thirdFriday.Add(
new TimeSpan(13,30,0));
362 time = time.AddMonths(1);
367 return thirdFriday.Add(
new TimeSpan(13,30,0));
376 time = time.AddMonths(1);
381 return thirdFriday.Add(
new TimeSpan(13,30,0));
390 time = time.AddMonths(1);
395 return thirdFriday.Add(
new TimeSpan(13,30,0));
404 time = time.AddMonths(1);
409 return thirdFriday.Add(
new TimeSpan (13,30,0));
421 time = time.AddMonths(1);
426 var priorBusinessDay = secondFriday.AddDays(-1);
429 priorBusinessDay = priorBusinessDay.AddDays(-1);
431 return priorBusinessDay.Add(TimeSpan.FromHours(21));
443 var priorBusinessDay = secondFriday.AddDays(-1);
446 priorBusinessDay = priorBusinessDay.AddDays(-1);
448 return priorBusinessDay.Add(TimeSpan.FromHours(21));
460 time = time.AddMonths(1);
465 var priorBusinessDay = secondFriday.AddDays(-1);
468 priorBusinessDay = priorBusinessDay.AddDays(-1);
470 return priorBusinessDay.Add(TimeSpan.FromHours(21));
485 secondLastBusinessDay = secondLastBusinessDay.AddDays(-1);
487 return secondLastBusinessDay.Add(TimeSpan.FromHours(6));
499 time = time.AddMonths(1);
507 thirdFriday = thirdFriday.AddDays(-1);
521 time = time.AddMonths(1);
529 thirdFriday = thirdFriday.AddDays(-1);
543 time = time.AddMonths(1);
551 thirdFriday = thirdFriday.AddDays(-1);
565 time = time.AddMonths(1);
570 var thursdaypriorsecondFriday = secondFriday.AddDays(-1);
574 thursdaypriorsecondFriday = thursdaypriorsecondFriday.AddDays(-1);
576 return thursdaypriorsecondFriday.Add(TimeSpan.FromHours(21));
588 time = time.AddMonths(1);
593 var thursdaypriorsecondFriday = secondFriday.AddDays(-1);
597 thursdaypriorsecondFriday = thursdaypriorsecondFriday.AddDays(-1);
599 return thursdaypriorsecondFriday.Add(TimeSpan.FromHours(21));
611 time = time.AddMonths(1);
618 thirdFriday = thirdFriday.AddDays(-1);
620 return thirdFriday.Add(
new TimeSpan(13, 30, 0));
632 time = time.AddMonths(1);
639 thirdFriday = thirdFriday.AddDays(-1);
641 return thirdFriday.Add(
new TimeSpan(13, 30, 0));
653 time = time.AddMonths(1);
660 thirdFriday = thirdFriday.AddDays(-1);
662 return thirdFriday.Add(
new TimeSpan(13, 30, 0));
674 time = time.AddMonths(1);
681 thirdFriday = thirdFriday.AddDays(-1);
683 return thirdFriday.Add(
new TimeSpan(13, 30, 0));
694 var expiryDate = nextThirdFriday.AddDays(-30);
698 if (holidays.Contains(expiryDate) || holidays.Contains(nextThirdFriday))
700 expiryDate = expiryDate.AddDays(-1);
703 return expiryDate.Add(
new TimeSpan(13, 0, 0));
715 time = time.AddMonths(1);
721 return thirdWednesday.Add(
new TimeSpan(18, 30, 0));
733 time = time.AddMonths(1);
740 return thirdFriday.Add(
new TimeSpan(13, 30, 0));
749 time = time.AddMonths(1);
762 time = time.AddMonths(1);
790 time = time.AddMonths(1);
794 var wednesdays = (from dateRange in Enumerable.Range(1, DateTime.DaysInMonth(time.Year, time.Month))
795 where
new DateTime(time.Year, time.Month, dateRange).DayOfWeek == DayOfWeek.Wednesday
796 select
new DateTime(time.Year, time.Month, dateRange));
798 var distanceFromFifteenthDay = wednesdays.Select(x => Math.Abs(15 - x.Day)).ToList();
799 var wednesdayIndex = distanceFromFifteenthDay.IndexOf(distanceFromFifteenthDay.Min());
800 var closestWednesday = wednesdays.ElementAt(wednesdayIndex);
806 return closestWednesday.Add(
new TimeSpan(20, 0, 0));
820 var priorBusinessDay = secondFriday.AddDays(-1);
824 while (holidays.Contains(priorBusinessDay) || !priorBusinessDay.IsCommonBusinessDay())
826 priorBusinessDay = priorBusinessDay.AddDays(-1);
828 return priorBusinessDay.Add(
new TimeSpan(14, 30, 0));
839 var lastDay =
new DateTime(time.Year, time.Month, DateTime.DaysInMonth(time.Year, time.Month));
840 var priorBusinessDay = lastDay.AddDays(-1);
844 while (holidays.Contains(priorBusinessDay) || !priorBusinessDay.IsCommonBusinessDay())
846 priorBusinessDay = priorBusinessDay.AddDays(-1);
848 return priorBusinessDay.Add(
new TimeSpan(13, 45, 0));
864 while (holidays.Contains(expiryday) || !expiryday.IsCommonBusinessDay())
866 expiryday = expiryday.AddDays(-1);
868 return expiryday.Add(
new TimeSpan(15, 30, 0));
884 while (holidays.Contains(expiryday) || !expiryday.IsCommonBusinessDay())
886 expiryday = expiryday.AddDays(-1);
888 return expiryday.Add(
new TimeSpan(15, 30, 0));
904 while (holidays.Contains(expiryday) || !expiryday.IsCommonBusinessDay())
906 expiryday = expiryday.AddDays(-1);
908 return expiryday.Add(
new TimeSpan(15, 30, 0));
921 var lastDay =
new DateTime(time.Year, time.Month, DateTime.DaysInMonth(time.Year, time.Month));
927 return priorBusinessDay.Add(
new TimeSpan(16, 0, 0));
942 return lastTradingDay.Add(
new TimeSpan(16, 15, 0));
957 return lastTradingDay.Add(
new TimeSpan(16, 15, 0));
971 return lastTradingDay.Add(
new TimeSpan(16, 15, 0));
986 return lastTradingDay.Add(
new TimeSpan(16, 15, 0));
1000 return lastTradingDay.Add(
new TimeSpan(16, 15, 0));
1014 return lastTradingDay.Add(
new TimeSpan(16, 15, 0));
1027 time = time.AddMonths(1);
1031 var sixteenth =
new DateTime(time.Year,time.Month,16);
1045 time = time.AddMonths(1);
1049 var sixteenth =
new DateTime(time.Year,time.Month, 16);
1063 time = time.AddMonths(1);
1067 var fifteenth =
new DateTime(time.Year,time.Month,15);
1080 time = time.AddMonths(1);
1084 var fifteenth =
new DateTime(time.Year,time.Month,15);
1097 time = time.AddMonths(1);
1101 var fifteenth =
new DateTime(time.Year,time.Month,15);
1114 time = time.AddMonths(1);
1118 var fifteenth =
new DateTime(time.Year,time.Month,15);
1131 time = time.AddMonths(1);
1135 var fifteenth =
new DateTime(time.Year,time.Month,15);
1148 time = time.AddMonths(1);
1152 var fifteenth =
new DateTime(time.Year,time.Month,15);
1165 time = time.AddMonths(1);
1169 var fifteenth =
new DateTime(time.Year,time.Month,15);
1196 return lastBusinessDay;
1206 time = time.AddMonths(1);
1219 var twoDaysPrior = thirdWednesday.AddDays(-2);
1221 return twoDaysPrior.Add(
new TimeSpan(10, 16, 0));
1237 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14,16,0));
1251 return businessDayPrecedingThridWednesday.Add(
new TimeSpan(14,16,0));
1267 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14,16,0));
1279 time = time.AddMonths(1);
1287 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14,16,0));
1303 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14,16,0));
1319 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14,16,0));
1331 time = time.AddMonths(1);
1339 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14,16,0));
1350 var fifteenth =
new DateTime(time.Year, time.Month, 15);
1356 return fifteenth.Add(
new TimeSpan(08,0,0));
1370 return lastPrecedingBusinessDay.Add(
new TimeSpan(14,15,0));
1385 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14,16,0));
1400 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14,16,0));
1412 time = time.AddMonths(1);
1420 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14,16,0));
1432 time = time.AddMonths(1);
1440 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
1452 time = time.AddMonths(1);
1460 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
1474 return lastFriday.Add(
new TimeSpan(15, 0, 0));
1488 return lastFriday.Add(
new TimeSpan(15, 0, 0));
1500 time = time.AddMonths(1);
1508 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
1521 var secondBusinessDayPrecedingThirdWednesday = thirdWednesday.AddDays(-2);
1522 while (holidays.Contains(secondBusinessDayPrecedingThirdWednesday) || !secondBusinessDayPrecedingThirdWednesday.IsCommonBusinessDay())
1524 secondBusinessDayPrecedingThirdWednesday = secondBusinessDayPrecedingThirdWednesday.AddDays(-1);
1527 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(3,0,0));
1540 time = time.AddMonths(1);
1548 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
1561 time = time.AddMonths(1);
1569 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
1582 time = time.AddMonths(1);
1590 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
1603 time = time.AddMonths(1);
1611 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
1623 time = time.AddMonths(1);
1631 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
1645 time = time.AddMonths(1);
1651 return seventhBusinessDayPrecedingLastBusinessDay.Add(
new TimeSpan(12,01,0));
1664 time = time.AddMonths(1);
1670 return seventhBusinessDayPrecedingLastBusinessDay.Add(
new TimeSpan(12,01,0));
1682 time = time.AddMonths(1);
1687 return lastBusinessDay.Add(
new TimeSpan(12,01,0));
1700 time = time.AddMonths(1);
1705 return lastBusinessDay.Add(
new TimeSpan(12,01,0));
1723 .Add(TimeSpan.FromHours(11));
1735 time = time.AddMonths(1);
1743 while (holidays.Contains(secondBusinessDayBeforeThirdWednesday) || !secondBusinessDayBeforeThirdWednesday.IsCommonBusinessDay())
1745 secondBusinessDayBeforeThirdWednesday = secondBusinessDayBeforeThirdWednesday.AddDays(-1);
1748 return secondBusinessDayBeforeThirdWednesday.Add(
new TimeSpan(19, 0, 0));
1761 time = time.AddMonths(1);
1767 return sevenBusinessDaysBeforeLastBusinessDay.Add(
new TimeSpan(12, 1, 0));
1780 time = time.AddMonths(1);
1825 return lastBusinessDay;
1839 var lastDay =
new DateTime(time.Year, time.Month, DateTime.DaysInMonth(time.Year, time.Month));
1841 while (holidays.Contains(lastDay) || !lastDay.IsCommonBusinessDay())
1843 lastDay = lastDay.AddDays(-1);
1905 return lastBusinessDay;
1992 return lastBusinessDay;
2006 var previousMonth = time.AddMonths(-1);
2007 var lastDay =
new DateTime(previousMonth.Year, previousMonth.Month, DateTime.DaysInMonth(previousMonth.Year, previousMonth.Month));
2009 while (!lastDay.IsCommonBusinessDay() || holidays.Contains(lastDay))
2011 lastDay = lastDay.AddDays(-1);
2098 return lastBusinessDay;
2109 var previousMonth = time.AddMonths(-1);
2110 var twentyFifthDay =
new DateTime(previousMonth.Year, previousMonth.Month, 25);
2111 while (!twentyFifthDay.IsCommonBusinessDay() || holidays.Contains(twentyFifthDay))
2116 return twentyFifthDay;
2131 return lastBusinessDay;
2190 return lastBusinessDay;
2236 var twentyFifthDayPriorMonth =
new DateTime(time.Year, time.Month, 25).AddMonths(-1);
2242 return twentyFifthDayPriorMonth;
2256 return lastBusinessDay;
2270 return lastBusinessDay;
2295 return lastBusinessDay;
2309 return lastBusinessDay;
2323 return lastBusinessDay;
2345 var twoMonthsPriorToContractMonth = time.AddMonths(-2);
2347 DateTime lastBusinessDay;
2349 if (twoMonthsPriorToContractMonth.Month == 2)
2360 return lastBusinessDay;
2371 var twentyFifth =
new DateTime(time.Year,time.Month,25);
2372 twentyFifth = twentyFifth.AddMonths(-1);
2374 var businessDays = -3;
2402 DateTime publicationDate;
2406 publicationDate =
new DateTime(time.Year, time.Month, 21).AddMonths(-1);
2410 publicationDate = publicationDate.AddDays(-1);
2412 while (!publicationDate.IsCommonBusinessDay());
2414 return publicationDate;
2428 return lastBusinessDay;
2453 return lastBusinessDay;
2467 return lastBusinessDay;
2503 while (holidays.Contains(lastBusinessDay) || !lastBusinessDay.IsCommonBusinessDay())
2505 lastBusinessDay = lastBusinessDay.AddDays(-1);
2508 return lastBusinessDay;
2521 while (holidays.Contains(lastBusinessDay) || !lastBusinessDay.IsCommonBusinessDay())
2523 lastBusinessDay = lastBusinessDay.AddDays(-1);
2526 return lastBusinessDay;
2539 while (holidays.Contains(lastBusinessDay) || !lastBusinessDay.IsCommonBusinessDay())
2541 lastBusinessDay = lastBusinessDay.AddDays(-1);
2544 return lastBusinessDay;
2568 while (holidays.Contains(lastBusinessDay) || !lastBusinessDay.IsCommonBusinessDay())
2570 lastBusinessDay = lastBusinessDay.AddDays(-1);
2573 return lastBusinessDay;
2597 while (holidays.Contains(lastBusinessDay) || !lastBusinessDay.IsCommonBusinessDay())
2599 lastBusinessDay = lastBusinessDay.AddDays(-1);
2602 return lastBusinessDay;
2615 while (holidays.Contains(lastBusinessDay) || !lastBusinessDay.IsCommonBusinessDay())
2617 lastBusinessDay = lastBusinessDay.AddDays(-1);
2620 return lastBusinessDay;
2633 while (holidays.Contains(lastBusinessDay) || !lastBusinessDay.IsCommonBusinessDay())
2635 lastBusinessDay = lastBusinessDay.AddDays(-1);
2638 return lastBusinessDay;
2651 while (holidays.Contains(lastBusinessDay) || !lastBusinessDay.IsCommonBusinessDay())
2653 lastBusinessDay = lastBusinessDay.AddDays(-1);
2656 return lastBusinessDay;
2667 var twentyFifthDayInPriorMonth =
new DateTime(time.Year, time.Month, 25).AddMonths(-1);
2670 while (i < 3 || !twentyFifthDayInPriorMonth.IsCommonBusinessDay() || holidays.Contains(twentyFifthDayInPriorMonth))
2672 if (twentyFifthDayInPriorMonth.IsCommonBusinessDay() &&
2673 !holidays.Contains(twentyFifthDayInPriorMonth))
2677 twentyFifthDayInPriorMonth = twentyFifthDayInPriorMonth.AddDays(-1);
2680 return twentyFifthDayInPriorMonth;
2691 var previousMonth = time.AddMonths(-1);
2692 previousMonth =
new DateTime(previousMonth.Year, previousMonth.Month, DateTime.DaysInMonth(previousMonth.Year, previousMonth.Month));
2705 var precedingMonth = time.AddMonths(-1);
2717 var previousMonth = time.AddMonths(-1);
2730 var twentyFifthPreviousMonth =
new DateTime(time.Year, time.Month, 25).AddMonths(-1);
2736 return twentyFifthPreviousMonth;
2747 var precedingMonth = time.AddMonths(-1);
2759 var firstDay =
new DateTime(time.Year,time.Month,1);
2774 var secondPrecedingMonth = time.AddMonths(-2);
2775 var nthLastBusinessDay = secondPrecedingMonth.Month == 12 ? 2 : 1;
2787 var fourteenthDay =
new DateTime(time.Year,time.Month,14);
2789 return twelfthDay.Add(
new TimeSpan(12,0,0));
2802 time = time.AddMonths(1);
2807 return lastBusinessDay.Add(
new TimeSpan(12,0,0));
2829 time = time.AddMonths(1);
2833 var lastday =
new DateTime(time.Year,time.Month,1);
2834 lastday = lastday.AddDays(-1);
2836 return tenthday.Add(
new TimeSpan(12,0,0));
2848 time = time.AddMonths(1);
2864 var daysInMonth = DateTime.DaysInMonth(time.Year, time.Month);
2866 if(time.Month == 11)
2868 var priorThursday = (from day in Enumerable.Range(1, daysInMonth)
2869 where
new DateTime(time.Year, time.Month, day).DayOfWeek == DayOfWeek.Thursday
2870 select
new DateTime(time.Year, time.Month, day)).Reverse().ElementAt(1);
2873 priorThursday = priorThursday.AddDays(-7);
2875 return priorThursday;
2878 var lastThursday = (from day in Enumerable.Range(1, daysInMonth)
2879 where
new DateTime(time.Year, time.Month, day).DayOfWeek == DayOfWeek.Thursday
2880 select
new DateTime(time.Year, time.Month, day)).Reverse().ElementAt(0);
2883 lastThursday = lastThursday.AddDays(-7);
2885 return lastThursday;
2898 time = time.AddMonths(1);
2917 time = time.AddMonths(1);
2932 time = time.AddMonths(1);
2953 time = time.AddMonths(1);
2971 time = time.AddMonths(1);
2975 var precedingMonth = time.AddMonths(-1);
2988 time = time.AddMonths(1);
3076 time = time.AddMonths(1);
3084 return lastBusinessDay;
3098 return lastBusinessDay;
3112 return lastBusinessDay;
3126 return lastBusinessDay;
3139 return lastBusinessDay.Add(
new TimeSpan(13, 30, 0));
3152 return lastBusinessDay.Add(
new TimeSpan(13, 25, 0));
3165 return lastBusinessDay.Add(
new TimeSpan(13, 30, 0));
3178 return lastBusinessDay.Add(
new TimeSpan(13, 25, 0));
3192 return lastBusinessDay;
3206 return lastBusinessDay;
3220 return lastBusinessDay;
3234 return lastBusinessDay;
3246 time = time.AddMonths(1);
3254 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
3266 time = time.AddMonths(1);
3274 return secondBusinessDayPrecedingThirdWednesday;
3286 time = time.AddMonths(1);
3294 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
3306 time = time.AddMonths(1);
3314 return firstBusinessDayPrecedingThirdWednesday;
3326 time = time.AddMonths(1);
3334 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
3346 time = time.AddMonths(1);
3354 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
3366 time = time.AddMonths(1);
3374 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
3392 return secondBusinessDayPrecedingLastBusinessDay.Add(
new TimeSpan(6,30,0));
3404 time = time.AddMonths(1);
3412 return firstBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
3424 time = time.AddMonths(1);
3432 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(14, 16, 0));
3448 return secondBusinessDayPrecedingThirdWednesday.Add(
new TimeSpan(3,0,0));
3457 time = time.AddMonths(1);
3462 return thirdFriday.Add(
new TimeSpan(13,30,0));
3471 time = time.AddMonths(1);
3476 return thirdFriday.Add(
new TimeSpan(13,30,0));
3485 time = time.AddMonths(1);
3490 return thirdFriday.Add(
new TimeSpan(13,30,0));
3499 time = time.AddMonths(1);
3504 return thirdFriday.Add(
new TimeSpan(13,30,0));
3519 var previousMonth = time.AddMonths(-1);
3520 var twentyFifthDay =
new DateTime(previousMonth.Year, previousMonth.Month, 25);
3522 var businessDays = -4;
3545 return lastBusinessDay;
3560 return lastBusinessDay;
3577 return lastBusinessDay;
3593 return lastBusinessDay;
3609 return lastBusinessDay;
3629 while (holidays.Contains(lastFriday))
3632 while (holidays.Contains(lastFriday))
3653 return lastBusinessDay;
3677 return lastFriday.Add(
new TimeSpan(15, 0, 0));
3700 return lastFriday.Add(
new TimeSpan(15, 0, 0));
3723 while (holidays.Contains(lastThursday))
3728 return lastThursday.Add(
new TimeSpan(15, 0, 0));
3752 while (holidays.Contains(lastThursday))
3757 return lastThursday.Add(
new TimeSpan(15, 0, 0));