Skip to content

Commit

Permalink
Reinstate xfail on test_monthly_freq
Browse files Browse the repository at this point in the history
Pandas fix yet to be included to a release - see comments in
code by test.

Also:
- corrects typing of decorated hypothesis strategies.
- updates `test_yahoo` flaky list
  • Loading branch information
maread99 committed Sep 22, 2024
1 parent a85fc00 commit 82b3b3b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 45 deletions.
66 changes: 21 additions & 45 deletions tests/hypstrtgy.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def calendar_session(
draw,
calendar_name: str,
limit: tuple[pd.Timestamp | None, pd.Timestamp | None] = (None, None),
) -> st.SearchStrategy[pd.Timestamp]:
) -> pd.Timestamp:
"""Return strategy to generate a session for a given calendar.
Parameters
Expand Down Expand Up @@ -96,7 +96,7 @@ def calendar_start_end_sessions(
limit: tuple[pd.Timestamp | None, pd.Timestamp | None] = (None, None),
min_dist: int | pd.Timedelta = 0,
max_dist: int | pd.Timedelta | None = None,
) -> st.SearchStrategy[tuple[pd.Timestamp, pd.Timestamp]]:
) -> tuple[pd.Timestamp, pd.Timestamp]:
"""Return strategy to generate a start and end session for a given calendar.
Parameters
Expand Down Expand Up @@ -163,7 +163,7 @@ def start_minutes(
draw,
calendar_name: str,
limit: tuple[pd.Timestamp | None, pd.Timestamp | None] = (None, None),
) -> st.SearchStrategy[pd.Timestamp]:
) -> pd.Timestamp:
"""Return strategy to generate a 'start' minute for a given calendar.
Minute will represent a trading minute (not a close).
Expand Down Expand Up @@ -211,7 +211,7 @@ def end_minutes(
draw,
calendar_name: str,
limit: tuple[pd.Timestamp | None, pd.Timestamp | None] = (None, None),
) -> st.SearchStrategy[pd.Timestamp]:
) -> pd.Timestamp:
"""Return strategy to generate an 'end' minute for a given calendar.
Minute will represent a trading minute, excluding open minutes, or a
Expand Down Expand Up @@ -267,7 +267,7 @@ def end_minutes(
def calendar_start_end_minutes(
draw,
calendar_name: str,
) -> st.SearchStrategy[tuple[pd.Timestamp, pd.Timestamp]]:
) -> tuple[pd.Timestamp, pd.Timestamp]:
"""Return strategy to generate a start and end minute for a given calendar.
'start' will be a trading minute.
Expand Down Expand Up @@ -297,9 +297,7 @@ def get_pp_default() -> dict[str, typing.Any]:


@st.composite
def pp_start_end_sessions(
draw, calendar_name: str
) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_start_end_sessions(draw, calendar_name: str) -> dict[str, typing.Any]:
"""Return strategy to generate period parameters with 'start' and 'end' only.
'start' and 'end' will both be sessions of `calendar`.
Expand All @@ -312,9 +310,7 @@ def pp_start_end_sessions(


@st.composite
def pp_end_minute_only(
draw, calendar_name: str
) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_end_minute_only(draw, calendar_name: str) -> dict[str, typing.Any]:
"""Return strategy to generate period parameters with 'end' only.
'end' will be a trading minute or a close minute of `calendar_name`.
Expand All @@ -327,9 +323,7 @@ def pp_end_minute_only(


@st.composite
def pp_start_end_minutes(
draw, calendar_name: str
) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_start_end_minutes(draw, calendar_name: str) -> dict[str, typing.Any]:
"""Return strategy to generate period parameters with 'start' and 'end' only.
'start' will be a trading minute, 'end' will be a trading minute or a
Expand All @@ -344,7 +338,7 @@ def pp_start_end_minutes(


@st.composite
def pp_days(draw, calendar_name: str) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_days(draw, calendar_name: str) -> dict[str, typing.Any]:
"""Return strategy to generate specific arrangment of period parameters.
duration defined in 'days'.
Expand Down Expand Up @@ -374,7 +368,7 @@ def pp_days_start_session(
draw,
calendar_name: str,
start_will_roll_to_ms: bool = False,
) -> st.SearchStrategy[dict[str, typing.Any]]:
) -> dict[str, typing.Any]:
"""Return strategy to generate specific arrangment of period parameters.
duration defined in 'days'.
Expand Down Expand Up @@ -411,9 +405,7 @@ def pp_days_start_session(


@st.composite
def pp_days_end_session(
draw, calendar_name: str
) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_days_end_session(draw, calendar_name: str) -> dict[str, typing.Any]:
"""Return strategy to generate specific arrangment of period parameters.
duration defined in 'days'.
Expand All @@ -438,9 +430,7 @@ def pp_days_end_session(


@st.composite
def pp_days_start_minute(
draw, calendar_name: str
) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_days_start_minute(draw, calendar_name: str) -> dict[str, typing.Any]:
"""Return strategy to generate specific arrangment of period parameters.
duration defined in 'days'.
Expand All @@ -461,9 +451,7 @@ def pp_days_start_minute(


@st.composite
def pp_days_end_minute(
draw, calendar_name: str
) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_days_end_minute(draw, calendar_name: str) -> dict[str, typing.Any]:
"""Return strategy to generate specific arrangment of period parameters.
duration defined in 'days'.
Expand All @@ -481,7 +469,7 @@ def pp_days_end_minute(


@st.composite
def pp_caldur(draw) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_caldur(draw) -> dict[str, typing.Any]:
"""Return strategy to generate specific arrangment of period parameters.
duration defined in 'weeks' and/or 'months' and/or 'years' (i.e.
Expand All @@ -500,9 +488,7 @@ def pp_caldur(draw) -> st.SearchStrategy[dict[str, typing.Any]]:


@st.composite
def pp_caldur_start_session(
draw, calendar_name: str
) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_caldur_start_session(draw, calendar_name: str) -> dict[str, typing.Any]:
"""Return strategy to generate specific arrangment of period parameters.
- duration defined in 'weeks' and/or 'months' and/or 'years' (i.e.
Expand Down Expand Up @@ -530,9 +516,7 @@ def pp_caldur_start_session(


@st.composite
def pp_caldur_end_session(
draw, calendar_name: str
) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_caldur_end_session(draw, calendar_name: str) -> dict[str, typing.Any]:
"""Return strategy to generate specific arrangment of period parameters.
- duration defined in 'weeks' and/or 'months' and/or 'years' (i.e.
Expand Down Expand Up @@ -568,9 +552,7 @@ def pp_caldur_end_session(


@st.composite
def pp_caldur_start_minute(
draw, calendar_name: str
) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_caldur_start_minute(draw, calendar_name: str) -> dict[str, typing.Any]:
"""Return strategy to generate specific arrangment of period parameters.
- duration defined in 'weeks' and/or 'months' and/or 'years' (i.e.
Expand Down Expand Up @@ -598,9 +580,7 @@ def pp_caldur_start_minute(


@st.composite
def pp_caldur_end_minute(
draw, calendar_name: str
) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_caldur_end_minute(draw, calendar_name: str) -> dict[str, typing.Any]:
"""Return strategy to generate specific arrangment of period parameters.
- duration defined in 'weeks' and/or 'months' and/or 'years' (i.e.
Expand All @@ -619,7 +599,7 @@ def pp_caldur_end_minute(


@st.composite
def pp_intraday(draw) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_intraday(draw) -> dict[str, typing.Any]:
"""Return strategy to generate specific arrangment of period parameters.
- duration defined in 'minutes' and/or 'hours' (i.e. in trading
Expand All @@ -637,9 +617,7 @@ def pp_intraday(draw) -> st.SearchStrategy[dict[str, typing.Any]]:


@st.composite
def pp_intraday_start_minute(
draw, calendar_name: str
) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_intraday_start_minute(draw, calendar_name: str) -> dict[str, typing.Any]:
"""Return strategy to generate specific arrangment of period parameters.
- duration defined in 'minutes' and/or 'hours' (i.e. in trading
Expand All @@ -660,9 +638,7 @@ def pp_intraday_start_minute(


@st.composite
def pp_intraday_end_minute(
draw, calendar_name: str
) -> st.SearchStrategy[dict[str, typing.Any]]:
def pp_intraday_end_minute(draw, calendar_name: str) -> dict[str, typing.Any]:
"""Return strategy to generate specific arrangment of period parameters.
- duration defined in 'minutes' and/or 'hours' (i.e. in trading
Expand Down
6 changes: 6 additions & 0 deletions tests/test_pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,12 @@ def test_cbday_freq(self, daily_pt_ss, xnys):
df.pt.downsample("3d", xnys),
)

# TODO Remove xfail when pandas >3 or fix otherwise released
# NB pd bug manifests in test, not package (manifests where takes a slice to
# evaluate 'subset').
# pandas issue ref is https://github.com/pandas-dev/pandas/issues/58604
# https://github.com/pandas-dev/pandas/pull/58043, related PR, ya merged to dev
@pytest.mark.xfail(reason="Known pd issue with py3.12, should resolve with pd>3.0")
def test_monthly_freq(self, daily_pt, xnys, x247, one_day, symbols):
"""Verify "MS" and "QS" frequencies."""
df = daily_pt
Expand Down
3 changes: 3 additions & 0 deletions tests/test_yahoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
# ...sessions that yahoo temporarily fails to return prices for if (seemingly)
# send a high frequency of requests for prices from the same IP address.
_flakylist = (
pd.Timestamp("2024-08-26"),
pd.Timestamp("2024-08-25"),
pd.Timestamp("2024-08-24"),
pd.Timestamp("2024-05-28"),
pd.Timestamp("2024-05-27"),
pd.Timestamp("2024-01-21"),
Expand Down

0 comments on commit 82b3b3b

Please sign in to comment.