mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 13:32:08 +00:00
Refactor quandl and reddit view
This commit is contained in:
@@ -9,9 +9,9 @@ from prompt_toolkit.completion import NestedCompleter
|
||||
from gamestonk_terminal.due_diligence import business_insider_view as bi_view
|
||||
from gamestonk_terminal.due_diligence import financial_modeling_prep_view as fmp_view
|
||||
from gamestonk_terminal.due_diligence import finviz_view as fvz_view
|
||||
from gamestonk_terminal.due_diligence import market_watch_api as mw_api
|
||||
from gamestonk_terminal.due_diligence import quandl_api as q_api
|
||||
from gamestonk_terminal.due_diligence import reddit_api as r_api
|
||||
from gamestonk_terminal.due_diligence import market_watch_view as mw_view
|
||||
from gamestonk_terminal.due_diligence import quandl_view as q_view
|
||||
from gamestonk_terminal.due_diligence import reddit_view as r_view
|
||||
from gamestonk_terminal.due_diligence import news_view
|
||||
from gamestonk_terminal import feature_flags as gtff
|
||||
from gamestonk_terminal.helper_funcs import get_flair
|
||||
@@ -129,7 +129,7 @@ class DueDiligenceController:
|
||||
|
||||
def call_red(self, other_args: List[str]):
|
||||
""" Process red command """
|
||||
r_api.due_diligence(other_args, self.ticker)
|
||||
r_view.due_diligence(other_args, self.ticker)
|
||||
|
||||
def call_insider(self, other_args: List[str]):
|
||||
""" Process insider command """
|
||||
@@ -165,15 +165,15 @@ class DueDiligenceController:
|
||||
|
||||
def call_warnings(self, other_args: List[str]):
|
||||
""" Process rating command """
|
||||
mw_api.sean_seah_warnings(other_args, self.ticker)
|
||||
mw_view.sean_seah_warnings(other_args, self.ticker)
|
||||
|
||||
def call_sec(self, other_args: List[str]):
|
||||
""" Process sec command """
|
||||
mw_api.sec_fillings(other_args, self.ticker)
|
||||
mw_view.sec_fillings(other_args, self.ticker)
|
||||
|
||||
def call_short(self, other_args: List[str]):
|
||||
""" Process short command """
|
||||
q_api.short_interest(other_args, self.ticker, self.start)
|
||||
q_view.short_interest(other_args, self.ticker, self.start)
|
||||
|
||||
|
||||
def menu(stock: DataFrame, ticker: str, start: str, interval: str):
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
""" Quandl View """
|
||||
__docformat__ = "numpy"
|
||||
|
||||
import argparse
|
||||
from typing import List
|
||||
import quandl
|
||||
from matplotlib import pyplot as plt
|
||||
import matplotlib.ticker as ticker
|
||||
import matplotlib.ticker
|
||||
import pandas as pd
|
||||
from gamestonk_terminal.helper_funcs import (
|
||||
check_positive,
|
||||
@@ -11,7 +15,19 @@ from gamestonk_terminal.helper_funcs import (
|
||||
from gamestonk_terminal import config_terminal as cfg
|
||||
|
||||
|
||||
def short_interest(l_args, s_ticker, s_start):
|
||||
def short_interest(other_args: List[str], ticker: str, start: str):
|
||||
"""Display short interest for a given ticker and a given start date
|
||||
|
||||
Parameters
|
||||
----------
|
||||
other_args : List[str]
|
||||
argparse other args - ["-d", "10"]
|
||||
ticker : str
|
||||
Stock ticker
|
||||
start : str
|
||||
Start date of the stock data
|
||||
"""
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
add_help=False,
|
||||
prog="short",
|
||||
@@ -40,18 +56,18 @@ def short_interest(l_args, s_ticker, s_start):
|
||||
)
|
||||
|
||||
try:
|
||||
ns_parser = parse_known_args_and_warn(parser, l_args)
|
||||
ns_parser = parse_known_args_and_warn(parser, other_args)
|
||||
if not ns_parser:
|
||||
return
|
||||
|
||||
quandl.ApiConfig.api_key = cfg.API_KEY_QUANDL
|
||||
|
||||
if ns_parser.b_nyse:
|
||||
df_short_interest = quandl.get(f"FINRA/FNYX_{s_ticker}")
|
||||
df_short_interest = quandl.get(f"FINRA/FNYX_{ticker}")
|
||||
else:
|
||||
df_short_interest = quandl.get(f"FINRA/FNSQ_{s_ticker}")
|
||||
df_short_interest = quandl.get(f"FINRA/FNSQ_{ticker}")
|
||||
|
||||
df_short_interest = df_short_interest[s_start:]
|
||||
df_short_interest = df_short_interest[start:]
|
||||
df_short_interest.columns = [
|
||||
"".join(
|
||||
" " + char if char.isupper() else char.strip() for char in idx
|
||||
@@ -77,18 +93,18 @@ def short_interest(l_args, s_ticker, s_start):
|
||||
ax.set_ylabel("Shares")
|
||||
ax.set_xlabel("Date")
|
||||
|
||||
if s_start:
|
||||
if start:
|
||||
ax.set_title(
|
||||
f"{('NASDAQ', 'NYSE')[ns_parser.b_nyse]} Short Interest on {s_ticker} from {s_start.date()}"
|
||||
f"{('NASDAQ', 'NYSE')[ns_parser.b_nyse]} Short Interest on {ticker} from {start.date()}"
|
||||
)
|
||||
else:
|
||||
ax.set_title(
|
||||
f"{('NASDAQ', 'NYSE')[ns_parser.b_nyse]} Short Interest on {s_ticker}"
|
||||
f"{('NASDAQ', 'NYSE')[ns_parser.b_nyse]} Short Interest on {ticker}"
|
||||
)
|
||||
|
||||
ax.legend(labels=["Short Volume", "Total Volume"])
|
||||
ax.tick_params(axis="both", which="major")
|
||||
ax.yaxis.set_major_formatter(ticker.EngFormatter())
|
||||
ax.yaxis.set_major_formatter(matplotlib.ticker.EngFormatter())
|
||||
ax_twin = ax.twinx()
|
||||
ax_twin.tick_params(axis="y", colors="green")
|
||||
ax_twin.set_ylabel("Percentage of Volume Shorted", color="green")
|
||||
@@ -98,7 +114,9 @@ def short_interest(l_args, s_ticker, s_start):
|
||||
color="green",
|
||||
)
|
||||
ax_twin.tick_params(axis="y", which="major", color="green")
|
||||
ax_twin.yaxis.set_major_formatter(ticker.FormatStrFormatter("%.0f%%"))
|
||||
ax_twin.yaxis.set_major_formatter(
|
||||
matplotlib.ticker.FormatStrFormatter("%.0f%%")
|
||||
)
|
||||
plt.xlim([df_short_interest.index[0], df_short_interest.index[-1]])
|
||||
|
||||
df_short_interest["% of Volume Shorted"] = df_short_interest[
|
||||
@@ -1,4 +1,8 @@
|
||||
""" Reddit View """
|
||||
__docformat__ = "numpy"
|
||||
|
||||
import argparse
|
||||
from typing import List
|
||||
from datetime import datetime, timedelta
|
||||
from psaw import PushshiftAPI
|
||||
import praw
|
||||
@@ -7,7 +11,17 @@ from gamestonk_terminal import config_terminal as cfg
|
||||
from gamestonk_terminal.reddit_helpers import print_and_record_reddit_post
|
||||
|
||||
|
||||
def due_diligence(l_args, s_ticker):
|
||||
def due_diligence(other_args: List[str], ticker: str):
|
||||
"""Display Reddit due diligence data for a given ticker
|
||||
|
||||
Parameters
|
||||
----------
|
||||
other_args : List[str]
|
||||
argparse other args - ["-l", "5"]
|
||||
ticker : str
|
||||
Stock ticker
|
||||
"""
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
add_help=False,
|
||||
prog="red",
|
||||
@@ -47,7 +61,7 @@ def due_diligence(l_args, s_ticker):
|
||||
)
|
||||
|
||||
try:
|
||||
ns_parser = parse_known_args_and_warn(parser, l_args)
|
||||
ns_parser = parse_known_args_and_warn(parser, other_args)
|
||||
if not ns_parser:
|
||||
return
|
||||
|
||||
@@ -83,7 +97,7 @@ def due_diligence(l_args, s_ticker):
|
||||
]
|
||||
|
||||
submissions = psaw_api.search_submissions(
|
||||
after=int(n_ts_after), subreddit=l_sub_reddits, q=s_ticker, filter=["id"]
|
||||
after=int(n_ts_after), subreddit=l_sub_reddits, q=ticker, filter=["id"]
|
||||
)
|
||||
d_submission = {}
|
||||
n_flair_posts_found = 0
|
||||
Reference in New Issue
Block a user