mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 05:21:48 +00:00
black gamestonk_terminal
This commit is contained in:
@@ -27,4 +27,4 @@ API_TWITTER_SECRET_KEY = os.getenv("GT_API_TWITTER_SECRET_KEY") or "REPLACE_ME"
|
||||
API_TWITTER_BEARER_TOKEN = os.getenv("GT_API_TWITTER_BEARER_TOKEN") or "REPLACE_ME"
|
||||
|
||||
# https://fred.stlouisfed.org/docs/api/api_key.html
|
||||
API_FRED_KEY = os.getenv("GT_FRED_API_KEY") or "REPLACE_ME"
|
||||
API_FRED_KEY = os.getenv("GT_FRED_API_KEY") or "REPLACE_ME"
|
||||
|
||||
@@ -6,6 +6,7 @@ from gamestonk_terminal.helper_funcs import (
|
||||
)
|
||||
from gamestonk_terminal.config_terminal import API_FRED_KEY
|
||||
|
||||
|
||||
def get_GDP(l_args):
|
||||
fred = Fred(api_key=FRED_API_KEY)
|
||||
parser = argparse.ArgumentParser(
|
||||
@@ -17,26 +18,25 @@ def get_GDP(l_args):
|
||||
)
|
||||
parser.add_argument(
|
||||
"-n",
|
||||
dest='n_to_get',
|
||||
dest="n_to_get",
|
||||
type=int,
|
||||
default=-1,
|
||||
required=False,
|
||||
help="Number of GDP Values to Grab",
|
||||
)
|
||||
|
||||
parser.add_argument("-s",
|
||||
dest = "start_date",
|
||||
type = str,
|
||||
default='1/1/2020',
|
||||
required=False,
|
||||
help='Date to Start')
|
||||
parser.add_argument(
|
||||
"-s",
|
||||
dest="start_date",
|
||||
type=str,
|
||||
default="1/1/2020",
|
||||
required=False,
|
||||
help="Date to Start",
|
||||
)
|
||||
|
||||
parser.add_argument("-p",
|
||||
dest = "plot_",
|
||||
type = bool,
|
||||
default = False,
|
||||
required=False,
|
||||
help = 'Plot GDP')
|
||||
parser.add_argument(
|
||||
"-p", dest="plot_", type=bool, default=False, required=False, help="Plot GDP"
|
||||
)
|
||||
|
||||
try:
|
||||
ns_parser = parse_known_args_and_warn(parser, l_args)
|
||||
@@ -44,7 +44,7 @@ def get_GDP(l_args):
|
||||
if not ns_parser:
|
||||
return
|
||||
|
||||
gdp = fred.get_series('GDP',ns_parser.start_date)
|
||||
gdp = fred.get_series("GDP", ns_parser.start_date)
|
||||
|
||||
if int(ns_parser.n_to_get) > 0:
|
||||
lastn = gdp.tail(int(ns_parser.n_to_get))
|
||||
@@ -57,15 +57,16 @@ def get_GDP(l_args):
|
||||
|
||||
if ns_parser.plot_:
|
||||
plt.figure()
|
||||
lastn.plot(style = 'ok')
|
||||
plt.xlabel('Time')
|
||||
plt.ylabel('GDP')
|
||||
lastn.plot(style="ok")
|
||||
plt.xlabel("Time")
|
||||
plt.ylabel("GDP")
|
||||
plt.show()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print("")
|
||||
return
|
||||
|
||||
|
||||
def custom_data(l_args):
|
||||
fred = Fred(api_key=FRED_API_KEY)
|
||||
|
||||
@@ -76,30 +77,23 @@ def custom_data(l_args):
|
||||
Custom Data
|
||||
""",
|
||||
)
|
||||
parser.add_argument('-id',
|
||||
dest = 'series_id',
|
||||
required = True,
|
||||
type=str,
|
||||
help = 'FRED Series ID')
|
||||
parser.add_argument("-s",
|
||||
dest="start_date",
|
||||
type=str,
|
||||
default='1/1/2020',
|
||||
required=False,
|
||||
help='Date to Start')
|
||||
parser.add_argument("-p",
|
||||
dest="plot_",
|
||||
type=bool,
|
||||
default=False,
|
||||
required=False,
|
||||
help='Plot data')
|
||||
parser.add_argument("-disp",
|
||||
dest="disp_",
|
||||
type=bool,
|
||||
default=True,
|
||||
required=False,
|
||||
help='Printdata')
|
||||
|
||||
parser.add_argument(
|
||||
"-id", dest="series_id", required=True, type=str, help="FRED Series ID"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s",
|
||||
dest="start_date",
|
||||
type=str,
|
||||
default="1/1/2020",
|
||||
required=False,
|
||||
help="Date to Start",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p", dest="plot_", type=bool, default=False, required=False, help="Plot data"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-disp", dest="disp_", type=bool, default=True, required=False, help="Printdata"
|
||||
)
|
||||
|
||||
try:
|
||||
ns_parser = parse_known_args_and_warn(parser, l_args)
|
||||
@@ -107,16 +101,16 @@ def custom_data(l_args):
|
||||
if not ns_parser:
|
||||
return
|
||||
|
||||
data = fred.get_series(ns_parser.series_id,ns_parser.start_date)
|
||||
data = fred.get_series(ns_parser.series_id, ns_parser.start_date)
|
||||
if ns_parser.disp_:
|
||||
for date, val in data.iteritems():
|
||||
print(f'Date: {date.strftime("%m-%d-%Y")}, DATA: {val} ')
|
||||
try:
|
||||
if ns_parser.plot_:
|
||||
plt.figure()
|
||||
data.plot(style='ok')
|
||||
plt.xlabel('Time')
|
||||
plt.ylabel('DATA')
|
||||
data.plot(style="ok")
|
||||
plt.xlabel("Time")
|
||||
plt.ylabel("DATA")
|
||||
plt.show()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
@@ -126,7 +120,3 @@ def custom_data(l_args):
|
||||
print(e)
|
||||
print("")
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -19,14 +19,10 @@ def print_fred():
|
||||
print(" cust User Specified FRED Data")
|
||||
return
|
||||
|
||||
|
||||
def fred_menu():
|
||||
fred_parser = argparse.ArgumentParser(prog="fa", add_help=False)
|
||||
choices = [
|
||||
"help",
|
||||
"q",
|
||||
"quit",
|
||||
"GDP",
|
||||
"cust"]
|
||||
choices = ["help", "q", "quit", "GDP", "cust"]
|
||||
fred_parser.add_argument("cmd", choices=choices)
|
||||
completer = NestedCompleter.from_nested_dict({c: None for c in choices})
|
||||
|
||||
|
||||
@@ -52,9 +52,7 @@ def print_help(s_ticker, s_start, s_interval, b_is_market_open):
|
||||
print(
|
||||
" sen sentiment of the market, \t from: reddit, stocktwits, twitter"
|
||||
)
|
||||
print(
|
||||
" fred Data from Federal Reserve Bank of St.Louis"
|
||||
)
|
||||
print(" fred Data from Federal Reserve Bank of St.Louis")
|
||||
|
||||
if s_ticker:
|
||||
print(
|
||||
|
||||
Reference in New Issue
Block a user