finpandas.core package¶
Submodules¶
finpandas.core.connections module¶
finpandas base module.
-
class
finpandas.core.connections.
DatabaseConnection
(database: str, username: str = 'finpandas', password: Optional[str] = None, _host: str = 'database-blacktip.cpeql2xeyjqq.us-east-2.rds.amazonaws.com', _port: int = 3306)[source]¶ Bases:
object
Establish a connection with the database.
- Args:
username (str): your username password (str): your password
-
_commitdb
(table_name: str, dataframe: pandas.core.frame.DataFrame)[source]¶ commit to the database
- Args:
table_name (str): the name of the table to commit to dataframe (pd.DataFrame): the data to commit to the table
-
_create_engine
() → sqlalchemy.engine.base.Engine[source]¶ establish connection to MySQL database
- Returns:
sqlalchemy.engine.Engine: SQLAlchemy engine instance
-
_host
: str = 'database-blacktip.cpeql2xeyjqq.us-east-2.rds.amazonaws.com'¶
-
_port
: int = 3306¶
-
database
: str¶
-
password
: str = None¶
-
query
(command: str)[source]¶ query information directly from the database
- Args:
command (str): the string mySQL command to execute
- Returns:
sqlalchemy.engine.Result: the results of the query
-
username
: str = 'finpandas'¶
finpandas.core.datasources module¶
Used for analysis of public companies filing with the United States SEC.
-
class
finpandas.core.datasources.
Fundamentals
(database: str = 'xbrl', username: str = 'finpandas', password: Optional[str] = None, _host: str = 'database-blacktip.cpeql2xeyjqq.us-east-2.rds.amazonaws.com', _port: int = 3306)[source]¶ Bases:
finpandas.core.connections.DatabaseConnection
Fundamentals API
- Args:
database (str, optional): database to connect to. Defaults to ‘xbrl’.
-
database
: str = 'xbrl'¶
-
ten_k
(ticker_or_cik: Union[str, int], years: Union[int, Iterable[int]]) → finpandas.dataframes.forms.Form10K[source]¶ get company 10-Ks for selected years
- Args:
ticker_or_cik (Union[str,int]): company’s ticker or SEC issued Central Index Key (CIK) years (Union[int,Iterable[int]]): a year or iterable of years of interest
- Returns:
Form10K: a representation of the company’s 10Ks
-
ten_q
(ticker_or_cik: Union[str, int], periods: Union[int, Iterable[int], Tuple[Union[str, int], Union[str, int]], Iterable[Tuple[Union[str, int], Union[str, int]]]]) → finpandas.dataframes.forms.Form10Q[source]¶ get company 10-Qs for selected periods
- Args:
ticker_or_cik (Union[str,int]): company’s ticker or SEC issued Central Index Key (CIK) periods (Union[int,Iterable[int],Tuple[Union[str,int],Union[str,int]], Iterable[Tuple[Union[str,int],Union[str,int]]]]): the year of interest, will get all
quarters; years of interest, will get all quarters; (year, quarter) pair; (year, quarter) pairs of interest
- Raises:
NestedDepthError: inputted periods is not one of the correct formats
- Returns:
Form10Q: a representation of the company’s 10Qs
- Example:
Querying 10-Q reports for Apple Inc.:
df = instance.ten_q("AAPL", 2019) df = instance.ten_q("AAPL", [2018, 2019]) df = instance.ten_q("AAPL", (2019, "q1")) df = instance.ten_q("AAPL", [(2019, "q1"), (2019, "q2")]
-
class
finpandas.core.datasources.
Stocks
(database: str = 'stocks', username: str = 'finpandas', password: Optional[str] = None, _host: str = 'database-blacktip.cpeql2xeyjqq.us-east-2.rds.amazonaws.com', _port: int = 3306)[source]¶ Bases:
finpandas.core.connections.DatabaseConnection
Stocks API
- Args:
database (str, optional): database to connect to. Defaults to ‘stocks’.
-
database
: str = 'stocks'¶
-
price
(ticker_or_cik: Union[str, int], period_start: str, period_end: Optional[str] = None) → pandas.core.frame.DataFrame[source]¶ queries the price of a given equity over a period
- Args:
- ticker_or_cik (Union[str,int]): company or fund’s ticker or SEC
issued Central Index Key (CIK)
- period_start (str): the starting day for the period,
in year-month-day format (e.g. 2020-06-30).
- period_end (str, optional): the ending day for the period,
in year-month-day format (e.g. 2020-06-30). Defaults to None, indicating a single day period_start.
- Returns:
pd.DataFrame: a representation of the company’s historical stock price
Module contents¶
finpandas core utilities