1
0
mirror of https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git synced 2025-07-25 23:51:32 +00:00

updated all docstrings

This commit is contained in:
2021-07-02 12:41:36 -07:00
parent acc0ebdd28
commit 43976e873a
8 changed files with 114 additions and 359 deletions

View File

@@ -30,7 +30,7 @@ class IEX_Symbol:
Parameters
----------
IEX_TOKEN : str
IEX Token
IEX API Token
"""
try:
self.IEX_TOKEN = os.environ["IEX"]
@@ -47,12 +47,28 @@ class IEX_Symbol:
schedule.every().day.do(self.clear_charts)
def clear_charts(self) -> None:
"""Clears cache of chart data."""
"""
Clears cache of chart data.
Charts are cached so that only 1 API call per 24 hours is needed since the
chart data is expensive and a large download.
"""
self.charts = {}
def get_symbol_list(
self, return_df=False
) -> Optional[Tuple[pd.DataFrame, datetime]]:
"""Gets list of all symbols supported by IEX
Parameters
----------
return_df : bool, optional
return the dataframe of all stock symbols, by default False
Returns
-------
Optional[Tuple[pd.DataFrame, datetime]]
If `return_df` is set to `True` returns a dataframe, otherwise returns `None`.
"""
reg_symbols = r.get(
f"https://cloud.iexapis.com/stable/ref-data/symbols?token={self.IEX_TOKEN}",
@@ -145,18 +161,16 @@ class IEX_Symbol:
return symbol_list
def price_reply(self, symbol: Stock) -> str:
"""Returns current market price or after hours if its available for a given stock symbol.
"""Returns price movement of Stock for the last market day, or after hours.
Parameters
----------
symbols : list
List of stock symbols.
symbol : Stock
Returns
-------
Dict[str, str]
Each symbol passed in is a key with its value being a human readable
markdown formatted string of the symbols price and movement.
str
Formatted markdown
"""
IEXurl = f"https://cloud.iexapis.com/stable/stock/{symbol.id}/quote?token={self.IEX_TOKEN}"
@@ -223,13 +237,12 @@ class IEX_Symbol:
Parameters
----------
symbols : list
List of stock symbols.
symbol : Stock
Returns
-------
Dict[str, str]
Each symbol passed in is a key with its value being a human readable formatted string of the symbols div dates.
str
Formatted markdown
"""
if symbol.symbol.upper() in self.otc_list:
return "OTC stocks do not currently support any commands."
@@ -284,17 +297,16 @@ class IEX_Symbol:
return f"${symbol.id.upper()} either doesn't exist or pays no dividend."
def news_reply(self, symbol: Stock) -> str:
"""Gets recent english news on stock symbols.
"""Gets most recent, english, non-paywalled news
Parameters
----------
symbols : list
List of stock symbols.
symbol : Stock
Returns
-------
Dict[str, str]
Each symbol passed in is a key with its value being a human readable markdown formatted string of the symbols news.
str
Formatted markdown
"""
if symbol.symbol.upper() in self.otc_list:
return "OTC stocks do not currently support any commands."
@@ -323,17 +335,16 @@ class IEX_Symbol:
return f"News for **{symbol.id.upper()}**:\n" + "\n".join(line[:5])
def info_reply(self, symbol: Stock) -> str:
"""Gets information on stock symbols.
"""Gets description for Stock
Parameters
----------
symbols : List[str]
List of stock symbols.
symbol : Stock
Returns
-------
Dict[str, str]
Each symbol passed in is a key with its value being a human readable formatted string of the symbols information.
str
Formatted text
"""
if symbol.symbol.upper() in self.otc_list:
return "OTC stocks do not currently support any commands."
@@ -354,17 +365,16 @@ class IEX_Symbol:
return f"No information found for: {symbol}\nEither today is boring or the symbol does not exist."
def stat_reply(self, symbol: Stock) -> str:
"""Gets key statistics for each symbol in the list
"""Key statistics on a Stock
Parameters
----------
symbols : List[str]
List of stock symbols
symbol : Stock
Returns
-------
Dict[str, str]
Each symbol passed in is a key with its value being a human readable formatted string of the symbols statistics.
str
Formatted markdown
"""
if symbol.symbol.upper() in self.otc_list:
return "OTC stocks do not currently support any commands."
@@ -503,7 +513,7 @@ class IEX_Symbol:
Returns
-------
list[str]
list of $ID: NAME
list of $ID: NAME, CHANGE%
"""
stocks = r.get(