Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ymyke committed Mar 13, 2022
1 parent e699858 commit 47f4620
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions pypme/mod_investpy_pme.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
"""
Types can be any of stock, etf, fund, crypto.
"""Calculate PME and get the prices from Investing.com via the `investpy` module.
Important: The Investing API has rate limiting measures in place and will block you if
you hit the API too often. You will notice by getting 429 errors (or maybe
also/alternatively 503). Wait roughly 2 seconds between each consecutive call to the API
via the functions in this module.
Args:
- pme_type: One of "stock", "etf", "fund", "crypto", "bond", "index", "certificate".
Defaults to "stock".
- pme_ticker: The ticker symbol/name.
- pme_country: The ticker's country of residence. Defaults to "united states".
Refer to the `pme` module to understand other arguments and what the functions return.
"""

from typing import List, Tuple
Expand All @@ -8,12 +20,9 @@
import investpy
from .pme import verbose_xpme

# FIXME Add documentation (here and in README)


def get_historical_data(ticker: str, type: str, **kwargs) -> pd.DataFrame:
"""Small wrapper to make the investpy interface accessible in a more unified fashion.
"""
"""Small wrapper to make the investpy interface accessible in a more unified fashion."""
kwargs[type] = ticker
if type == "crypto" and "country" in kwargs:
del kwargs["country"]
Expand All @@ -28,7 +37,8 @@ def investpy_verbose_pme(
pme_type: str = "stock",
pme_country: str = "united states",
) -> Tuple[float, float, pd.DataFrame]:
"""Calculate PME for unevenly spaced / scheduled cashflows and return vebose information. FIXME
"""Calculate PME return vebose information, retrieving PME price information from
Investing.com in real time.
"""
dates_as_str = [x.strftime("%d/%m/%Y") for x in sorted(dates)]
pmedf = get_historical_data(
Expand All @@ -54,7 +64,8 @@ def investpy_pme(
pme_type: str = "stock",
pme_country: str = "united states",
) -> Tuple[float, float, pd.DataFrame]:
"""Calculate PME for unevenly spaced / scheduled cashflows and return the PME IRR only. FIXME
"""Calculate PME and return the PME IRR only, retrieving PME price information from
Investing.com in real time.
"""
return investpy_verbose_pme(
dates, cashflows, prices, pme_ticker, pme_type, pme_country
Expand Down

0 comments on commit 47f4620

Please sign in to comment.