mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-30 14:02:06 +00:00
* First commit * Renamed to bot * change from discordbot to bots imports * refractor cmds + autocomplete helpers + updated dps plots/candle + quote cmd * isort fix * Update helpers.py * Added first refactor * Added commands and refactor * Added description handler * Through grains * ta + image border helper * Added indices * merged * Finished econ * options refactor * dark_pool_shorts, candle, quote done * pagination/dropdown logic to helpers + fixes * dd/disc/insider done + add image logic to helpers * linting * removed plt style * Almost done with Gov * fixing conflicts * Finished gov (excpect ones mentioned) * screener done * Test bug refactor * Store changes to switch * Finished refactor * Fixed error * Delete ::40 * Fixed issue * Fixed black * finished * fixes Co-authored-by: teh_coderer <me@tehcoderer.com> Co-authored-by: didierlopes.eth <dro.lopes@campus.fct.unl.pt>
105 lines
2.8 KiB
Python
105 lines
2.8 KiB
Python
import disnake
|
|
|
|
import bots.config_discordbot as cfg
|
|
from bots.config_discordbot import logger
|
|
from bots.menus.menu import Menu
|
|
from gamestonk_terminal.stocks.dark_pool_shorts import stockgrid_model
|
|
|
|
|
|
def sidtc_command(sort="float", num: int = 10):
|
|
"""Short interest and days to cover [Stockgrid]"""
|
|
|
|
# Debug
|
|
if cfg.DEBUG:
|
|
logger.debug("dps-sidtc %s %s", sort, num)
|
|
|
|
# Check for argument
|
|
possible_sorts = ("float", "dtc", "si")
|
|
|
|
if sort not in possible_sorts:
|
|
raise Exception(f"The possible sorts are: {', '.join(possible_sorts)}")
|
|
|
|
if num < 0:
|
|
raise Exception("Number has to be above 0")
|
|
|
|
# Retrieve data
|
|
df = stockgrid_model.get_short_interest_days_to_cover(sort)
|
|
df = df.iloc[:num]
|
|
|
|
# Debug user output
|
|
if cfg.DEBUG:
|
|
logger.debug(df.to_string())
|
|
|
|
# Output data
|
|
title = "Stocks: [Stockgrid] Short Interest and Days to Cover"
|
|
dp_date = df["Date"].values[0]
|
|
df = df.drop(columns=["Date"])
|
|
df["Short Interest"] = df["Short Interest"] / 1_000_000
|
|
df.head()
|
|
df.columns = [
|
|
"Ticker",
|
|
"Float Short %",
|
|
"Days to Cover",
|
|
"Short Interest (1M)",
|
|
]
|
|
future_column_name = df["Ticker"]
|
|
df = df.transpose()
|
|
df.columns = future_column_name
|
|
df.drop("Ticker")
|
|
embeds = []
|
|
choices = [
|
|
disnake.SelectOption(label="Overview", value="0", emoji="🟢"),
|
|
]
|
|
initial_str = "Overview"
|
|
i = 1
|
|
for col_name in df.columns.values:
|
|
menu = f"\nPage {i}: {col_name}"
|
|
initial_str += f"\nPage {i}: {col_name}"
|
|
if i < 19:
|
|
choices.append(
|
|
disnake.SelectOption(label=menu, value=f"{i}", emoji="🟢"),
|
|
)
|
|
if i == 20:
|
|
choices.append(
|
|
disnake.SelectOption(label="Max Reached", value=f"{i}", emoji="🟢"),
|
|
)
|
|
i += 1
|
|
|
|
reports = [f"{initial_str}"]
|
|
embeds.append(
|
|
disnake.Embed(
|
|
title="Dark Pool Shorts", description=initial_str, colour=cfg.COLOR
|
|
).set_author(
|
|
name=cfg.AUTHOR_NAME,
|
|
icon_url=cfg.AUTHOR_ICON_URL,
|
|
)
|
|
)
|
|
|
|
for column in df.columns.values:
|
|
description = (
|
|
"```The following data corresponds to the date: "
|
|
+ dp_date
|
|
+ "\n\n"
|
|
+ df[column].fillna("").to_string()
|
|
+ "```",
|
|
)
|
|
embeds.append(
|
|
disnake.Embed(
|
|
title=title,
|
|
description=description,
|
|
colour=cfg.COLOR,
|
|
).set_author(
|
|
name=cfg.AUTHOR_NAME,
|
|
icon_url=cfg.AUTHOR_ICON_URL,
|
|
)
|
|
)
|
|
reports.append(f"{description}")
|
|
|
|
return {
|
|
"view": Menu,
|
|
"title": title,
|
|
"description": reports,
|
|
"embed": embeds,
|
|
"choices": choices,
|
|
}
|