Move built-in extensions code

This commit is contained in:
Theodore Aptekarev
2023-06-30 20:07:48 +02:00
parent 1782bad5e6
commit aed421b674
36 changed files with 1681 additions and 1 deletions

View File

@@ -14,7 +14,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.256"
rev: "v0.0.275"
hooks:
- id: ruff
- repo: https://github.com/codespell-project/codespell

View File

@@ -0,0 +1,11 @@
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.model.item.empty import Empty
from openbb_sdk_core.app.router import Router
router = Router(prefix="")
@router.command
def load() -> CommandOutput[Empty]: # type: ignore
"""Crypto Intraday Price."""
return CommandOutput(item=Empty())

View File

@@ -0,0 +1,409 @@
import datetime
from typing import List, Literal, Union
from openbb_sdk_core.app.model.command_context import CommandContext
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.model.item.empty import Empty
from openbb_sdk_core.app.provider_interface import ProviderChoices
from openbb_sdk_core.app.router import Router
datetype = Union[datetime.datetime, str]
list_str = Union[List[str], str]
groups = Literal[
"sector",
"industry",
"basic_materials",
"communication_services",
"consumer_cyclical",
"consumer_defensive",
"energy",
"financial",
"healthcare",
"industrials",
"real_Estate",
"technology",
"utilities",
"country",
"capitalization",
]
router = Router(prefix="")
# Remove this once the placeholders are replaced with real commands
# pylint: disable=unused-argument
@router.command
def corecpi(
cc: CommandContext,
provider: ProviderChoices,
start_date: datetype,
end_date: datetype,
countries: Union[List[str], str] = "united_states",
perspective: Literal["ENRG", "FOOD", "TOT", "TOT_FOODENG"] = "TOT",
frequency: Literal["M", "Q", "A"] = "M",
units: Literal["AGRWTH", "IDX2015"] = "AGRWTH",
) -> CommandOutput[Empty]: # type: ignore
"""CORECPI."""
return CommandOutput(item=Empty())
# pylint: disable=too-many-arguments
@router.command
def cpi(
cc: CommandContext,
provider: ProviderChoices,
countries: list_str,
start_date: datetype,
end_date: datetype,
units: Literal["growth_previous", "growth_same", "index_2015"] = "growth_same",
frequency: Literal["annual", "monthly", "quarterly"] = "monthly",
harmonized: bool = False,
smart_select: bool = True,
) -> CommandOutput[Empty]: # type: ignore
"""CPI."""
return CommandOutput(item=Empty())
@router.command
def cpi_options(cc: CommandContext, provider: ProviderChoices) -> CommandOutput[Empty]:
"""Get the options for v3 cpi(options=True)"""
return CommandOutput(item=Empty())
@router.command
def index(
cc: CommandContext,
provider: ProviderChoices,
indices_: list_str, # without the underscore pylint raises "redefined-outer-name"
start_date: datetype,
end_date: datetype,
interval: Literal[
"1m",
"2m",
"5m",
"15m",
"30m",
"60m",
"90m",
"1h",
"1d",
"5d",
"1wk",
"1mo",
"3mo",
] = "1d",
column: str = "close",
returns: bool = False,
) -> CommandOutput[Empty]: # type: ignore
"""Get index from yfinance."""
return CommandOutput(item=Empty())
@router.command
def available_indices(
cc: CommandContext,
provider: ProviderChoices,
) -> CommandOutput[Empty]:
"""AVAILABLE_INDICES."""
return CommandOutput(item=Empty())
@router.command
def macro(
cc: CommandContext,
provider: ProviderChoices,
parameters: list_str,
countries: list_str,
transform: str,
start_date: datetype,
end_date: datetype,
) -> CommandOutput[Empty]: # type: ignore
"""Query EconDB for macro data."""
return CommandOutput(item=Empty())
@router.command
def macro_countries(
cc: CommandContext,
provider: ProviderChoices,
) -> CommandOutput[Empty]:
"""MACRO_COUNTRIES."""
return CommandOutput(item=Empty())
@router.command
def macro_parameters(
cc: CommandContext,
provider: ProviderChoices,
) -> CommandOutput[Empty]:
"""MACRO_PARAMETERS."""
return CommandOutput(item=Empty())
@router.command
def balance(
cc: CommandContext,
provider: ProviderChoices,
countries: list_str,
start_date: datetype,
end_date: datetype,
) -> CommandOutput[Empty]:
"""BALANCE."""
return CommandOutput(item=Empty())
@router.command
def bigmac(
cc: CommandContext,
provider: ProviderChoices,
countries: list_str,
) -> CommandOutput[Empty]:
"""BIGMAC."""
return CommandOutput(item=Empty())
@router.command
def country_codes(
cc: CommandContext,
provider: ProviderChoices,
) -> CommandOutput[Empty]:
"""COUNTRY_CODES."""
return CommandOutput(item=Empty())
@router.command
def currencies(
cc: CommandContext,
provider: ProviderChoices,
) -> CommandOutput[Empty]:
"""CURRENCIES."""
return CommandOutput(item=Empty())
@router.command
def debt(
cc: CommandContext,
provider: ProviderChoices,
countries: list_str,
start_date: datetype,
end_date: datetype,
) -> CommandOutput[Empty]:
"""DEBT."""
return CommandOutput(item=Empty())
@router.command
def events(
cc: CommandContext,
provider: ProviderChoices,
countries: list_str,
start_date: datetype,
end_date: datetype,
) -> CommandOutput[Empty]:
"""EVENTS."""
return CommandOutput(item=Empty())
@router.command
def fgdp(
cc: CommandContext,
provider: ProviderChoices,
countries: list_str,
start_date: datetype,
end_date: datetype,
type_: Literal["real", "nominal"] = "real", # type is a reserved word
units: Literal["Q", "A"] = "A",
) -> CommandOutput[Empty]:
"""FGDP."""
return CommandOutput(item=Empty())
@router.command
def fred(
cc: CommandContext,
provider: ProviderChoices,
series_id: list_str,
start_date: datetype,
end_date: datetype,
) -> CommandOutput[Empty]:
"""FRED."""
return CommandOutput(item=Empty())
@router.command
def fred_search(
cc: CommandContext, provider: ProviderChoices, term: str
) -> CommandOutput[Empty]:
"""FRED Search (was fred_notes)."""
return CommandOutput(item=Empty())
@router.command
def futures(
cc: CommandContext,
provider: ProviderChoices,
future_type: Literal[
"Indices", "Energy", "Metals", "Meats", "Grains", "Softs", "Bonds", "Currencies"
],
) -> CommandOutput[Empty]:
"""FUTURES. 2 sources"""
return CommandOutput(item=Empty())
@router.command
def gdp(
cc: CommandContext,
provider: ProviderChoices,
countries: list_str,
start_date: datetype,
end_date: datetype,
units: Literal["USD_CAP", "MLN_USD"] = "USD_CAP",
) -> CommandOutput[Empty]:
"""GDP."""
return CommandOutput(item=Empty())
@router.command
def glbonds(
cc: CommandContext,
provider: ProviderChoices,
) -> CommandOutput[Empty]:
"""GLBONDS."""
return CommandOutput(item=Empty())
@router.command
def indices(
cc: CommandContext,
provider: ProviderChoices,
) -> CommandOutput[Empty]:
"""INDICES."""
return CommandOutput(item=Empty())
@router.command
def overview(
cc: CommandContext,
provider: ProviderChoices,
) -> CommandOutput[Empty]:
"""OVERVIEW."""
return CommandOutput(item=Empty())
@router.command
def perfmap(
cc: CommandContext, provider: ProviderChoices, group: groups
) -> CommandOutput[Empty]:
"""PERFMAP."""
return CommandOutput(item=Empty())
@router.command
def performance(
cc: CommandContext, provider: ProviderChoices, group: groups
) -> CommandOutput[Empty]:
"""PERFORMANCE."""
return CommandOutput(item=Empty())
@router.command
def revenue(
cc: CommandContext,
provider: ProviderChoices,
countries: list_str,
start_date: datetype,
end_date: datetype,
units: Literal["PC_GDP", "THOUSAND_USD_PER_CAPITA"] = "PC_GDP",
) -> CommandOutput[Empty]:
"""REVENUE."""
return CommandOutput(item=Empty())
@router.command
def rgdp(
cc: CommandContext,
provider: ProviderChoices,
countries: list_str,
start_date: datetype,
end_date: datetype,
units: Literal["IDX", "PC_CHGPP", "PC_CHGPY"],
) -> CommandOutput[Empty]:
"""RGDP."""
return CommandOutput(item=Empty())
@router.command
def rtps(
cc: CommandContext,
provider: ProviderChoices,
) -> CommandOutput[Empty]:
"""RTPS."""
return CommandOutput(item=Empty())
@router.command
def search_index(
cc: CommandContext, provider: ProviderChoices, keyword: str
) -> CommandOutput[Empty]:
"""SEARCH_INDEX."""
return CommandOutput(item=Empty())
@router.command
def spending(
cc: CommandContext,
provider: ProviderChoices,
countries: list_str,
start_date: datetype,
end_date: datetype,
units: Literal["PC_GDP", "THOUSAND_USD_PER_CAPITA"] = "PC_GDP",
perspective: Literal[
"TOT",
"RECULTREL",
"HOUCOMM",
"PUBORN",
"EDU",
"ENVPORT",
"GRALPUBSER",
"SOCPROT",
"ECOAFF",
"DEF",
"HEALTH",
] = "TOT",
) -> CommandOutput[Empty]:
"""SPENDING."""
return CommandOutput(item=Empty())
@router.command
def trust(
cc: CommandContext,
provider: ProviderChoices,
countries: list_str,
start_date: datetype,
end_date: datetype,
) -> CommandOutput[Empty]:
"""TRUST."""
return CommandOutput(item=Empty())
@router.command
def usbonds(
cc: CommandContext,
provider: ProviderChoices,
) -> CommandOutput[Empty]:
"""USBONDS."""
return CommandOutput(item=Empty())
@router.command
def valuation(
cc: CommandContext, provider: ProviderChoices, group: groups
) -> CommandOutput[Empty]:
"""VALUATION."""
return CommandOutput(item=Empty())

View File

@@ -0,0 +1,27 @@
# pylint: disable=W0613:unused-argument
from openbb_sdk_core.app.model.command_context import CommandContext
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.model.item.empty import Empty
from openbb_sdk_core.app.provider_interface import ProviderChoices, StandardParams
from openbb_sdk_core.app.query import Query
from openbb_sdk_core.app.router import Router
from pydantic import BaseModel
router = Router(prefix="")
@router.command(query="TreasuryRates")
def treasury(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Get treasury rates."""
return CommandOutput(item=Query(**locals()).execute())
@router.command
def ycrv() -> CommandOutput[Empty]: # type: ignore
"""Yield curve."""
return CommandOutput(item=Empty())

View File

@@ -0,0 +1,11 @@
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.model.item.empty import Empty
from openbb_sdk_core.app.router import Router
router = Router(prefix="")
@router.command
def load() -> CommandOutput[Empty]: # type: ignore
"""Forex Intraday Price."""
return CommandOutput(item=Empty())

View File

@@ -0,0 +1,17 @@
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.model.item.empty import Empty
from openbb_sdk_core.app.router import Router
router = Router(prefix="")
@router.command
def globalnews() -> CommandOutput[Empty]: # type: ignore
"""Global news."""
return CommandOutput(item=Empty())
@router.command
def sectornews() -> CommandOutput[Empty]: # type: ignore
"""Sector news."""
return CommandOutput(item=Empty())

View File

@@ -0,0 +1,15 @@
import pkg_resources
from openbb_provider.provider.provider_registry import Builder, ProviderRegistry
# This could get more complicated as we add more things.
def build_registry() -> ProviderRegistry:
builder = Builder()
extensions = []
entry_points = pkg_resources.iter_entry_points("openbb_provider_extension")
for entry_point in entry_points:
extensions.append(entry_point.load())
builder.add_providers(extensions)
return builder.build()

View File

@@ -0,0 +1,33 @@
from openbb_provider.provider.abstract.provider import ProviderName
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.router import CommandMap, Router
router = Router()
def __create_command_coverage(provider_name: ProviderName):
"""Create a command coverage function for a specific provider."""
def command_coverage() -> CommandOutput[list]:
"""Get command coverage for a specific provider."""
provider_coverage = CommandMap().coverage
return CommandOutput(item=provider_coverage[provider_name])
command_coverage.__name__ = provider_name
return command_coverage
def create_command_coverage_routers():
"""Create a router for each provider."""
meta_router = Router()
for provider_name in ProviderName.__args__:
data_router = Router()
data_router.command(
func=__create_command_coverage(provider_name),
)
meta_router.include_router(router=data_router)
return meta_router
router.include_router(router=create_command_coverage_routers())

View File

@@ -0,0 +1,193 @@
import re
from typing import Annotated, Type, TypeVar
from fastapi import Depends
from openbb_provider.model.abstract.data import Data, QueryParams
from openbb_provider.provider.abstract.fetcher import Fetcher
from openbb_provider.provider.abstract.provider import ProviderName
from openbb_provider.provider.provider_map import build_provider_mapping
from openbb_provider_plugin.model.item.registry import build_registry
from openbb_sdk_core.app.model.command_context import CommandContext
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.router import Router
registry = build_registry()
meta_router = Router()
Q = TypeVar("Q", bound=QueryParams)
D = TypeVar("D", bound=Data)
def create_standardized(
QueryParamsType: Type[QueryParams],
DataType: Type[Data],
provider: ProviderName,
):
def standardized(
cc: CommandContext,
query: Annotated[QueryParamsType, Depends()], # type: ignore
) -> CommandOutput[DataType]: # type: ignore
registry.api_keys[provider] = getattr(
cc.user_settings.credentials, provider + "_api_key"
)
item = registry.standardized(
provider_name=provider,
query=query,
)
return CommandOutput(item=item)
return standardized
def create_simple(
QueryParamsType: Type[QueryParams],
DataType: Type[Data],
provider: ProviderName,
):
def simple(
cc: CommandContext,
query: Annotated[QueryParamsType, Depends()], # type: ignore
) -> CommandOutput[DataType]: # type: ignore
registry.api_keys[provider] = getattr(
cc.user_settings.credentials, provider + "_api_key"
)
item = registry.simple(
provider_name=provider,
query=query,
)
return CommandOutput(item=item)
return simple
def find_fetcher(
provider_name: ProviderName, endpoint_name: str, provider_registry_mapping: dict
) -> Fetcher:
"""Find the Provider-specific Fetcher based on a given endpoint name.
Parameter
----------
provider_name (ProviderName): The name of the data provider.
endpoint_name (str): The name of the data endpoint.
provider_registry_mapping (dict): The internal provider registry mapping.
Return
-------
Fetcher: The Fetcher that is used for creating an endpoint.
"""
# TODO: We receive the ProviderName as a lowercase string (benzinga), but the
# fetcher name convention is CamelCase (BenzingaStockPriceFetcher)
# or all capital (FMPStockPriceFetcher).
# It will break in the case that the Fetcher name is in CamelCase (BenZingaStockPriceFetcher).
# Solution: Have a mapping of provider names to fetcher names.
# {"benzinga": "BenZinga", "fmp": "FMP", "polygon": "Polygon"}
try:
query_params = provider_name.capitalize() + endpoint_name + "QueryParams"
fetcher = provider_registry_mapping[provider_name].__dict__["fetcher_dict"][
"get_provider_query_type"
][query_params]
except KeyError:
query_params = provider_name.upper() + endpoint_name + "QueryParams"
fetcher = provider_registry_mapping[provider_name].__dict__["fetcher_dict"][
"get_provider_query_type"
][query_params]
return fetcher
def fix_path(path: str) -> str:
"""Fixes the path by trimming underscores in between single letters.
Example: s_e_c_filings -> sec_fillings
Parameter
---------
path (str): The path of the endpoint.
Return
-------
str: The updated path of the endpoint.
"""
words = path.split("_")
merged_words = []
merged_word = []
for word in words:
if len(word) == 1:
merged_word.append(word)
else:
if merged_word:
merged_words.append("".join(merged_word))
merged_word = []
merged_words.append(word)
if merged_word:
merged_words.append("".join(merged_word))
return "_".join(merged_words)
def build_meta_router(provider_registry_mapping: dict, func) -> Router:
"""Create a meta router that dynamically includes all the routes and commands.
Parameter
----------
provider_registry_mapping (dict): provider table mapping
standard (bool): whether to use the OpenBB standard path
Return
-------
Router: meta router
"""
provider_mapping = build_provider_mapping()
for data_endpoint in provider_mapping["Data"]:
providers = list(provider_mapping["Data"][data_endpoint].keys())
if "openbb" in providers:
providers.remove("openbb")
endpoint_name = data_endpoint.replace("Data", "")
subpath = "_".join(re.findall("[A-Z][^A-Z]*", endpoint_name)).lower()
subpath = fix_path(path=subpath)
for provider_name in providers:
data_router = Router(prefix=f"/{provider_name}/{subpath}")
fetcher = find_fetcher(
provider_name, endpoint_name, provider_registry_mapping
)
command_args = {}
if "simple" in func.__name__:
query_type = fetcher.get_provider_query_type()
data_type = fetcher.get_provider_data_type()
command_args["path"] = "/simple"
elif "standardized" in func.__name__:
query_type = fetcher.get_provider_query_type()
data_type = fetcher.get_data_type()
command_args["path"] = "/standardized"
data_router.command(
func=func(query_type, data_type, provider_name),
description=data_type.__doc__,
**command_args,
)
meta_router.include_router(router=data_router)
return meta_router
init_meta_dict = {
"create_standardized": {
"func": create_standardized,
},
"create_simple": {
"func": create_simple,
},
}
for key, value in init_meta_dict.items():
router = Router()
# router = build_meta_router(
# provider_registry_mapping=registry.provider_mapping,
# func=value["func"],
# )

View File

@@ -0,0 +1,71 @@
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.model.item.empty import Empty
from openbb_sdk_core.app.router import Router
router = Router(prefix="/ca")
@router.command
def get() -> CommandOutput[Empty]: # type: ignore
"""Company peers."""
return CommandOutput(item=Empty())
@router.command
def balance() -> CommandOutput[Empty]: # type: ignore
"""Company balance sheet."""
return CommandOutput(item=Empty())
@router.command
def cashflow() -> CommandOutput[Empty]: # type: ignore
"""Company cashflow."""
return CommandOutput(item=Empty())
@router.command
def hcorr() -> CommandOutput[Empty]: # type: ignore
"""Company historical correlation."""
return CommandOutput(item=Empty())
@router.command
def hist() -> CommandOutput[Empty]: # type: ignore
"""Company historical prices."""
return CommandOutput(item=Empty())
@router.command
def income() -> CommandOutput[Empty]: # type: ignore
"""Company income statement."""
return CommandOutput(item=Empty())
@router.command
def scorr() -> CommandOutput[Empty]: # type: ignore
"""Company sector correlation."""
return CommandOutput(item=Empty())
@router.command
def screener() -> CommandOutput[Empty]: # type: ignore
"""Company screener."""
return CommandOutput(item=Empty())
@router.command
def sentiment() -> CommandOutput[Empty]: # type: ignore
"""Company sentiment."""
return CommandOutput(item=Empty())
@router.command
def similar() -> CommandOutput[Empty]: # type: ignore
"""Company similar."""
return CommandOutput(item=Empty())
@router.command
def volume() -> CommandOutput[Empty]: # type: ignore
"""Company volume."""
return CommandOutput(item=Empty())

View File

@@ -0,0 +1,21 @@
# pylint: disable=W0613:unused-argument
"""Due Diligence Router."""
from openbb_sdk_core.app.model.command_context import CommandContext
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.provider_interface import ProviderChoices, StandardParams
from openbb_sdk_core.app.query import Query
from openbb_sdk_core.app.router import Router
from pydantic import BaseModel
router = Router(prefix="/dd")
@router.command(query="SECFilings")
def sec(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""SEC Filings."""
return CommandOutput(item=Query(**locals()).execute())

View File

@@ -0,0 +1,111 @@
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.model.item.empty import Empty
from openbb_sdk_core.app.router import Router
router = Router(prefix="/disc")
@router.command
def active() -> CommandOutput[Empty]: # type: ignore
"""Most active stocks by intraday trade volumes."""
return CommandOutput(item=Empty())
@router.command
def arkord() -> CommandOutput[Empty]: # type: ignore
"""Order by ARK INvestment Management LLC."""
return CommandOutput(item=Empty())
@router.command
def asc() -> CommandOutput[Empty]: # type: ignore
"""Small cap stocks with revenue and earnings growth more than 25%."""
return CommandOutput(item=Empty())
@router.command
def dividends() -> CommandOutput[Empty]: # type: ignore
return CommandOutput(item=Empty())
@router.command
def filings() -> CommandOutput[Empty]: # type: ignore
"""The most-recent form submissions to the SEC."""
return CommandOutput(item=Empty())
@router.command
def fipo() -> CommandOutput[Empty]: # type: ignore
"""Future IPOs dates."""
return CommandOutput(item=Empty())
@router.command
def gainers() -> CommandOutput[Empty]: # type: ignore
"""Show latest top gainers."""
return CommandOutput(item=Empty())
@router.command
def gtech() -> CommandOutput[Empty]: # type: ignore
"""Tech stocks with revenue and earnings growth more than 25%."""
return CommandOutput(item=Empty())
@router.command
def hotpenny() -> CommandOutput[Empty]: # type: ignore
"""Today's hot penny stocks."""
return CommandOutput(item=Empty())
@router.command
def ipo() -> CommandOutput[Empty]: # type: ignore
return CommandOutput(item=Empty())
@router.command
def losers() -> CommandOutput[Empty]: # type: ignore
"""Show latest top losers."""
return CommandOutput(item=Empty())
@router.command
def lowfloat() -> CommandOutput[Empty]: # type: ignore
"""Low float stocks under 10M shares float."""
return CommandOutput(item=Empty())
@router.command
def pipo() -> CommandOutput[Empty]: # type: ignore
"""Past IPOs dates."""
return CommandOutput(item=Empty())
@router.command
def rtat() -> CommandOutput[Empty]: # type: ignore
"""Top 10 retail traded stocks per day."""
return CommandOutput(item=Empty())
@router.command
def trending() -> CommandOutput[Empty]: # type: ignore
"""Trending news."""
return CommandOutput(item=Empty())
@router.command
def ugs() -> CommandOutput[Empty]: # type: ignore
"""Undervalued stocks with revenue and earnings growth above 25%."""
return CommandOutput(item=Empty())
@router.command
def ulc() -> CommandOutput[Empty]: # type: ignore
"""Potentially undervalued large cap stocks."""
return CommandOutput(item=Empty())
@router.command
def upcoming() -> CommandOutput[Empty]: # type: ignore
"""Upcoming earnings release dates."""
return CommandOutput(item=Empty())

View File

@@ -0,0 +1,75 @@
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.model.item.empty import Empty
from openbb_sdk_core.app.router import Router
router = Router(prefix="/dps")
@router.command
def psi() -> CommandOutput[Empty]: # type: ignore
"""Price vs short interest volume"""
return CommandOutput(item=Empty())
@router.command
def ctb() -> CommandOutput[Empty]: # type: ignore
"""Cost to borrow of stocks."""
return CommandOutput(item=Empty())
@router.command
def dpotc() -> CommandOutput[Empty]: # type: ignore
"""Dark pools (ATS) vs OTC data."""
return CommandOutput(item=Empty())
@router.command
def ftd() -> CommandOutput[Empty]: # type: ignore
"""Fails-to-deliver data."""
return CommandOutput(item=Empty())
@router.command
def hsi() -> CommandOutput[Empty]: # type: ignore
"""Show top high short interest stocks of over 20% ratio."""
return CommandOutput(item=Empty())
@router.command
def pos() -> CommandOutput[Empty]: # type: ignore
"""Dark pool short position."""
return CommandOutput(item=Empty())
@router.command
def prom() -> CommandOutput[Empty]: # type: ignore
"""Promising tickers based on dark pool shares regression."""
return CommandOutput(item=Empty())
@router.command
def psi_q() -> CommandOutput[Empty]: # type: ignore
return CommandOutput(item=Empty())
@router.command
def psi_sg() -> CommandOutput[Empty]: # type: ignore
return CommandOutput(item=Empty())
@router.command
def shorted() -> CommandOutput[Empty]: # type: ignore
"""Most shorted stocks."""
return CommandOutput(item=Empty())
@router.command
def sidtc() -> CommandOutput[Empty]: # type: ignore
"""Short interest and days to cover."""
return CommandOutput(item=Empty())
@router.command
def spos() -> CommandOutput[Empty]: # type: ignore
"""Net short vs position."""
return CommandOutput(item=Empty())

View File

@@ -0,0 +1,341 @@
# pylint: disable=W0613:unused-argument
"""Fundamental Analysis Router."""
from openbb_sdk_core.app.model.command_context import CommandContext
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.model.item.empty import Empty
from openbb_sdk_core.app.provider_interface import ProviderChoices, StandardParams
from openbb_sdk_core.app.query import Query
from openbb_sdk_core.app.router import Router
from pydantic import BaseModel
router = Router(prefix="/fa")
@router.command(query="BalanceSheet")
def balance(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Balance Sheet."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="CashFlowStatement")
def cash(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Cash Flow Statement."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="ExecutiveCompensation")
def comp(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Executive Compensation."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="EarningsCalendar")
def earning(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Earnings Calendar."""
return CommandOutput(item=Query(**locals()).execute())
@router.command
def emp() -> CommandOutput[Empty]: # type: ignore
"""Number of Employees."""
return CommandOutput(item=Empty())
@router.command(query="AnalystEstimates")
def est(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Analyst Estimates."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="IncomeStatement")
def income(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Income Statement."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="StockInsiderTrading")
def ins(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Stock Insider Trading."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="KeyMetrics")
def metrics(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Key Metrics."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="KeyExecutives")
def mgmt(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Key Executives."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="CompanyOverview")
def overview(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Company Overview."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="InstitutionalOwnership")
def own(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Institutional Ownership."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="PriceTarget")
def pta(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Price Target."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="PriceTargetConsensus")
def pt(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Price Target Consensus."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="RevenueGeographic")
def revgeo(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Revenue Geographic."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="RevenueBusinessLine")
def revseg(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Revenue Business Line."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="ShareStatistics")
def shrs(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Share Statistics."""
return CommandOutput(item=Query(**locals()).execute())
@router.command
def shares() -> CommandOutput[Empty]: # type: ignore
return CommandOutput(item=Empty())
@router.command(query="EarningsCallTranscript")
def transcript(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Earnings Call Transcript."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="HistoricalStockSplits")
def split(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Historical Stock Splits."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="HistoricalDividends")
def cal(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
) -> CommandOutput[BaseModel]:
"""Historical Dividends."""
return CommandOutput(item=Query(**locals()).execute())
@router.command
def customer() -> CommandOutput[Empty]: # type: ignore
"""List of customers of the company."""
return CommandOutput(item=Empty())
@router.command
def divs() -> CommandOutput[Empty]: # type: ignore
"""Show historical dividends for company."""
return CommandOutput(item=Empty())
@router.command
def dcfc() -> CommandOutput[Empty]: # type: ignore
"""Determine the (historical) discounted cash flow."""
return CommandOutput(item=Empty())
@router.command
def dupont() -> CommandOutput[Empty]: # type: ignore
"""Detailed breakdown for Return on Equity (RoE)."""
return CommandOutput(item=Empty())
@router.command
def enterprise() -> CommandOutput[Empty]: # type: ignore
"""Enterprise value."""
return CommandOutput(item=Empty())
@router.command
def epsfc() -> CommandOutput[Empty]: # type: ignore
"""Earnings Estimate by Analysts - EPS."""
return CommandOutput(item=Empty())
@router.command
def analysis() -> CommandOutput[Empty]: # type: ignore
"""Analyse SEC filings with the help of machine learning."""
return CommandOutput(item=Empty())
@router.command
def fama_coe() -> CommandOutput[Empty]: # type: ignore
"""Fama French 3 Factor Model - Coefficient of Earnings."""
return CommandOutput(item=Empty())
@router.command
def fama_raw() -> CommandOutput[Empty]: # type: ignore
"""Fama French 3 Factor Model - Raw Data."""
return CommandOutput(item=Empty())
@router.command
def fraud() -> CommandOutput[Empty]: # type: ignore
"""Key fraud ratios including M-score, Z-score and McKee."""
return CommandOutput(item=Empty())
@router.command
def growth() -> CommandOutput[Empty]: # type: ignore
"""Growth of financial statement items and ratios."""
return CommandOutput(item=Empty())
@router.command
def historical_5() -> CommandOutput[Empty]: # type: ignore
return CommandOutput(item=Empty())
@router.command
def key() -> CommandOutput[Empty]: # type: ignore
return CommandOutput(item=Empty())
@router.command
def mktcap() -> CommandOutput[Empty]: # type: ignore
"""Obtain the market capitalization or enterprise value."""
return CommandOutput(item=Empty())
@router.command # CHECK IF NEWS ARE NEEDED HERE
def news() -> CommandOutput[Empty]: # type: ignore
return CommandOutput(item=Empty())
@router.command
def rating() -> CommandOutput[Empty]: # type: ignore
"""Analyst prices and ratings over time of the company."""
return CommandOutput(item=Empty())
@router.command
def ratios() -> CommandOutput[Empty]: # type: ignore
"""Extensive set of ratios over time."""
return CommandOutput(item=Empty())
@router.command
def revfc() -> CommandOutput[Empty]: # type: ignore
"""Earning Estimate by Analysts - Revenue."""
return CommandOutput(item=Empty())
@router.command
def rot() -> CommandOutput[Empty]: # type: ignore
"""Number of analyst ratings over time on a monthly basis."""
return CommandOutput(item=Empty())
@router.command
def score() -> CommandOutput[Empty]: # type: ignore
"""Value investing scores for any time period."""
return CommandOutput(item=Empty())
@router.command
def sec() -> CommandOutput[Empty]: # type: ignore
return CommandOutput(item=Empty())
@router.command
def supplier() -> CommandOutput[Empty]: # type: ignore
"""List of suppliers of the company."""
return CommandOutput(item=Empty())

View File

@@ -0,0 +1,74 @@
"""Due Diligence Router."""
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.model.item.empty import Empty
from openbb_sdk_core.app.router import Router
router = Router(prefix="/gov")
@router.command
def contracts() -> CommandOutput[Empty]: # type: ignore
"""Return government contracts."""
return CommandOutput(item=Empty())
@router.command
def government_trading() -> CommandOutput[Empty]: # type: ignore
"""Return government trading."""
return CommandOutput(item=Empty())
@router.command # Isn't this one the same as the one above?
def gtrades() -> CommandOutput[Empty]: # type: ignore
"""Return government trades."""
return CommandOutput(item=Empty())
@router.command
def histcont() -> CommandOutput[Empty]: # type: ignore
"""Historical quarterly government contracts."""
return CommandOutput(item=Empty())
@router.command
def lastcontracts() -> CommandOutput[Empty]: # type: ignore
"""Return last government contracts given out."""
return CommandOutput(item=Empty())
@router.command
def lasttrades() -> CommandOutput[Empty]: # type: ignore
"""Last trades."""
return CommandOutput(item=Empty())
@router.command
def lobbying() -> CommandOutput[Empty]: # type: ignore
"""Corporate lobbying details."""
return CommandOutput(item=Empty())
@router.command
def qtrcontracts() -> CommandOutput[Empty]: # type: ignore
"""Quarterly government contracts analysis."""
return CommandOutput(item=Empty())
@router.command
def topbuys() -> CommandOutput[Empty]: # type: ignore
"""Show most purchased stocks."""
return CommandOutput(item=Empty())
@router.command
def toplobbying() -> CommandOutput[Empty]: # type: ignore
"""Top corporate lobbying tickers."""
return CommandOutput(item=Empty())
@router.command
def topsells() -> CommandOutput[Empty]: # type: ignore
"""Show most sold stocks."""
return CommandOutput(item=Empty())

View File

@@ -0,0 +1,104 @@
"""Due Diligence Router."""
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.model.item.empty import Empty
from openbb_sdk_core.app.router import Router
router = Router(prefix="/ins")
@router.command
def act() -> CommandOutput[Empty]: # type: ignore
"""Insider activity over time."""
return CommandOutput(item=Empty())
@router.command
def blcp() -> CommandOutput[Empty]: # type: ignore
"""Big latest CEO/CFO purchaces ($25k+)."""
return CommandOutput(item=Empty())
@router.command
def blcs() -> CommandOutput[Empty]: # type: ignore
"""Big latest CEO/CFO sales ($100k+)."""
return CommandOutput(item=Empty())
@router.command
def blip() -> CommandOutput[Empty]: # type: ignore
"""Big latest insider purchaces ($25+)."""
return CommandOutput(item=Empty())
@router.command
def blis() -> CommandOutput[Empty]: # type: ignore
"""Big latest insider sales ($100k+)."""
return CommandOutput(item=Empty())
@router.command
def blop() -> CommandOutput[Empty]: # type: ignore
"""Big latest officer purchaces ($25k+)."""
return CommandOutput(item=Empty())
@router.command
def blos() -> CommandOutput[Empty]: # type: ignore
"""Big latest officer sales ($100k+)."""
return CommandOutput(item=Empty())
@router.command # Can't use filter because it's a python keyword
def filt() -> CommandOutput[Empty]: # type: ignore
"""Filter insiders based on preset."""
return CommandOutput(item=Empty())
@router.command
def lcb() -> CommandOutput[Empty]: # type: ignore
"""Latest cluster buys."""
return CommandOutput(item=Empty())
@router.command
def lins() -> CommandOutput[Empty]: # type: ignore
"""Last insider trading of the company."""
return CommandOutput(item=Empty())
@router.command
def lip() -> CommandOutput[Empty]: # type: ignore
"""Latest insider purchaces."""
return CommandOutput(item=Empty())
@router.command
def lis() -> CommandOutput[Empty]: # type: ignore
"""Latest insider sales."""
return CommandOutput(item=Empty())
@router.command
def lit() -> CommandOutput[Empty]: # type: ignore
"""Latest insider trading (all filings)."""
return CommandOutput(item=Empty())
@router.command
def lpsb() -> CommandOutput[Empty]: # type: ignore
"""Latest penny stock buys."""
return CommandOutput(item=Empty())
@router.command
def print_insider_data() -> CommandOutput[Empty]: # type: ignore
"""Print insider data."""
return CommandOutput(item=Empty())
@router.command
def stats() -> CommandOutput[Empty]: # type: ignore
"""Insider stats of the company."""
return CommandOutput(item=Empty())

View File

@@ -0,0 +1,93 @@
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.model.item.empty import Empty
from openbb_sdk_core.app.router import Router
router = Router(prefix="/options")
@router.command
def chains() -> CommandOutput[Empty]: # type: ignore
"""Return options chains with greeks."""
return CommandOutput(item=Empty())
@router.command
def dte() -> CommandOutput[Empty]: # type: ignore
return CommandOutput(item=Empty())
@router.command
def eodchain() -> CommandOutput[Empty]: # type: ignore
"""Gets option chain at a specific date."""
return CommandOutput(item=Empty())
@router.command
def expirations() -> CommandOutput[Empty]: # type: ignore
"""Return options expirations."""
return CommandOutput(item=Empty())
@router.command
def grhist() -> CommandOutput[Empty]: # type: ignore
"""Plot option greek history."""
return CommandOutput(item=Empty())
@router.command
def hist() -> CommandOutput[Empty]: # type: ignore
"""Plot option history."""
return CommandOutput(item=Empty())
@router.command
def info() -> CommandOutput[Empty]: # type: ignore
"""Display option information (volatility, IV rank, etc.)."""
return CommandOutput(item=Empty())
@router.command
def last_price() -> CommandOutput[Empty]: # type: ignore
"""Return last price of an option."""
return CommandOutput(item=Empty())
@router.command
def oi() -> CommandOutput[Empty]: # type: ignore
"""Plot option open interest."""
return CommandOutput(item=Empty())
@router.command
def pcr() -> CommandOutput[Empty]: # type: ignore
"""Display put/call ratio for ticker."""
return CommandOutput(item=Empty())
@router.command
def price() -> CommandOutput[Empty]: # type: ignore
return CommandOutput(item=Empty())
@router.command
def unu() -> CommandOutput[Empty]: # type: ignore
"""Show unusual options activity."""
return CommandOutput(item=Empty())
@router.command
def voi() -> CommandOutput[Empty]: # type: ignore
"""Plot volume and open interest."""
return CommandOutput(item=Empty())
@router.command
def vol() -> CommandOutput[Empty]: # type: ignore
"""Plot volume."""
return CommandOutput(item=Empty())
@router.command
def vsurf() -> CommandOutput[Empty]: # type: ignore
"""Show 3D volatility surface."""
return CommandOutput(item=Empty())

View File

@@ -0,0 +1,74 @@
# pylint: disable=import-outside-toplevel, W0613:unused-argument
"""Stocks Router."""
from typing import Optional
from openbb_sdk_core.app.model.command_context import CommandContext
from openbb_sdk_core.app.model.command_output import CommandOutput
from openbb_sdk_core.app.model.item.empty import Empty
from openbb_sdk_core.app.provider_interface import (
ExtraParams,
ProviderChoices,
StandardParams,
)
from openbb_sdk_core.app.query import Query
from openbb_sdk_core.app.router import Router
from pydantic import BaseModel
from builtin_extensions.stocks.ca.ca_router import router as ca_router
from builtin_extensions.stocks.dd.dd_router import router as dd_router
from builtin_extensions.stocks.disc.disc_router import router as disc_router
from builtin_extensions.stocks.dps.dps_router import router as dps_router
from builtin_extensions.stocks.fa.fa_router import router as fa_router
from builtin_extensions.stocks.gov.gov_router import router as gov_router
from builtin_extensions.stocks.ins.ins_router import router as ins_router
from builtin_extensions.stocks.options.options_router import router as options_router
router = Router(prefix="")
router.include_router(fa_router)
router.include_router(ca_router)
router.include_router(dd_router)
router.include_router(dps_router)
router.include_router(disc_router)
router.include_router(gov_router)
router.include_router(ins_router)
router.include_router(options_router)
@router.command(query="StockEOD")
def load(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
extra_params: Optional[ExtraParams] = None,
) -> CommandOutput[BaseModel]:
"""Load stock data for a specific ticker."""
return CommandOutput(item=Query(**locals()).execute())
@router.command(query="StockNews")
def news(
cc: CommandContext,
provider: ProviderChoices,
standard_params: StandardParams,
extra_params: Optional[ExtraParams] = None,
) -> CommandOutput[BaseModel]:
"""Get news for one or more stock tickers."""
return CommandOutput(item=Query(**locals()).execute())
@router.command
def tob() -> CommandOutput[Empty]:
"""View top of book for loaded ticker (US exchanges only)."""
return CommandOutput(item=Empty())
@router.command
def quote() -> CommandOutput[Empty]:
"""View the current price for a specific stock ticker."""
return CommandOutput(item=Empty())
@router.command
def search() -> CommandOutput[Empty]:
"""Search a specific stock ticker for analysis."""
return CommandOutput(item=Empty())