mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-12 20:31:18 +00:00
* 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>
82 lines
2.2 KiB
Python
82 lines
2.2 KiB
Python
import logging
|
|
|
|
import df2img
|
|
import pandas as pd
|
|
|
|
import bots.config_discordbot as cfg
|
|
from bots.helpers import save_image
|
|
from gamestonk_terminal.decorators import log_start_end
|
|
from gamestonk_terminal.economy import wsj_model
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@log_start_end(log=logger)
|
|
def overview_command():
|
|
"""Market data overview [Wall St. Journal]"""
|
|
# Debug user input
|
|
if cfg.DEBUG:
|
|
logger.debug("econ-overview")
|
|
|
|
# Retrieve data
|
|
df = wsj_model.market_overview()
|
|
|
|
# Check for argument
|
|
if df.empty:
|
|
raise Exception("No available data found")
|
|
|
|
df["Last Price"] = pd.to_numeric(df["Price"].astype(float))
|
|
df["Change"] = pd.to_numeric(df["Chg"].astype(float))
|
|
df["% Change"] = pd.to_numeric(df["%Chg"].astype(float))
|
|
df = df.drop(columns=["Price", "Chg", "%Chg"])
|
|
|
|
# Debug user output
|
|
if cfg.DEBUG:
|
|
logger.debug(df.to_string())
|
|
|
|
formats = {"Last Price": "${:.2f}", "Change": "${:.2f}", "% Change": "{:.2f}%"}
|
|
for col, value in formats.items():
|
|
df[col] = df[col].map(lambda x: value.format(x)) # pylint: disable=W0640
|
|
|
|
df = df.fillna("")
|
|
df.set_index(" ", inplace=True)
|
|
font_color = (
|
|
["white"] * 2
|
|
+ [
|
|
[
|
|
"#e4003a" if boolv else "#00ACFF"
|
|
for boolv in df["Change"].str.contains("-")
|
|
]
|
|
]
|
|
+ [
|
|
[
|
|
"#e4003a" if boolv else "#00ACFF"
|
|
for boolv in df["% Change"].str.contains("-")
|
|
]
|
|
]
|
|
)
|
|
fig = df2img.plot_dataframe(
|
|
df,
|
|
fig_size=(720, (40 + (40 * len(df.index)))),
|
|
col_width=[8, 3, 3],
|
|
tbl_header=cfg.PLT_TBL_HEADER,
|
|
tbl_cells=cfg.PLT_TBL_CELLS,
|
|
font=cfg.PLT_TBL_FONT,
|
|
row_fill_color=cfg.PLT_TBL_ROW_COLORS,
|
|
paper_bgcolor="rgba(0, 0, 0, 0)",
|
|
)
|
|
fig.update_traces(
|
|
cells=(
|
|
dict(
|
|
align=["center", "right"],
|
|
font=dict(color=font_color),
|
|
)
|
|
)
|
|
)
|
|
|
|
imagefile = save_image("econ-indices.png", fig)
|
|
return {
|
|
"title": "Economy: [WSJ] Market Overview",
|
|
"imagefile": imagefile,
|
|
}
|