From f117637364715b05e86dd1acd642e30cf80dc62e Mon Sep 17 00:00:00 2001 From: ymyke Date: Wed, 6 Apr 2022 13:36:34 +0200 Subject: [PATCH] Rename investpy pme functions to xpme Resolves #9 --- README.md | 12 ++++++------ pypme/__init__.py | 4 ++-- pypme/mod_investpy_pme.py | 6 +++--- tests/test_investpy_pypme.py | 14 +++++++------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 621d25c..da902a4 100644 --- a/README.md +++ b/README.md @@ -40,26 +40,26 @@ Notes: case, the IRR is for the underlying period. - `verbose_pme`: Calculate PME for evenly spaced cashflows and return vebose information. -- `investpy_pme` and `investpy_verbose_pme`: Use price information from Investing.com. +- `investpy_xpme` and `investpy_verbose_xpme`: Use price information from Investing.com. See below. ## Investpy examples -- using investpy to retrieve PME prices online -Use `investpy_pme` and `investpy_verbose_pme` to use a ticker from Investing.com and +Use `investpy_xpme` and `investpy_verbose_xpme` to use a ticker from Investing.com and compare with those prices. Like so: ```python from datetime import date -from pypme import investpy_pme +from pypme import investpy_xpme common_args = { "dates": [date(2012, 1, 1), date(2013, 1, 1)], "cashflows": [-100], "prices": [1, 1], } -print(investpy_pme(pme_ticker="Global X Lithium", pme_type="etf", **common_args)) -print(investpy_pme(pme_ticker="bitcoin", pme_type="crypto", **common_args)) -print(investpy_pme(pme_ticker="SRENH", pme_type="stock", pme_country="switzerland", **common_args)) +print(investpy_xpme(pme_ticker="Global X Lithium", pme_type="etf", **common_args)) +print(investpy_xpme(pme_ticker="bitcoin", pme_type="crypto", **common_args)) +print(investpy_xpme(pme_ticker="SRENH", pme_type="stock", pme_country="switzerland", **common_args)) ``` Produces: diff --git a/pypme/__init__.py b/pypme/__init__.py index bcc4636..fb4119c 100644 --- a/pypme/__init__.py +++ b/pypme/__init__.py @@ -1,7 +1,7 @@ __version__ = '0.2.0' from .pme import verbose_pme, pme, verbose_xpme, xpme from .mod_investpy_pme import ( - investpy_verbose_pme, - investpy_pme, + investpy_verbose_xpme, + investpy_xpme, pick_prices_from_dataframe, ) diff --git a/pypme/mod_investpy_pme.py b/pypme/mod_investpy_pme.py index 503fd54..9fdedfe 100644 --- a/pypme/mod_investpy_pme.py +++ b/pypme/mod_investpy_pme.py @@ -41,7 +41,7 @@ def get_historical_data(ticker: str, type: str, **kwargs) -> pd.DataFrame: return getattr(investpy, "get_" + type + "_historical_data")(**kwargs) -def investpy_verbose_pme( +def investpy_verbose_xpme( dates: List[date], cashflows: List[float], prices: List[float], @@ -64,7 +64,7 @@ def investpy_verbose_pme( ) -def investpy_pme( +def investpy_xpme( dates: List[date], cashflows: List[float], prices: List[float], @@ -75,6 +75,6 @@ def investpy_pme( """Calculate PME and return the PME IRR only, retrieving PME price information from Investing.com in real time. """ - return investpy_verbose_pme( + return investpy_verbose_xpme( dates, cashflows, prices, pme_ticker, pme_type, pme_country )[0] diff --git a/tests/test_investpy_pypme.py b/tests/test_investpy_pypme.py index fadb9ad..91f67ff 100644 --- a/tests/test_investpy_pypme.py +++ b/tests/test_investpy_pypme.py @@ -1,7 +1,7 @@ import pytest from datetime import date import pandas as pd -from pypme.mod_investpy_pme import investpy_pme, investpy_verbose_pme +from pypme.mod_investpy_pme import investpy_xpme, investpy_verbose_xpme @pytest.mark.parametrize( @@ -32,7 +32,7 @@ ), ], ) -def test_investpy_pme( +def test_investpy_xpme( mocker, dates, cashflows, @@ -53,7 +53,7 @@ def test_investpy_pme( {"Close": {pd.Timestamp(x): y for x, y in zip(pme_timestamps, pme_prices)}} ), ) - pme_irr, asset_irr, df = investpy_verbose_pme( + pme_irr, asset_irr, df = investpy_verbose_xpme( dates=dates, cashflows=cashflows, prices=prices, @@ -63,7 +63,7 @@ def test_investpy_pme( assert round(asset_irr * 100.0, 2) == round(target_asset_irr, 2) assert isinstance(df, pd.DataFrame) - pme_irr = investpy_pme( + pme_irr = investpy_xpme( dates=dates, cashflows=cashflows, prices=prices, @@ -72,9 +72,9 @@ def test_investpy_pme( assert round(pme_irr * 100.0, 2) == round(target_pme_irr, 2) -def test_investpy_pme_networked(): - """Test `investpy_pme` with an actual network/API call.""" - pme_irr, asset_irr, df = investpy_verbose_pme( +def test_investpy_xpme_networked(): + """Test `investpy_xpme` with an actual network/API call.""" + pme_irr, asset_irr, df = investpy_verbose_xpme( dates=[date(2012, 1, 1), date(2013, 1, 1)], cashflows=[-100], prices=[1, 1.1],