Skip to main content

Alternative

The Alternative module provides programmatic access to the commands from within the OpenBB Terminal. Import the OpenBB SDK module, and then access the functions similarly to how the Terminal menus are navigated. The code completion will be activated upon entering ., after, openbb.alt

How to Use

​ The examples provided below will assume that the following import block is included at the beginning of the Python script or Notebook file: ​

from openbb_terminal.sdk import openbb
import pandas as pd

A brief description below highlights the main Functions and Modules available in the Alternative SDK

OSS

PathTypeDescription
openbb.alt.oss.topFunctionGet top repositories
openbb.alt.oss.searchFunctionSearch repositories
openbb.alt.oss.historyFunctionDisplay a repo star history
openbb.alt.oss.rossFunctionStartups from ross index
openbb.alt.oss.github_dataFunctionGet repository stats
openbb.alt.oss.summaryFunctionGet repository summary

Covid

PathTypeDescription
openbb.alt.covid.global_deathsFunctionhistorical deaths for given country
openbb.alt.covid.slopesFunctionLoad cases and find slope over period
openbb.alt.covid.statFunctionShow historical cases and deaths by country
openbb.alt.covid.global_casesFunctionhistorical cases for given country
openbb.alt.covid.ovFunctionoverview historical cases and deaths by country

Alternatively you can print the contents of the Alternative SDK with: ​

help(openbb.alt.covid)
help(openbb.alt.oss)

Examples - OSS

note

To use some of the OSS SDK commands you will need a GitHub API key - you can get one here

alt.oss.top

​ The alt.oss.top SDK command lets you display top repositories - You can pass different parameters like sortby categories and limit to enhance the output. ​

summary = pd.DataFrame.from_dict(openbb.alt.oss.top(sortby='stars', categories='finance', limit=10))
print(summary[['full_name', 'open_issues', 'stargazers_count']])
full_nameopen_issuesstargazers_count
vnpy/vnpy819487
OpenBB-finance/OpenBBTerminal14917645
plotly/dash70717645
waditu/tushare55611829
wilsonfreitas/awesome-quant910874
microsoft/qlib2329926
firefly-iii/firefly-iii1039228
ranaroussi/yfinance4417938
mrjbq7/ta-lib1817157
QuantConnect/Lean4176773

alt.oss.summary

The alt.oss.summary SDK command gets you some info on a reposity - You just pass the repo path and can see all kinds of interesting information.

summary = pd.DataFrame.from_dict(openbb.alt.oss.summary(repo="openbb-finance/openbbterminal"))
print(summary)
MetricValue
NameOpenBBTerminal
OwnerOpenBB-finance
Creation Date2020-12-20
Last Update2022-11-17
Topicsartificial-intelligence, crypto, cryptocurrenc...
Stars17643
Forks1849
Open Issues152
LanguagePython
LicenseMIT License
Releases10
Last Release Downloads10201

Examples - Covid

alt.covid.global_deaths

The global_deaths command lets you check quickly the global deaths for any country

global_deaths = pd.DataFrame.from_dict(openbb.alt.covid.global_deaths(country="US"))
print(global_deaths)
DateUS
2020-01-230.0
2020-01-240.0
2020-01-250.0
2020-01-260.0
2020-01-270.0
......
2022-11-12-40.0
2022-11-131.0
2022-11-14216.0
2022-11-15387.0
2022-11-16825.0

alt.covid.slopes

The slopes command lets you check the slopes per country

covid_slopes = pd.DataFrame.from_dict(openbb.alt.covid.slopes())
print(covid_slopes)
CountrySlope
Japan52199.941713
Korea, South42252.945717
Germany40376.811123
US38365.586207
Taiwan*28677.574861
France24898.053393
Italy20608.297664
Greece7841.223359
Australia6222.661846
Russia5837.264739
Chile5792.311457
Brazil5605.621802
United Kingdom4755.022692
Singapore3867.323471
Switzerland3393.054950
Malaysia3154.148387
......

You can pass days_back limit and ascend to further drill down in your data.

covid_slopes_params = pd.DataFrame.from_dict(
openbb.alt.covid.slopes(days_back=30, limit=10, ascend=True)
)
print(covid_slopes_params)
CountrySlope
Colombia-9917.200222
Iran-4000.273415
Slovakia-3553.934372
Poland-563.439600
Lebanon-364.833815
Bangladesh-175.475640
Albania-96.862736
Bulgaria-39.990656
Turkey-31.636263
Belarus-21.939043