etf
- +Introduction to ETF
+The ETF module wraps the functions from the ETF menu, within the OpenBB Terminal, allowing programmatic access to the commands. Import the OpenBB SDK module, and then find the ETF functions similarly to how the Terminal menus are navigated. The code completion will be activated after entering the . in: openbb.etf
from openbb_terminal.sdk import openbb
+import pandas as pd
+%matplotlib widget
+
+ How to Use + + + +
+ETFs are categorized into different buckets, use. the code block below as a way to generate the list of all categories:
+etf_list = pd.DataFrame.from_dict(openbb.etf.etf_by_category('')).transpose()
+etf_list.set_index(keys = ['category', 'family'])
+etf_list.sort_values(by=['total_assets'], ascending = False)
+
+categories = list(etf_list['category'].drop_duplicates())
+
After determining the category to research, the same code block can be repeated, replacing the empty category in the syntax:
+etf_category = pd.DataFrame.from_dict(openbb.etf.etf_by_category('Trading--Leveraged Equity')).transpose()
+etf_category.sort_values(by=['total_assets'], ascending = False)
+
A list of all tickers in the category can be generated from the index of the DataFrame:
+tickers = list(etf_category.index)
+This list of tickers can then be used for comparison analysis, or portfolio optimization. For example, comparing the performance metrics of all Technology ETFs available:
+performance = openbb.stocks.ca.screener(similar = tickers, data_type = 'performance')
+performance.sort_values(by=['Perf Quart'])
+
To peer into the holdings of a specific ETF:
+openbb.etf.holdings('NXTG')
+
The ETF screener is accessible through the SDK. Values for the screener are set in the file: ~/OpenBBTerminal/openbb_terminal/etf/screener/presets/etf_config.ini
openbb.etf.scr.screen(preset='etf_config.ini')
+In this example, the configuration file is set to return results with a maximum Beta value of -2.
+
The current top gainers, losers, and volume for ETFs is returned with:
+openbb.etf.disc.mover(sort_type = 'decliners')
+
+openbb.etf.disc.mover(sort_type = 'gainers')
+
+openbb.etf.disc.mover(sort_type = 'active')
+