mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-28 20:23:36 +00:00
standardise date, vwap in crypto eod and forex eod
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
"""FMP Cryptos end of day fetcher."""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from openbb_provider.abstract.fetcher import Fetcher
|
||||
from openbb_provider.helpers import get_querystring
|
||||
from openbb_provider.metadata import DATA_DESCRIPTIONS
|
||||
from openbb_provider.models.crypto_eod import CryptoEODData, CryptoEODQueryParams
|
||||
from pydantic import Field, NonNegativeInt, validator
|
||||
|
||||
@@ -27,7 +26,6 @@ class FMPCryptoEODQueryParams(CryptoEODQueryParams):
|
||||
class FMPCryptoEODData(CryptoEODData):
|
||||
"""FMP Crypto end of day Data."""
|
||||
|
||||
date: datetime = Field(description=DATA_DESCRIPTIONS.get("date", ""))
|
||||
adjClose: float = Field(
|
||||
description="Adjusted Close Price of the symbol.", alias="adj_close"
|
||||
)
|
||||
@@ -41,7 +39,6 @@ class FMPCryptoEODData(CryptoEODData):
|
||||
changePercent: float = Field(
|
||||
description=r"Change \% in the price of the symbol.", alias="change_percent"
|
||||
)
|
||||
vwap: float = Field(description="Volume Weighted Average Price of the symbol.")
|
||||
label: str = Field(description="Human readable format of the date.")
|
||||
changeOverTime: float = Field(
|
||||
description=r"Change \% in the price of the symbol over a period of time.",
|
||||
@@ -63,7 +60,14 @@ class FMPCryptoEODFetcher(
|
||||
):
|
||||
@staticmethod
|
||||
def transform_query(params: Dict[str, Any]) -> FMPCryptoEODQueryParams:
|
||||
return FMPCryptoEODQueryParams(**params)
|
||||
now = datetime.now().date()
|
||||
transformed_params = params
|
||||
if params.get("start_date") is None:
|
||||
transformed_params["start_date"] = now - timedelta(days=7)
|
||||
|
||||
if params.get("end_date") is None:
|
||||
transformed_params["end_date"] = now
|
||||
return FMPCryptoEODQueryParams(**transformed_params)
|
||||
|
||||
@staticmethod
|
||||
def extract_data(
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
"""FMP Forex end of day fetcher."""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from openbb_provider.abstract.fetcher import Fetcher
|
||||
from openbb_provider.metadata import DATA_DESCRIPTIONS
|
||||
from openbb_provider.models.forex_eod import ForexEODData, ForexEODQueryParams
|
||||
from pydantic import Field, validator
|
||||
|
||||
@@ -22,7 +21,6 @@ class FMPForexEODQueryParams(ForexEODQueryParams):
|
||||
class FMPForexEODData(ForexEODData):
|
||||
"""FMP Forex end of day Data."""
|
||||
|
||||
date: datetime = Field(description=DATA_DESCRIPTIONS.get("date", ""))
|
||||
adjClose: float = Field(
|
||||
description="Adjusted Close Price of the symbol.", alias="adj_close"
|
||||
)
|
||||
@@ -36,9 +34,6 @@ class FMPForexEODData(ForexEODData):
|
||||
changePercent: float = Field(
|
||||
description=r"Change \% in the price of the symbol.", alias="change_percent"
|
||||
)
|
||||
vwap: Optional[float] = Field(
|
||||
description="Volume Weighted Average Price of the symbol."
|
||||
)
|
||||
label: str = Field(description="Human readable format of the date.")
|
||||
changeOverTime: float = Field(
|
||||
description=r"Change \% in the price of the symbol over a period of time.",
|
||||
@@ -60,7 +55,14 @@ class FMPForexEODFetcher(
|
||||
):
|
||||
@staticmethod
|
||||
def transform_query(params: Dict[str, Any]) -> FMPForexEODQueryParams:
|
||||
return FMPForexEODQueryParams(**params)
|
||||
now = datetime.now().date()
|
||||
transformed_params = params
|
||||
if params.get("start_date") is None:
|
||||
transformed_params["start_date"] = now - timedelta(days=7)
|
||||
|
||||
if params.get("end_date") is None:
|
||||
transformed_params["end_date"] = now
|
||||
return FMPForexEODQueryParams(**transformed_params)
|
||||
|
||||
@staticmethod
|
||||
def extract_data(
|
||||
|
||||
@@ -7,7 +7,7 @@ from typing import Any, Dict, List, Literal, Optional
|
||||
from openbb_provider.abstract.fetcher import Fetcher
|
||||
from openbb_provider.metadata import QUERY_DESCRIPTIONS
|
||||
from openbb_provider.models.crypto_eod import CryptoEODData, CryptoEODQueryParams
|
||||
from pydantic import Field, PositiveFloat, PositiveInt, validator
|
||||
from pydantic import Field, PositiveInt, validator
|
||||
|
||||
from openbb_polygon.utils.helpers import get_data
|
||||
|
||||
@@ -38,20 +38,18 @@ class PolygonCryptoEODData(CryptoEODData):
|
||||
|
||||
class Config:
|
||||
fields = {
|
||||
"date": "t",
|
||||
"open": "o",
|
||||
"high": "h",
|
||||
"low": "l",
|
||||
"close": "c",
|
||||
"volume": "v",
|
||||
"vwap": "vw",
|
||||
}
|
||||
|
||||
t: datetime = Field(description="The timestamp of the data.")
|
||||
n: PositiveInt = Field(
|
||||
description="The number of transactions for the symbol in the time period."
|
||||
)
|
||||
vw: PositiveFloat = Field(
|
||||
description="The volume weighted average price of the symbol."
|
||||
)
|
||||
|
||||
@validator("t", pre=True, check_fields=False)
|
||||
def time_validate(cls, v): # pylint: disable=E0213
|
||||
|
||||
@@ -7,7 +7,7 @@ from typing import Any, Dict, List, Literal, Optional
|
||||
from openbb_provider.abstract.fetcher import Fetcher
|
||||
from openbb_provider.metadata import QUERY_DESCRIPTIONS
|
||||
from openbb_provider.models.forex_eod import ForexEODData, ForexEODQueryParams
|
||||
from pydantic import Field, PositiveFloat, PositiveInt, validator
|
||||
from pydantic import Field, PositiveInt, validator
|
||||
|
||||
from openbb_polygon.utils.helpers import get_data
|
||||
|
||||
@@ -38,20 +38,18 @@ class PolygonForexEODData(ForexEODData):
|
||||
|
||||
class Config:
|
||||
fields = {
|
||||
"date": "t",
|
||||
"open": "o",
|
||||
"high": "h",
|
||||
"low": "l",
|
||||
"close": "c",
|
||||
"volume": "v",
|
||||
"vwap": "vw",
|
||||
}
|
||||
|
||||
t: datetime = Field(description="The timestamp of the data.")
|
||||
n: PositiveInt = Field(
|
||||
description="The number of transactions for the symbol in the time period."
|
||||
)
|
||||
vw: PositiveFloat = Field(
|
||||
description="The volume weighted average price of the symbol."
|
||||
)
|
||||
|
||||
@validator("t", pre=True, check_fields=False)
|
||||
def time_validate(cls, v): # pylint: disable=E0213
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
### THIS FILE IS AUTO-GENERATED. DO NOT EDIT. ###
|
||||
|
||||
|
||||
|
||||
from openbb_core.app.static.container import Container
|
||||
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ class CLASS_crypto(Container):
|
||||
|
||||
CryptoEOD
|
||||
---------
|
||||
date : datetime
|
||||
The date of the data.
|
||||
open : PositiveFloat
|
||||
The open price of the symbol.
|
||||
high : PositiveFloat
|
||||
@@ -67,6 +69,8 @@ class CLASS_crypto(Container):
|
||||
The close price of the symbol.
|
||||
volume : PositiveFloat
|
||||
The volume of the symbol.
|
||||
vwap : PositiveFloat
|
||||
Volume Weighted Average Price of the symbol.
|
||||
|
||||
fmp
|
||||
===
|
||||
@@ -79,8 +83,6 @@ class CLASS_crypto(Container):
|
||||
|
||||
CryptoEOD
|
||||
---------
|
||||
date : datetime
|
||||
The date of the data.
|
||||
adjClose : float
|
||||
Adjusted Close Price of the symbol.
|
||||
unadjustedVolume : float
|
||||
@@ -89,8 +91,6 @@ class CLASS_crypto(Container):
|
||||
Change in the price of the symbol from the previous day.
|
||||
changePercent : float
|
||||
Change \% in the price of the symbol.
|
||||
vwap : float
|
||||
Volume Weighted Average Price of the symbol.
|
||||
label : str
|
||||
Human readable format of the date.
|
||||
changeOverTime : float
|
||||
@@ -115,12 +115,8 @@ class CLASS_crypto(Container):
|
||||
|
||||
CryptoEOD
|
||||
---------
|
||||
t : datetime
|
||||
The timestamp of the data.
|
||||
n : PositiveInt
|
||||
The number of transactions for the symbol in the time period.
|
||||
vw : PositiveFloat
|
||||
The volume weighted average price of the symbol."""
|
||||
The number of transactions for the symbol in the time period."""
|
||||
inputs = filter_inputs(
|
||||
provider_choices={
|
||||
"provider": provider,
|
||||
|
||||
@@ -171,6 +171,8 @@ class CLASS_forex(Container):
|
||||
|
||||
ForexEOD
|
||||
--------
|
||||
date : datetime
|
||||
The date of the data.
|
||||
open : PositiveFloat
|
||||
The open price of the symbol.
|
||||
high : PositiveFloat
|
||||
@@ -181,6 +183,8 @@ class CLASS_forex(Container):
|
||||
The close price of the symbol.
|
||||
volume : NonNegativeFloat
|
||||
The volume of the symbol.
|
||||
vwap : Optional[PositiveFloat]
|
||||
Volume Weighted Average Price of the symbol.
|
||||
|
||||
fmp
|
||||
===
|
||||
@@ -192,8 +196,6 @@ class CLASS_forex(Container):
|
||||
|
||||
ForexEOD
|
||||
--------
|
||||
date : datetime
|
||||
The date of the data.
|
||||
adjClose : float
|
||||
Adjusted Close Price of the symbol.
|
||||
unadjustedVolume : float
|
||||
@@ -202,8 +204,6 @@ class CLASS_forex(Container):
|
||||
Change in the price of the symbol from the previous day.
|
||||
changePercent : float
|
||||
Change \% in the price of the symbol.
|
||||
vwap : Optional[float]
|
||||
Volume Weighted Average Price of the symbol.
|
||||
label : str
|
||||
Human readable format of the date.
|
||||
changeOverTime : float
|
||||
@@ -228,12 +228,8 @@ class CLASS_forex(Container):
|
||||
|
||||
ForexEOD
|
||||
--------
|
||||
t : datetime
|
||||
The timestamp of the data.
|
||||
n : PositiveInt
|
||||
The number of transactions for the symbol in the time period.
|
||||
vw : PositiveFloat
|
||||
The volume weighted average price of the symbol."""
|
||||
The number of transactions for the symbol in the time period."""
|
||||
inputs = filter_inputs(
|
||||
provider_choices={
|
||||
"provider": provider,
|
||||
|
||||
@@ -1123,11 +1123,19 @@ class CLASS_stocks_fa(Container):
|
||||
HistoricalDividends
|
||||
-------------------
|
||||
date : date
|
||||
None
|
||||
The date of the historical dividends.
|
||||
label : str
|
||||
None
|
||||
The label of the historical dividends.
|
||||
adj_dividend : float
|
||||
The adjusted dividend of the historical dividends.
|
||||
dividend : float
|
||||
None
|
||||
The dividend of the historical dividends.
|
||||
record_date : Optional[date]
|
||||
The record date of the historical dividends.
|
||||
payment_date : Optional[date]
|
||||
The payment date of the historical dividends.
|
||||
declaration_date : Optional[date]
|
||||
The declaration date of the historical dividends.
|
||||
|
||||
fmp
|
||||
===
|
||||
@@ -1139,14 +1147,7 @@ class CLASS_stocks_fa(Container):
|
||||
|
||||
HistoricalDividends
|
||||
-------------------
|
||||
adjDividend : float
|
||||
None
|
||||
recordDate : Optional[date]
|
||||
None
|
||||
paymentDate : Optional[date]
|
||||
None
|
||||
declarationDate : Optional[date]
|
||||
None"""
|
||||
All fields are standardized."""
|
||||
inputs = filter_inputs(
|
||||
provider_choices={
|
||||
"provider": provider,
|
||||
@@ -2565,6 +2566,7 @@ class CLASS_stocks_fa(Container):
|
||||
def own(
|
||||
self,
|
||||
symbol: str,
|
||||
include_current_quarter: bool = False,
|
||||
date: Optional[datetime.date] = None,
|
||||
chart: bool = False,
|
||||
provider: Optional[Literal["fmp"]] = None,
|
||||
@@ -2582,8 +2584,10 @@ class CLASS_stocks_fa(Container):
|
||||
The provider to use for the query.
|
||||
symbol : ConstrainedStrValue
|
||||
Symbol to get data for.
|
||||
include_current_quarter : bool
|
||||
Include current quarter data.
|
||||
date : Optional[date]
|
||||
None
|
||||
A specific date to get data for.
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -2603,95 +2607,96 @@ class CLASS_stocks_fa(Container):
|
||||
InstitutionalOwnership
|
||||
----------------------
|
||||
symbol : ConstrainedStrValue
|
||||
None
|
||||
cik : ConstrainedStrValue
|
||||
None
|
||||
Symbol to get data for.
|
||||
cik : Optional[str]
|
||||
The CIK of the company.
|
||||
date : date
|
||||
None
|
||||
The date of the data.
|
||||
investors_holding : int
|
||||
The number of investors holding the stock.
|
||||
last_investors_holding : int
|
||||
The number of investors holding the stock in the last quarter.
|
||||
investors_holding_change : int
|
||||
The change in the number of investors holding the stock.
|
||||
number_of_13f_shares : Optional[int]
|
||||
The number of 13F shares.
|
||||
last_number_of_13f_shares : Optional[int]
|
||||
The number of 13F shares in the last quarter.
|
||||
number_of_13f_shares_change : Optional[int]
|
||||
The change in the number of 13F shares.
|
||||
total_invested : float
|
||||
The total amount invested.
|
||||
last_total_invested : float
|
||||
The total amount invested in the last quarter.
|
||||
total_invested_change : float
|
||||
The change in the total amount invested.
|
||||
ownership_percent : float
|
||||
The ownership percent.
|
||||
last_ownership_percent : float
|
||||
The ownership percent in the last quarter.
|
||||
ownership_percent_change : float
|
||||
The change in the ownership percent.
|
||||
new_positions : int
|
||||
The number of new positions.
|
||||
last_new_positions : int
|
||||
The number of new positions in the last quarter.
|
||||
new_positions_change : int
|
||||
he change in the number of new positions.
|
||||
increased_positions : int
|
||||
The number of increased positions.
|
||||
last_increased_positions : int
|
||||
The number of increased positions in the last quarter.
|
||||
increased_positions_change : int
|
||||
The change in the number of increased positions.
|
||||
closed_positions : int
|
||||
The number of closed positions.
|
||||
last_closed_positions : int
|
||||
The number of closed positions in the last quarter.
|
||||
closed_positions_change : int
|
||||
The change in the number of closed positions.
|
||||
reduced_positions : int
|
||||
The number of reduced positions.
|
||||
last_reduced_positions : int
|
||||
The number of reduced positions in the last quarter.
|
||||
reduced_positions_change : int
|
||||
The change in the number of reduced positions.
|
||||
total_calls : int
|
||||
Total number of call options contracts traded for Apple Inc. on the specified date.
|
||||
last_total_calls : int
|
||||
Total number of call options contracts traded for Apple Inc. on the previous reporting date.
|
||||
total_calls_change : int
|
||||
Change in the total number of call options contracts traded between the current and previous reporting dates.
|
||||
total_puts : int
|
||||
Total number of put options contracts traded for Apple Inc. on the specified date.
|
||||
last_total_puts : int
|
||||
Total number of put options contracts traded for Apple Inc. on the previous reporting date.
|
||||
total_puts_change : int
|
||||
Change in the total number of put options contracts traded between the current and previous reporting dates.
|
||||
put_call_ratio : float
|
||||
The put-call ratio, which is the ratio of the total number of put options to call options traded on the specified date.
|
||||
last_put_call_ratio : float
|
||||
The put-call ratio on the previous reporting date.
|
||||
put_call_ratio_change : float
|
||||
Change in the put-call ratio between the current and previous reporting dates.
|
||||
|
||||
fmp
|
||||
===
|
||||
|
||||
Parameters
|
||||
----------
|
||||
includeCurrentQuarter : bool
|
||||
None
|
||||
All fields are standardized.
|
||||
|
||||
|
||||
InstitutionalOwnership
|
||||
----------------------
|
||||
investorsHolding : int
|
||||
None
|
||||
lastInvestorsHolding : int
|
||||
None
|
||||
investorsHoldingChange : int
|
||||
None
|
||||
numberOf13Fshares : int
|
||||
None
|
||||
lastNumberOf13Fshares : int
|
||||
None
|
||||
numberOf13FsharesChange : int
|
||||
None
|
||||
totalInvested : float
|
||||
None
|
||||
lastTotalInvested : float
|
||||
None
|
||||
totalInvestedChange : float
|
||||
None
|
||||
ownershipPercent : float
|
||||
None
|
||||
lastOwnershipPercent : float
|
||||
None
|
||||
ownershipPercentChange : float
|
||||
None
|
||||
newPositions : int
|
||||
None
|
||||
lastNewPositions : int
|
||||
None
|
||||
newPositionsChange : int
|
||||
None
|
||||
increasedPositions : int
|
||||
None
|
||||
lastIncreasedPositions : int
|
||||
None
|
||||
increasedPositionsChange : int
|
||||
None
|
||||
closedPositions : int
|
||||
None
|
||||
lastClosedPositions : int
|
||||
None
|
||||
closedPositionsChange : int
|
||||
None
|
||||
reducedPositions : int
|
||||
None
|
||||
lastReducedPositions : int
|
||||
None
|
||||
reducedPositionsChange : int
|
||||
None
|
||||
totalCalls : int
|
||||
None
|
||||
lastTotalCalls : int
|
||||
None
|
||||
totalCallsChange : int
|
||||
None
|
||||
totalPuts : int
|
||||
None
|
||||
lastTotalPuts : int
|
||||
None
|
||||
totalPutsChange : int
|
||||
None
|
||||
putCallRatio : float
|
||||
None
|
||||
lastPutCallRatio : float
|
||||
None
|
||||
putCallRatioChange : float
|
||||
None"""
|
||||
All fields are standardized."""
|
||||
inputs = filter_inputs(
|
||||
provider_choices={
|
||||
"provider": provider,
|
||||
},
|
||||
standard_params={
|
||||
"symbol": symbol,
|
||||
"include_current_quarter": include_current_quarter,
|
||||
"date": date,
|
||||
},
|
||||
extra_params=kwargs,
|
||||
|
||||
@@ -23,4 +23,5 @@ DATA_DESCRIPTIONS = {
|
||||
"close": "The close price of the symbol.",
|
||||
"volume": "The volume of the symbol.",
|
||||
"adj_close": "The adjusted close price of the symbol.",
|
||||
"vwap": "Volume Weighted Average Price of the symbol.",
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Crypto aggregate end of day price data model."""
|
||||
|
||||
|
||||
from datetime import date
|
||||
from datetime import date, datetime
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field, PositiveFloat
|
||||
@@ -28,8 +28,10 @@ class CryptoEODQueryParams(QueryParams, BaseSymbol):
|
||||
class CryptoEODData(Data):
|
||||
"""Crypto end of day price Data."""
|
||||
|
||||
date: datetime = Field(description=DATA_DESCRIPTIONS.get("date", ""))
|
||||
open: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("open", ""))
|
||||
high: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("high", ""))
|
||||
low: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("low", ""))
|
||||
close: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("close", ""))
|
||||
volume: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("volume", ""))
|
||||
vwap: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("vwap", ""))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Forex aggregate end of day price data model."""
|
||||
|
||||
|
||||
from datetime import date
|
||||
from datetime import date, datetime
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field, NonNegativeFloat, PositiveFloat
|
||||
@@ -28,8 +28,10 @@ class ForexEODQueryParams(QueryParams, BaseSymbol):
|
||||
class ForexEODData(Data):
|
||||
"""Forex end of day price Data."""
|
||||
|
||||
date: datetime = Field(description=DATA_DESCRIPTIONS.get("date", ""))
|
||||
open: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("open", ""))
|
||||
high: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("high", ""))
|
||||
low: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("low", ""))
|
||||
close: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("close", ""))
|
||||
volume: NonNegativeFloat = Field(description=DATA_DESCRIPTIONS.get("volume", ""))
|
||||
vwap: Optional[PositiveFloat] = Field(description=DATA_DESCRIPTIONS.get("vwap", ""))
|
||||
|
||||
@@ -34,6 +34,4 @@ class StockEODData(Data):
|
||||
low: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("low", ""))
|
||||
close: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("close", ""))
|
||||
volume: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("volume", ""))
|
||||
vwap: PositiveFloat = Field(
|
||||
description="Volume Weighted Average Price of the symbol."
|
||||
)
|
||||
vwap: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("vwap", ""))
|
||||
|
||||
Reference in New Issue
Block a user