diff --git a/etc/requirements.txt b/etc/requirements.txt index b4cbd32..b8c3bc4 100644 --- a/etc/requirements.txt +++ b/etc/requirements.txt @@ -8,11 +8,11 @@ asttokens==2.4.0 # via stack-data backcall==0.2.0 # via ipython -bqplot==0.12.40 +bqplot==0.12.42 # via market-analy (pyproject.toml) certifi==2023.7.22 # via requests -charset-normalizer==3.3.0 +charset-normalizer==3.3.1 # via requests colorama==0.4.6 # via @@ -63,7 +63,7 @@ korean-lunar-calendar==0.3.1 # via exchange-calendars lxml==4.9.3 # via yahooquery -market-prices==0.11 +market-prices==0.11.1 # via market-analy (pyproject.toml) markupsafe==2.1.3 # via jinja2 @@ -126,7 +126,7 @@ toolz==0.12.0 # via exchange-calendars tqdm==4.66.1 # via yahooquery -traitlets==5.11.2 +traitlets==5.12.0 # via # bqplot # comm @@ -145,7 +145,7 @@ tzdata==2023.3 # market-analy (pyproject.toml) # market-prices # pandas -urllib3==2.0.6 +urllib3==2.0.7 # via requests valimp==0.1 # via market-prices diff --git a/etc/requirements_dependabot/requirements_tests.txt b/etc/requirements_dependabot/requirements_tests.txt index c2ae8b1..8c8c79a 100644 --- a/etc/requirements_dependabot/requirements_tests.txt +++ b/etc/requirements_dependabot/requirements_tests.txt @@ -8,13 +8,13 @@ asttokens==2.4.0 # via stack-data backcall==0.2.0 # via ipython -black==23.9.1 +black==23.10.1 # via market-analy (pyproject.toml) -bqplot==0.12.40 +bqplot==0.12.42 # via market-analy (pyproject.toml) certifi==2023.7.22 # via requests -charset-normalizer==3.3.0 +charset-normalizer==3.3.1 # via requests click==8.1.7 # via black @@ -79,7 +79,7 @@ korean-lunar-calendar==0.3.1 # via exchange-calendars lxml==4.9.3 # via yahooquery -market-prices==0.11 +market-prices==0.11.1 # via market-analy (pyproject.toml) markupsafe==2.1.3 # via jinja2 @@ -140,11 +140,11 @@ pyluach==2.2.0 # via exchange-calendars pyparsing==3.1.1 # via matplotlib -pytest==7.4.2 +pytest==7.4.3 # via # market-analy (pyproject.toml) # pytest-mock -pytest-mock==3.11.1 +pytest-mock==3.12.0 # via market-analy (pyproject.toml) python-dateutil==2.8.2 # via @@ -173,7 +173,7 @@ toolz==0.12.0 # via exchange-calendars tqdm==4.66.1 # via yahooquery -traitlets==5.11.2 +traitlets==5.12.0 # via # bqplot # comm @@ -194,7 +194,7 @@ tzdata==2023.3 # market-analy (pyproject.toml) # market-prices # pandas -urllib3==2.0.6 +urllib3==2.0.7 # via requests valimp==0.1 # via market-prices diff --git a/etc/requirements_dev.txt b/etc/requirements_dev.txt index 93a124e..1d24dd0 100644 --- a/etc/requirements_dev.txt +++ b/etc/requirements_dev.txt @@ -12,7 +12,7 @@ argon2-cffi-bindings==21.2.0 # via argon2-cffi arrow==1.3.0 # via isoduration -astroid==3.0.0 +astroid==3.0.1 # via pylint asttokens==2.4.0 # via stack-data @@ -22,17 +22,17 @@ attrs==23.1.0 # via # jsonschema # referencing -babel==2.13.0 +babel==2.13.1 # via jupyterlab-server backcall==0.2.0 # via ipython beautifulsoup4==4.12.2 # via nbconvert -black==23.9.1 +black==23.10.1 # via market-analy (pyproject.toml) bleach==6.1.0 # via nbconvert -bqplot==0.12.40 +bqplot==0.12.42 # via market-analy (pyproject.toml) build==1.0.3 # via pip-tools @@ -42,7 +42,7 @@ cffi==1.16.0 # via argon2-cffi-bindings cfgv==3.4.0 # via pre-commit -charset-normalizer==3.3.0 +charset-normalizer==3.3.1 # via requests click==8.1.7 # via @@ -118,7 +118,7 @@ importlib-resources==6.1.0 # via matplotlib iniconfig==2.0.0 # via pytest -ipykernel==6.25.2 +ipykernel==6.26.0 # via jupyterlab ipython==8.16.1 # via @@ -157,7 +157,7 @@ jsonschema[format-nongpl]==4.19.1 # nbformat jsonschema-specifications==2023.7.1 # via jsonschema -jupyter-client==8.4.0 +jupyter-client==8.5.0 # via # ipykernel # jupyter-server @@ -171,11 +171,11 @@ jupyter-core==5.4.0 # nbclient # nbconvert # nbformat -jupyter-events==0.7.0 +jupyter-events==0.8.0 # via jupyter-server jupyter-lsp==2.2.0 # via jupyterlab -jupyter-server==2.7.3 +jupyter-server==2.9.1 # via # jupyter-lsp # jupyterlab @@ -197,7 +197,7 @@ korean-lunar-calendar==0.3.1 # via exchange-calendars lxml==4.9.3 # via yahooquery -market-prices==0.11 +market-prices==0.11.1 # via market-analy (pyproject.toml) markupsafe==2.1.3 # via @@ -215,7 +215,7 @@ mccabe==0.7.0 # pylint mistune==3.0.2 # via nbconvert -mypy==1.6.0 +mypy==1.6.1 # via market-analy (pyproject.toml) mypy-extensions==1.0.0 # via @@ -310,7 +310,7 @@ pygments==2.16.1 # via # ipython # nbconvert -pylint==3.0.1 +pylint==3.0.2 # via market-analy (pyproject.toml) pyluach==2.2.0 # via exchange-calendars @@ -318,11 +318,11 @@ pyparsing==3.1.1 # via matplotlib pyproject-hooks==1.0.0 # via build -pytest==7.4.2 +pytest==7.4.3 # via # market-analy (pyproject.toml) # pytest-mock -pytest-mock==3.11.1 +pytest-mock==3.12.0 # via market-analy (pyproject.toml) python-dateutil==2.8.2 # via @@ -419,7 +419,7 @@ tornado==6.3.3 # terminado tqdm==4.66.1 # via yahooquery -traitlets==5.11.2 +traitlets==5.12.0 # via # bqplot # comm @@ -459,11 +459,11 @@ tzdata==2023.3 # pandas uri-template==1.3.0 # via jsonschema -urllib3==2.0.6 +urllib3==2.0.7 # via requests valimp==0.1 # via market-prices -virtualenv==20.24.5 +virtualenv==20.24.6 # via pre-commit wcwidth==0.2.8 # via prompt-toolkit diff --git a/tests/conftest.py b/tests/conftest.py index e1db2a3..3524bc9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -75,6 +75,17 @@ def _pickle_new_prices(symbols: str, path: pathlib.Path): file.close() +CAL_START = "1986-03-13" +XLON = xcals.get_calendar("XLON", start=CAL_START) +CAL_MAPPING = { + "AZN.L": XLON, + "BARC.L": XLON, + "MSFT": xcals.get_calendar("XNYS", start=CAL_START), + "9988.HK": xcals.get_calendar("XHKG", start=CAL_START), +} +DELAY_MAPPING = {"AZN.L": 15, "BARC.L": 15, "MSFT": 0, "9988.HK": 15} + + def _unpickle_prices(path: pathlib.Path, class_mocker) -> mp.PricesYahoo: """Reconstruct an instance of `PricesYahoo` to use in testing""" file = open(path, "rb") @@ -87,7 +98,9 @@ def _mock_now(*args, **kwargs) -> pd.Timestamp: # reconstruct each of the data instances symbols = pickle.load(file) - prices = mp.PricesYahoo(symbols) + calendars = {s: CAL_MAPPING[s] for s in symbols} + delays = {s: DELAY_MAPPING[s] for s in symbols} + prices = mp.PricesYahoo(symbols, calendars=calendars, delays=delays) for bi in prices.bis: data = prices._pdata[bi] diff --git a/tests/test_analysis.py b/tests/test_analysis.py index c649830..d308e11 100644 --- a/tests/test_analysis.py +++ b/tests/test_analysis.py @@ -298,13 +298,16 @@ def tz(self) -> abc.Iterator[ZoneInfo]: yield ZoneInfo("Europe/London") def test_constructor_raises(self): + prices = mp.PricesYahoo( + "AZN.L, MSFT", calendars=["XLON", "XNYS"], delays=[15, 0] + ) msg = re.escape( "The Analysis class requires a `prices` instance that gets" "price data for a single symbol, although the past instance" " gets prices for 2: ['AZN.L', 'MSFT']." ) with pytest.raises(ValueError, match=msg): - analysis.Analysis(mp.PricesYahoo("AZN.L, MSFT")) + analysis.Analysis(prices) def test_prices(self, analy, prices_analysis): assert analy.prices is prices_analysis @@ -1399,13 +1402,14 @@ def tz(self) -> abc.Iterator[ZoneInfo]: yield ZoneInfo("America/New_York") def test_constructor_raises(self): + prices = mp.PricesYahoo("MSFT", calendars="XNYS", delays=0) msg = re.escape( "The Compare class requires a `prices` instance that gets" "price data for multiple symbols, although the past instance" "gets prices for only one: MSFT." ) with pytest.raises(ValueError, match=msg): - analysis.Compare(mp.PricesYahoo("MSFT")) + analysis.Compare(prices) def test_prices(self, analy, prices_compare): assert analy.prices is prices_compare