mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-13 12:51:49 +00:00
minor formatting changes
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
# fred
|
||||
# FRED
|
||||
|
||||
The purpose of fred is to have the ability to look at economic data.
|
||||
|
||||
* [GDP](#GDP)
|
||||
* [gdp](#gdp)
|
||||
* Get GDP data
|
||||
* [cust](#cust)
|
||||
* Get custom fred data
|
||||
|
||||
## GDP <a name="GDP"></a>
|
||||
## gdp <a name="gdp"></a>
|
||||
```text
|
||||
usage: GDP [-n N_TO_GET] [-s START_DATE] [-p PLOT]]
|
||||
usage: gdp [-n N_TO_GET] [-s START_DATE] [-p PLOT]]
|
||||
```
|
||||
Gets GDP data. Data is released quarterly
|
||||
* -n : Number of points to display. If unspecified, it will display all available.
|
||||
* -s : Start Date. Format m/d/y. First point to get
|
||||
* -p : Option to plot. Defaults to False
|
||||
|
||||
To get the last 20 reported GDP values:
|
||||
To get and plot the last 20 reported GDP values:
|
||||
````
|
||||
GDP -n 20
|
||||
gdp -n 20
|
||||
````
|
||||
To plot all GDP data since 1/1/2010:
|
||||
To show all GDP data since 1/1/2010, with no plot.
|
||||
````
|
||||
GDP -s 1/1/2010 -p True
|
||||
gdp -s 1/1/2010 -p True
|
||||
````
|
||||
|
||||
|
||||
@@ -35,12 +35,12 @@ usage: cust [-id] [-s START_DATE] [-p PLOT] [-disp DISP]
|
||||
````
|
||||
* -id : Series ID for FRED data. Required argument
|
||||
* -s : Start data to acquire data. Defaults to 1/1/2020
|
||||
* -p : Option to plot. Defaults to False
|
||||
* -disp : Option to print data to console. Defaults to True.
|
||||
* -p : Option to plot. Defaults to True
|
||||
* -disp : Option to print data to console. Defaults to False.
|
||||
|
||||
The GDP is specifically defined in this menu, but to reproduce it with the custom function, it would be
|
||||
````
|
||||
cust -id GDP -s 1/1/2020 -p True -disp False
|
||||
cust -id GDP -s 1/1/2020 -p True
|
||||
````
|
||||
|
||||
The plot flag allows for plotting and the disp flag tells whether or not to print data to the console.
|
||||
The plot flag allows for plotting and the disp flag tells whether to print data to the console.
|
||||
@@ -35,7 +35,11 @@ def get_GDP(l_args):
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-p", dest="plot_", type=bool, default=False, required=False, help="Plot GDP"
|
||||
"-p", dest="plot",
|
||||
type=bool,
|
||||
default=True,
|
||||
required=False,
|
||||
help="Plot GDP"
|
||||
)
|
||||
|
||||
try:
|
||||
@@ -55,12 +59,13 @@ def get_GDP(l_args):
|
||||
for date, val in lastn.iteritems():
|
||||
print(f'Date: {date.strftime("%m-%d-%Y")}, GDP: {val} ')
|
||||
|
||||
if ns_parser.plot_:
|
||||
if ns_parser.plot:
|
||||
plt.figure()
|
||||
lastn.plot(style="ok")
|
||||
plt.xlabel("Time")
|
||||
plt.ylabel("GDP")
|
||||
plt.show()
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print("")
|
||||
@@ -78,8 +83,12 @@ def custom_data(l_args):
|
||||
""",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-id", dest="series_id", required=True, type=str, help="FRED Series ID"
|
||||
"-id", dest="series_id",
|
||||
required=True,
|
||||
type=str,
|
||||
help="FRED Series ID"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-s",
|
||||
dest="start_date",
|
||||
@@ -89,10 +98,20 @@ def custom_data(l_args):
|
||||
help="Date to Start",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p", dest="plot_", type=bool, default=False, required=False, help="Plot data"
|
||||
"-p",
|
||||
dest="plot",
|
||||
type=bool,
|
||||
default=True,
|
||||
required=False,
|
||||
help="Plot data"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-disp", dest="disp_", type=bool, default=True, required=False, help="Printdata"
|
||||
"-disp",
|
||||
dest="disp",
|
||||
type=bool,
|
||||
default=False,
|
||||
required=False,
|
||||
help="Print data"
|
||||
)
|
||||
|
||||
try:
|
||||
@@ -102,11 +121,11 @@ def custom_data(l_args):
|
||||
return
|
||||
|
||||
data = fred.get_series(ns_parser.series_id, ns_parser.start_date)
|
||||
if ns_parser.disp_:
|
||||
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_:
|
||||
if ns_parser.plot:
|
||||
plt.figure()
|
||||
data.plot(style="ok")
|
||||
plt.xlabel("Time")
|
||||
|
||||
@@ -10,19 +10,19 @@ from gamestonk_terminal.fred import fred_api
|
||||
def print_fred():
|
||||
""" Print help """
|
||||
|
||||
print("\nFred Economic Data:") # https://github.com/JerBouma/FundamentalAnalysis
|
||||
print("\nFred Economic Data:")
|
||||
print(" help show this menu again")
|
||||
print(" q quit this menu, and shows back to main menu")
|
||||
print(" quit quit to abandon program")
|
||||
print(" ")
|
||||
print(" GDP get GDP")
|
||||
print(" gdp get GDP")
|
||||
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"]
|
||||
fred_parser = argparse.ArgumentParser(prog="fred", add_help=False)
|
||||
choices = ["help", "q", "quit", "gdp", "cust"]
|
||||
fred_parser.add_argument("cmd", choices=choices)
|
||||
completer = NestedCompleter.from_nested_dict({c: None for c in choices})
|
||||
|
||||
@@ -51,14 +51,14 @@ def fred_menu():
|
||||
should_print_help = True
|
||||
|
||||
elif ns_known_args.cmd == "q":
|
||||
# Just leave the FA menu
|
||||
# Leave the fred menu
|
||||
return False
|
||||
|
||||
elif ns_known_args.cmd == "quit":
|
||||
# Abandon the program
|
||||
return True
|
||||
|
||||
elif ns_known_args.cmd == "GDP":
|
||||
elif ns_known_args.cmd == "gdp":
|
||||
fred_api.get_GDP(l_args)
|
||||
|
||||
elif ns_known_args.cmd == "cust":
|
||||
|
||||
@@ -52,7 +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 economic data, \t\t\t from: Federal Reserve Bank of St. Louis ")
|
||||
|
||||
if s_ticker:
|
||||
print(
|
||||
|
||||
Reference in New Issue
Block a user