mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-13 04:41:24 +00:00
Change stock_market_menu name to command
This commit is contained in:
@@ -1,11 +1,51 @@
|
||||
import argparse
|
||||
from alpha_vantage.sectorperformance import SectorPerformances
|
||||
from alpha_vantage.timeseries import TimeSeries
|
||||
import re
|
||||
import config_bot as cfg
|
||||
import pandas as pd
|
||||
from stock_market_helper_funcs import *
|
||||
|
||||
|
||||
# ----------------------------------------------- PRINT_HELP ----------------------------------------------------------
|
||||
def print_help(s_ticker, s_start, s_interval, b_is_market_open):
|
||||
""" Print help
|
||||
"""
|
||||
print("What do you want to do?")
|
||||
print(" gainers show latest top gainers")
|
||||
print(" sectors show sectors performance")
|
||||
print(" view view and load a specific stock ticker for technical analysis")
|
||||
print(" clear clear a specific stock ticker from analysis")
|
||||
print(" load load a specific stock ticker for analysis")
|
||||
print(" help help to see this menu again")
|
||||
print(" quit to abandon the program")
|
||||
|
||||
s_intraday = (f'Intraday {s_interval}', 'Daily')[s_interval == "1440min"]
|
||||
if s_ticker and s_start:
|
||||
print(f"\n{s_intraday} Stock: {s_ticker} (from {s_start.strftime('%Y-%m-%d')})")
|
||||
elif s_ticker:
|
||||
print(f"\n{s_intraday} Stock: {s_ticker}")
|
||||
else:
|
||||
print("\nStock: ?")
|
||||
print(f"Market {('CLOSED', 'OPEN')[b_is_market_open]}.")
|
||||
|
||||
if s_ticker:
|
||||
print("\nMenus:")
|
||||
print(" fa fundamental analysis")
|
||||
print(" ta technical analysis")
|
||||
print(" pred prediction techniques")
|
||||
|
||||
'''
|
||||
print("\nPrediction:")
|
||||
print(" ma")
|
||||
print(" ema")
|
||||
print(" lr")
|
||||
print(" knn")
|
||||
print(" arima")
|
||||
print(" rnn")
|
||||
print(" lstm")
|
||||
print(" prophet")
|
||||
'''
|
||||
|
||||
# ---------------------------------------------------- SECTORS ----------------------------------------------------
|
||||
def sectors(l_args):
|
||||
parser = argparse.ArgumentParser(prog='sectors', description='Plot sectors performance')
|
||||
@@ -24,7 +24,7 @@
|
||||
import argparse
|
||||
import pandas as pd
|
||||
from stock_market_helper_funcs import *
|
||||
import stock_market_menu as smm
|
||||
import command as cmd
|
||||
from fundamental_analysis import menu as fam
|
||||
from technical_analysis import menu as tam
|
||||
|
||||
@@ -33,46 +33,6 @@ from technical_analysis import menu as tam
|
||||
import config_bot as cfg
|
||||
from alpha_vantage.timeseries import TimeSeries
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------------
|
||||
def print_help(s_ticker, s_start, s_interval, b_is_market_open):
|
||||
""" Print help
|
||||
"""
|
||||
print("What do you want to do?")
|
||||
print(" gainers show latest top gainers")
|
||||
print(" sectors show sectors performance")
|
||||
print(" view view and load a specific stock ticker for technical analysis")
|
||||
print(" clear clear a specific stock ticker from analysis")
|
||||
print(" load load a specific stock ticker for analysis")
|
||||
print(" help help to see this menu again")
|
||||
print(" quit to abandon the program")
|
||||
|
||||
s_intraday = (f'Intraday {s_interval}', 'Daily')[s_interval == "1440min"]
|
||||
if s_ticker and s_start:
|
||||
print(f"\n{s_intraday} Stock: {s_ticker} (from {s_start.strftime('%Y-%m-%d')})")
|
||||
elif s_ticker:
|
||||
print(f"\n{s_intraday} Stock: {s_ticker}")
|
||||
else:
|
||||
print("\nStock: ?")
|
||||
print(f"Market {('CLOSED', 'OPEN')[b_is_market_open]}.")
|
||||
|
||||
if s_ticker:
|
||||
print("\nMenus:")
|
||||
print(" fa fundamental analysis")
|
||||
print(" ta technical analysis")
|
||||
print(" pred prediction techniques")
|
||||
|
||||
'''
|
||||
print("\nPrediction:")
|
||||
print(" ma")
|
||||
print(" ema")
|
||||
print(" lr")
|
||||
print(" knn")
|
||||
print(" arima")
|
||||
print(" rnn")
|
||||
print(" lstm")
|
||||
print(" prophet")
|
||||
'''
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------------
|
||||
def main():
|
||||
@@ -96,7 +56,7 @@ def main():
|
||||
|
||||
# Add list of arguments that the main parser accepts
|
||||
menu_parser = argparse.ArgumentParser(prog='stock_market_bot', add_help=False)
|
||||
menu_parser.add_argument('cmd', choices=['gainers', 'sectors', 'view', 'clear', 'load',
|
||||
menu_parser.add_argument('opt', choices=['gainers', 'sectors', 'view', 'clear', 'load',
|
||||
'fa', 'ta', 'help', 'quit'])
|
||||
|
||||
# Add list of arguments that the fundamental analysis parser accepts
|
||||
@@ -118,7 +78,7 @@ def main():
|
||||
|
||||
# Print first welcome message and help
|
||||
print("\nWelcome to Didier's Stock Market Bot\n")
|
||||
print_help(s_ticker, s_start, s_interval, b_is_stock_market_open())
|
||||
cmd.print_help(s_ticker, s_start, s_interval, b_is_stock_market_open())
|
||||
print("\n")
|
||||
|
||||
# Loop forever and ever
|
||||
@@ -135,38 +95,38 @@ def main():
|
||||
continue
|
||||
|
||||
# --------------------------------------------------- GAINERS --------------------------------------------------
|
||||
if ns_known_args.cmd == 'gainers':
|
||||
smm.gainers(l_args)
|
||||
if ns_known_args.opt == 'gainers':
|
||||
cmd.gainers(l_args)
|
||||
|
||||
# --------------------------------------------------- SECTORS --------------------------------------------------
|
||||
if ns_known_args.cmd == 'sectors':
|
||||
smm.sectors(l_args)
|
||||
if ns_known_args.opt == 'sectors':
|
||||
cmd.sectors(l_args)
|
||||
|
||||
# --------------------------------------------------- CLEAR ----------------------------------------------------
|
||||
elif ns_known_args.cmd == 'clear':
|
||||
elif ns_known_args.opt == 'clear':
|
||||
print("Clearing stock ticker to be used for analysis")
|
||||
s_ticker = ""
|
||||
s_start = ""
|
||||
|
||||
# ---------------------------------------------------- LOAD ----------------------------------------------------
|
||||
elif ns_known_args.cmd == 'load':
|
||||
[s_ticker, s_start, s_interval, df_stock] = smm.load(l_args, s_ticker, s_start, s_interval, df_stock)
|
||||
elif ns_known_args.opt == 'load':
|
||||
[s_ticker, s_start, s_interval, df_stock] = cmd.load(l_args, s_ticker, s_start, s_interval, df_stock)
|
||||
|
||||
# ---------------------------------------------------- VIEW ----------------------------------------------------
|
||||
elif ns_known_args.cmd == 'view':
|
||||
smm.view(l_args, s_ticker, s_start, s_interval, df_stock)
|
||||
elif ns_known_args.opt == 'view':
|
||||
cmd.view(l_args, s_ticker, s_start, s_interval, df_stock)
|
||||
|
||||
# ---------------------------------------------------- HELP ----------------------------------------------------
|
||||
elif ns_known_args.cmd == 'help':
|
||||
print_help(s_ticker, s_start, s_interval, b_is_stock_market_open())
|
||||
elif ns_known_args.opt == 'help':
|
||||
cmd.print_help(s_ticker, s_start, s_interval, b_is_stock_market_open())
|
||||
|
||||
# ----------------------------------------------------- QUIT ----------------------------------------------------
|
||||
elif ns_known_args.cmd == 'quit':
|
||||
elif ns_known_args.opt == 'quit':
|
||||
print("Hope you made money today. Good bye my lover, good bye my friend.\n")
|
||||
return
|
||||
|
||||
# ------------------------------------------- FUNDAMENTAL ANALYSIS ---------------------------------------------
|
||||
elif ns_known_args.cmd == 'fa':
|
||||
elif ns_known_args.opt == 'fa':
|
||||
b_quit = fam.fa_menu(fa_parser, s_ticker, s_start, s_interval)
|
||||
|
||||
if b_quit:
|
||||
@@ -176,7 +136,7 @@ def main():
|
||||
print_help(s_ticker, s_start, s_interval, b_is_stock_market_open())
|
||||
|
||||
# -------------------------------------------- TECHNICAL ANALYSIS ----------------------------------------------
|
||||
elif ns_known_args.cmd == 'ta':
|
||||
elif ns_known_args.opt == 'ta':
|
||||
b_quit = tam.ta_menu(ta_parser, df_stock, s_ticker, s_start, s_interval)
|
||||
|
||||
if b_quit:
|
||||
|
||||
Reference in New Issue
Block a user