From 597cf5118ba70969da58fcfee94bcaf018012356 Mon Sep 17 00:00:00 2001 From: Artem Veremey Date: Sun, 31 Oct 2021 11:43:34 -0700 Subject: [PATCH] Next batch of Markdown lint fixes (#888) * Next batch of Markdown lint fixes * Fixing a deliberate mistake --- .github/ISSUE_TEMPLATE/bug_report.md | 5 +- .github/workflows/test.yml | 2 +- .markdownlintrc | 3 +- changelogs/W07_2021.md | 49 ++- changelogs/W27_2021.md | 2 +- .../common/behavioural_analysis/README.md | 288 ++++++++++------- .../FUNE-TUNING-NN-models.md | 223 ++++++++----- .../prediction_techniques/README-gpu-accel.md | 22 +- .../common/prediction_techniques/README.md | 306 ++++++++++-------- .../common/technical_analysis/README.md | 178 +++++----- 10 files changed, 645 insertions(+), 433 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 92fd5418000..abbd2dabe57 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -16,8 +16,9 @@ Steps(from the start) and commands to reproduce the behavior If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - - OS: [e.g. Mac Sierra] - - Python version [e.g. 3.6.8] + +- OS: [e.g. Mac Sierra] +- Python version [e.g. 3.6.8] **Additional context** Add any other information that you think could be useful for us. diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1e91191d821..4d2110e73d2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -94,7 +94,7 @@ jobs: - name: Lint Code Base uses: docker://avtodev/markdown-lint:v1 with: - args: "./gamestonk_terminal/options/README.md ./*.md" + args: "./gamestonk_terminal/options/README.md ./*.md ./changelogs/*.md ./gamestonk_terminal/common/**/*.md" tests-python: name: Vanilla Python Tests - (${{ matrix.python-version }}, ${{ matrix.os }}) needs: test diff --git a/.markdownlintrc b/.markdownlintrc index c118d7b4662..e1645bcd26f 100644 --- a/.markdownlintrc +++ b/.markdownlintrc @@ -1,10 +1,11 @@ { "default": true, - "MD033": false, + "MD025": false, "MD013": { "line_length": 120, "tables": false }, + "MD033": false, "MD036": false, "MD041": false } diff --git a/changelogs/W07_2021.md b/changelogs/W07_2021.md index 37a5af92ab7..e4443e13362 100644 --- a/changelogs/W07_2021.md +++ b/changelogs/W07_2021.md @@ -8,38 +8,65 @@ Hey guys, hear me out. -I’ve been here for quite some time, although my account shows only few weeks old. (That’s thanks to the fact that on my previous account I had my username as my full name …) And Reddit has been one of the apps I spent most of my time on. This is regardless whether I want to learn about the stock market, attend NASA’s AMA on Perseverance, or even for the memes on WSB community. +I’ve been here for quite some time, although my account shows only few weeks old. (That’s thanks to the fact that on my +previous account I had my username as my full name …) And Reddit has been one of the apps I spent most of my time on. +This is regardless whether I want to learn about the stock market, attend NASA’s AMA on Perseverance, or even for the +memes on WSB community. -Hence, I felt like I owed something to the community. For that reason, and also because I can, I developed a multi-purpose terminal. +Hence, I felt like I owed something to the community. For that reason, and also because I can, I developed a +multi-purpose terminal. -I changed my reddit account because it had my full legal name, and then in my first post I share my own personal github…. life’s tricky. -Anyway, I’ve lost a lot of time around the README files, so that before you lose any time cloning the repo, you have full disclosure to whatever you’ll get out of this repo. +I changed my reddit account because it had my full legal name, and then in my first post I share my own personal +github…. life’s tricky. +Anyway, I’ve lost a lot of time around the README files, so that before you lose any time cloning the repo, you have +full disclosure to whatever you’ll get out of this repo. But in summary, the Terminal has 7 distinct menus: **Discover Stocks** -- Some features are: Top gainers; Sectors performance; upcoming earnings releases; top high shorted interest stocks; top stocks with low float; top orders on fidelity; and some SPAC websites with news/calendars. + +- Some features are: Top gainers; Sectors performance; upcoming earnings releases; top high shorted interest stocks; +- top stocks with low float; top orders on fidelity; and some SPAC websites with news/calendars. **Market Sentiment** -- Main features are: Scrolling through Reddit main posts, and most tickers mentions; Extracting trending symbols on stocktwits, or even stocktwit sentiment based on bull/bear flags; Twitter in-depth sentiment prediction using AI; Google mentions over time. + +- Main features are: Scrolling through Reddit main posts, and most tickers mentions; Extracting trending symbols on +stocktwits, or even stocktwit sentiment based on bull/bear flags; Twitter in-depth sentiment prediction using AI; +Google mentions over time. **Research Web pages** + - List of good pages to do research on a stock, e.g. macroaxis, zacks, macrotrends, .. **Fundamental Analysis** -- Read financials from a company from Market Watch, Yahoo Finance, Alpha Vantage, and Financial Modeling Prep API. Since I only rely on free data, I added the information from all of these, so that the user can get it from the source it trusts the most. Also exports management team behind stock, along with their pages on Google, to speed up research process. + +- Read financials from a company from Market Watch, Yahoo Finance, Alpha Vantage, and Financial Modeling Prep API. +Since I only rely on free data, I added the information from all of these, so that the user can get it from the source +it trusts the most. Also exports management team behind stock, along with their pages on Google, to speed up research +process. **Technical Analysis** + - The usual technical indicators: sma, rsi, macd, adx, bbands, and more. **Due Diligence** -- It has several features that I found to be really useful. Some of them are: Latest news of the company; Analyst prices and ratings; Price target from several analysts plot over time vs stock price; Insider activity, and these timestamps marked on the stock price historical data; Latest SEC fillings; Short interest over time; A check for financial warnings based on Sean Seah book. + +- It has several features that I found to be really useful. Some of them are: Latest news of the company; Analyst +prices and ratings; Price target from several analysts plot over time vs stock price; Insider activity, and these +timestamps marked on the stock price historical data; Latest SEC fillings; Short interest over time; A check for +financial warnings based on Sean Seah book. **Prediction Techniques** -- The one I had more fun with. It tries to predict the stock price, from simple models like sma and arima to complex neural network models, like LSTM. The additional capability here is that all of these are easy to configure. Either through command line arguments, or even in form of a configuration file to define your NN. -About me, I’m a Sensor Fusion Engineer, and I enjoy working in self-learning projects in my spare time involving mostly some sort of ML/AI. I’m more than happy to add features that you request to the repo, and will keep on top of bugs. +- The one I had more fun with. It tries to predict the stock price, from simple models like sma and arima to complex +neural network models, like LSTM. The additional capability here is that all of these are easy to configure. Either +through command line arguments, or even in form of a configuration file to define your NN. -I’m sorry that there isn’t a simple web interface for this which may be limiting for some of you. It’s not that I didn’t want to, but more that I don’t have experience with such. If one of you guys is keen on creating it for this terminal, that would be amazing. +About me, I’m a Sensor Fusion Engineer, and I enjoy working in self-learning projects in my spare time involving mostly +some sort of ML/AI. I’m more than happy to add features that you request to the repo, and will keep on top of bugs. + +I’m sorry that there isn’t a simple web interface for this which may be limiting for some of you. It’s not that I +didn’t want to, but more that I don’t have experience with such. If one of you guys is keen on creating it for this +terminal, that would be amazing. Your feedback is very much appreciated! diff --git a/changelogs/W27_2021.md b/changelogs/W27_2021.md index 3f3bbcf22bf..87c0397acbe 100644 --- a/changelogs/W27_2021.md +++ b/changelogs/W27_2021.md @@ -2,7 +2,7 @@ [#529 - A bunch of bugfixes](https://github.com/GamestonkTerminal/GamestonkTerminal/pull/529) -[#532 - Improve menu UX ](https://github.com/GamestonkTerminal/GamestonkTerminal/pull/532) +[#532 - Improve menu UX](https://github.com/GamestonkTerminal/GamestonkTerminal/pull/532) [#533 - Add supply and customer feature](https://github.com/GamestonkTerminal/GamestonkTerminal/pull/533) diff --git a/gamestonk_terminal/common/behavioural_analysis/README.md b/gamestonk_terminal/common/behavioural_analysis/README.md index 0fba235a7ef..1257f89565c 100644 --- a/gamestonk_terminal/common/behavioural_analysis/README.md +++ b/gamestonk_terminal/common/behavioural_analysis/README.md @@ -1,196 +1,230 @@ # BEHAVIOURAL ANALYSIS -This menu aims to extrapolate behavioural analysis regarding a pre-loaded ticker, and the usage of the following commands along with an example will be exploited below. +This menu aims to extrapolate behavioural analysis regarding a pre-loaded ticker, and the usage of the following +commands along with an example will be exploited below. - * [finbrain](#finbrain) - - sentiment from 15+ major news headlines - * [stats](#stats) - - sentiment stats including comparison with sector +* [finbrain](#finbrain) + * sentiment from 15+ major news headlines +* [stats](#stats) + * sentiment stats including comparison with sector [REDDIT](#REDDIT) - * [wsb](#wsb) - - show what WSB gang is up to in subreddit wallstreetbets - * [watchlist](#watchlist) - - show other users watchlist - * [popular](#popular) - - show popular tickers - * [spac_c](#spac_c) - - show other users spacs announcements from subreddit SPACs community - * [spac](#spac) - - show other users spacs announcements from other subs + +* [wsb](#wsb) + * show what WSB gang is up to in subreddit wallstreetbets +* [watchlist](#watchlist) + * show other users watchlist +* [popular](#popular) + * show popular tickers +* [spac_c](#spac_c) + * show other users spacs announcements from subreddit SPACs community +* [spac](#spac) + * show other users spacs announcements from other subs [STOCKTWITS](#STOCKTWITS) - * [bullbear](#bullbear) - - estimate quick sentiment from last 30 messages on board - * [messages](#messages) - - output up to the 30 last messages on the board - * [trending](#trending) - - trending stocks - * [stalker](#stalker) - - stalk stocktwits user's last messages + +* [bullbear](#bullbear) + * estimate quick sentiment from last 30 messages on board +* [messages](#messages) + * output up to the 30 last messages on the board +* [trending](#trending) + * trending stocks +* [stalker](#stalker) + * stalk stocktwits user's last messages [TWITTER](#TWITTER) - * [infer](#infer) - - infer about stock's sentiment from latest tweets - * [sentiment](#sentiment) - - in-depth sentiment prediction from tweets over time + +* [infer](#infer) + * infer about stock's sentiment from latest tweets +* [sentiment](#sentiment) + * in-depth sentiment prediction from tweets over time [GOOGLE](#GOOGLE) - * [mentions](#mentions) - - interest over time based on stock's mentions - * [regions](#regions) - - regions that show highest interest in stock - * [queries](#queries) - - top related queries with this stock - * [rise](#rise) - - top rising related queries with stock + +* [mentions](#mentions) + * interest over time based on stock's mentions +* [regions](#regions) + * regions that show highest interest in stock +* [queries](#queries) + * top related queries with this stock +* [rise](#rise) + * top rising related queries with stock [SENTIMENT INVESTOR](#SENTIMENTINVESTOR) - * [metrics](#metrics) - - core social sentiment metrics for this stock - * [social](#social) - - social media figures for stock popularity - * [historical](#historical) - - plot the past week of data for a selected metric + +* [metrics](#metrics) + * core social sentiment metrics for this stock +* [social](#social) + * social media figures for stock popularity +* [historical](#historical) + * plot the past week of data for a selected metric ## finbrain -``` + +```text usage: finbrain ``` -FinBrain collects the news headlines from 15+ major financial news sources on a daily basis and analyzes them to generate sentiment scores for more than 4500 US stocks. FinBrain Technologies develops deep learning algorithms for financial analysis and prediction, which currently serves traders from more than 150 countries all around the world. [Source: See https://finbrain.tech] + +FinBrain collects the news headlines from 15+ major financial news sources on a daily basis and analyzes them to +generate sentiment scores for more than 4500 US stocks. FinBrain Technologies develops deep learning algorithms for +financial analysis and prediction, which currently serves traders from more than 150 countries all around the world. +[Source: See ] ![finbrain2](https://user-images.githubusercontent.com/25267873/111629515-49c97000-87e9-11eb-92a6-a9eebb4b4bd9.png) -Captura de ecrã 2021-03-18, às 12 53 31 - +Finbrain ## stats -``` + +```text usage: stats ``` -Sentiment stats which displays buzz, news score, articles last week, articles weekly average, bullish vs bearish percentages, sector average bullish percentage, and sector average news score. [Source: https://finnhub.io] -Captura de ecrã 2021-05-03, às 15 26 09 +Sentiment stats which displays buzz, news score, articles last week, articles weekly average, bullish vs bearish +percentages, sector average bullish percentage, and sector average news score. [Source: ] +Stats # REDDIT ## wsb -``` + +```text usage: wsb [-l N_LIMIT] [-n] ``` + Print what WSB gang are up to in subreddit wallstreetbets. [Source: Reddit] - * -l : limit of posts to print. Default 10. - * -n : new flag, if true the posts retrieved are based on being more recent rather than their score. Default False. + +* -l : limit of posts to print. Default 10. +* -n : new flag, if true the posts retrieved are based on being more recent rather than their score. Default False. wsb - ## watchlist -``` + +```text usage: watchlist [-l N_LIMIT] ``` + Print other users watchlist. [Source: Reddit] - * -l : limit of posts to print. Default 5. + +* -l : limit of posts to print. Default 5. watchlist - ## popular -``` + +```text usage: popular [-l N_LIMIT] [-s S_SUBREDDIT] [-d N_DAYS] ``` + Print latest popular tickers. [Source: Reddit] - * -l : limit of posts retrieved per sub reddit. Default 50. - * -s : subreddits to look for tickers, e.g. pennystocks,stocks. Default: pennystocks, RobinHoodPennyStocks, Daytrading, StockMarket, stocks, investing, wallstreetbets. + +* -l : limit of posts retrieved per sub reddit. Default 50. +* -s : subreddits to look for tickers, e.g. pennystocks,stocks. Default: pennystocks, RobinHoodPennyStocks, Daytrading, +StockMarket, stocks, investing, wallstreetbets. popular - ## spac_c -``` + +```text usage: spac_c [-l N_LIMIT] [-p] ``` + Print other users SPACs announcement under subreddit 'SPACs'. [Source: Reddit] - * -l : limit of posts with SPACs retrieved. Default 10. - * -p : popular flag, if true the posts retrieved are based on score rather than time. Default False. + +* -l : limit of posts with SPACs retrieved. Default 10. +* -p : popular flag, if true the posts retrieved are based on score rather than time. Default False. spac_c - ## spac -``` + +```text usage: spac [-h] [-l N_LIMIT] [-d N_DAYS] ``` + Print other users SPACs announcement under subreddit 'SPACs'. [Source: Reddit] - * -l : limit of posts with SPACs retrieved. Default 5. + +* -l : limit of posts with SPACs retrieved. Default 5. spac - # STOCKTWITS ## bullbear -``` + +```text usage: bullbear [-t S_TICKER] ``` + Print bullbear sentiment based on last 30 messages on the board. Also prints the watchlist_count. [Source: Stocktwits] - * -t : ticker to gather sentiment from. + +* -t : ticker to gather sentiment from. sentiment - ## messages -``` + +```text usage: messages [-t S_TICKER] [-l N_LIM] ``` + Print up to 30 of the last messages on the board. [Source: Stocktwits] - * -t : get board messages from this ticker. Default pre-loaded. - * -l : limit messages shown. Default 30. + +* -t : get board messages from this ticker. Default pre-loaded. +* -l : limit messages shown. Default 30. messages - ## trending -``` + +```text usage: trending ``` + Stocks trending. [Source: Stocktwits] trending - ## stalker -``` + +```text usage: stalker [-u S_USER] [-l N_LIM] ``` + Print up to the last 30 messages of a user. [Source: Stocktwits] - * -u : username. Default newsfilter. - * -l : limit messages shown. Default 30. + +* -u : username. Default newsfilter. +* -l : limit messages shown. Default 30. stalker - # TWITTER -Uses VADER sentiment. VADER (Valence Aware Dictionary and sEntiment Reasoner) is a lexicon and rule-based sentiment analysis -tool that is specifically attuned to sentiments expressed in social media. + +Uses VADER sentiment. VADER (Valence Aware Dictionary and sEntiment Reasoner) is a lexicon and rule-based sentiment +analysis tool that is specifically attuned to sentiments expressed in social media. The output of VADER analysis : -``` + +```text The compound score is computed by summing the valence scores of each word in the lexicon, adjusted according to the rules, and then normalized to be between -1 (most extreme negative) and +1 (most extreme positive). This is the most useful metric if you want a single unidimensional measure of sentiment for a given sentence. Calling it a 'normalized, weighted composite score' is accurate. ``` + A sample tweet is shown below along with what the VADER polarity scores are. -```' +```text Have some $SENS 🚀🏆\n👉FDA approval coming very soon, 👉News is out, amazing test results. \n👉Very high short interest rate. \n👉Major short squeeze coming. \n\n$amc $gme $nakd $ctrm $tsla $aapl $oeg $aht $bbby $bb $fsr $spce https://t.co/B0cPhufpA2' ``` This gives the following scores: + ```python created_at Thu Jun 03 20:37:54 text Have some $SENS 🚀🏆\n👉FDA approval coming very... @@ -200,64 +234,82 @@ negative 0 neutral 0.823 ``` -Note that both functions use twitters v2 endpoint, which only gives 7 days of historical data. It also requires at least 10 tweets be pulled. +Note that both functions use twitters v2 endpoint, which only gives 7 days of historical data. It also requires at +least 10 tweets be pulled. ## infer -``` + +```text usage: infer [-n N_NUM] ``` -Print quick sentiment inference from last tweets that contain the ticker. This model splits the text into character-level tokens and uses theVADER model to make predictions. - * -n : num of latest tweets to infer from. Default 100. +Print quick sentiment inference from last tweets that contain the ticker. This model splits the text into +character-level tokens and uses theVADER model to make predictions. + +* -n : num of latest tweets to infer from. Default 100. ## sentiment -``` + +```text usage: sentiment [-n N_NUM] [-d N_DAYS_PAST] ``` -Plot in-depth sentiment extracted from tweets from last days that contain pre-defined ticker. This model splits the text into character-level tokens and uses the VADER model to make predictions. - * -n : num of tweets to extract per hour. Default 15. - * -d : num of days in the past to extract tweets. Default 6. Max 6 + +Plot in-depth sentiment extracted from tweets from last days that contain pre-defined ticker. This model splits the +text into character-level tokens and uses the VADER model to make predictions. + +* -n : num of tweets to extract per hour. Default 15. +* -d : num of days in the past to extract tweets. Default 6. Max 6 # GOOGLE ## mentions -``` + +```text usage: mentions [-s S_START] ``` + Plot weekly bars of stock's interest over time. other users watchlist. [Source: Google] - * -s : starting date (format YYYY-MM-DD) from when we are interested in stock's mentions. Default: the one provided in main menu. + +* -s : starting date (format YYYY-MM-DD) from when we are interested in stock's mentions. Default: the one provided +in main menu. ![gme](https://user-images.githubusercontent.com/25267873/108776894-e9813e80-755a-11eb-8b7e-654124c0ef8f.png) - ## regions -``` + +```text usage: regions [-n N_NUM] ``` + Plot bars of regions based on stock's interest. [Source: Google] - * -n : number of regions to plot that show highest interest. Default 10. + +* -n : number of regions to plot that show highest interest. Default 10. ![regions](https://user-images.githubusercontent.com/25267873/108776889-e8e8a800-755a-11eb-8bcc-fcf7b6156f50.png) - ## queries -``` + +```text usage: queries [-n N_NUM] ``` + Print top related queries with this stock's query. [Source: Google] - * -n : number of top related queries to print. Default 10. -Captura de ecrã 2021-02-22, às 22 15 16 +* -n : number of top related queries to print. Default 10. +Queries ## rise -``` + +```text usage: rise [-n N_NUM] ``` -Print top rising related queries with this stock's query. [Source: Google] - * -n : number of top rising related queries to print. Default 10. -Captura de ecrã 2021-02-22, às 22 21 21 +Print top rising related queries with this stock's query. [Source: Google] + +* -n : number of top rising related queries to print. Default 10. + +Rise # SENTIMENTINVESTOR @@ -294,7 +346,7 @@ dividing it by the average of the past week of sentiment values. ## metrics -``` +```text usage: metrics [-h] [ticker] ``` @@ -302,9 +354,10 @@ The `metrics` command presents the four core metrics provided by Sentiment Inves including AHI, RHI, sentiment and SGP, as described above. Optional arguments: -- [optional, positional] ticker + +* [optional, positional] ticker ticker to use instead of the loaded one -- `-h`, `--help` +* `-h`, `--help` show this help message Example output: @@ -313,7 +366,7 @@ Example output: ## social -``` +```text usage: social [-h] [ticker] ``` @@ -322,9 +375,10 @@ of mentions it has received on social media in the last hour and the sentiment score of those comments. Optional arguments: -- [optional, positional] ticker + +* [optional, positional] ticker ticker to use instead of the loaded one -- `-h`, `--help` +* `-h`, `--help` show this help message Example output: @@ -333,7 +387,7 @@ Example output: ## historical -``` +```text usage: historical [-t TICKER] [-s [{date,value}]] [-d [{asc,desc}]] [-h] [{sentiment,AHI,RHI,SGP}] ``` @@ -343,17 +397,19 @@ SentimentInvestor core metric, one of: It also outputs a sorted table of the mean value for that metric for each day. Positional arguments: -- one of `sentiment`, `AHI`, `RHI` or `SGP` + +* one of `sentiment`, `AHI`, `RHI` or `SGP` (optional) the metric to plot (default: `sentiment`) Optional arguments: -- `-t`, `--ticker TICKER` + +* `-t`, `--ticker TICKER` ticker for which to fetch data -- `-s`, `--sort [{date,value}]` +* `-s`, `--sort [{date,value}]` the parameter to sort output table by -- `-d`, `--direction [{asc,desc}]` +* `-d`, `--direction [{asc,desc}]` the direction to sort the output table -- `-h`, `--help` +* `-h`, `--help` show this help message Example output: diff --git a/gamestonk_terminal/common/prediction_techniques/FUNE-TUNING-NN-models.md b/gamestonk_terminal/common/prediction_techniques/FUNE-TUNING-NN-models.md index f5d7c9048c6..fedd4f30acd 100644 --- a/gamestonk_terminal/common/prediction_techniques/FUNE-TUNING-NN-models.md +++ b/gamestonk_terminal/common/prediction_techniques/FUNE-TUNING-NN-models.md @@ -1,141 +1,186 @@ # Validate/Tweaking Neural Network Model -Note: Modeling a NN this way is intended for learning purposes (or fun) only. A user guess or YOLOing on GME may present better returns - No financial advisor tho. +Note: Modeling a NN this way is intended for learning purposes (or fun) only. A user guess or YOLOing on GME may +present better returns - No financial advisor tho. 1. **Select the stock that you want to attempt to predict share price** -``` -load MSFT -``` + + ```text + load MSFT + ``` 2. **Slice the stock price to only relevant data** -Look at the overall share price and try to understand from when does it start behaving similarly. E.g. looking at MSFT, for me, it starts behaving similarly after 2014. Before that, the stock price is rather flat, and not representative of the current pattern. -``` -load MSFT -s 2014-01-01 -``` + Look at the overall share price and try to understand from when does it start behaving similarly. E.g. looking at + MSFT, for me, it starts behaving similarly after 2014. Before that, the stock price is rather flat, and not + representative of the current pattern. + + ```text + load MSFT -s 2014-01-01 + ``` 3. **Out of this training data, select which part will be used for validation** -Anyone reading this, note this is quite a discussion between the devs. Since this is a time series, there is an inherent -ordering of the data. However, since returns are random, it is hard to predict, and ordering data may not have any meaning. + Anyone reading this, note this is quite a discussion between the devs. Since this is a time series, there is an + inherent ordering of the data. However, since returns are random, it is hard to predict, and ordering data may not + have any meaning. -To this end, we allow users to specify how much validation data to use and if it should be shuffled. By default, we will split -into 10% validation data with a random shuffle. This will allow the user to see how the model performs at various times in your sequence. + To this end, we allow users to specify how much validation data to use and if it should be shuffled. By default, we + will split into 10% validation data with a random shuffle. This will allow the user to see how the model performs + at various times in your sequence. -``` --v/--valid : validation split of data. Default 0.1 (10%) ---no_shuffle : Flag that will order the validation data so that the last (-v) percent of data is the validation. -``` -To try "backtesting" to a certain data, you can specify the end date. This will forecast and compare the true data from that time. -``` --e/--end : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. -``` + ```text + -v/--valid : validation split of data. Default 0.1 (10%) + --no_shuffle : Flag that will order the validation data so that the last (-v) percent of data is the validation. + ``` + + To try "backtesting" to a certain data, you can specify the end date. This will forecast and compare the true data + from that time. + + ```text + -e/--end : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. + ``` 4. **Pre-processing data** -Decide whether you want to pre-process your share price data or not. I.e. do you want to use these values between 18 and 245, or perhaps normalize these between 0 and 1? The later may improve performance. -``` -Preprocess = "minmax" -``` -This is defined in the config file. + Decide whether you want to pre-process your share price data or not. I.e. do you want to use these values between 18 + and 245, or perhaps normalize these between 0 and 1? The later may improve performance. + + ```text + Preprocess = "minmax" + ``` + + This is defined in the config file. 5. **Select input, prediction days and jumps in training data** -The **input** corresponds to the number of days that our model will use for prediction. + The **input** corresponds to the number of days that our model will use for prediction. -The more past days, the more information our model will have to make a sensible prediction. However, the more days being used will lead to a model that takes longer to train, and some days in the past may have no affect in the prediction. In order to facilitate this decision, think of it in terms of months, e.g. 40 days corresponds to roughly 2 months of data. If you think that the share price today can impact the value that it will take in 2 months, then 40 is a good value, otherwise pick a shorter value. -``` --i/--input : number of days to use for prediction. Default 40. -``` + The more past days, the more information our model will have to make a sensible prediction. However, the more days + being used will lead to a model that takes longer to train, and some days in the past may have no affect in the + prediction. In order to facilitate this decision, think of it in terms of months, e.g. 40 days corresponds to + roughly 2 months of data. If you think that the share price today can impact the value that it will take in 2 + months, then 40 is a good value, otherwise pick a shorter value. -The **prediction days** is the number we want to predict for. + ```text + -i/--input : number of days to use for prediction. Default 40. + ``` -Personally, I recommend to set this for a really short window. This is because the bigger the window, the less reliable the prediction is. This is mainly due to the fact that by having a larger prediction horizon, more unexpected events (news, insider trading activity, rumours, ...) can occur, which may shift share price. -``` --d/--days : prediciton days. Default 5. -``` + The **prediction days** is the number we want to predict for. + + Personally, I recommend to set this for a really short window. This is because the bigger the window, the less + reliable the prediction is. This is mainly due to the fact that by having a larger prediction horizon, more + unexpected events (news, insider trading activity, rumours, ...) can occur, which may shift share price. + + ```text + -d/--days : prediction days. Default 5. + ``` 6. **Select NN architecture.** TL;DR: LSTM > RNN > MLP -**MLP**: The neurons don't have any memory. -**RNN***: The neurons can only retain really recent memory. -**LSTM** (improved RNN): The neurons have a long-term memory, hence why this is used for text prediction, since the beginning of a sentence is important to predict the ending. + **MLP**: The neurons don't have any memory. + **RNN***: The neurons can only retain really recent memory. + **LSTM** (improved RNN): The neurons have a long-term memory, hence why this is used for text prediction, since the + beginning of a sentence is important to predict the ending. -Have a look at: https://colah.github.io/posts/2015-08-Understanding-LSTMs/ + Have a look at: 7. **Define NN Model** -**Number of hidden layers**: Due to the complexity of these NN models (particularly LSTM), this value should be kept low (2, 3 or 4). Otherwise, the model will not generalize well to unseen examples (i.e. it will overfit). + **Number of hidden layers**: Due to the complexity of these NN models (particularly LSTM), this value should be kept + low (2, 3 or 4). Otherwise, the model will not generalize well to unseen examples (i.e. it will overfit). -**Number of units per layers**: This is one of the hardest to know how to set, I usually set this one by trial and iteration, and understanding how the model performs. Note: Be carefully about this iterative process, to not overfit your hyperparameters to work well in the validation data. Because then it may fail badly on the real prediction. + **Number of units per layers**: This is one of the hardest to know how to set, I usually set this one by trial and + iteration, and understanding how the model performs. Note: Be carefully about this iterative process, to not overfit + your hyperparameters to work well in the validation data. Because then it may fail badly on the real prediction. -**Activation function**: _tanh_ is recommended. It is proved to outperform other activation functions. See https://stats.stackexchange.com/questions/101560/tanh-activation-function-vs-sigmoid-activation-function + **Activation function**: _tanh_ is recommended. It is proved to outperform other activation functions. + See -**Dropout layer**: As a rule of thumb, an LSTM layer should be followed by a Dropout layer with a 20% rate. This is in order to prevent overfitting, while keeping model accuracy. + **Dropout layer**: As a rule of thumb, an LSTM layer should be followed by a Dropout layer with a 20% rate. This is + in order to prevent overfitting, while keeping model accuracy. -**Dense layer**: Dense layer to represent outputs. + **Dense layer**: Dense layer to represent outputs. -``` -Long_Short_Term_Memory \ - = [ {'LSTM': - {'units':25, 'activation':'tanh', 'return_sequences':True} }, - {"Dropout": - {"rate": 0.2} }, - {'LSTM': - {'units':15, 'activation':'tanh', 'return_sequences':False} }, - {'Dense': - {'activation':'linear'} }] -``` -This model is set in [config_neural_network_models.py](/config_neural_network_models.py) + ```python + Long_Short_Term_Memory \ + = [ {'LSTM': + {'units':25, 'activation':'tanh', 'return_sequences':True} }, + {"Dropout": + {"rate": 0.2} }, + {'LSTM': + {'units':15, 'activation':'tanh', 'return_sequences':False} }, + {'Dense': + {'activation':'linear'} }] + ``` + + This model is set in [config_neural_network_models.py](/config_neural_network_models.py) 8. **Model compilation with loss function and optimization technique** -**Loss function**: Often chosen having the activation functions of the hidden layers in mind. See https://machinelearningmastery.com/how-to-choose-loss-functions-when-training-deep-learning-neural-networks/, and https://www.tensorflow.org/api_docs/python/tf/keras/losses. -``` -Loss = "mae" -``` -This is defined in the config file. + **Loss function**: Often chosen having the activation functions of the hidden layers in mind. + See , + and . -**Optimizer technique**:Adaptive Moment Estimation (_adam_) is usually the default choice for this type of problems. See https://www.tensorflow.org/api_docs/python/tf/keras/optimizers. + ```python + Loss = "mae" + ``` -The optimizer selection has been moved to the config_neural_network_models.py file and the new argument is the learning rate. -This tells your model how "fast" to train by adjusting the factor that gets multiplied to the loss function for updating weights -``` ---lr : learning rate. Default 0.01. -``` + This is defined in the config file. + + **Optimizer technique**:Adaptive Moment Estimation (_adam_) is usually the default choice for this type of problems. + See . + + The optimizer selection has been moved to the config_neural_network_models.py file and the new argument is the + learning rate. This tells your model how "fast" to train by adjusting the factor that gets multiplied to the loss + function for updating weights. + + ```text + --lr : learning rate. Default 0.01. + ``` 9. **Training epochs** -Select the number of epochs to train your model. The bigger number of epochs, the longer the training will take, and also increase chances of overfitting. + Select the number of epochs to train your model. The bigger number of epochs, the longer the training will take, and + also increase chances of overfitting. -An early stopping has been implemented that will (if desired) stop training once the validation loss has plateaued. the patience (number of -epochs with no improvement) can be found in the config file. -``` ---epochs : number of training epochs. Default 200. -``` + An early stopping has been implemented that will (if desired) stop training once the validation loss has plateaued. + The patience (number of epochs with no improvement) can be found in the config file. + + ```text + --epochs : number of training epochs. Default 200. + ``` 10. **Model training loops** -Select the number of loops to - using the defined model - train and predict. This allows to build confidence on the model you are building, and understand what's the median results and also the lower and upper quantiles, of 10 and 90%, respectively. -``` ---loops: number of loops to iterate and train models. Default 1. -``` + Select the number of loops to - using the defined model - train and predict. This allows to build confidence on the + model you are building, and understand what's the median results and also the lower and upper quantiles, of 10 and + 90%, respectively. + + ```text + --loops: number of loops to iterate and train models. Default 1. + ``` 11. **Interpret accuracy metrics** -Interpret the following metrics: MAPE, R2, MAE, MSE and RMSE. + Interpret the following metrics: MAPE, R2, MAE, MSE and RMSE. 12. **Advanced User** -``` ---batch_size: batch size for model training, should not be used unless advanced user. Default None. -``` -This can be set to `floor(log2(input_layer_size))` for much faster training if a large amount of input samples (assuming you have the RAM for it). It shouldn't have much effect on the results. -``` ---xla_cpu: if present, will enable XLA for CPU (overrides environment variables during run). ---xla_gpu: if present, will enable XLA for GPU (overrides environment variables during run). ---force_allow_gpu_growth: if true, will force TensorFlow to allow GPU memory usage to grow as needed. Otherwise will allocate 100% of available GPU memory when CUDA is set up. Default true. -``` -See https://www.tensorflow.org/xla + ```text + --batch_size: batch size for model training, should not be used unless advanced user. Default None. + ``` -In the Roadmap: Cross-Validation (Forward Chaining, K-Fold, Group K-fold), NN to use sentiment analysis + This can be set to `floor(log2(input_layer_size))` for much faster training if a large amount of input samples + (assuming you have the RAM for it). It shouldn't have much effect on the results. + + ```text + --xla_cpu: if present, will enable XLA for CPU (overrides environment variables during run). + --xla_gpu: if present, will enable XLA for GPU (overrides environment variables during run). + --force_allow_gpu_growth: if true, will force TensorFlow to allow GPU memory usage to grow as needed. + Otherwise will allocate 100% of available GPU memory when CUDA is set up. Default true. + ``` + + See + + In the Roadmap: Cross-Validation (Forward Chaining, K-Fold, Group K-fold), NN to use sentiment analysis diff --git a/gamestonk_terminal/common/prediction_techniques/README-gpu-accel.md b/gamestonk_terminal/common/prediction_techniques/README-gpu-accel.md index a7907b5207e..4557f74225d 100644 --- a/gamestonk_terminal/common/prediction_techniques/README-gpu-accel.md +++ b/gamestonk_terminal/common/prediction_techniques/README-gpu-accel.md @@ -1,12 +1,15 @@ -# GPU acceleration with CUDA +# GPU Acceleration -Most up-to-date docs and recommendations: https://www.tensorflow.org/install/gpu +## GPU acceleration with CUDA + +Most up-to-date docs and recommendations: ### CUDA 11.0.3, cuDNN 8.0.5 - Tested working 1. Install [CUDA 11.0.3](https://developer.nvidia.com/cuda-toolkit-archive) -2. Install [cuDNN 8.0.5 for CUDA 11.0](https://developer.nvidia.com/rdp/cudnn-archive). This requires signing up for the nvidia developer program. To install, copy the bin/, lib/, include/ dirs into your CUDA install dirs. +2. Install [cuDNN 8.0.5 for CUDA 11.0](https://developer.nvidia.com/rdp/cudnn-archive). This requires signing up for +the nvidia developer program. To install, copy the bin/, lib/, include/ dirs into your CUDA install dirs. | Platform | CUDA path | | -------- | ---------------------------------------------------------- | @@ -19,7 +22,8 @@ Most up-to-date docs and recommendations: https://www.tensorflow.org/install/gpu ### CUDA 11.2.1, cuDNN 8.1 - may work, requires hack -Getting this to run at all requires you to make a link for cusolver10. Even with this fix I ran into out-of-memory issues, so your mileage may vary. See https://github.com/tensorflow/tensorflow/issues/44777. +Getting this to run at all requires you to make a link for cusolver10. Even with this fix I ran into out-of-memory +issues, so your mileage may vary. See . Linux: @@ -37,7 +41,9 @@ mklink /h cusolver64_10.dll cusolver64_11.dll ## Enable XLA for Neural Networks -For neural network training, there are flags defined to enable XLA and GPU options. Note that XLA and especially GPU acceleration may be slower than the defaults if you are not configuring a larger batch size. The default settings produce matrices that are too small to effectively take advantage of these features. +For neural network training, there are flags defined to enable XLA and GPU options. Note that XLA and especially GPU +acceleration may be slower than the defaults if you are not configuring a larger batch size. The default settings +produce matrices that are too small to effectively take advantage of these features. ```bash > load -t GME @@ -48,7 +54,8 @@ For neural network training, there are flags defined to enable XLA and GPU optio ## Globally enable XLA -XLA is a domain specific compiler for linear algebra that can accelerate TensorFlow models if you can get it working. https://www.tensorflow.org/xla +XLA is a domain specific compiler for linear algebra that can accelerate TensorFlow models if you can get it working. + | Env var name | Value | | ------------------------- | ------------------------------------------------------------ | @@ -58,7 +65,8 @@ XLA is a domain specific compiler for linear algebra that can accelerate TensorF ## Globally enable GPU + XLA -By default, TensorFlow will allocate 100% of your available GPU memory before it starts doing work. Using `TF_FORCE_GPU_ALLOW_GROWTH` below will override this behavior so that it only allocates memory as needed. +By default, TensorFlow will allocate 100% of your available GPU memory before it starts doing work. Using +`TF_FORCE_GPU_ALLOW_GROWTH` below will override this behavior so that it only allocates memory as needed. | Env var name | Value | | ------------------------- | ------------------------------------------------------------ | diff --git a/gamestonk_terminal/common/prediction_techniques/README.md b/gamestonk_terminal/common/prediction_techniques/README.md index ff7369ac9dd..0cf3e5c79b0 100644 --- a/gamestonk_terminal/common/prediction_techniques/README.md +++ b/gamestonk_terminal/common/prediction_techniques/README.md @@ -1,149 +1,180 @@ # PREDICTION TECHNIQUES -This menu aims to predict the share price of a pre-loaded stock, and the usage of the following commands along with an example will be exploited below. See [How to fune-tuning a NN model](FUNE-TUNING-NN-models.md). +This menu aims to predict the share price of a pre-loaded stock, and the usage of the following commands along with an +example will be exploited below. See [How to fune-tuning a NN model](FUNE-TUNING-NN-models.md). - * [ets](#ets) - - Exponential Smoothing (e.g. Holt-Winters) - * [knn](#knn) - - k-Nearest Neighbors - * [linear](#linear) - - linear regression (polynomial 1) - * [quadratic](#quadratic) - - quadratic regression (polynomial 2) - * [cubic](#cubic) - - cubic regression (polynomial 3) - * [regression](#regression) - - regression (other polynomial) - * [arima](#arima) - - autoregressive integrated moving average - * [mlp](#mlp) - - MultiLayer Perceptron - * [rnn](#rnn) - - Recurrent Neural Network - - Contains a [looping example](#looping) - * [lstm](#lstm) - - Long-Short Term Memory - - Contains a [backtesting example](#backtesting) - * [conv1d](#conv1d) - - 1D Convolutional Neural Net - -**Note:** _Use this at your own discretion. All of these prediciton techniques rely solely on the closing price of the stock. This means that there are several factors that the models aren't aware of at the time of prediction, and may - drastically - move the price up or down. Examples are: news, analyst price targets, reddit post, tweets from Elon Musk, and so on._ - -**Note 2:** _[Enabling GPU acceleration for TensorFlow requires CUDA setup](README-gpu-accel.md) and will probably not provide any speedup unless you are building large custom models._ +* [ets](#ets) + * Exponential Smoothing (e.g. Holt-Winters) +* [knn](#knn) + * k-Nearest Neighbors +* [linear](#linear) + * linear regression (polynomial 1) +* [quadratic](#quadratic) + * quadratic regression (polynomial 2) +* [cubic](#cubic) + * cubic regression (polynomial 3) +* [regression](#regression) + * regression (other polynomial) +* [arima](#arima) + * autoregressive integrated moving average +* [mlp](#mlp) + * MultiLayer Perceptron +* [rnn](#rnn) + * Recurrent Neural Network + * Contains a [looping example](#looping) +* [lstm](#lstm) + * Long-Short Term Memory + * Contains a [backtesting example](#backtesting) +* [conv1d](#conv1d) + * 1D Convolutional Neural Net +**Note:** _Use this at your own discretion. All of these prediciton techniques rely solely on the closing price of the +stock. This means that there are several factors that the models aren't aware of at the time of prediction, and may - +drastically - move the price up or down. Examples are: news, analyst price targets, reddit post, tweets from Elon Musk, +and so on._ +**Note 2:** _[Enabling GPU acceleration for TensorFlow requires CUDA setup](README-gpu-accel.md) and will probably not +provide any speedup unless you are building large custom models._ ## ets -``` + +```text usage: ets [-t TREND] [-s SEASONAL] [-p SEASONAL_PERIODS] [-d N_DAYS] ``` -Exponential Smoothing (based on trend+seasonality, see https://otexts.com/fpp2/taxonomy.html): - * -t : trend component: N: None, A: Additive, Ad: Additive Damped. Default N. - * -s : seasonality component: N: None, A: Additive, M: Multiplicative. Default N. - * -p : seasonal periods. Default 5. - * -d : prediction days. Default 5. - * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. + +Exponential Smoothing (based on trend+seasonality, see ): + +* -t : trend component: N: None, A: Additive, Ad: Additive Damped. Default N. +* -s : seasonality component: N: None, A: Additive, M: Multiplicative. Default N. +* -p : seasonal periods. Default 5. +* -d : prediction days. Default 5. +* -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. ![ets_pltr](https://user-images.githubusercontent.com/25267873/110266847-97a6d280-7fb6-11eb-997e-0b598abc713b.png) ## knn -``` + +```text usage: knn [-i N_INPUTS] [-d N_DAYS] [-n N_NEIGHBORS] ``` + k-Nearest Neighbors: - * -i : number of days to use for prediction. Default 40. - * -d : prediction days. Default 5. - * -n : number of neighbors to use on the algorithm. Default 20. - * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. + +* -i : number of days to use for prediction. Default 40. +* -d : prediction days. Default 5. +* -n : number of neighbors to use on the algorithm. Default 20. +* -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. ![knn](https://user-images.githubusercontent.com/25267873/108604942-d169bd80-73a8-11eb-9021-6f787cbd41e3.png) ## linear -``` + +```text usage: linear [-i N_INPUTS] [-d N_DAYS] usage: regression -p 1 [-i N_INPUTS] [-d N_DAYS] ``` + Linear Regression (p=1): - * -i : number of days to use for prediction. Default 40. - * -d : prediction days. Default 5. - * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. + +* -i : number of days to use for prediction. Default 40. +* -d : prediction days. Default 5. +* -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. ![linear](https://user-images.githubusercontent.com/25267873/108604948-d3cc1780-73a8-11eb-860f-49274a34038b.png) ## quadratic -``` + +```text usage: quadratic [-i N_INPUTS] [-d N_DAYS] usage: regression -p 2 [-i N_INPUTS] [-d N_DAYS] ``` + Quadratic Regression (p=2): - * -i : number of days to use for prediction. Default 40. - * -d : prediction days. Default 5. - * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. + +* -i : number of days to use for prediction. Default 40. +* -d : prediction days. Default 5. +* -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. ![quadratic](https://user-images.githubusercontent.com/25267873/108604935-cca50980-73a8-11eb-9af1-bba807203cc6.png) ## cubic -``` + +```text usage: cubic [-i N_INPUTS] [-d N_DAYS] usage: regression -p 3 [-i N_INPUTS] [-d N_DAYS] ``` + Cubic Regression (p=3): - * -i : number of days to use for prediction. Default 40. - * -d : prediction days. Default 5. - * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. + +* -i : number of days to use for prediction. Default 40. +* -d : prediction days. Default 5. +* -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. ![cubic](https://user-images.githubusercontent.com/25267873/108604941-d169bd80-73a8-11eb-9220-84a7013e1283.png) ## regression -``` + +```text usage: regression -p N_POLYNOMIAL [-i N_INPUTS] [-d N_DAYS] ``` + Regression: - * -i : number of days to use for prediction. Default 40. - * -d : prediction days. Default 5. - * -p : polynomial associated with regression. Required. - * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. + +* -i : number of days to use for prediction. Default 40. +* -d : prediction days. Default 5. +* -p : polynomial associated with regression. Required. +* -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. ![regression](https://user-images.githubusercontent.com/25267873/108604946-d3338100-73a8-11eb-9e99-fa526fb56672.png) ## arima -``` + +```text usage: arima [-d N_DAYS] [-i {aic,aicc,bic,hqic,oob}] [-s] [-r] [-o S_ORDER] ``` + Auto-Regressive Integrated Moving Average: - * -d : prediciton days. Default 5. - * -i : information criteria - used if auto_arima library is invoked. Default aic. - * -s : weekly seasonality flag. Default False. - * -r : results about ARIMA summary flag. Default False. - * -o : arima model order. If the model order is defined, auto_arima is not invoked, deeming information criteria useless.
Example: `-o 5,1,4` where: - * p = 5 : order (number of time lags) of the autoregressive model. - * d = 1 : degree of differencing (the number of times the data have had past values subtracted). - * q = 4 : order of the moving-average model. - * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. + +* -d : prediciton days. Default 5. +* -i : information criteria - used if auto_arima library is invoked. Default aic. +* -s : weekly seasonality flag. Default False. +* -r : results about ARIMA summary flag. Default False. +* -o : arima model order. If the model order is defined, auto_arima is not invoked, deeming information criteria useless. +
Example: `-o 5,1,4` where: + * p = 5 : order (number of time lags) of the autoregressive model. + * d = 1 : degree of differencing (the number of times the data have had past values subtracted). + * q = 4 : order of the moving-average model. +* -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. ![arima](https://user-images.githubusercontent.com/25267873/108604947-d3cc1780-73a8-11eb-9dbb-53b959ae7947.png) ## mlp -``` + +```text usage: mlp [-d N_DAYS] [-i N_INPUTS] [--epochs N_EPOCHS] [-e S_END_DATE] [--loops N_LOOPS] [-v VALID] [--lr LEARNING_RATE] [--no_shuffle] ``` -MulitLayer Perceptron: - * -d : prediciton days. Default 5. - * -i : number of days to use for prediction. Default 40. - * --epochs : number of training epochs. Default 200. - * -v : validation split. Default 0.1 - * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. - * --xla_cpu: if present, will enable XLA for CPU (overrides environment variables during run). - * --xla_gpu: if present, will enable XLA for GPU (overrides environment variables during run). - * --force_allow_gpu_growth: if true, will force TensorFlow to allow GPU memory usage to grow as needed. Otherwise will allocate 100% of available GPU memory when CUDA is set up. Default true. - * --batch_size: batch size for model training, should not be used unless advanced user. Default None. - * --lr : learning rate for optimizer - * --loops: number of loops to iterate and train models. Default 1. - * --no_shuffle : split validation data in time_ordered way instead of random. -Due to the complexity of defining a model through command line, one can define it in: [config_neural_network_models.txt](/config_neural_network_models.py) -``` +MulitLayer Perceptron: + +* -d : prediciton days. Default 5. +* -i : number of days to use for prediction. Default 40. +* --epochs : number of training epochs. Default 200. +* -v : validation split. Default 0.1 +* -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. +* --xla_cpu: if present, will enable XLA for CPU (overrides environment variables during run). +* --xla_gpu: if present, will enable XLA for GPU (overrides environment variables during run). +* --force_allow_gpu_growth: if true, will force TensorFlow to allow GPU memory usage to grow as needed. Otherwise will + allocate 100% of available GPU memory when CUDA is set up. Default true. +* --batch_size: batch size for model training, should not be used unless advanced user. Default None. +* --lr : learning rate for optimizer +* --loops: number of loops to iterate and train models. Default 1. +* --no_shuffle : split validation data in time_ordered way instead of random. + +Due to the complexity of defining a model through command line, one can define it in: +[config_neural_network_models.txt](/config_neural_network_models.py) + +```python MultiLayer_Perceptron \ = [ {'Dense': {'units':50, 'activation':'relu'} }, @@ -160,26 +191,32 @@ MultiLayer_Perceptron \ ![mlp](https://user-images.githubusercontent.com/25267873/108604944-d2025400-73a8-11eb-9ab6-52972160cd2a.png) ## rnn -``` + +```text usage: rnn [-d N_DAYS] [-i N_INPUTS] [--epochs N_EPOCHS] [-p {normalization,standardization,none}] [-l {mae,mape,mse,msle}] [-e S_END_DATE] [--loops N_LOOPS] [-v VALID] [--lr LEARNING_RATE] [--no_shuffle] ``` -Recurrent Neural Network: - * -d : prediciton days. Default 5. - * -i : number of days to use for prediction. Default 40. - * --epochs : number of training epochs. Default 200. - * -v : validation split. Default 0.1 - * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. - * --xla_cpu: if present, will enable XLA for CPU (overrides environment variables during run). - * --xla_gpu: if present, will enable XLA for GPU (overrides environment variables during run). - * --force_allow_gpu_growth: if true, will force TensorFlow to allow GPU memory usage to grow as needed. Otherwise will allocate 100% of available GPU memory when CUDA is set up. Default true. - * --batch_size: batch size for model training, should not be used unless advanced user. Default None. - * --loops: number of loops to iterate and train models. Default 1. - * --lr : learning rate for optimizer - * --no_shuffle : split validation data in time_ordered way instead of random. -Due to the complexity of defining a model through command line, one can define it in: [config_neural_network_models.txt](/config_neural_network_models.py) -``` +Recurrent Neural Network: + +* -d : prediciton days. Default 5. +* -i : number of days to use for prediction. Default 40. +* --epochs : number of training epochs. Default 200. +* -v : validation split. Default 0.1 +* -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. +* --xla_cpu: if present, will enable XLA for CPU (overrides environment variables during run). +* --xla_gpu: if present, will enable XLA for GPU (overrides environment variables during run). +* --force_allow_gpu_growth: if true, will force TensorFlow to allow GPU memory usage to grow as needed. + Otherwise will allocate 100% of available GPU memory when CUDA is set up. Default true. +* --batch_size: batch size for model training, should not be used unless advanced user. Default None. +* --loops: number of loops to iterate and train models. Default 1. +* --lr : learning rate for optimizer +* --no_shuffle : split validation data in time_ordered way instead of random. + +Due to the complexity of defining a model through command line, one can define it in: +[config_neural_network_models.txt](/config_neural_network_models.py) + +```python Recurrent_Neural_Network \ = [ {'SimpleRNN': {'units':100, 'activation':'linear', 'return_sequences':True} }, @@ -201,28 +238,33 @@ Recurrent_Neural_Network \ Captura de ecrã 2021-03-22, às 02 14 38 - ## lstm -``` + +```text usage: lstm [-d N_DAYS] [-i N_INPUTS] [--epochs N_EPOCHS] [-e S_END_DATE] [--loops N_LOOPS] [-v VALID] [--lr LEARNING_RATE] [--no_shuffle] ``` -Long-Short Term Memory: - * -d : prediction days. Default 5. - * -i : number of days to use for prediction. Default 40. - * --epochs : number of training epochs. Default 200. - * -v : validation split. Default 0.1 - * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. - * --xla_cpu: if present, will enable XLA for CPU (overrides environment variables during run). - * --xla_gpu: if present, will enable XLA for GPU (overrides environment variables during run). - * --force_allow_gpu_growth: if true, will force TensorFlow to allow GPU memory usage to grow as needed. Otherwise will allocate 100% of available GPU memory when CUDA is set up. Default true. - * --batch_size: batch size for model training, should not be used unless advanced user. Default None. - * --loops: number of loops to iterate and train models. Default 1 - * --lr : learning rate for optimizer - * --no_shuffle : split validation data in time_ordered way instead of random. -Due to the complexity of defining a model through command line, one can define it in: [config_neural_network_models.py](/config_neural_network_models.py) -``` +Long-Short Term Memory: + +* -d : prediction days. Default 5. +* -i : number of days to use for prediction. Default 40. +* --epochs : number of training epochs. Default 200. +* -v : validation split. Default 0.1 +* -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. +* --xla_cpu: if present, will enable XLA for CPU (overrides environment variables during run). +* --xla_gpu: if present, will enable XLA for GPU (overrides environment variables during run). +* --force_allow_gpu_growth: if true, will force TensorFlow to allow GPU memory usage to grow as needed. Otherwise will + allocate 100% of available GPU memory when CUDA is set up. Default true. +* --batch_size: batch size for model training, should not be used unless advanced user. Default None. +* --loops: number of loops to iterate and train models. Default 1 +* --lr : learning rate for optimizer +* --no_shuffle : split validation data in time_ordered way instead of random. + +Due to the complexity of defining a model through command line, one can define it in: +[config_neural_network_models.py](/config_neural_network_models.py) + +```python Long_Short_Term_Memory \ = [ {'LSTM': {'units':25, 'activation':'tanh', 'return_sequences':True} }, @@ -243,20 +285,24 @@ Long_Short_Term_Memory \ Captura de ecrã 2021-03-14, às 00 06 51 ## conv1d -``` + +```text usage: lstm [-d N_DAYS] [-i N_INPUTS] [--epochs N_EPOCHS] [-e S_END_DATE] [--loops N_LOOPS] [-v VALID] [--lr LEARNING_RATE] [--no_shuffle] ``` + 1D Convolutional Neural Net: - * -d : prediction days. Default 5. - * -i : number of days to use for prediction. Default 40. - * --epochs : number of training epochs. Default 50. - * -v : validation split. Default 0.1 - * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. - * --xla_cpu: if present, will enable XLA for CPU (overrides environment variables during run). - * --xla_gpu: if present, will enable XLA for GPU (overrides environment variables during run). - * --force_allow_gpu_growth: if true, will force TensorFlow to allow GPU memory usage to grow as needed. Otherwise will allocate 100% of available GPU memory when CUDA is set up. Default true. - * --batch_size: batch size for model training, should not be used unless advanced user. Default None. - * --loops: number of loops to iterate and train models. Default 1. - * --lr : learning rate for optimizer - * --no_shuffle : split validation data in time_ordered way instead of random. + +* -d : prediction days. Default 5. +* -i : number of days to use for prediction. Default 40. +* --epochs : number of training epochs. Default 50. +* -v : validation split. Default 0.1 +* -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. +* --xla_cpu: if present, will enable XLA for CPU (overrides environment variables during run). +* --xla_gpu: if present, will enable XLA for GPU (overrides environment variables during run). +* --force_allow_gpu_growth: if true, will force TensorFlow to allow GPU memory usage to grow as needed. Otherwise will + allocate 100% of available GPU memory when CUDA is set up. Default true. +* --batch_size: batch size for model training, should not be used unless advanced user. Default None. +* --loops: number of loops to iterate and train models. Default 1. +* --lr : learning rate for optimizer +* --no_shuffle : split validation data in time_ordered way instead of random. diff --git a/gamestonk_terminal/common/technical_analysis/README.md b/gamestonk_terminal/common/technical_analysis/README.md index 9eb21bd0891..2e7258f5a25 100644 --- a/gamestonk_terminal/common/technical_analysis/README.md +++ b/gamestonk_terminal/common/technical_analysis/README.md @@ -1,59 +1,67 @@ # TECHNICAL ANALYSIS -This menu aims to perform a technical analysis on a pre-loaded ticker chart, and the usage of the following commands along with an example will be exploited below. +This menu aims to perform a technical analysis on a pre-loaded ticker chart, and the usage of the following commands +along with an example will be exploited below. - * [view](#view) - - view historical data and trendlines [Finviz] - * [summary](#summary) - - technical summary report [FinBrain API] - * [recom](#recom) - - recommendation based on Technical Indicators [Tradingview API] - * [pr](#pr) - - pattern recognition [Finnhub] +* [view](#view) + * view historical data and trendlines [Finviz] +* [summary](#summary) + * technical summary report [FinBrain API] +* [recom](#recom) + * recommendation based on Technical Indicators [Tradingview API] +* [pr](#pr) + * pattern recognition [Finnhub] [OVERLAP](#OVERLAP) - * [ema](#ema) - - exponential moving average - * [sma](#sma) - - simple moving average - * [vwap](#vwap) - - volume weighted average price + +* [ema](#ema) + * exponential moving average +* [sma](#sma) + * simple moving average +* [vwap](#vwap) + * volume weighted average price [MOMENTUM](#MOMENTUM) - * [cci](#cci) - - commodity channel index - * [macd](#macd) - - moving average convergence/divergence - * [rsi](#rsi) - - relative strength index - * [stoch](#stoch) - - stochastic oscillator + +* [cci](#cci) + * commodity channel index +* [macd](#macd) + * moving average convergence/divergence +* [rsi](#rsi) + * relative strength index +* [stoch](#stoch) + * stochastic oscillator [TREND](#TREND) - * [adx](#adx) - - average directional movement index - * [aroon](#aroon) - - aroon indicator + +* [adx](#adx) + * average directional movement index +* [aroon](#aroon) + * aroon indicator [VOLATILITY](#VOLATILITY) - * [bbands](#bbands) - - bollinger bands + +* [bbands](#bbands) + * bollinger bands [VOLUME](#VOLUME) - * [ad](#ad) - - Accumulation/distribution line values - * [obv](#obv) - - on balance volume + +* [ad](#ad) + * Accumulation/distribution line values +* [obv](#obv) + * on balance volume [CUSTOM](#CUSTOM) - * [fib](#fib) - - Shows fibonocci levels +* [fib](#fib) + * Shows fibonocci levels -**S/O to https://github.com/twopirllc/pandas-ta** _Owing to this library, it is fairly easy to add other technical indicators. So, let us know if there's any other that you would like._ +**S/O to ** _Owing to this library, it is fairly easy to add other technical +indicators. So, let us know if there's any other that you would like._ ## view -``` + +```text usage: view ``` @@ -61,152 +69,172 @@ View historical price with trendlines. [Source: Finviz] ![aapl](https://user-images.githubusercontent.com/25267873/113757843-02107700-970b-11eb-99ab-eb9b1312547f.png) - ## summary -``` + +```text usage: summary ``` -Technical summary report provided by FinBrain's API. FinBrain Technologies develops deep learning algorithms for financial analysis and prediction, which currently serves traders from more than 150 countries all around the world. [Source: https://finbrain.tech] +Technical summary report provided by FinBrain's API. FinBrain Technologies develops deep learning algorithms for +financial analysis and prediction, which currently serves traders from more than 150 countries all around the world. +[Source: ] Captura de ecrã 2021-03-29, às 00 31 29 - ## recom -``` + +```text usage: recom [-s {crypto,forex,cfd}] [-e EXCHANGE] [-i {1M,1W,1d,4h,1h,15m,5m,1m}] ``` -Print tradingview recommendation based on technical indicators. [Source: https://pypi.org/project/tradingview-ta/] +Print tradingview recommendation based on technical indicators. [Source: ] * -s : screener. Default america. * -e : exchange, e.g. NASDAQ, NYSE. Default uses Alpha Vantage to get this information from ticker * -i : interval. Default is showing all of different intervals. -Captura de ecrã 2021-03-31, às 00 14 41 - +Recom ## pr -``` + +```text usage: pr [-r {1,5,15,30,60,D,W,M}] ``` -Display pattern recognition signals on the data. [Source: https://finnhub.io] + +Display pattern recognition signals on the data. [Source: ] * -r : Plot resolution to look for pattern signals. Default 'D'. ![pr](https://user-images.githubusercontent.com/25267873/116812520-06338700-ab47-11eb-8db4-8f5e940507ed.png) -Captura de ecrã 2021-05-02, às 02 27 10 - +PR # OVERLAP ## ema -``` + +```text usage: ema [-l N_LENGTH] [-o N_OFFSET] ``` + ![ema](https://user-images.githubusercontent.com/25267873/108602300-33bac200-7399-11eb-971a-f23f7097aba3.png) - ## sma -``` + +```text usage: sma [-l L_LENGTH] [-o N_OFFSET] ``` + ![sma](https://user-images.githubusercontent.com/25267873/108602304-36b5b280-7399-11eb-86fe-d490fb32aaff.png) - ## vwap + VWAP is available for intraday data. This plots the most recent day only. -``` + +```text usage: vwap [-o N_OFFSET] ``` -![vwap](https://user-images.githubusercontent.com/18151143/127217340-0f38bafd-fc16-4be4-a80a-6b89913559f5.png) +![vwap](https://user-images.githubusercontent.com/18151143/127217340-0f38bafd-fc16-4be4-a80a-6b89913559f5.png) # MOMENTUM ## cci -``` + +```text usage: cci [-l N_LENGTH] [-s N_SCALAR] [-o N_OFFSET] ``` + ![cci](https://user-images.githubusercontent.com/25267873/108602745-96ad5880-739b-11eb-9e86-a1706c3ecb1f.png) - ## macd -``` + +```text usage: macd [-f N_FAST] [-s N_SLOW] [--signal N_SIGNAL] [-o N_OFFSET] ``` + ![macd](https://user-images.githubusercontent.com/25267873/108602739-92813b00-739b-11eb-8a4e-8fa7ed66b2b6.png) - ## rsi -``` + +```text usage: rsi [-l N_LENGTH] [-s N_SCALAR] [-d N_DRIFT] [-o N_OFFSET] ``` + ![rsi](https://user-images.githubusercontent.com/25267873/108602743-957c2b80-739b-11eb-9d0d-6f530b3abb91.png) - ## stoch -``` + +```text usage: stoch [-k N_FASTKPERIOD] [-d N_SLOWDPERIOD] [--slowkperiod N_SLOWKPERIOD] [-o N_OFFSET] ``` -![stoch](https://user-images.githubusercontent.com/25267873/108602744-9614c200-739b-11eb-8e4d-2cdc9981cb67.png) +![stoch](https://user-images.githubusercontent.com/25267873/108602744-9614c200-739b-11eb-8e4d-2cdc9981cb67.png) # TREND ## adx -``` + +```text usage: adx [-l N_LENGTH] [-s N_SCALAR] [-d N_DRIFT] [-o N_OFFSET] ``` + ![adx](https://user-images.githubusercontent.com/25267873/108602991-2bfd1c80-739d-11eb-973f-b836c1b839e6.png) - ## aroon -``` + +```text usage: aroon [-l N_LENGTH] [-s N_SCALAR] [-o N_OFFSET] ``` -![aroon](https://user-images.githubusercontent.com/25267873/108602987-2b648600-739d-11eb-9a90-154145190595.png) +![aroon](https://user-images.githubusercontent.com/25267873/108602987-2b648600-739d-11eb-9a90-154145190595.png) # VOLATILITY ## bbands -``` + +```text usage: bbands [-h] [-l N_LENGTH] [-s N_STD] [-m S_MAMODE] [-o N_OFFSET] ``` -![bbands](https://user-images.githubusercontent.com/25267873/108602984-28699580-739d-11eb-9b82-2683a9840145.png) +![bbands](https://user-images.githubusercontent.com/25267873/108602984-28699580-739d-11eb-9b82-2683a9840145.png) # VOLUME ## ad -``` + +```text usage: ad [-o N_OFFSET] [--open] ``` + ![ad](https://user-images.githubusercontent.com/18151143/127217265-73415705-3321-478f-b5a0-3ae1487c74ac.png) - ## obv -``` + +```text usage: obv [-o N_OFFSET] ``` + ![obv](https://user-images.githubusercontent.com/18151143/127217286-d73c1079-1b84-4da9-a5d4-39f4eb2d6b1b.png) # CUSTOM ## fib + Shows fibonocci levels + ```python usage: fib [-p PERIOD] [--start] [--end] ``` + * -p/--period: Number of days to lookback for retracement. Default = 120. * --start: Allows for custom selection of min point. * --end : Allows for custom selection of max point. -The fibonocci retracement works by looking at a minimum and maximum point. Between these values, there is typically support/resistance at -23.5 %, 38.2%, 50% and 61.8%. Those values follow the golden ratio from the fibonocci sequence. +The fibonocci retracement works by looking at a minimum and maximum point. Between these values, there is typically +support/resistance at 23.5 %, 38.2%, 50% and 61.8%. Those values follow the golden ratio from the fibonocci sequence. -The `--start` and `--end` flags allow the user to select dates for the min and max points as your retracement levels. Both flags are required if using. +The `--start` and `--end` flags allow the user to select dates for the min and max points as your retracement levels. +Both flags are required if using. ![Fib1](https://user-images.githubusercontent.com/18151143/127217240-0b4cd88b-8fd3-484f-941e-b02a0efe08dd.png)