OpenBB – An Introductory Guide to Investment Research – AlgoTrading101 Blog


What is OpenBB used for?

OpenBB is primarily used by investors, quants, and traders to create reports, perform investment research, create custom charts and analyses, optimize portfolios, run sentiment and machine learning analyses, and more.

How to get started with OpenBB?

To get started with OpenBB, you will have several options that depend on your preferences and operating system. In this article, I’ll follow the Windows version of OpenBB and show you how to set it up. If you don’t use Windows, check out the steps here.

The Windows version features an installer that can be downloaded from the following page. To do so we can simply click the “Download” button for the Windows installer. When the download is complete, you might get a warning from your antivirus software.

Don’t worry, it’s not a virus. The warning is the reason that OpenBB is still in Beta. The next step is to open up the installer exe file and start the installation process. It should take a minute or so. After it’s installed, you will see the OpenBB Terminal icon on your screen.

Click the icon to get started with OpenBB.

If you press a key (e.g., ENTER) you’ll be presented with some of the features that the OpenBB Terminal has to offer. In the following headers, we’ll explore some of those features so that you can get an idea of the product and its current state.

How to get stock data with OpenBB Terminal?

To get stock data with OpenBB Terminal, all you need to do is to use use the stocks menu and execute the quote function with the stock symbol of your interest provided. For example, let us obtain the price data of Microsoft:

              Ticker Quote
┌────────────────┬───────────────────────┐
│                │ MSFT                  │
├────────────────┼───────────────────────┤
│ Name           │ Microsoft Corporation │
├────────────────┼───────────────────────┤
│ Price          │ 232.70                │
├────────────────┼───────────────────────┤
│ Open           │ 233.76                │
├────────────────┼───────────────────────┤
│ High           │ 234.92                │
├────────────────┼───────────────────────┤
│ Low            │ 231.15                │
├────────────────┼───────────────────────┤
│ Previous Close │ 235.87                │
├────────────────┼───────────────────────┤
│ Volume         │ 12,347,163            │
├────────────────┼───────────────────────┤
│ 52 Week High   │ 349.67                │
├────────────────┼───────────────────────┤
│ 52 Week Low    │ 219.13                │
├────────────────┼───────────────────────┤
│ Change         │ -3.17                 │
├────────────────┼───────────────────────┤
│ Change %       │ -1.34%                │
└────────────────┴───────────────────────┘

How to plot data with OpenBB Terminal?

To plot data with OpenBB Terminal, you can use the candle function. Prior to that, you will need to load the data for the symbol of your interest. For example, let’s load the data for Dropbox and plot it:

Loading Daily DBX stock with starting period 2019-10-28 for analysis.

Company:  Dropbox, Inc.
Exchange: NASDAQ/NMS (GLOBAL MARKET)
Currency: USD

                                           DBX Performance

│ 1 Day │ 1 Week │ 1 Month │ 1 Year │ YTD │ Volatility (1Y) │ Volume (10D avg) │ Last Price │

│ 2.04 % │ 2.8 %  │ 7.26 %  │ -27.16 % │ -11.78 % │ 38.45 % │ 2.35 M           │ 22.02 │

And now we plot the price chart:

How to get Crypto data with OpenBB Terminal?

To get Crypto data with OpenBB Terminal, you will need to access the crypto menu and utilize a function you might be interested in. For example, let us obtain the current trending Cryptocurrencies by using the disc function.

This will open a few options that we can choose from. Each option shows the data pool it is utilizing.

Let’s see the top trending ones by writing cgtreding. The result is as follows:

            Trending coins on CoinGecko
┌─────────────┬──────────────┬─────────────────────┐
│ Symbol      │ Name         │ market_cap Cap Rank │
├─────────────┼──────────────┼─────────────────────┤
│ dogecoin    │ Dogecoin     │ 8                   │
├─────────────┼──────────────┼─────────────────────┤
│ aptos       │ Aptos        │ 55                  │
├─────────────┼──────────────┼─────────────────────┤
│ enq-enecuum │ Enecuum      │ 965                 │
├─────────────┼──────────────┼─────────────────────┤
│ monkeyball  │ MonkeyLeague │ 813                 │
├─────────────┼──────────────┼─────────────────────┤
│ dogechain   │ Dogechain    │ 327                 │
├─────────────┼──────────────┼─────────────────────┤
│ binancecoin │ BNB          │ 4                   │
├─────────────┼──────────────┼─────────────────────┤
│ husd        │ HUSD         │ 351                 │
└─────────────┴──────────────┴─────────────────────┘

How to get Futures data with OpenBB Terminal?

To get Futures data with OpenBB Terminal, you can access the future menu (under the economy menu) and use the search, historical, or curve functions that will return data on the symbol of your interest. For example, let’s obtain some general future data by writing:

     Futures/Commodities [Source: Wall St. Journal]
┌───────────────────────────┬─────────┬─────────┬───────┐
│                           │ Price   │ Chg     │ %Chg  │
├───────────────────────────┼─────────┼─────────┼───────┤
│ Crude Oil                 │ 85.49   │ -2.41   │ -2.74 │
├───────────────────────────┼─────────┼─────────┼───────┤
│ Brent Crude               │ 91.61   │ -2.16   │ -2.30 │
├───────────────────────────┼─────────┼─────────┼───────┤
│ Gold                      │ 1639.80 │ -5.00   │ -0.30 │
├───────────────────────────┼─────────┼─────────┼───────┤
│ Silver                    │ 19.120  │ -0.027  │ -0.14 │
├───────────────────────────┼─────────┼─────────┼───────┤
│ Natural Gas               │ 6.504   │ 0.551   │ 9.26  │
├───────────────────────────┼─────────┼─────────┼───────┤
│ Unleaded Gasoline         │ 2.4858  │ -0.0771 │ -3.01 │
├───────────────────────────┼─────────┼─────────┼───────┤
│ Copper                    │ 3.3785  │ -0.0505 │ -1.47 │
├───────────────────────────┼─────────┼─────────┼───────┤
│ Corn                      │ 687.75  │ 7.00    │ 1.03  │
├───────────────────────────┼─────────┼─────────┼───────┤
│ Wheat                     │ 873.50  │ 44.25   │ 5.34  │
├───────────────────────────┼─────────┼─────────┼───────┤
│ Bloomberg Commodity Index │ 112.75  │ 0.99    │ 0.89  │
└───────────────────────────┴─────────┴─────────┴───────┘

How to get Options data with OpenBB Terminal?

To get Options data with OpenBB Terminal, you can access the options submenu from the stocks menu and use one of the many functions such as info, chains, parity, greeks, pricing, hedge, and more. For example, let’s load PG data and obtain the put/call ratio by providing the interval for the option:

load -t PG
stocks/options/pcr 10

How to add external API Keys to OpenBB?

To add external API Keys to OpenBB, you can access the keys menu where you will find a list of all possible APIs that OpenBB Terminal Supports. To add a key, write the provider’s name and then the key (e.g., iex apiKey123). Press ENTER to save the key.

Once you add a key, OpenBB will perform an API request test to validate that the key is correct. If it is, it will be colored green. If it isn’t correct, the key will be in red.

How to use Reports in OpenBB?

To use Reports in OpenBB, navigate to the reports menu and choose the report type that you want to use. Currently, you can choose between stocks, crypto, economy, equity, portfolio, forex, and more. Let’s observe what the equity report looks like for Microsoft:

This will open an HTML page with a generated comprehensive equity report that you can inspect. I’ll just show a few snippets of it in the pictures below:

How to create Portfolios in OpenBB?

To create Portfolios in OpenBB, you will need to access the portfolio menu and adding your assets to it by using the load function that intakes the excel file with your portfolio details. OpenBB comes prepared with an example portfolio that we can load the following way:

load -f Public_Equity_Orderbook.xlsx

Here are the mandatory variables that the portfolio sheet needs to have:

  • Date – The date the trade occurred
  • Name – The name of the security
  • Type – The type of security. Use Cash/Stock/Crypto/ETF as appropriate
  • Price – The price the security was added or removed, on a per-unit basis
  • Quantity – How much of the security in question was added or removed
  • Side – Whether you bought or sold. Use Buy/Deposit/1 to add to the portfolio or Sell/Withdrawal/0 to remove from the portfolio a search criterion, country, sector, or industry.

Now that we loaded the portfolio, we can define what our benchmark is. To add the benchmark we do the following:

bench SPDR S&P 500 ETF Trust (SPY)

Now we can use all the portfolio menu functions to obtain data about our portfolio. For example, let’s obtain the summary and performance of the portfolio.

Summary of Portfolio vs Benchmark for all period
┌───────────────────┬───────────┬───────────┬────────────┐
│                   │ Portfolio │ Benchmark │ Difference │
├───────────────────┼───────────┼───────────┼────────────┤
│ Volatility        │ 0.02      │ 0.01      │ 0.00       │
├───────────────────┼───────────┼───────────┼────────────┤
│ Skew              │ -1.84     │ -0.56     │ -1.28      │
├───────────────────┼───────────┼───────────┼────────────┤
│ Kurtosis          │ 32.52     │ 11.08     │ 21.44      │
├───────────────────┼───────────┼───────────┼────────────┤
│ Maximum Drawdowwn │ -0.48     │ -0.34     │ -0.14      │
├───────────────────┼───────────┼───────────┼────────────┤
│ Sharpe ratio      │ 0.04      │ 0.05      │ -0.01      │
├───────────────────┼───────────┼───────────┼────────────┤
│ Sortino ratio     │ 0.05      │ 0.06      │ -0.01      │
├───────────────────┼───────────┼───────────┼────────────┤
│ R2 Score          │ 0.55      │ 0.55      │ 0.00       │
└───────────────────┴───────────┴───────────┴────────────┘
Portfolio vs. Benchmark - Totals in period: all
┌──────────────────┬───────────┬───────────┬────────────┐
│                  │ Portfolio │ Benchmark │ Difference │
├──────────────────┼───────────┼───────────┼────────────┤
│ Total Investment │ 48693.95  │ 48693.95  │ -          │
├──────────────────┼───────────┼───────────┼────────────┤
│ Total Value      │ 53096.91  │ 61769.33  │ -8672.42   │
├──────────────────┼───────────┼───────────┼────────────┤
│ Total % Return   │ 9.04%     │ 26.85%    │ -17.81%    │
├──────────────────┼───────────┼───────────┼────────────┤
│ Total Abs Return │ 4402.96   │ 13075.38  │ -8672.42   │
└──────────────────┴───────────┴───────────┴────────────┘

How to use Econometrics in OpenBB?

To use Econometrics in OpenBB, you will need to access the econometrics menu and load a dataset on which you want to perform the analysis on. Then, select functions that are categorized into the exploration, tests, regression, and regression tests groups.

For example, let’s load an example dataset called danish_data (Danish money demand data) that OpenBB has provided us with:

Dataset danish_data | Showing 10 of 55 rows
┌─────────────────────┬───────┬──────┬───────┬──────┬──────┐
│                     │ lrm   │ lry  │ lpy   │ ibo  │ ide  │
├─────────────────────┼───────┼──────┼───────┼──────┼──────┤
│ 1974-01-01 00:00:00 │ 11.63 │ 5.90 │ -0.62 │ 0.15 │ 0.09 │
├─────────────────────┼───────┼──────┼───────┼──────┼──────┤
│ 1974-04-01 00:00:00 │ 11.60 │ 5.87 │ -0.58 │ 0.18 │ 0.10 │
├─────────────────────┼───────┼──────┼───────┼──────┼──────┤
│ 1974-07-01 00:00:00 │ 11.58 │ 5.84 │ -0.54 │ 0.17 │ 0.10 │
├─────────────────────┼───────┼──────┼───────┼──────┼──────┤
│ 1974-10-01 00:00:00 │ 11.60 │ 5.81 │ -0.50 │ 0.15 │ 0.10 │
├─────────────────────┼───────┼──────┼───────┼──────┼──────┤
│ 1975-01-01 00:00:00 │ 11.59 │ 5.80 │ -0.49 │ 0.13 │ 0.09 │
├─────────────────────┼───────┼──────┼───────┼──────┼──────┤
│ 1975-04-01 00:00:00 │ 11.60 │ 5.79 │ -0.45 │ 0.13 │ 0.08 │
├─────────────────────┼───────┼──────┼───────┼──────┼──────┤
│ 1975-07-01 00:00:00 │ 11.65 │ 5.83 │ -0.44 │ 0.13 │ 0.08 │
├─────────────────────┼───────┼──────┼───────┼──────┼──────┤
│ 1975-10-01 00:00:00 │ 11.76 │ 5.93 │ -0.44 │ 0.13 │ 0.07 │
├─────────────────────┼───────┼──────┼───────┼──────┼──────┤
│ 1976-01-01 00:00:00 │ 11.75 │ 5.94 │ -0.40 │ 0.14 │ 0.07 │
├─────────────────────┼───────┼──────┼───────┼──────┼──────┤
│ 1976-04-01 00:00:00 │ 11.77 │ 5.94 │ -0.37 │ 0.15 │ 0.08 │
└─────────────────────┴───────┴──────┴───────┴──────┴──────┘

Now, let’s perform an OLS regression between the lrm and ide variables as an example:

ols -d danish_data.ide -i danish_data.lrm

You can also test the residuals for autocorrelation and heteroscedasticity by using commands such as bgod and bpag.

┌──────────┬─────────────────┐
│          │ Breusch-Godfrey │
├──────────┼─────────────────┤
│ LM-stat  │ 46.35           │
├──────────┼─────────────────┤
│ p-value  │ 0.00            │
├──────────┼─────────────────┤
│ f-stat   │ 37.02           │
├──────────┼─────────────────┤
│ fp-value │ 0.00            │
└──────────┴─────────────────┘
┌──────────┬───────────────┐
│          │ Breusch-Pagan │
├──────────┼───────────────┤
│ lm-stat  │ 26.48         │
├──────────┼───────────────┤
│ p-value  │ nan           │
├──────────┼───────────────┤
│ f-stat   │ 50.15         │
├──────────┼───────────────┤
│ fp-value │ 0.00          │
└──────────┴───────────────┘

How to do behavioral sentiment analysis with OpenBB?

To do behavioral sentiment analysis with OpenBB, you can access the ba submenu that has useful functions that can obtain sentiment scores from Twitter, news outlets, capture trends, and more. For example, let’s gauge the headlines sentiment of AMZN:

stocks/ba/load AMZN
headlines

How to do quantitative analysis with OpenBB?

To do quantitative analysis with OpenBB, you will need to access the qa submenu and utilize functions that are categorized into statistics, plots, rolling metrics, risk, and other. For example, let’s load the Dropbox stock and compare its Beta to Box:

stocks/qa/load DBX
beta -r BOX

As another example, let’s check the trend and seasonality of DBX:

How to do technical analysis with OpenBB?

To do technical analysis with OpenBB, you will need to access the ta submenu and utilize its functions which are categorized into overlap, momentum, trend, volatility, volume, and custom. For example, let us load BTC data and plot the Bollinger Bands for it:

crypto/ta/load BTC
bbands

For another example, let’s show the stochastic oscillator:

How to write your automated script in OpenBB?

To write your automated script in OpenBB, you will need to add a script to the routines folder. They are written the same way that you would use the terminal and end in the .openbb file extension. You can copy and edit existing scripts or create new ones.

It is important that any of your scripts remain inside of the routines folder in order to be executable by the OpenBB Terminal. Below is a simple script that takes an asset symbol as an argument and shows insider trading stats:

# exe example_with_inputs.openbb -i TSLA,AAPL,MSFT

# Go to the stocks menu
stocks

# Load a ticker, given the argument used. E.g. -i TSLA
load $ARGV[0]

# Go to insider trading
ins

# Show insider stats
stats

These scripts can be as simple or complicated as for your needs.

Leave a Reply

Your email address will not be published.