mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 21:12:16 +00:00
* few changes * import fix * missed removing test config * column order fix * import fix * removed df2img add new deps * req * update readme * add dep for image export, fix * get rid of yahoo-fin, add image export lib * import issues in some machines fix * images dir fix * init fix * fix? * test * test * Fixed text handling Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: DjangoServer <colin99delahunty@gmail.com>
40 lines
1.0 KiB
Python
Executable File
40 lines
1.0 KiB
Python
Executable File
import io
|
|
import logging
|
|
|
|
from PIL import Image
|
|
|
|
from bots import config_discordbot as cfg
|
|
from bots.helpers import image_border
|
|
from gamestonk_terminal.decorators import log_start_end
|
|
from gamestonk_terminal.stocks.technical_analysis import finviz_model
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@log_start_end(log=logger)
|
|
def view_command(ticker=""):
|
|
"""Displays image from Finviz [Finviz]"""
|
|
|
|
# Debug
|
|
if cfg.DEBUG:
|
|
logger.debug("ta view %s", ticker)
|
|
|
|
# Check for argument
|
|
if ticker == "":
|
|
raise Exception("Stock ticker is required")
|
|
|
|
image_data = finviz_model.get_finviz_image(ticker)
|
|
dataBytesIO = io.BytesIO(image_data)
|
|
im = Image.open(dataBytesIO)
|
|
im = im.resize((800, 340), Image.ANTIALIAS)
|
|
imagefile = "ta_view.png"
|
|
|
|
im.save(dataBytesIO, "PNG", quality=100)
|
|
dataBytesIO.seek(0)
|
|
imagefile = image_border(imagefile, base64=dataBytesIO)
|
|
|
|
return {
|
|
"title": f"Stocks: [Finviz] Trendlines & Data {ticker.upper()}",
|
|
"imagefile": imagefile,
|
|
}
|