Pallas, the situation is far worse than you might imagine.
US markets typically close early at 1pm (Eastern) the day before Christmas or Independence Day and the day after Thanksgiving.
However since Christmas and Independence Day could fall on a weekend there are numerous exceptions. The market may close the full day Friday for a Saturday holiday or Monday for a Sunday holiday. You would expect this would move the day of the 1pm early close to either the Thursday or Friday beforehand. Except sometimes they close at 1pm the day after Independence Day (if that would be a Friday). Or don't close early at all if the holiday was on a Sunday or Monday. You get the idea.
And all the markets (NYSE, NASDAQ, etc) don't always close at the same time. This is especially true for presidential funerals and whatnot.
So while it would be nice to have a "market state" object it would actually need to be "expected time of close of trading" per security.
And that doesn't even count the days the markets were closed by weather or interrupted by glitches or brief memorial services.
Perhaps less importantly the markets will occasionally stay open after the expected close to process orders for customers affected by earlier glitches.
I think the most realistic option is to just start wrapping things up after 3pm (Eastern) and treat all the other stuff as unavoidable exceptions. If you want you can try to avoid the holiday chaos by not trading at all a day or two before or after a holiday.