mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-01 15:01:18 +00:00
* init * updates * Update helpers.py * tests * Update helpers.py * Update command_runner.py * Update helpers.py * deps * Update helpers.py * only check `async` if model is specified, revert `qa`, `ta`, and `econometrics` * merge issues * Update command_runner.py * remove typing and type: ignore * fix helpers typing * add aiohttp to core deps, remove from charting * remove @overload * ruff * import helper from source * helpers typing+pylint * black --------- Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Co-authored-by: Pratyush Shukla <ps4534@nyu.edu> Co-authored-by: Henrique Joaquim <h.joaquim@campus.fct.unl.pt> Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
122 lines
3.4 KiB
Python
122 lines
3.4 KiB
Python
"""ETF Router."""
|
|
|
|
from openbb_core.app.model.command_context import CommandContext
|
|
from openbb_core.app.model.obbject import OBBject
|
|
from openbb_core.app.provider_interface import (
|
|
ExtraParams,
|
|
ProviderChoices,
|
|
StandardParams,
|
|
)
|
|
from openbb_core.app.query import Query
|
|
from openbb_core.app.router import Router
|
|
from pydantic import BaseModel
|
|
|
|
from openbb_etf.discovery.discovery_router import router as discovery_router
|
|
|
|
router = Router(prefix="")
|
|
router.include_router(discovery_router)
|
|
|
|
# pylint: disable=unused-argument
|
|
|
|
|
|
@router.command(model="EtfSearch")
|
|
async def search(
|
|
cc: CommandContext,
|
|
provider_choices: ProviderChoices,
|
|
standard_params: StandardParams,
|
|
extra_params: ExtraParams,
|
|
) -> OBBject[BaseModel]:
|
|
"""Search for ETFs.
|
|
|
|
An empty query returns the full list of ETFs from the provider.
|
|
"""
|
|
return await OBBject.from_query(Query(**locals()))
|
|
|
|
|
|
@router.command(model="EtfHistorical", operation_id="etf_historical")
|
|
async def historical(
|
|
cc: CommandContext,
|
|
provider_choices: ProviderChoices,
|
|
standard_params: StandardParams,
|
|
extra_params: ExtraParams,
|
|
) -> OBBject[BaseModel]:
|
|
"""ETF Historical Market Price."""
|
|
return await OBBject.from_query(Query(**locals()))
|
|
|
|
|
|
@router.command(model="EtfInfo")
|
|
async def info(
|
|
cc: CommandContext,
|
|
provider_choices: ProviderChoices,
|
|
standard_params: StandardParams,
|
|
extra_params: ExtraParams,
|
|
) -> OBBject[BaseModel]:
|
|
"""ETF Information Overview."""
|
|
return await OBBject.from_query(Query(**locals()))
|
|
|
|
|
|
@router.command(model="EtfSectors")
|
|
async def sectors(
|
|
cc: CommandContext,
|
|
provider_choices: ProviderChoices,
|
|
standard_params: StandardParams,
|
|
extra_params: ExtraParams,
|
|
) -> OBBject[BaseModel]:
|
|
"""ETF Sector weighting."""
|
|
return await OBBject.from_query(Query(**locals()))
|
|
|
|
|
|
@router.command(model="EtfCountries")
|
|
async def countries(
|
|
cc: CommandContext,
|
|
provider_choices: ProviderChoices,
|
|
standard_params: StandardParams,
|
|
extra_params: ExtraParams,
|
|
) -> OBBject[BaseModel]:
|
|
"""ETF Country weighting."""
|
|
return await OBBject.from_query(Query(**locals()))
|
|
|
|
|
|
@router.command(model="PricePerformance")
|
|
async def price_performance(
|
|
cc: CommandContext,
|
|
provider_choices: ProviderChoices,
|
|
standard_params: StandardParams,
|
|
extra_params: ExtraParams,
|
|
) -> OBBject[BaseModel]:
|
|
"""Price performance as a return, over different periods."""
|
|
return await OBBject.from_query(Query(**locals()))
|
|
|
|
|
|
@router.command(model="EtfHoldings")
|
|
async def holdings(
|
|
cc: CommandContext,
|
|
provider_choices: ProviderChoices,
|
|
standard_params: StandardParams,
|
|
extra_params: ExtraParams,
|
|
) -> OBBject[BaseModel]:
|
|
"""Get the holdings for an individual ETF."""
|
|
return await OBBject.from_query(Query(**locals()))
|
|
|
|
|
|
@router.command(model="EtfHoldingsDate")
|
|
async def holdings_date(
|
|
cc: CommandContext,
|
|
provider_choices: ProviderChoices,
|
|
standard_params: StandardParams,
|
|
extra_params: ExtraParams,
|
|
) -> OBBject[BaseModel]:
|
|
"""Get the holdings filing date for an individual ETF."""
|
|
return await OBBject.from_query(Query(**locals()))
|
|
|
|
|
|
@router.command(model="EtfHoldingsPerformance")
|
|
async def holdings_performance(
|
|
cc: CommandContext,
|
|
provider_choices: ProviderChoices,
|
|
standard_params: StandardParams,
|
|
extra_params: ExtraParams,
|
|
) -> OBBject[BaseModel]:
|
|
"""Get the ETF holdings performance."""
|
|
return await OBBject.from_query(Query(**locals()))
|