Files
OpenBB/bots/cmds/screener_cmds.py
teh_coderer 50cafd500e Discord bot massive improvement (#1481)
* allow logs feature flag

* Adding log collection md

* upload last log at startup

* additions/refractor

* refactor

* lint/black ++

* disc

* TimeRotating Logger and upload to s3

* corrected regex error

* makeup for config

* logging/disc/sia/etf/++

* append .log before uploading

* process to upload logs to s3

* candle ta/etfmcds

* fix

* ta candles

* implement presignedURL

* fixed regex

* ma's in 1 cmd, delete older files

* refactor ta candle

* updates

* black

* moon?

* Logger uploader

* rotate every hour

* only archive if successful

* chavis suggestions

* windows

* ta

* commands_dict update

* discord tacmds

* log_collection error fix

* fix

* fix

* pylint

* bb fix

* only log filesize

* fixes

* discord logs

* Delete log_collection.md

* fixes for other bots on images

* bots image upload fix

* updated helpers/load candle

* more ta cc/housekeeping/refactors/slashcmds

* update bots cmds_dict

* adjustments to font size/fixes

* test fixs/disc earnings

* missed a spot

* fixes had > revesred

* reversed the >< again oops

* remove logger branch code blocking tests

* black fix

* fix missing sources in docstr/daily candle dt tz

* load_candle refactor with docstring

* moved insiders to disc

* Lucas logging changes

* Fixing log_collection.md

* testing scenario

* more ta converted

* more ta

* Update config_terminal : remove print of verbosity

* table cfg/fix matplt/ screener +

* fix

* what's sleep? 1 more line.. or 2. scr df2img

* juan more. fix news 1m chart issue

* ticker.upper() fixes

* Update log collection

* Updating log collection - change tmp folder

Co-authored-by: LBolte29 <lbolte@gmx.net>
Co-authored-by: Chavithra PARANA <chavithra@gmail.com>
Co-authored-by: LBolte29 <97528701+LBolte29@users.noreply.github.com>
Co-authored-by: jose-donato <43375532+jose-donato@users.noreply.github.com>
Co-authored-by: didierlopes.eth <dro.lopes@campus.fct.unl.pt>
2022-03-16 10:21:27 +00:00

194 lines
6.5 KiB
Python

from __future__ import annotations
import disnake
from disnake.ext import commands
from bots.common import commands_dict
from bots.helpers import ShowView, presets_custom_autocomp, signals_autocomp
from bots.stocks.screener.financial import financial_command
from bots.stocks.screener.historical import historical_command
from bots.stocks.screener.overview import overview_command
from bots.stocks.screener.ownership import ownership_command
from bots.stocks.screener.performance import performance_command
from bots.stocks.screener.presets_custom import presets_custom_command
from bots.stocks.screener.presets_default import presets_default_command
from bots.stocks.screener.technical import technical_command
from bots.stocks.screener.valuation import valuation_command
# pylint: disable=R0912
class ScreenerCommands(commands.Cog):
"""Screener menu"""
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.slash_command(name="scr")
async def scr(self, inter):
pass
@scr.sub_command()
async def presets_default(self, inter: disnake.AppCmdInter):
"""Displays every available preset"""
await ShowView().discord(presets_default_command, inter, "scr presets_default")
@scr.sub_command()
async def presets_custom(self, inter: disnake.AppCmdInter):
"""Displays every available preset"""
await ShowView().discord(presets_custom_command, inter, "scr presets_custom")
@scr.sub_command()
async def historical(
self,
inter: disnake.AppCmdInter,
signal: str = commands.Param(autocomplete=signals_autocomp),
start="",
):
"""Displays trades made by the congress/senate/house [quiverquant.com]
Parameters
-----------
signal: Signal. Default: most_volatile
start: Starting date in YYYY-MM-DD format
"""
await ShowView().discord(
historical_command, inter, "scr historical", signal, start
)
@scr.sub_command()
async def overview(
self,
inter: disnake.AppCmdInter,
preset: str = commands.Param(autocomplete=presets_custom_autocomp),
sort: str = commands.Param(choices=commands_dict.screener_sort["overview"]),
limit: int = 5,
ascend: bool = False,
):
"""Displays stocks with overview data such as Sector and Industry [Finviz]
Parameters
-----------
preset: screener preset
sort: column to sort by
limit: number of stocks to display
ascend: whether it's sorted by ascending order or not. Default: False
"""
await ShowView().discord(
overview_command, inter, "scr overview", preset, sort, limit, ascend
)
@scr.sub_command()
async def valuation(
self,
inter: disnake.AppCmdInter,
preset: str = commands.Param(autocomplete=presets_custom_autocomp),
sort: str = commands.Param(choices=commands_dict.screener_sort["valuation"]),
limit: int = 5,
ascend: bool = False,
):
"""Displays results from chosen preset focusing on valuation metrics [Finviz]
Parameters
-----------
preset: screener preset
sort: column to sort by
limit: number of stocks to display
ascend: whether it's sorted by ascending order or not. Default: False
"""
await ShowView().discord(
valuation_command, inter, "scr valuation", preset, sort, limit, ascend
)
@scr.sub_command()
async def financial(
self,
inter: disnake.AppCmdInter,
preset: str = commands.Param(autocomplete=presets_custom_autocomp),
sort: str = commands.Param(choices=commands_dict.screener_sort["financial"]),
limit: int = 5,
ascend: bool = False,
):
"""Displays returned results from preset by financial metrics [Finviz]
Parameters
-----------
preset: screener preset
sort: column to sort by
limit: number of stocks to display
ascend: whether it's sorted by ascending order or not. Default: False
"""
await ShowView().discord(
financial_command, inter, "scr financial", preset, sort, limit, ascend
)
@scr.sub_command()
async def ownership(
self,
inter: disnake.AppCmdInter,
preset: str = commands.Param(autocomplete=presets_custom_autocomp),
sort: str = commands.Param(choices=commands_dict.screener_sort["ownership"]),
limit: int = 5,
ascend: bool = False,
):
"""Displays stocks based on own share float and ownership data [Finviz]
Parameters
-----------
preset: screener preset
sort: column to sort by
limit: number of stocks to display
ascend: whether it's sorted by ascending order or not. Default: False
"""
await ShowView().discord(
ownership_command, inter, "scr ownership", preset, sort, limit, ascend
)
@scr.sub_command()
async def performance(
self,
inter: disnake.AppCmdInter,
preset: str = commands.Param(autocomplete=presets_custom_autocomp),
sort: str = commands.Param(choices=commands_dict.screener_sort["performance"]),
limit: int = 5,
ascend: bool = False,
):
"""Displays stocks and sort by performance categories [Finviz]
Parameters
-----------
preset: screener preset
sort: column to sort by
limit: number of stocks to display
ascend: whether it's sorted by ascending order or not. Default: False
"""
await ShowView().discord(
performance_command, inter, "scr performance", preset, sort, limit, ascend
)
@scr.sub_command()
async def technical(
self,
inter: disnake.AppCmdInter,
preset: str = commands.Param(autocomplete=presets_custom_autocomp),
sort: str = commands.Param(choices=commands_dict.screener_sort["technical"]),
limit: int = 5,
ascend: bool = False,
):
"""Displays stocks according to chosen preset, sorting by technical factors [Finviz]
Parameters
-----------
preset: screener preset
sort: column to sort by
limit: number of stocks to display
ascend: whether it's sorted by ascending order or not. Default: False
"""
await ShowView().discord(
technical_command, inter, "scr technical", preset, sort, limit, ascend
)
def setup(bot: commands.Bot):
bot.add_cog(ScreenerCommands(bot))