refactored PriceTargetConsensus for stocks.fa.pt

This commit is contained in:
Pratyush Shukla
2023-08-02 00:39:28 +05:30
parent 96955b836b
commit 49d653401d
2 changed files with 28 additions and 52 deletions

View File

@@ -1,10 +1,8 @@
"""FMP Price Target Consensus fetcher."""
from enum import Enum
from typing import Any, Dict, List, Optional
from openbb_provider.abstract.data import Data
from openbb_provider.abstract.fetcher import Fetcher
from openbb_provider.models.price_target_consensus import (
PriceTargetConsensusData,
@@ -14,34 +12,23 @@ from openbb_provider.models.price_target_consensus import (
from openbb_fmp.utils.helpers import create_url, get_data_many
class Interval(str, Enum):
oneminute = "1min"
fiveminute = "5min"
fifteenminute = "15min"
thirtyminute = "30min"
onehour = "1hour"
fourhour = "4hour"
day = "day"
class FMPPriceTargetConsensusQueryParams(PriceTargetConsensusQueryParams):
"""FMP Price Target Consensus query.
"""FMP Price Target Consensus Query.
Source: https://site.financialmodelingprep.com/developer/docs/price-target-consensus-api/
Parameter
---------
symbol : str
The symbol of the company.
"""
class FMPPriceTargetConsensusData(Data):
symbol: str
targetHigh: float
targetLow: float
targetConsensus: float
targetMedian: float
class FMPPriceTargetConsensusData(PriceTargetConsensusData):
"""FMP Price Target Consensus Data."""
class Config:
fields = {
"target_high": "targetHigh",
"target_low": "targetLow",
"target_consensus": "targetConsensus",
"target_median": "targetMedian",
}
class FMPPriceTargetConsensusFetcher(

View File

@@ -5,36 +5,25 @@ from openbb_provider.abstract.data import Data
from openbb_provider.abstract.query_params import QueryParams
from openbb_provider.models.base import BaseSymbol
from pydantic import Field
class PriceTargetConsensusQueryParams(QueryParams, BaseSymbol):
"""Price Target Consensus query.
Parameter
---------
symbol : str
The symbol of the company.
"""
"""Price Target Consensus Query."""
class PriceTargetConsensusData(Data):
"""Price target consensus data.
class PriceTargetConsensusData(Data, BaseSymbol):
"""Price target consensus Data."""
Returns
-------
symbol : str
The symbol of the asset.
target_high : float
The high target of the price target consensus.
target_low : float
The low target of the price target consensus.
target_consensus : float
The consensus target of the price target consensus.
target_median : float
The median target of the price target consensus.
"""
symbol: str
target_high: float
target_low: float
target_consensus: float
target_median: float
target_high: float = Field(
description="The high target of the price target consensus."
)
target_low: float = Field(
description="The low target of the price target consensus."
)
target_consensus: float = Field(
description="The consensus target of the price target consensus."
)
target_median: float = Field(
description="The median target of the price target consensus."
)