From e338b3a008924cba1cb9e5e4ee7d26a691e04ab9 Mon Sep 17 00:00:00 2001 From: Loic Coyle Date: Sat, 22 Jun 2024 23:42:26 +0200 Subject: [PATCH 1/2] build(deps): update lock file --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 7f2e1ff..7a4592c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.0 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "appnope" @@ -2064,9 +2064,9 @@ docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.link testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy (>=0.9.1)", "pytest-ruff"] [extras] -premium = ["selenium", "webdriver-manager"] +premium = ["selenium"] [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4.0" -content-hash = "79b43190183d3827f506292ea737f1cd95cad8d73703b9cd098e1a0bc4452744" +content-hash = "527480bc4bae4f423536119cba6ba6d7e71d5861915b6401c066ada48066ea32" From 7503eca75f93477bc00357740714e3fa86dcc6e6 Mon Sep 17 00:00:00 2001 From: Loic Coyle Date: Sat, 22 Jun 2024 23:44:09 +0200 Subject: [PATCH 2/2] feat(ticker): fetch pre/post market data with `prepost` arg of `history` --- docs/docs/guide/ticker/historical.md | 1 + tests/test_ticker.py | 12 +++++++----- yahooquery/base.py | 1 + yahooquery/ticker.py | 4 ++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/docs/guide/ticker/historical.md b/docs/docs/guide/ticker/historical.md index f8860e3..df327bc 100644 --- a/docs/docs/guide/ticker/historical.md +++ b/docs/docs/guide/ticker/historical.md @@ -16,6 +16,7 @@ | end | Specific ending date | `str` or `datetime.datetime` | | optional | If a string is passed, use the format `YYYY-MM-DD` | adj_timezone | Adjust datetime to the specific symbol's timezone | `bool` | `True` | optional | `True`
`False` | adj_ohlc | Calculates an adjusted open, high, low and close prices according to split and dividend information | `bool` | `False` | optional | `True`
`False` + | prepost | Include Pre and Post market data | `bool` | `False` | optional | `True`
`False` !!! tip "One Minute Interval Data" The Yahoo Finance API restricts the amount of one minute interval data to seven days per request. However, the data availability extends to 30 days. The following will allow the user to retrieve the last 30 days of one minute interval data, with the one caveat that **4 requests are made in 7 day ranges to retrieve the desired data**: diff --git a/tests/test_ticker.py b/tests/test_ticker.py index c5495b8..acf359a 100644 --- a/tests/test_ticker.py +++ b/tests/test_ticker.py @@ -141,15 +141,17 @@ def test_p_get_financial_data(ticker): @pytest.mark.parametrize( - "period, interval", + "period, interval, prepost", [ - (p, i) - for p, i in zip( - ["1d", "1mo", "1y", "5y", "max"], ["1m", "1m", "1d", "1wk", "3mo"] + (p, i, prepost) + for p, i, prepost in zip( + ["1d", "1mo", "1y", "5y", "max"], + ["1m", "1m", "1d", "1wk", "3mo"], + [True, False, True, False, False], ) ], ) -def test_history(ticker, period, interval): +def test_history(ticker, period, interval, prepost): assert isinstance(ticker.history(period, interval), pd.DataFrame) diff --git a/yahooquery/base.py b/yahooquery/base.py index 0162d29..d9c226a 100644 --- a/yahooquery/base.py +++ b/yahooquery/base.py @@ -684,6 +684,7 @@ class _YahooFinance(object): "events": {"required": False, "default": "div,split"}, "numberOfPoints": {"required": False, "default": None}, "formatted": {"required": False, "default": False}, + "includePrePost": {"required": False, "default": None}, }, }, "options": { diff --git a/yahooquery/ticker.py b/yahooquery/ticker.py index 37cb549..efdcd9e 100644 --- a/yahooquery/ticker.py +++ b/yahooquery/ticker.py @@ -1231,6 +1231,7 @@ def history( end=None, adj_timezone=True, adj_ohlc=False, + prepost=False, ): """ Historical pricing data @@ -1256,6 +1257,8 @@ def history( adj_ohlc: bool, default False, optional Calculates an adjusted open, high, low and close prices according to split and dividend information + prepost: bool, default False, optional + Include Pre and Post market data. Returns ------- @@ -1287,6 +1290,7 @@ def history( "Interval values must be one of {}".format(", ".join(intervals)) ) params["interval"] = interval.lower() + params["includePrePost"] = prepost if params["interval"] == "1m" and period == "1mo": df = self._history_1m(adj_timezone, adj_ohlc) else: