SPB Git

spb/wp39_uqo

Public
1.3 KB · 31 lines python
1import datetime as dt23import polars as pl45from wp39.calendar import close_time_utc, regular_session_bounds_utc, shift_trading_days, trading_days_between6from wp39.features import session_bounds_table789def test_regular_session_bounds_in_both_dst_regimes():10    o, c = regular_session_bounds_utc(dt.date(2024, 1, 10))   # EST: 09:30 ET = 14:30 UTC11    assert (o.hour, o.minute) == (14, 30) and (c.hour, c.minute) == (21, 0)12    o, c = regular_session_bounds_utc(dt.date(2024, 7, 10))   # EDT: 09:30 ET = 13:30 UTC13    assert (o.hour, o.minute) == (13, 30) and (c.hour, c.minute) == (20, 0)141516def test_early_close_day():17    b = session_bounds_table(dt.date(2023, 11, 20), dt.date(2023, 11, 30))18    r = b.filter(pl.col("session_date") == dt.date(2023, 11, 24)).row(0, named=True)19    assert r["close_minute"] == 210  # 13:00 ET close the day after Thanksgiving202122def test_shift_trading_days_skips_weekends_and_holidays():23    assert shift_trading_days(dt.date(2024, 7, 5), -1) == dt.date(2024, 7, 3)   # July 4 holiday24    assert shift_trading_days(dt.date(2024, 7, 8), -1) == dt.date(2024, 7, 5)25    assert trading_days_between(dt.date(2024, 7, 3), dt.date(2024, 7, 8)) == 2262728def test_close_print_is_at_1600_et():29    c = close_time_utc(dt.date(2022, 3, 14))  # first session after the spring-forward30    assert (c.hour, c.minute) == (20, 0)31
Files · main
Menu

Theme