refactored AvailableIndices for economy.available_indices

This commit is contained in:
Pratyush Shukla
2023-07-25 22:48:29 +05:30
parent 821a570a3f
commit 8d24e571b7
2 changed files with 23 additions and 33 deletions

View File

@@ -3,34 +3,31 @@
from typing import Dict, List, Optional
from openbb_provider.abstract.data import Data, QueryParams
from openbb_provider.abstract.fetcher import Fetcher
from openbb_provider.helpers import data_transformer
from openbb_provider.models.available_indices import (
AvailableIndicesData,
AvailableIndicesQueryParams,
)
from pydantic import Field
from openbb_fmp.utils.helpers import get_data_many
class FMPAvailableIndicesQueryParams(QueryParams):
"""FMP Available Indices query.
class FMPAvailableIndicesQueryParams(AvailableIndicesQueryParams):
"""FMP Available Indices Query.
Source: https://site.financialmodelingprep.com/developer/docs/#Historical-stock-index-prices
"""
class FMPAvailableIndicesData(Data):
"""FMP Available Indices data."""
class FMPAvailableIndicesData(AvailableIndicesData):
"""FMP Available Indices Data."""
symbol: str
name: Optional[str]
currency: Optional[str]
stockExchange: str = Field(alias="stock_exchange")
exchangeShortName: str = Field(alias="exchange_short_name")
class Config:
fields = {
"stock_exchange": "stockExchange",
"exchange_short_name": "exchangeShortName",
}
class FMPAvailableIndicesFetcher(

View File

@@ -4,33 +4,26 @@
from typing import Optional
from openbb_provider.abstract.data import Data, QueryParams
from openbb_provider.models.base import BaseSymbol
from pydantic import Field
class AvailableIndicesQueryParams(QueryParams):
"""Available Indices query."""
"""Available Indices Query."""
class AvailableIndicesData(Data):
"""Available Indices data.
class AvailableIndicesData(Data, BaseSymbol):
"""Available Indices Data.
Returns the major indices from Dow Jones, Nasdaq and, S&P 500.
Returns
-------
symbol : str
The symbol of the index.
name : Optional[str]
The name of the index.
currency : Optional[str]
The currency the index is traded in.
stock_exchange : str
The stock exchange where the index is listed.
exchange_short_name : str
The short name of the stock exchange where the index is listed.
"""
symbol: str
name: Optional[str]
currency: Optional[str]
stock_exchange: str
exchange_short_name: str
name: Optional[str] = Field(description="The name of the index.")
currency: Optional[str] = Field(description="The currency the index is traded in.")
stock_exchange: str = Field(
description="The stock exchange where the index is listed."
)
exchange_short_name: str = Field(
description="The short name of the stock exchange where the index is listed."
)