Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deps #77

Merged
merged 2 commits into from
Oct 26, 2023
Merged

Deps #77

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions etc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions etc/requirements_dependabot/requirements_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
34 changes: 17 additions & 17 deletions etc/requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -310,19 +310,19 @@ 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
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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]
Expand Down
8 changes: 6 additions & 2 deletions tests/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down