util package#
Submodules#
util.afterhours module#
- util.afterhours.afterHours()[source]#
Simple code to check if the current time is after hours in the US. Source: https://www.reddit.com/r/algotrading/comments/9x9xho/python_code_to_check_if_market_is_open_in_your/
- Returns:
True if it is currently after-hours, False otherwise.
- Return type:
bool
util.cg_data module#
util.confirm_stock module#
util.db module#
util.disc_util module#
util.earnings_scraper module#
util.exchange_data module#
util.formatting module#
- util.formatting.format_change(change)[source]#
Converts a float to a string with a plus sign if the float is positive, and a minus sign if the float is negative.
- Parameters:
change (float) – The percentual change of an asset.
- Returns:
The formatted change.
- Return type:
str
- async util.formatting.format_embed(og_df, type, source)[source]#
Formats the dataframe to an embed.
- Parameters:
df (pd.DataFrame) – A dataframe with the columns: Symbol Price % Change Volume
type (str) – The type used in the title of the embed
source (str) – The source used for this data
- Returns:
A Discord embed containing the formatted data
- Return type:
discord.Embed
- util.formatting.format_embed_length(data)[source]#
If the length of the data is greater than 1024 characters, it will be shortened to that amount.
- Parameters:
data (list) – The list containing the description for an embed.
- Returns:
The shortened description.
- Return type:
list
- util.formatting.human_format(number, absolute=False, decimals=0)[source]#
Takes a number and returns a human readable string. Taken from: https://stackoverflow.com/questions/579310/formatting-long-numbers-as-strings-in-python/45846841.
- Parameters:
number (float) – The number to be formatted.
absolute (bool) – If True, the number will be converted to its absolute value.
decimals (int) – The number of decimals to be used.
- Returns:
The formatted number as a string.
- Return type:
str