system.database package

Submodules

system.database.fre_database module

class system.database.fre_database.FREDatabase(database_uri='sqlite:///instance/fre_database.db')

Bases: object

check_table_empty(table_name: str)bool

Returns True if the table is empty, returns false if the table is not empty

clear_table(table_list)
create_buy_transaction(uid, cash, symbol, shares, price, timestamp)

Record the buying transaction info into database :param uid: user id :param cash: new cash after buying :param symbol: stock ticker :param shares: shares to buy :param price: price to buy at :param timestamp: when the transaction happens :return: None

create_sell_transaction(uid, new_cash, symbol, shares, new_shares, price, timestamp)

Record the selling transaction info into database. :param uid: user id :param new_cash: cash after selling :param symbol: stock ticker :param shares: shares holding after selling :param new_shares: negative, shares to sell :param price: price to sell at :param timestamp: when the transaction happens :return: None

create_table(table_list: Collection[str])None

This function is for creating all kinds of tables if that table not exists in database. :param table_list: a list of string of table names :return: None

drop_table(table_name)
execute_sql_statement(sql_stmt, change=False)
get_portfolio(uid: int, symbol: str = '')Dict[str, Union[List[float], List[str], str, float]]

Get portfolio info or position info(if symbol is provided) :param uid: user id :param symbol: stock symbol :return: Portfolio (or symbol’s position) info in a dictionary

get_sp500_sectors()
get_sp500_symbol_map()
get_sp500_symbols()
get_transaction(uid: int)Dict[str, Union[List[str], List[float], List[int]]]

Extract the transaction record from transactions table :param uid: user id :return: Transaction info in a dictionary

get_user(email_address: str, uid: int)Dict[str, Union[int, float, str]]

Module contents