mirror of
https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git
synced 2025-07-22 22:21:33 +00:00
just need to smash bugs and the update is done
This commit is contained in:
134
T_info.py
134
T_info.py
@@ -3,34 +3,9 @@
|
||||
|
||||
import re
|
||||
import requests as r
|
||||
import pandas as pd
|
||||
|
||||
from typing import List, Dict
|
||||
|
||||
|
||||
class T_info:
|
||||
STOCK_REGEX = "[$]([a-zA-Z]{1,4})"
|
||||
CRYPTO_REGEX = "[$$]([a-zA-Z]{1,9})"
|
||||
|
||||
def find_symbols(self, text: str) -> List[str, str]:
|
||||
"""Finds stock tickers starting with a dollar sign, and cryptocurrencies with two dollar signs
|
||||
in a blob of text and returns them in a list.
|
||||
Only returns each match once. Example: Whats the price of $tsla?
|
||||
|
||||
Parameters
|
||||
----------
|
||||
text : str
|
||||
Blob of text.
|
||||
|
||||
Returns
|
||||
-------
|
||||
List[str]
|
||||
List of stock symbols as strings without dollar sign.
|
||||
"""
|
||||
symbols = list(set(re.findall(self.SYMBOL_REGEX, text)))
|
||||
crypto = list(set(re.findall(self.SYMBOL_REGEX, text)))
|
||||
return
|
||||
|
||||
license = re.sub(
|
||||
r"\b\n",
|
||||
" ",
|
||||
@@ -80,112 +55,3 @@ If you have any questions get in touch: @MisterBiggs or[anson@ansonbiggs.com](ht
|
||||
|
||||
_Donations can only be made in a chat directly with @simplestockbot_
|
||||
"""
|
||||
|
||||
def status(self) -> str:
|
||||
"""Checks IEX Status dashboard for any current API issues.
|
||||
|
||||
Returns
|
||||
-------
|
||||
str
|
||||
Human readable text on status of IEX API
|
||||
"""
|
||||
|
||||
def price_reply(self, symbols: list) -> Dict[str, str]:
|
||||
"""Returns current market price or after hours if its available for a given stock symbol.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
symbols : list
|
||||
List of stock symbols.
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
def dividend_reply(self, symbol: str) -> Dict[str, str]:
|
||||
"""Returns the most recent, or next dividend date for a stock symbol.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
symbols : list
|
||||
List of stock symbols.
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
def news_reply(self, symbols: list) -> Dict[str, str]:
|
||||
"""Gets recent english news on stock symbols.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
symbols : list
|
||||
List of stock symbols.
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
def info_reply(self, symbols: List[str]) -> Dict[str, str]:
|
||||
"""Gets information on stock symbols.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
symbols : List[str]
|
||||
List of stock symbols.
|
||||
|
||||
Returns
|
||||
-------
|
||||
Dict[str, str]
|
||||
Each symbol passed in is a key with its value being a human readable formatted string of the symbols information.
|
||||
"""
|
||||
|
||||
def intra_reply(self, symbol: str) -> pd.DataFrame:
|
||||
"""Returns price data for a symbol since the last market open.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
symbol : str
|
||||
Stock symbol.
|
||||
|
||||
Returns
|
||||
-------
|
||||
pd.DataFrame
|
||||
Returns a timeseries dataframe with high, low, and volume data if its available. Otherwise returns empty pd.DataFrame.
|
||||
"""
|
||||
|
||||
def chart_reply(self, symbol: str) -> pd.DataFrame:
|
||||
"""Returns price data for a symbol of the past month up until the previous trading days close.
|
||||
Also caches multiple requests made in the same day.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
symbol : str
|
||||
Stock symbol.
|
||||
|
||||
Returns
|
||||
-------
|
||||
pd.DataFrame
|
||||
Returns a timeseries dataframe with high, low, and volume data if its available. Otherwise returns empty pd.DataFrame.
|
||||
"""
|
||||
|
||||
def stat_reply(self, symbols: List[str]) -> Dict[str, str]:
|
||||
"""Gets key statistics for each symbol in the list
|
||||
|
||||
Parameters
|
||||
----------
|
||||
symbols : List[str]
|
||||
List of stock symbols
|
||||
|
||||
Returns
|
||||
-------
|
||||
Dict[str, str]
|
||||
Each symbol passed in is a key with its value being a human readable formatted string of the symbols statistics.
|
||||
"""
|
||||
|
Reference in New Issue
Block a user