Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Intro Guide to QA menu #2273

Merged
merged 3 commits into from
Aug 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 138 additions & 3 deletions website/content/terminal/common/qa/_index.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,143 @@
---
title: Introduction to the Quantitative Analysis Menu
keywords: "quantitative, analysis, qa, q/a, daily, indicators, signals, average, summary, normality, line, hist, cdf, bw, acf, qqplot, rolling, spread, quantile, skew, kurtosis, var, es, sh, so, om, raw, decompose, cusum, capm, beta, histogram, auto-correlation, value, median, crypto, forex, fx, cryptocurrency, stocks"
date: "2022-08-08"
type: guides
status: publish
excerpt: "This guide introduces the Quantitative Analysis menu, which is common across many sections of the OpenBB Terminal, briefly describes the features, and provides examples in context."
geekdocCollapseSection: true
---

In finance and investment management, **Quantitative Analysis** refers to the application of mathematical and statistical methodologies. Quantitative analysts are those that work in this subject (quants). Quants typically focus on a few topics, such as derivative structure or pricing, risk management, algorithmic trading, and investment management. Industrial mathematics jobs are similar to those in other industries. The procedure usually entails scanning through large databases for patterns, such as correlations between liquid assets or price movement patterns (trend following or mean reversion). High-frequency trading may be used in the resulting strategies.
<a href = "https://www.investopedia.com/terms/q/quantitativeanalysis.asp" target="_blank">Quantitative analysis (QA)</a> in finance is an approach that emphasizes mathematical and statistical analysis to help determine the value of a financial asset, such as a stock or option. The ultimate goal of financial quantitative analysis is to use quantifiable statistics and metrics to assist investors in making profitable investment decisions. Quantitative analysis is different from qualitative analysis, which looks at factors such as how companies are structured, the makeup of their management teams, and what their strengths and weaknesses are.

**Available commands**
{{< toc-tree >}}
The Quantitative Analysis menu is a common menu to three asset classes:

<a href = "https://openbb-finance.github.io/OpenBBTerminal/terminal/crypto/" target="_blank">Crypto</a> <br>
<a href = "https://openbb-finance.github.io/OpenBBTerminal/terminal/forex/" target= "_blank">Forex</a> <br>
<a href = "https://openbb-finance.github.io/OpenBBTerminal/terminal/stocks/" target = "_blank">Stocks</a> <br>

<img width="1110" alt="The Quantitative Analysis menu" src="https://user-images.githubusercontent.com/85772166/183483507-a4bef3e8-6603-46fb-a022-424f18af32d6.png">

<h2>How to use the Quantitative Analysis Menu</h2>

Enter the menu, through one of the asset classes listed above, by entering `qa` in the Terminal. The ticker that is loaded before entering the menu will determine the timeframe for the analysis. To alter it, use the `load` function and pick a new `--start` and `--end` for the observation window. The QA functions target a specified column of the data. By default, this is returns. Use the `pick` command to chose a new target column.

<img width="358" alt="Picking a new target column" src="https://user-images.githubusercontent.com/85772166/183483572-6127eaff-69d2-4d67-8e60-8d7756a043b0.png">

The menu is divided into five categories of functions:
- Statistics
- Plots
- Rolling Metrics
- Risk
- Other

A summary of exportable statistics is displayed with the command, `summary`. The example here shows $APPL.

<img width="1109" alt="QA summary for Apple" src="https://user-images.githubusercontent.com/85772166/183483647-3414adae-c4de-4b1e-81a5-04a4d8a51e19.png">

A simple line chart for the target column as a time-series is called with the `line` command.

![Line chart of Apple highs over time](https://user-images.githubusercontent.com/85772166/183483733-043f9c21-c408-4526-8c39-16937a05d46a.png)

Optional arguments to this command allows the user to draw and annotate on the chart.

````
2022 Aug 08, 12:14 /stocks/qa/ $ line -h
usage: line [--log] [-d] [--ml ML] [--ms MS] [-h] [--export EXPORT]

Show line plot of selected data and allow to draw lines or highlight specific datetimes.

options:
--log Plot with y on log scale (default: False)
-d, --draw Draw lines and annotate on the plot (default: False)
--ml ML Draw vertical line markers to highlight certain events (default: )
--ms MS Draw scatter markers to highlight certain events (default: )
-h, --help show this help message (default: False)
--export EXPORT Export figure into png, jpg, pdf, svg (default: )

For more information and examples, use 'about line' to access the related guide.

2022 Aug 08, 12:20 /stocks/qa/ $ pick high

2022 Aug 08, 12:20 /stocks/qa/ $ line --draw
Click twice for annotation.
Close window to keep using terminal.

Annotation: Lower Highs
````

![Annotated line chart](https://user-images.githubusercontent.com/85772166/183483798-82fb59f6-df9a-4b03-8dd5-542d7d20dcc6.png)

Compare the beta between the loaded asset and another, using the `-r` flag to deviate from the defaulted comparison, $SPY.

````
2022 Aug 08, 12:34 /stocks/qa/ $ beta -r MSFT

Loading Daily MSFT stock with starting period 2019-08-05 for analysis.
````

<img width="762" alt="Beta of $AAPL relative to $MSFT" src="https://user-images.githubusercontent.com/85772166/183483898-dac417a8-0afe-46d2-b8e9-e855e8752fc8.png">

Most outputs are equipped with an `--export` flag, allowing the user to save the tables as a CSV, JSON, or XLSX file. The exports can then be imported into other menus like <a href="https://openbb-finance.github.io/OpenBBTerminal/terminal/econometrics/" target="_blank"> Econometrics</a>. Additional information on each specific command is displayed by attaching `-h` to it.

<h2>Examples</h2>

Box and Whisker plots for monthly and yearly scales:

````
2022 Aug 08, 12:47 /stocks/qa/ $ bw
````

![Monthly box and whisker plot for Apple](https://user-images.githubusercontent.com/85772166/183483965-a6c2d076-4896-47ec-a314-fc6a574ad8de.png)

````
2022 Aug 08, 12:47 /stocks/qa/ $ bw -y
````

![Yearly box and whisker plot for Apple](https://user-images.githubusercontent.com/85772166/183484096-73eadd0c-1618-4e95-a27b-79e81cd6afad.png)

Pick `logret` for rate of change to the returns of the asset:

````
2022 Aug 08, 12:47 /stocks/qa/ $ pick logret

2022 Aug 08, 12:51 /stocks/qa/ $ bw -y
````

![Yearly rate of change on returns from Apple](https://user-images.githubusercontent.com/85772166/183484172-5c001e9d-911c-44cd-848c-9ae5ec13dbc2.png)

`decompose` shows a visual representation of trend and seasonality.

![Additive Decompose of daily $AAPL data](https://user-images.githubusercontent.com/85772166/183484221-8e65e855-8a18-4bfd-8d49-b44ad50691b1.png)

`skew` shows the asymmetric distribution over a specified window (default of 14).

![Apple skewness indicator](https://user-images.githubusercontent.com/85772166/183484305-0ca714c4-a138-4c69-aee4-16fcc3aa3ac4.png)

`skew -w 5` Changing the window to five takes out some of the smoothness:

![Apple skewness indicator with a window of 5 days](https://user-images.githubusercontent.com/85772166/183484465-5c121ebc-d2d9-4f1d-a51f-10366aa4456a.png)

Sharpe Ratio over time, `sh`:

![Sharpe Ratio for Apple over time](https://user-images.githubusercontent.com/85772166/183484549-6bc723e3-42cc-4c2a-96d6-72ab96402833.png)

`cdf` calls the cumulative distribution function. Apple over the long term exhibits a steep curve.

![Cumulative Distribution Function of Apple](https://user-images.githubusercontent.com/85772166/183484623-00e6ce46-4378-4391-94e3-9ea2045d2fb4.png)

Compared with Apple, Amazon is a more gently sloping s-curve.

![Cumulative Distribution Function of AMZN](https://user-images.githubusercontent.com/85772166/183484706-86874eb7-d454-4d38-aa78-d521fa56b1bd.png)

`capm` shows the stock's risk against the market's. $AAPL carries the risk of whatever happens to the markets, happens to the stock.

````
2022 Aug 08, 13:51 /stocks/qa/ $ capm
Beta: 1.15
Systematic Risk: 46.40%
Unsystematic Risk: 53.60%
````
Read more about this subject on Wikipedia: https://en.wikipedia.org/wiki/Quantitative_analysis_(finance)

Back to the <a href = "https://openbb-finance.github.io/OpenBBTerminal/" target="_blank">Getting Started Guide</a>