diff --git a/openbb_sdk/builtin_extensions/economy/economy_router.py b/openbb_sdk/builtin_extensions/economy/economy_router.py index 6eb6cda7a33..385cf69f60a 100644 --- a/openbb_sdk/builtin_extensions/economy/economy_router.py +++ b/openbb_sdk/builtin_extensions/economy/economy_router.py @@ -40,7 +40,7 @@ router = Router(prefix="") @router.command def corecpi( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, start_date: datetype, end_date: datetype, countries: Union[List[str], str] = "united_states", @@ -56,7 +56,7 @@ def corecpi( @router.command def cpi( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, countries: list_str, start_date: datetype, end_date: datetype, @@ -70,7 +70,7 @@ def cpi( @router.command -def cpi_options(cc: CommandContext, provider: ProviderChoices) -> CommandOutput[Empty]: +def cpi_options(cc: CommandContext, provider_choices: ProviderChoices) -> CommandOutput[Empty]: """Get the options for v3 cpi(options=True)""" return CommandOutput(results=Empty()) @@ -78,7 +78,7 @@ def cpi_options(cc: CommandContext, provider: ProviderChoices) -> CommandOutput[ @router.command def index( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, indices_: list_str, # without the underscore pylint raises "redefined-outer-name" start_date: datetype, end_date: datetype, @@ -107,7 +107,7 @@ def index( @router.command def available_indices( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, ) -> CommandOutput[Empty]: """AVAILABLE_INDICES.""" return CommandOutput(results=Empty()) @@ -116,7 +116,7 @@ def available_indices( @router.command def macro( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, parameters: list_str, countries: list_str, transform: str, @@ -130,7 +130,7 @@ def macro( @router.command def macro_countries( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, ) -> CommandOutput[Empty]: """MACRO_COUNTRIES.""" return CommandOutput(results=Empty()) @@ -139,7 +139,7 @@ def macro_countries( @router.command def macro_parameters( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, ) -> CommandOutput[Empty]: """MACRO_PARAMETERS.""" return CommandOutput(results=Empty()) @@ -148,7 +148,7 @@ def macro_parameters( @router.command def balance( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, countries: list_str, start_date: datetype, end_date: datetype, @@ -160,7 +160,7 @@ def balance( @router.command def bigmac( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, countries: list_str, ) -> CommandOutput[Empty]: """BIGMAC.""" @@ -170,7 +170,7 @@ def bigmac( @router.command def country_codes( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, ) -> CommandOutput[Empty]: """COUNTRY_CODES.""" return CommandOutput(results=Empty()) @@ -179,7 +179,7 @@ def country_codes( @router.command def currencies( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, ) -> CommandOutput[Empty]: """CURRENCIES.""" return CommandOutput(results=Empty()) @@ -188,7 +188,7 @@ def currencies( @router.command def debt( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, countries: list_str, start_date: datetype, end_date: datetype, @@ -200,7 +200,7 @@ def debt( @router.command def events( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, countries: list_str, start_date: datetype, end_date: datetype, @@ -212,7 +212,7 @@ def events( @router.command def fgdp( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, countries: list_str, start_date: datetype, end_date: datetype, @@ -226,7 +226,7 @@ def fgdp( @router.command def fred( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, series_id: list_str, start_date: datetype, end_date: datetype, @@ -237,7 +237,7 @@ def fred( @router.command def fred_search( - cc: CommandContext, provider: ProviderChoices, term: str + cc: CommandContext, provider_choices: ProviderChoices, term: str ) -> CommandOutput[Empty]: """FRED Search (was fred_notes).""" return CommandOutput(results=Empty()) @@ -246,7 +246,7 @@ def fred_search( @router.command def futures( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, future_type: Literal[ "Indices", "Energy", "Metals", "Meats", "Grains", "Softs", "Bonds", "Currencies" ], @@ -258,7 +258,7 @@ def futures( @router.command def gdp( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, countries: list_str, start_date: datetype, end_date: datetype, @@ -271,7 +271,7 @@ def gdp( @router.command def glbonds( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, ) -> CommandOutput[Empty]: """GLBONDS.""" return CommandOutput(results=Empty()) @@ -280,7 +280,7 @@ def glbonds( @router.command def indices( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, ) -> CommandOutput[Empty]: """INDICES.""" return CommandOutput(results=Empty()) @@ -289,7 +289,7 @@ def indices( @router.command def overview( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, ) -> CommandOutput[Empty]: """OVERVIEW.""" return CommandOutput(results=Empty()) @@ -297,7 +297,7 @@ def overview( @router.command def perfmap( - cc: CommandContext, provider: ProviderChoices, group: groups + cc: CommandContext, provider_choices: ProviderChoices, group: groups ) -> CommandOutput[Empty]: """PERFMAP.""" return CommandOutput(results=Empty()) @@ -305,7 +305,7 @@ def perfmap( @router.command def performance( - cc: CommandContext, provider: ProviderChoices, group: groups + cc: CommandContext, provider_choices: ProviderChoices, group: groups ) -> CommandOutput[Empty]: """PERFORMANCE.""" return CommandOutput(results=Empty()) @@ -314,7 +314,7 @@ def performance( @router.command def revenue( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, countries: list_str, start_date: datetype, end_date: datetype, @@ -327,7 +327,7 @@ def revenue( @router.command def rgdp( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, countries: list_str, start_date: datetype, end_date: datetype, @@ -340,7 +340,7 @@ def rgdp( @router.command def rtps( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, ) -> CommandOutput[Empty]: """RTPS.""" return CommandOutput(results=Empty()) @@ -348,7 +348,7 @@ def rtps( @router.command def search_index( - cc: CommandContext, provider: ProviderChoices, keyword: str + cc: CommandContext, provider_choices: ProviderChoices, keyword: str ) -> CommandOutput[Empty]: """SEARCH_INDEX.""" return CommandOutput(results=Empty()) @@ -357,7 +357,7 @@ def search_index( @router.command def spending( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, countries: list_str, start_date: datetype, end_date: datetype, @@ -383,7 +383,7 @@ def spending( @router.command def trust( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, countries: list_str, start_date: datetype, end_date: datetype, @@ -395,7 +395,7 @@ def trust( @router.command def usbonds( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, ) -> CommandOutput[Empty]: """USBONDS.""" return CommandOutput(results=Empty()) @@ -403,7 +403,7 @@ def usbonds( @router.command def valuation( - cc: CommandContext, provider: ProviderChoices, group: groups + cc: CommandContext, provider_choices: ProviderChoices, group: groups ) -> CommandOutput[Empty]: """VALUATION.""" return CommandOutput(results=Empty()) diff --git a/openbb_sdk/builtin_extensions/fixedincome/fixedincome_router.py b/openbb_sdk/builtin_extensions/fixedincome/fixedincome_router.py index 7f924d633a1..5687f29a4e1 100644 --- a/openbb_sdk/builtin_extensions/fixedincome/fixedincome_router.py +++ b/openbb_sdk/builtin_extensions/fixedincome/fixedincome_router.py @@ -14,7 +14,7 @@ router = Router(prefix="") @router.command(query="TreasuryRates") def treasury( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Get treasury rates.""" diff --git a/openbb_sdk/builtin_extensions/stocks/dd/dd_router.py b/openbb_sdk/builtin_extensions/stocks/dd/dd_router.py index 7dc026a5ec4..b3760908248 100644 --- a/openbb_sdk/builtin_extensions/stocks/dd/dd_router.py +++ b/openbb_sdk/builtin_extensions/stocks/dd/dd_router.py @@ -14,7 +14,7 @@ router = Router(prefix="/dd") @router.command(query="SECFilings") def sec( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """SEC Filings.""" diff --git a/openbb_sdk/builtin_extensions/stocks/fa/fa_router.py b/openbb_sdk/builtin_extensions/stocks/fa/fa_router.py index 692c3bd5e51..780a3752d9d 100644 --- a/openbb_sdk/builtin_extensions/stocks/fa/fa_router.py +++ b/openbb_sdk/builtin_extensions/stocks/fa/fa_router.py @@ -15,7 +15,7 @@ router = Router(prefix="/fa") @router.command(query="BalanceSheet") def balance( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Balance Sheet.""" @@ -27,7 +27,7 @@ def balance( @router.command(query="CashFlowStatement") def cash( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Cash Flow Statement.""" @@ -39,7 +39,7 @@ def cash( @router.command(query="ExecutiveCompensation") def comp( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Executive Compensation.""" @@ -51,7 +51,7 @@ def comp( @router.command(query="EarningsCalendar") def earning( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Earnings Calendar.""" @@ -69,7 +69,7 @@ def emp() -> CommandOutput[Empty]: # type: ignore @router.command(query="AnalystEstimates") def est( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Analyst Estimates.""" @@ -81,7 +81,7 @@ def est( @router.command(query="IncomeStatement") def income( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Income Statement.""" @@ -93,7 +93,7 @@ def income( @router.command(query="StockInsiderTrading") def ins( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Stock Insider Trading.""" @@ -105,7 +105,7 @@ def ins( @router.command(query="KeyMetrics") def metrics( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Key Metrics.""" @@ -117,7 +117,7 @@ def metrics( @router.command(query="KeyExecutives") def mgmt( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Key Executives.""" @@ -129,7 +129,7 @@ def mgmt( @router.command(query="CompanyOverview") def overview( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Company Overview.""" @@ -141,7 +141,7 @@ def overview( @router.command(query="InstitutionalOwnership") def own( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Institutional Ownership.""" @@ -153,7 +153,7 @@ def own( @router.command(query="PriceTarget") def pta( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Price Target.""" @@ -165,7 +165,7 @@ def pta( @router.command(query="PriceTargetConsensus") def pt( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Price Target Consensus.""" @@ -177,7 +177,7 @@ def pt( @router.command(query="RevenueGeographic") def revgeo( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Revenue Geographic.""" @@ -189,7 +189,7 @@ def revgeo( @router.command(query="RevenueBusinessLine") def revseg( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Revenue Business Line.""" @@ -201,7 +201,7 @@ def revseg( @router.command(query="ShareStatistics") def shrs( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Share Statistics.""" @@ -218,7 +218,7 @@ def shares() -> CommandOutput[Empty]: # type: ignore @router.command(query="EarningsCallTranscript") def transcript( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Earnings Call Transcript.""" @@ -230,7 +230,7 @@ def transcript( @router.command(query="HistoricalStockSplits") def split( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Historical Stock Splits.""" @@ -242,7 +242,7 @@ def split( @router.command(query="HistoricalDividends") def cal( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, ) -> CommandOutput[BaseModel]: """Historical Dividends.""" diff --git a/openbb_sdk/builtin_extensions/stocks/stocks_router.py b/openbb_sdk/builtin_extensions/stocks/stocks_router.py index 1d4962307b0..1d7e79a1fbb 100644 --- a/openbb_sdk/builtin_extensions/stocks/stocks_router.py +++ b/openbb_sdk/builtin_extensions/stocks/stocks_router.py @@ -37,26 +37,26 @@ router.include_router(options_router) @router.command(query="StockEOD") def load( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, extra_params: Optional[ExtraParams] = None, ) -> CommandOutput[BaseModel]: """Load stock data for a specific ticker.""" return CommandOutput( - results=Query(**locals()).execute(), provider=provider.provider + results=Query(**locals()).execute(), provider=provider_choices.provider ) @router.command(query="StockNews") def news( cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, extra_params: Optional[ExtraParams] = None, ) -> CommandOutput[BaseModel]: """Get news for one or more stock tickers.""" return CommandOutput( - results=Query(**locals()).execute(), provider=provider.provider + results=Query(**locals()).execute(), provider=provider_choices.provider ) diff --git a/openbb_sdk/openbb_sdk_core/openbb_sdk_core/app/query.py b/openbb_sdk/openbb_sdk_core/openbb_sdk_core/app/query.py index a11edc75df8..27266a51db7 100644 --- a/openbb_sdk/openbb_sdk_core/openbb_sdk_core/app/query.py +++ b/openbb_sdk/openbb_sdk_core/openbb_sdk_core/app/query.py @@ -21,12 +21,12 @@ class Query: def __init__( self, cc: CommandContext, - provider: ProviderChoices, + provider_choices: ProviderChoices, standard_params: StandardParams, extra_params: Optional[ExtraParams] = None, ) -> None: self.cc = cc - self.provider = provider + self.provider = str(provider_choices.provider) self.standard_params = standard_params self.extra_params = extra_params self.name = self.standard_params.__class__.__name__ @@ -72,20 +72,19 @@ class Query: """Execute the query.""" registry = build_registry() - provider_name = str(self.provider.provider) creds = self.cc.user_settings.credentials - registry.api_keys[provider_name] = getattr(creds, provider_name + "_api_key") # type: ignore + registry.api_keys[self.provider] = getattr(creds, self.provider + "_api_key") # type: ignore query_params = self.to_query_params(self.standard_params) filtered = ( - self.filter_extra_params(self.extra_params, provider_name) + self.filter_extra_params(self.extra_params, self.provider) if self.extra_params else None ) return registry.fetch( - provider_name=provider_name, # type: ignore + provider_name=self.provider, # type: ignore # TODO: provider_name should accept a general object, otherwise we need to import from provider. query=query_params, # type: ignore # TODO: query should accept a general object, otherwise we need to import from provider. diff --git a/openbb_sdk/openbb_sdk_core/openbb_sdk_core/app/router.py b/openbb_sdk/openbb_sdk_core/openbb_sdk_core/app/router.py index e1a0d7647f2..61a8471b3bc 100644 --- a/openbb_sdk/openbb_sdk_core/openbb_sdk_core/app/router.py +++ b/openbb_sdk/openbb_sdk_core/openbb_sdk_core/app/router.py @@ -193,7 +193,7 @@ class Router: provider_interface = get_provider_interface() if query: if ( - "provider" not in func.__annotations__ + "provider_choices" not in func.__annotations__ or "standard_params" not in func.__annotations__ ): # "extra_params" not in func.__annotations__: raise AttributeError(f"Invalid signature: {func.__name__}") @@ -205,7 +205,7 @@ class Router: # provider provider_choices = provider_interface.provider_choices[query] - func.__annotations__["provider"] = Annotated[provider_choices, Depends()] # type: ignore + func.__annotations__["provider_choices"] = Annotated[provider_choices, Depends()] # type: ignore # standard_params standard_params = provider_interface.params[query]["standard"] @@ -219,10 +219,10 @@ class Router: data = provider_interface.merged_data[query] func.__annotations__["return"] = CommandOutput[List[data]] # type: ignore elif ( - "provider" in func.__annotations__ - and func.__annotations__["provider"] == ProviderChoices + "provider_choices" in func.__annotations__ + and func.__annotations__["provider_choices"] == ProviderChoices ): - func.__annotations__["provider"] = provider_interface.providers + func.__annotations__["provider_choices"] = provider_interface.providers return func