From b4e50bbbf30583f3a07e344fb62f9e9d1910fe48 Mon Sep 17 00:00:00 2001 From: Artem Veremey Date: Sat, 13 Mar 2021 14:17:25 -0800 Subject: [PATCH] Add a Candle Chart --- .../fundamental_analysis/trendline_api.py | 90 +++++++++++++++++++ gamestonk_terminal/main_helper.py | 48 ++++++++++ poetry.lock | 10 +-- pyproject.toml | 1 + requirements-full.txt | 21 ++--- requirements.txt | 16 ++-- terminal.py | 9 +- 7 files changed, 168 insertions(+), 27 deletions(-) create mode 100755 gamestonk_terminal/fundamental_analysis/trendline_api.py diff --git a/gamestonk_terminal/fundamental_analysis/trendline_api.py b/gamestonk_terminal/fundamental_analysis/trendline_api.py new file mode 100755 index 00000000000..cc994dde9ee --- /dev/null +++ b/gamestonk_terminal/fundamental_analysis/trendline_api.py @@ -0,0 +1,90 @@ +"""Fundamental Analysis Trendline Module""" +__docformat__ = "numpy" + +from pandas.core.frame import DataFrame +import yfinance as yf +from scipy.stats import linregress + + +def load_ticker(ticker: str, start_date: str) -> DataFrame: + """ + Loads a ticker data from Yahoo Finance, adds a data index column data_id and Open-Close High/Low columns. + + Parameters + ---------- + ticker : str + The stock ticker. + start_date : str + Start date to load stock ticker data formatted YYYY-MM-DD. + + Returns + ------- + DataFrame + A Panda's data frame with columns Open, High, Low, Close, Adj Close, Volume, date_id, OC-High, OC-Low. + """ + print(f"Start date: {start_date}") + df_data = yf.download(ticker, start=start_date, progress=False) + + df_data["date_id"] = ((df_data.index.date - df_data.index.date.min())).astype( + "timedelta64[D]" + ) + df_data["date_id"] = df_data["date_id"].dt.days + 1 + + df_data["OC_High"] = df_data[["Open", "Close"]].max(axis=1) + df_data["OC_Low"] = df_data[["Open", "Close"]].min(axis=1) + + return df_data + + +def find_trendline(df_data: DataFrame, y_key: str, high_low: str = "high") -> DataFrame: + """Attempts to find a trend line based on y_key column from a given stock ticker data frame. + + Parameters + ---------- + df_data : DataFrame + The stock ticker data frame with at least date_id, y_key columns. + + y_key : str + Column name to base the trend line on. + + high_low: str, optional + Either "high" or "low". High is the default. + + Returns + ------- + DataFrame + An updated Panda's data frame with {y_key}_trend column added containing trend data - if a trend is successfully found. + An original Panda's data frame - if no trend was found. + """ + + for iteration in [3, 4, 5, 6, 7]: + df_temp = df_data.copy() + while len(df_temp) > iteration: + reg = linregress( + x=df_temp["date_id"], + y=df_temp[y_key], + ) + + if high_low == "high": + df_temp = df_temp.loc[ + df_temp[y_key] > reg[0] * df_temp["date_id"] + reg[1] + ] + else: + df_temp = df_temp.loc[ + df_temp[y_key] < reg[0] * df_temp["date_id"] + reg[1] + ] + + if len(df_temp) > 1: + break + + if len(df_temp) == 1: + return df_data + + reg = linregress( + x=df_temp["date_id"], + y=df_temp[y_key], + ) + + df_data[f"{y_key}_trend"] = reg[0] * df_data["date_id"] + reg[1] + + return df_data diff --git a/gamestonk_terminal/main_helper.py b/gamestonk_terminal/main_helper.py index 06b58d69461..065b77325fd 100644 --- a/gamestonk_terminal/main_helper.py +++ b/gamestonk_terminal/main_helper.py @@ -1,7 +1,9 @@ import argparse from sys import stdout +import matplotlib.pyplot as plt import pandas as pd from alpha_vantage.timeseries import TimeSeries +import mplfinance as mpf import yfinance as yf from gamestonk_terminal.helper_funcs import ( @@ -14,6 +16,8 @@ from gamestonk_terminal.helper_funcs import ( ) from gamestonk_terminal import config_terminal as cfg +from gamestonk_terminal import feature_flags as gtff +from gamestonk_terminal.fundamental_analysis import trendline_api as trend def print_help(s_ticker, s_start, s_interval, b_is_market_open): @@ -24,6 +28,7 @@ def print_help(s_ticker, s_start, s_interval, b_is_market_open): print("") print(" clear clear a specific stock ticker from analysis") print(" load load a specific stock ticker for analysis") + print(" candle view a candle chart for a specific stock ticker") print(" view view and load a specific stock ticker for technical analysis") if s_ticker: print( @@ -222,6 +227,49 @@ def load(l_args, s_ticker, s_start, s_interval, df_stock): return [s_ticker, s_start, s_interval, df_stock] +def candle(s_ticker: str, s_start: str): + df_stock = trend.load_ticker(s_ticker, s_start) + df_stock = trend.find_trendline(df_stock, "OC_High", "high") + df_stock = trend.find_trendline(df_stock, "OC_Low", "low") + + mc = mpf.make_marketcolors( + up="green", down="red", edge="black", wick="black", volume="in", ohlc="i" + ) + + s = mpf.make_mpf_style(marketcolors=mc, gridstyle=":", y_on_right=True) + + ap0 = [] + + if "OC_High_trend" in df_stock.columns: + ap0.append( + mpf.make_addplot(df_stock["OC_High_trend"], color="g"), + ) + + if "OC_Low_trend" in df_stock.columns: + ap0.append( + mpf.make_addplot(df_stock["OC_Low_trend"], color="b"), + ) + + if gtff.USE_ION: + plt.ion() + + mpf.plot( + df_stock, + type="candle", + mav=(20, 50), + volume=True, + title=f"\n{s_ticker} - Last 6 months", + addplot=ap0, + xrotation=10, + style=s, + figratio=(10, 7), + figscale=1.10, + update_width_config=dict( + candle_linewidth=1.0, candle_width=0.8, volume_linewidth=1.0 + ), + ) + + def view(l_args, s_ticker, s_start, s_interval, df_stock): parser = argparse.ArgumentParser( add_help=False, diff --git a/poetry.lock b/poetry.lock index 413b94a316b..44353264ba9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2474,7 +2474,7 @@ prediction = ["fbprophet", "tensorflow", "pmdarima", "transformers", "flair", "t [metadata] lock-version = "1.1" python-versions = "^3.6.8" -content-hash = "c6df0db2b4e190d03157db0485cfa91c38ebf3155d90b34e366a7a5357f5f73a" +content-hash = "cfb418b140b12dd94550b1f21431ceb8bf23df30ae4ec9735a98bc76edbfbb85" [metadata.files] absl-py = [ @@ -3610,26 +3610,18 @@ pyyaml = [ {file = "PyYAML-5.4.1-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:bb4191dfc9306777bc594117aee052446b3fa88737cd13b7188d0e7aa8162185"}, {file = "PyYAML-5.4.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:6c78645d400265a062508ae399b60b8c167bf003db364ecb26dcab2bda048253"}, {file = "PyYAML-5.4.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:4e0583d24c881e14342eaf4ec5fbc97f934b999a6828693a99157fde912540cc"}, - {file = "PyYAML-5.4.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:72a01f726a9c7851ca9bfad6fd09ca4e090a023c00945ea05ba1638c09dc3347"}, - {file = "PyYAML-5.4.1-cp36-cp36m-manylinux2014_s390x.whl", hash = "sha256:895f61ef02e8fed38159bb70f7e100e00f471eae2bc838cd0f4ebb21e28f8541"}, {file = "PyYAML-5.4.1-cp36-cp36m-win32.whl", hash = "sha256:3bd0e463264cf257d1ffd2e40223b197271046d09dadf73a0fe82b9c1fc385a5"}, {file = "PyYAML-5.4.1-cp36-cp36m-win_amd64.whl", hash = "sha256:e4fac90784481d221a8e4b1162afa7c47ed953be40d31ab4629ae917510051df"}, {file = "PyYAML-5.4.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:5accb17103e43963b80e6f837831f38d314a0495500067cb25afab2e8d7a4018"}, {file = "PyYAML-5.4.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:e1d4970ea66be07ae37a3c2e48b5ec63f7ba6804bdddfdbd3cfd954d25a82e63"}, - {file = "PyYAML-5.4.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:cb333c16912324fd5f769fff6bc5de372e9e7a202247b48870bc251ed40239aa"}, - {file = "PyYAML-5.4.1-cp37-cp37m-manylinux2014_s390x.whl", hash = "sha256:fe69978f3f768926cfa37b867e3843918e012cf83f680806599ddce33c2c68b0"}, {file = "PyYAML-5.4.1-cp37-cp37m-win32.whl", hash = "sha256:dd5de0646207f053eb0d6c74ae45ba98c3395a571a2891858e87df7c9b9bd51b"}, {file = "PyYAML-5.4.1-cp37-cp37m-win_amd64.whl", hash = "sha256:08682f6b72c722394747bddaf0aa62277e02557c0fd1c42cb853016a38f8dedf"}, {file = "PyYAML-5.4.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d2d9808ea7b4af864f35ea216be506ecec180628aced0704e34aca0b040ffe46"}, {file = "PyYAML-5.4.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:8c1be557ee92a20f184922c7b6424e8ab6691788e6d86137c5d93c1a6ec1b8fb"}, - {file = "PyYAML-5.4.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:fd7f6999a8070df521b6384004ef42833b9bd62cfee11a09bda1079b4b704247"}, - {file = "PyYAML-5.4.1-cp38-cp38-manylinux2014_s390x.whl", hash = "sha256:bfb51918d4ff3d77c1c856a9699f8492c612cde32fd3bcd344af9be34999bfdc"}, {file = "PyYAML-5.4.1-cp38-cp38-win32.whl", hash = "sha256:fa5ae20527d8e831e8230cbffd9f8fe952815b2b7dae6ffec25318803a7528fc"}, {file = "PyYAML-5.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:0f5f5786c0e09baddcd8b4b45f20a7b5d61a7e7e99846e3c799b05c7c53fa696"}, {file = "PyYAML-5.4.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:294db365efa064d00b8d1ef65d8ea2c3426ac366c0c4368d930bf1c5fb497f77"}, {file = "PyYAML-5.4.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:74c1485f7707cf707a7aef42ef6322b8f97921bd89be2ab6317fd782c2d53183"}, - {file = "PyYAML-5.4.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:d483ad4e639292c90170eb6f7783ad19490e7a8defb3e46f97dfe4bacae89122"}, - {file = "PyYAML-5.4.1-cp39-cp39-manylinux2014_s390x.whl", hash = "sha256:fdc842473cd33f45ff6bce46aea678a54e3d21f1b61a7750ce3c498eedfe25d6"}, {file = "PyYAML-5.4.1-cp39-cp39-win32.whl", hash = "sha256:49d4cdd9065b9b6e206d0595fee27a96b5dd22618e7520c33204a4a3239d5b10"}, {file = "PyYAML-5.4.1-cp39-cp39-win_amd64.whl", hash = "sha256:c20cfa2d49991c8b4147af39859b167664f2ad4561704ee74c1de03318e898db"}, {file = "PyYAML-5.4.1.tar.gz", hash = "sha256:607774cbba28732bfa802b54baa7484215f530991055bb562efbed5b2f20a45e"}, diff --git a/pyproject.toml b/pyproject.toml index 1a0e0e14fb9..0eb5c36af5f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,7 @@ prompt-toolkit = "^3.0.16" jupyter = "^1.0.0" mplfinance = "^0.12.7-alpha.7" seaborn = "^0.11.0" +scipy = "1.5.4" [tool.poetry.dev-dependencies] pytest = "^6.2.2" diff --git a/requirements-full.txt b/requirements-full.txt index 961de5732f6..aae65b85025 100644 --- a/requirements-full.txt +++ b/requirements-full.txt @@ -1,5 +1,5 @@ -absl-py==0.11.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.2.0" -aiohttp==3.7.4; python_version >= "3.6" +absl-py==0.12.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.2.0" +aiohttp==3.7.4.post0; python_version >= "3.6" alpha-vantage==2.3.1 ansiwrap==0.8.4; python_version >= "3.6" appdirs==1.4.4; python_version >= "3.6" @@ -18,7 +18,7 @@ bs4==0.0.1 cachetools==4.2.1; python_version >= "3.5" and python_version < "4.0" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0") certifi==2020.12.5; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" cffi==1.14.5; implementation_name == "pypy" and python_version >= "3.6" -chardet==3.0.4; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" +chardet==4.0.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" click==7.1.2; python_full_version >= "3.6.0" and python_version >= "3.6" cloudpickle==1.6.0; python_version >= "3.6" cmdstanpy==0.4.0 @@ -54,7 +54,7 @@ holidays==0.10.5.2 hyperopt==0.2.5; python_version >= "3.6" idna-ssl==1.1.0; python_version < "3.7" and python_version >= "3.6" idna==2.10; python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "3.7" or python_version < "3.7" and python_version >= "3.6" and python_full_version >= "3.5.0" -importlib-metadata==3.7.0; python_version < "3.8" and python_version >= "3.6" and (python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.2.0" and python_version >= "3.6" and python_version < "3.8") +importlib-metadata==3.7.2; python_version < "3.8" and python_version >= "3.6" and python_full_version >= "3.6.1" and python_full_version < "4.0.0" and (python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.2.0" and python_version >= "3.6" and python_version < "3.8") inflection==0.5.1; python_version >= "3.5" ipykernel==5.5.0; python_version >= "3.6" ipython-genutils==0.2.0; python_full_version >= "3.6.1" and python_version >= "3.6" @@ -74,7 +74,7 @@ jupyterlab-pygments==0.1.2; python_version >= "3.6" jupyterlab-widgets==1.0.0; python_version >= "3.6" keras-preprocessing==1.1.2 kiwisolver==1.3.1; python_version >= "3.6" -konoha==4.6.3; python_full_version >= "3.6.1" and python_full_version < "4.0.0" and python_version >= "3.6" +konoha==4.6.4; python_full_version >= "3.6.1" and python_full_version < "4.0.0" and python_version >= "3.6" korean-lunar-calendar==0.2.1 langdetect==1.0.8; python_version >= "3.6" lunarcalendar==0.0.9; python_version >= "2.7" and python_version < "4" @@ -103,7 +103,7 @@ packaging==20.9; python_full_version >= "3.6.0" and python_version >= "3.6" and pandas-ta==0.2.45b pandas==1.1.5; python_full_version >= "3.6.1" pandocfilters==1.4.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6" -papermill==2.3.2; python_version >= "3.6" +papermill==2.3.3; python_version >= "3.6" parso==0.8.1; python_version >= "3.6" pathspec==0.8.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" patsy==0.5.1; python_version >= "3.6" @@ -116,8 +116,8 @@ praw==7.2.0; python_version >= "3.6" and python_version < "4.0" prawcore==2.0.0; python_version >= "3.6" and python_version < "4.0" prettytable==2.1.0; python_version >= "3.6" prometheus-client==0.9.0; python_version >= "3.5" -prompt-toolkit==3.0.16; python_full_version >= "3.6.1" -protobuf==3.15.5; python_full_version >= "3.6.0" and python_version >= "3.6" +prompt-toolkit==3.0.17; python_full_version >= "3.6.1" +protobuf==3.15.6; python_full_version >= "3.6.0" and python_version >= "3.6" psaw==0.0.12; python_version >= "3" ptyprocess==0.7.0; os_name != "nt" and python_version >= "3.6" and sys_platform != "win32" py==1.10.0; python_version >= "3.6" and python_full_version < "3.0.0" and implementation_name == "pypy" or implementation_name == "pypy" and python_version >= "3.6" and python_full_version >= "3.4.0" @@ -125,7 +125,7 @@ pyasn1-modules==0.2.8; python_version >= "2.7" and python_full_version < "3.0.0" pyasn1==0.4.8; python_version >= "3.5" and python_full_version < "3.0.0" and python_version < "4" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6") or python_version >= "3.5" and python_version < "4" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6") and python_full_version >= "3.6.0" pycparser==2.20; python_version >= "3.5" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.5" pygments==2.8.1; python_version >= "3.6" -pymeeus==0.5.5; python_version >= "3.5" +pymeeus==0.5.9; python_version >= "3.5" pyparsing==2.4.7; python_full_version >= "3.6.0" and python_version >= "3.6" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6") pyrsistent==0.17.3; python_version >= "3.6" pysocks==1.7.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" @@ -140,7 +140,7 @@ pyzmq==22.0.3; python_full_version >= "3.6.1" and python_version >= "3.6" qtconsole==5.0.2; python_version >= "3.6" qtpy==1.9.0; python_version >= "3.6" quandl==3.6.1; python_version >= "3.5" -rapidfuzz==1.1.2; python_version >= "2.7" +rapidfuzz==1.2.1; python_version >= "2.7" regex==2020.11.13; python_full_version >= "3.6.0" and python_version >= "3.6" requests-oauthlib==1.3.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6" requests==2.25.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") @@ -149,6 +149,7 @@ rsa==4.7.2; python_version >= "3.5" and python_version < "4" and (python_version sacremoses==0.0.43; python_full_version >= "3.6.0" and python_version >= "3.6" scikit-learn==0.24.1; python_version >= "3.6" scipy==1.5.4; python_version >= "3.6" +seaborn==0.11.1; python_version >= "3.6" segtok==1.5.10; python_version >= "3.6" send2trash==1.5.0; python_version >= "3.5" sentencepiece==0.1.91; python_full_version >= "3.6.0" and python_version >= "3.6" diff --git a/requirements.txt b/requirements.txt index f902ed62c77..a6b36ab22f8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -aiohttp==3.7.4; python_version >= "3.6" +aiohttp==3.7.4.post0; python_version >= "3.6" alpha-vantage==2.3.1 ansiwrap==0.8.4; python_version >= "3.6" appdirs==1.4.4; python_version >= "3.6" @@ -14,7 +14,7 @@ bleach==3.3.0; python_version >= "3.6" and python_full_version < "3.0.0" or pyth bs4==0.0.1 certifi==2020.12.5; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" cffi==1.14.5; implementation_name == "pypy" and python_version >= "3.6" -chardet==3.0.4; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" +chardet==4.0.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" click==7.1.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" colorama==0.4.4; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") convertdate==2.3.1; python_version >= "3.5" @@ -30,7 +30,7 @@ hijri-converter==2.1.1; python_version >= "3.6" holidays==0.10.5.2 idna-ssl==1.1.0; python_version < "3.7" and python_version >= "3.6" idna==2.10; python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "3.7" or python_version < "3.7" and python_version >= "3.6" and python_full_version >= "3.5.0" -importlib-metadata==3.7.0; python_version < "3.8" and python_version >= "3.6" +importlib-metadata==3.7.2; python_version < "3.8" and python_version >= "3.6" inflection==0.5.1; python_version >= "3.5" ipykernel==5.5.0; python_version >= "3.6" ipython-genutils==0.2.0; python_full_version >= "3.6.1" and python_version >= "3.6" @@ -67,7 +67,7 @@ packaging==20.9; python_version >= "3.6" and python_full_version < "3.0.0" or py pandas-ta==0.2.45b pandas==1.1.5; python_full_version >= "3.6.1" pandocfilters==1.4.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6" -papermill==2.3.2; python_version >= "3.6" +papermill==2.3.3; python_version >= "3.6" parso==0.8.1; python_version >= "3.6" pathspec==0.8.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" pexpect==4.8.0; sys_platform != "win32" and python_version >= "3.6" @@ -78,13 +78,13 @@ praw==7.2.0; python_version >= "3.6" and python_version < "4.0" prawcore==2.0.0; python_version >= "3.6" and python_version < "4.0" prettytable==2.1.0; python_version >= "3.6" prometheus-client==0.9.0; python_version >= "3.5" -prompt-toolkit==3.0.16; python_full_version >= "3.6.1" +prompt-toolkit==3.0.17; python_full_version >= "3.6.1" psaw==0.0.12; python_version >= "3" ptyprocess==0.7.0; os_name != "nt" and python_version >= "3.6" and sys_platform != "win32" py==1.10.0; python_version >= "3.6" and python_full_version < "3.0.0" and implementation_name == "pypy" or implementation_name == "pypy" and python_version >= "3.6" and python_full_version >= "3.4.0" pycparser==2.20; python_version >= "3.5" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.5" pygments==2.8.1; python_version >= "3.6" -pymeeus==0.5.5; python_version >= "3.5" +pymeeus==0.5.9; python_version >= "3.5" pyparsing==2.4.7; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" pyrsistent==0.17.3; python_version >= "3.6" pysocks==1.7.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" @@ -98,10 +98,12 @@ pyzmq==22.0.3; python_full_version >= "3.6.1" and python_version >= "3.6" qtconsole==5.0.2; python_version >= "3.6" qtpy==1.9.0; python_version >= "3.6" quandl==3.6.1; python_version >= "3.5" -rapidfuzz==1.1.2; python_version >= "2.7" +rapidfuzz==1.2.1; python_version >= "2.7" regex==2020.11.13; python_version >= "3.6" requests==2.25.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") retrying==1.3.3 +scipy==1.5.4; python_version >= "3.6" +seaborn==0.11.1; python_version >= "3.6" send2trash==1.5.0; python_version >= "3.5" six==1.15.0; python_full_version >= "3.6.1" and python_version >= "3.6" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0") and (python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.4.0") and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6") and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6") and (python_version >= "3.5" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.5") soupsieve==2.2; python_version >= "3.6" diff --git a/terminal.py b/terminal.py index cc40b922fce..e30805c294c 100644 --- a/terminal.py +++ b/terminal.py @@ -2,6 +2,7 @@ import argparse +from datetime import datetime, timedelta import pandas as pd from alpha_vantage.timeseries import TimeSeries from prompt_toolkit.completion import NestedCompleter @@ -13,7 +14,7 @@ from gamestonk_terminal.discovery import disc_menu as dm from gamestonk_terminal.due_diligence import dd_menu as ddm from gamestonk_terminal.fundamental_analysis import fa_menu as fam from gamestonk_terminal.helper_funcs import b_is_stock_market_open, get_flair -from gamestonk_terminal.main_helper import clear, export, load, print_help, view +from gamestonk_terminal.main_helper import clear, export, load, print_help, view, candle from gamestonk_terminal.menu import session from gamestonk_terminal.papermill import papermill_menu as mill from gamestonk_terminal.sentiment import sen_menu as sm @@ -52,6 +53,7 @@ def main(): "q", "clear", "load", + "candle", "view", "export", "disc", @@ -116,6 +118,11 @@ def main(): ) main_cmd = True + elif ns_known_args.opt == "candle": + candle( + s_ticker, (datetime.now() - timedelta(days=180)).strftime("%Y-%m-%d") + ) + elif ns_known_args.opt == "view": view(l_args, s_ticker, s_start, s_interval, df_stock) main_cmd = True