Skip to content

Commit

Permalink
feat: add extra field
Browse files Browse the repository at this point in the history
  • Loading branch information
montezdesousa committed May 13, 2024
1 parent 36605ec commit 09e5d1b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 22 deletions.
1 change: 1 addition & 0 deletions assets/extensions/obbject.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"packageName": "openbb-charting",
"extra": true,
"description": "Create custom charts from OBBject data."
}
]
25 changes: 25 additions & 0 deletions assets/extensions/provider.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"packageName": "openbb-alpha-vantage",
"extra": true,
"reprName": "Alpha Vantage",
"description": "Alpha Vantage provides realtime and historical\nfinancial market data through a set of powerful and developer-friendly data APIs\nand spreadsheets. From traditional asset classes (e.g., stocks, ETFs, mutual funds)\nto economic indicators, from foreign exchange rates to commodities,\nfrom fundamental data to technical indicators, Alpha Vantage\nis your one-stop-shop for enterprise-grade global market data delivered through\ncloud-based APIs, Excel, and Google Sheets. ",
"credentials": [
Expand All @@ -14,6 +15,7 @@
},
{
"packageName": "openbb-benzinga",
"extra": false,
"reprName": "Benzinga",
"description": "Benzinga is a financial data provider that offers an API\nfocused on information that moves the market.",
"credentials": [
Expand All @@ -23,6 +25,7 @@
},
{
"packageName": "openbb-biztoc",
"extra": true,
"reprName": "BizToc",
"description": "BizToc uses Rapid API for its REST API.\nYou may sign up for your free account at https://rapidapi.com/thma/api/biztoc.\n\nThe Base URL for all requests is:\n\n https://biztoc.p.rapidapi.com/\n\nIf you're not a developer but would still like to use Biztoc outside of the main website,\nwe've partnered with OpenBB, allowing you to pull in BizToc's news stream in their Terminal.",
"credentials": [
Expand All @@ -36,20 +39,23 @@
},
{
"packageName": "openbb-cboe",
"extra": true,
"reprName": "Chicago Board Options Exchange (CBOE)",
"description": "Cboe is the world's go-to derivatives and exchange network,\ndelivering cutting-edge trading, clearing and investment solutions to people\naround the world.",
"credentials": [],
"website": "https://www.cboe.com"
},
{
"packageName": "openbb-ecb",
"extra": true,
"reprName": "European Central Bank (ECB)",
"description": "The ECB Data Portal provides access to all official ECB statistics.\nThe portal also provides options to download data and comprehensive metadata for each dataset.\nStatistical publications and dashboards offer a compilation of key data on selected topics.",
"credentials": [],
"website": "https://data.ecb.europa.eu"
},
{
"packageName": "openbb-econdb",
"extra": false,
"reprName": "EconDB",
"description": "The mission of the company is to process information in ways that\nfacilitate understanding of the economic situation at different granularity levels.\n\nThe sources of data include official statistics agencies and so-called alternative\ndata sources where we collect direct observations of the market and generate\naggregate statistics.",
"credentials": [
Expand All @@ -59,27 +65,31 @@
},
{
"packageName": "openbb-federal-reserve",
"extra": false,
"reprName": "Federal Reserve (FED)",
"description": "Access data provided by the Federal Reserve System,\nthe Central Bank of the United States.",
"credentials": [],
"website": "https://www.federalreserve.gov/data.htm"
},
{
"packageName": "openbb-finra",
"extra": true,
"reprName": "Financial Industry Regulatory Authority (FINRA)",
"description": "FINRA Data provides centralized access to the abundance of data FINRA\nmakes available to the public, media, researchers and member firms.",
"credentials": [],
"website": "https://www.finra.org/finra-data"
},
{
"packageName": "openbb-finviz",
"extra": true,
"reprName": "FinViz",
"description": "Unofficial Finviz API - https://github.com/lit26/finvizfinance/releases",
"credentials": [],
"website": "https://finviz.com"
},
{
"packageName": "openbb-fmp",
"extra": false,
"reprName": "Financial Modeling Prep (FMP)",
"description": "Financial Modeling Prep is a new concept that informs you about\nstock market information (news, currencies, and stock prices).",
"credentials": [
Expand All @@ -93,6 +103,7 @@
},
{
"packageName": "openbb-fred",
"extra": false,
"reprName": "Federal Reserve Economic Data | St. Louis FED (FRED)",
"description": "Federal Reserve Economic Data is a database maintained by the\nResearch division of the Federal Reserve Bank of St. Louis that has more than\n816,000 economic time series from various sources.",
"credentials": [
Expand All @@ -106,13 +117,15 @@
},
{
"packageName": "openbb-government-us",
"extra": true,
"reprName": "Data.gov | United States Government",
"description": "Data.gov is the United States government's open data website.\nIt provides access to datasets published by agencies across the federal government.\nData.gov is intended to provide access to government open data to the public, achieve\nagency missions, drive innovation, fuel economic activity, and uphold the ideals of\nan open and transparent government.",
"credentials": [],
"website": "https://data.gov"
},
{
"packageName": "openbb-intrinio",
"extra": false,
"reprName": "Intrinio",
"description": "Intrinio is a financial data platform that provides real-time and\nhistorical financial market data to businesses and developers through an API.",
"credentials": [
Expand All @@ -126,6 +139,7 @@
},
{
"packageName": "openbb-nasdaq",
"extra": true,
"reprName": "NASDAQ",
"description": "Positioned at the nexus of technology and the capital markets, Nasdaq\nprovides premier platforms and services for global capital markets and beyond with\nunmatched technology, insights and markets expertise.",
"credentials": [
Expand All @@ -139,13 +153,15 @@
},
{
"packageName": "openbb-oecd",
"extra": false,
"reprName": "Organization for Economic Co-operation and Development (OECD)",
"description": "OECD.Stat includes data and metadata for OECD countries and selected\nnon-member economies.",
"credentials": [],
"website": "https://stats.oecd.org"
},
{
"packageName": "openbb-polygon",
"extra": false,
"reprName": "Polygon.io",
"description": "The Polygon.io Stocks API provides REST endpoints that let you query\nthe latest market data from all US stock exchanges. You can also find data on\ncompany financials, stock market holidays, corporate actions, and more.",
"credentials": [
Expand All @@ -159,27 +175,31 @@
},
{
"packageName": "openbb-sec",
"extra": false,
"reprName": "Securities and Exchange Commission (SEC)",
"description": "SEC is the public listings regulatory body for the United States.",
"credentials": [],
"website": "https://www.sec.gov/data"
},
{
"packageName": "openbb-seeking-alpha",
"extra": true,
"reprName": "Seeking Alpha",
"description": "Seeking Alpha is a data provider with access to news, analysis, and\nreal-time alerts on stocks.",
"credentials": [],
"website": "https://seekingalpha.com"
},
{
"packageName": "openbb-stockgrid",
"extra": true,
"reprName": "Stockgrid",
"description": "Stockgrid gives you a detailed view of what smart money is doing.\nGet in depth data about large option blocks being traded, including\nthe sentiment score, size, volume and order type. Stop guessing and\nbuild a strategy around the number 1 factor moving the market: money.",
"credentials": [],
"website": "https://www.stockgrid.io"
},
{
"packageName": "openbb-tiingo",
"extra": false,
"reprName": "Tiingo",
"description": "A Reliable, Enterprise-Grade Financial Markets API. Tiingo's APIs\npower hedge funds, tech companies, and individuals.",
"credentials": [
Expand All @@ -189,13 +209,15 @@
},
{
"packageName": "openbb-tmx",
"extra": true,
"reprName": "TMX",
"description": "Unofficial TMX Data Provider Extension\n TMX Group Companies\n - Toronto Stock Exchange\n - TSX Venture Exchange\n - TSX Trust\n - Montr\u00e9al Exchange\n - TSX Alpha Exchange\n - Shorcan\n - CDCC\n - CDS\n - TMX Datalinx\n - Trayport\n ",
"credentials": [],
"website": "https://www.tmx.com"
},
{
"packageName": "openbb-tradier",
"extra": true,
"reprName": "Tradier",
"description": "Tradier provides a full range of services in a scalable, secure,\nand easy-to-use REST-based API for businesses and individual developers.\nFast, secure, simple. Start in minutes.\nGet access to trading, account management, and market-data for\nTradier Brokerage accounts through our APIs.",
"credentials": [
Expand All @@ -210,6 +232,7 @@
},
{
"packageName": "openbb-tradingeconomics",
"extra": false,
"reprName": "Trading Economics",
"description": "Trading Economics provides its users with accurate information for\n196 countries including historical data and forecasts for more than 20 million economic\nindicators, exchange rates, stock market indexes, government bond yields and commodity\nprices. Our data for economic indicators is based on official sources, not third party\ndata providers, and our facts are regularly checked for inconsistencies.\nTrading Economics has received nearly 2 billion page views from all around the\nworld.",
"credentials": [
Expand All @@ -219,13 +242,15 @@
},
{
"packageName": "openbb-wsj",
"extra": true,
"reprName": "Wall Street Journal (WSJ)",
"description": "WSJ (Wall Street Journal) is a business-focused, English-language\ninternational daily newspaper based in New York City. The Journal is published six\ndays a week by Dow Jones & Company, a division of News Corp, along with its Asian\nand European editions. The newspaper is published in the broadsheet format and\nonline. The Journal has been printed continuously since its inception on\nJuly 8, 1889, by Charles Dow, Edward Jones, and Charles Bergstresser.\nThe WSJ is the largest newspaper in the United States, by circulation.\n ",
"credentials": [],
"website": "https://www.wsj.com"
},
{
"packageName": "openbb-yfinance",
"extra": false,
"reprName": "Yahoo Finance",
"description": "Yahoo! Finance is a web-based platform that offers financial news,\ndata, and tools for investors and individuals interested in tracking and analyzing\nfinancial markets and assets.",
"credentials": [],
Expand Down
14 changes: 14 additions & 0 deletions assets/extensions/router.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,72 @@
[
{
"packageName": "openbb-commodity",
"extra": false,
"description": "Commodity market data."
},
{
"packageName": "openbb-crypto",
"extra": false,
"description": "Cryptocurrency market data."
},
{
"packageName": "openbb-currency",
"extra": false,
"description": "Foreign exchange (FX) market data."
},
{
"packageName": "openbb-derivatives",
"extra": false,
"description": "Derivatives market data."
},
{
"packageName": "openbb-econometrics",
"extra": true,
"description": "Econometrics analysis tools."
},
{
"packageName": "openbb-economy",
"extra": false,
"description": "Economic data."
},
{
"packageName": "openbb-equity",
"extra": false,
"description": "Equity market data."
},
{
"packageName": "openbb-etf",
"extra": false,
"description": "Exchange Traded Funds market data."
},
{
"packageName": "openbb-fixedincome",
"extra": false,
"description": "Fixed Income market data."
},
{
"packageName": "openbb-index",
"extra": false,
"description": "Indices data."
},
{
"packageName": "openbb-news",
"extra": false,
"description": "Financial market news data."
},
{
"packageName": "openbb-quantitative",
"extra": true,
"description": "Quantitative analysis tools."
},
{
"packageName": "openbb-regulators",
"extra": false,
"description": "Financial market regulators data."
},
{
"packageName": "openbb-technical",
"extra": true,
"description": "Technical Analysis tools."
}
]
51 changes: 29 additions & 22 deletions assets/scripts/generate_extension_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from poetry.core.pyproject.toml import PyProjectTOML

THIS_DIR = Path(__file__).parent
PROVIDERS_PATH = Path(THIS_DIR, "..", "..", "openbb_platform/providers")
EXTENSIONS_PATH = Path(THIS_DIR, "..", "..", "openbb_platform/extensions")
OBBJECT_EXTENSIONS_PATH = Path(
THIS_DIR, "..", "..", "openbb_platform/obbject_extensions"
)
OPENBB_PLATFORM_PATH = Path(THIS_DIR, "..", "..", "openbb_platform")
PROVIDERS_PATH = OPENBB_PLATFORM_PATH / "providers"
EXTENSIONS_PATH = OPENBB_PLATFORM_PATH / "extensions"
OBBJECT_EXTENSIONS_PATH = OPENBB_PLATFORM_PATH / "obbject_extensions"

OPENBB_PLATFORM_TOML = PyProjectTOML(OPENBB_PLATFORM_PATH / "pyproject.toml")

def to_title(string: str) -> str:
"""Format string to title."""
Expand All @@ -30,7 +30,7 @@ def get_packages(path: Path, plugin_key: str) -> Dict[str, Any]:
poetry = pyproject.data["tool"]["poetry"]
name = poetry["name"]
plugin = poetry.get("plugins", {}).get(plugin_key)
packages[name] = list(plugin.values())[0] if plugin else ""
packages[name] = {"plugin": list(plugin.values())[0] if plugin else ""}
return packages


Expand All @@ -46,66 +46,73 @@ def to_camel(string: str):
return components[0] + "".join(x.title() for x in components[1:])


def createItem(package_name: str, obj: object, attrs: List[str]) -> Dict[str, str]:
def createItem(
package_name: str, obj: object, obj_attrs: List[str]
) -> Dict[str, Any]:
"""Create dictionary item from object attributes."""
item = {"packageName": package_name}
extras = OPENBB_PLATFORM_TOML.data["tool"]["poetry"].get("extras", {})
# Remove openbb- and replace - with _
clean_pkg_name = package_name[7:].replace("-", "_")
item = {"packageName": package_name, "extra": clean_pkg_name in extras}
item.update(
{to_camel(a): getattr(obj, a) for a in attrs if getattr(obj, a) is not None}
{to_camel(a): getattr(obj, a) for a in obj_attrs if getattr(obj, a) is not None}
)
return item


def generate_provider_extensions() -> None:
"""Generate providers_extensions.json."""
packages = get_packages(PROVIDERS_PATH, "openbb_provider_extension")
data: List[Dict[str, str]] = []
attrs = [
data: List[Dict[str, Any]] = []
obj_attrs = [
"repr_name",
"description",
"credentials",
"v3_credentials",
"website",
"instructions",
"logo_url",
]

for pkg_name, plugin in sorted(packages.items()):
for pkg_name, details in sorted(packages.items()):
plugin = details.get("plugin", "")
file_obj = plugin.split(":")
if len(file_obj) == 2:
file, obj = file_obj[0], file_obj[1]
module = import_module(file)
provider_obj = getattr(module, obj)
data.append(createItem(pkg_name, provider_obj, attrs))
data.append(createItem(pkg_name, provider_obj, obj_attrs))
write("provider", data)


def generate_router_extensions() -> None:
"""Generate router_extensions.json."""
packages = get_packages(EXTENSIONS_PATH, "openbb_core_extension")
data: List[Dict[str, str]] = []
attrs = ["description"]
for pkg_name, plugin in sorted(packages.items()):
data: List[Dict[str, Any]] = []
obj_attrs = ["description"]
for pkg_name, details in sorted(packages.items()):
plugin = details.get("plugin", "")
file_obj = plugin.split(":")
if len(file_obj) == 2:
file, obj = file_obj[0], file_obj[1]
module = import_module(file)
router_obj = getattr(module, obj)
data.append(createItem(pkg_name, router_obj, attrs))
data.append(createItem(pkg_name, router_obj, obj_attrs))
write("router", data)


def generate_obbject_extensions() -> None:
"""Generate obbject_extensions.json."""
packages = get_packages(OBBJECT_EXTENSIONS_PATH, "openbb_obbject_extension")
data: List[Dict[str, str]] = []
attrs = ["description"]
for pkg_name, plugin in sorted(packages.items()):
data: List[Dict[str, Any]] = []
obj_attrs = ["description"]
for pkg_name, details in sorted(packages.items()):
plugin = details.get("plugin", "")
file_obj = plugin.split(":")
if len(file_obj) == 2:
file, obj = file_obj[0], file_obj[1]
module = import_module(file)
ext_obj = getattr(module, obj)
data.append(createItem(pkg_name, ext_obj, attrs))
data.append(createItem(pkg_name, ext_obj, obj_attrs))
write("obbject", data)


Expand Down

0 comments on commit 09e5d1b

Please sign in to comment.