Skip to content

Commit

Permalink
Rename investpy pme functions to xpme
Browse files Browse the repository at this point in the history
Resolves #9
  • Loading branch information
ymyke committed Apr 6, 2022
1 parent 3e981cb commit f117637
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions pypme/__init__.py
Original file line number Diff line number Diff line change
@@ -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,
)
6 changes: 3 additions & 3 deletions pypme/mod_investpy_pme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -64,7 +64,7 @@ def investpy_verbose_pme(
)


def investpy_pme(
def investpy_xpme(
dates: List[date],
cashflows: List[float],
prices: List[float],
Expand All @@ -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]
14 changes: 7 additions & 7 deletions tests/test_investpy_pypme.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -32,7 +32,7 @@
),
],
)
def test_investpy_pme(
def test_investpy_xpme(
mocker,
dates,
cashflows,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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],
Expand Down

0 comments on commit f117637

Please sign in to comment.