summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanglewood <85772166+deeleeramone@users.noreply.github.com>2024-05-09 02:38:59 -0700
committerGitHub <noreply@github.com>2024-05-09 09:38:59 +0000
commit4d6074de2df9b7dd29fd9a7bb415de73d6b0200a (patch)
treeaf842b5711ab5836625800db3af91cb333b520ae
parent1a49dfdd9e34ce05810774a5a543c4c97b5b614a (diff)
[BugFix] Fix Currency Search (#6380)
* fix currency search * test artifact * static files
-rw-r--r--openbb_platform/core/openbb_core/provider/standard_models/currency_pairs.py10
-rw-r--r--openbb_platform/extensions/currency/integration/test_currency_api.py10
-rw-r--r--openbb_platform/extensions/currency/integration/test_currency_python.py10
-rw-r--r--openbb_platform/extensions/currency/openbb_currency/currency_router.py12
-rw-r--r--openbb_platform/openbb/assets/reference.json133
-rw-r--r--openbb_platform/openbb/package/currency.py60
-rw-r--r--openbb_platform/providers/fmp/openbb_fmp/models/currency_pairs.py23
-rw-r--r--openbb_platform/providers/intrinio/openbb_intrinio/models/currency_pairs.py25
-rw-r--r--openbb_platform/providers/polygon/openbb_polygon/models/currency_pairs.py130
-rw-r--r--openbb_platform/providers/polygon/tests/record/http/test_polygon_fetchers/test_polygon_currency_pairs_fetcher.yaml778
-rw-r--r--openbb_platform/providers/polygon/tests/test_polygon_fetchers.py2
11 files changed, 562 insertions, 631 deletions
diff --git a/openbb_platform/core/openbb_core/provider/standard_models/currency_pairs.py b/openbb_platform/core/openbb_core/provider/standard_models/currency_pairs.py
index 23326ebbc94..c910236c0d6 100644
--- a/openbb_platform/core/openbb_core/provider/standard_models/currency_pairs.py
+++ b/openbb_platform/core/openbb_core/provider/standard_models/currency_pairs.py
@@ -1,16 +1,24 @@
"""Currency Available Pairs Standard Model."""
+from typing import Optional
+
from pydantic import Field
from openbb_core.provider.abstract.data import Data
from openbb_core.provider.abstract.query_params import QueryParams
+from openbb_core.provider.utils.descriptions import DATA_DESCRIPTIONS
class CurrencyPairsQueryParams(QueryParams):
"""Currency Available Pairs Query."""
+ query: Optional[str] = Field(
+ default=None, description="Query to search for currency pairs."
+ )
+
class CurrencyPairsData(Data):
"""Currency Available Pairs Data."""
- name: str = Field(description="Name of the currency pair.")
+ symbol: str = Field(description=DATA_DESCRIPTIONS.get("symbol", ""))
+ name: Optional[str] = Field(default=None, description="Name of the currency pair.")
diff --git a/openbb_platform/extensions/currency/integration/test_currency_api.py b/openbb_platform/extensions/currency/integration/test_currency_api.py
index e85f2e931e9..58c47d3af72 100644
--- a/openbb_platform/extensions/currency/integration/test_currency_api.py
+++ b/openbb_platform/extensions/currency/integration/test_currency_api.py
@@ -27,23 +27,19 @@ def headers():
(
{
"provider": "polygon",
- "symbol": "USDJPY",
- "date": "2023-10-12",
- "search": "",
- "active": True,
- "order": "asc",
- "sort": "currency_name",
- "limit": 100,
+ "query": "eur",
}
),
(
{
"provider": "fmp",
+ "query": "eur",
}
),
(
{
"provider": "intrinio",
+ "query": "eur",
}
),
],
diff --git a/openbb_platform/extensions/currency/integration/test_currency_python.py b/openbb_platform/extensions/currency/integration/test_currency_python.py
index 2c81518ab41..62069b8796c 100644
--- a/openbb_platform/extensions/currency/integration/test_currency_python.py
+++ b/openbb_platform/extensions/currency/integration/test_currency_python.py
@@ -24,23 +24,19 @@ def obb(pytestconfig):
(
{
"provider": "polygon",
- "symbol": "USDJPY",
- "date": "2023-10-12",
- "search": "",
- "active": True,
- "order": "asc",
- "sort": "currency_name",
- "limit": 100,
+ "query": "eur",
}
),
(
{
"provider": "fmp",
+ "query": "eur",
}
),
(
{
"provider": "intrinio",
+ "query": "eur",
}
),
],
diff --git a/openbb_platform/extensions/currency/openbb_currency/currency_router.py b/openbb_platform/extensions/currency/openbb_currency/currency_router.py
index 111acd3b5e2..8999e507f42 100644
--- a/openbb_platform/extensions/currency/openbb_currency/currency_router.py
+++ b/openbb_platform/extensions/currency/openbb_currency/currency_router.py
@@ -21,18 +21,14 @@ router.include_router(price_router)
@router.command(
model="CurrencyPairs",
examples=[
- APIEx(parameters={"provider": "intrinio"}),
- APIEx(
- description="Search for 'EURUSD' currency pair using 'intrinio' as provider.",
- parameters={"provider": "intrinio", "symbol": "EURUSD"},
- ),
+ APIEx(parameters={"provider": "fmp"}),
APIEx(
- description="Search for actively traded currency pairs on the queried date using 'polygon' as provider.",
- parameters={"provider": "polygon", "date": "2024-01-02", "active": True},
+ description="Search for 'EUR' currency pair using 'intrinio' as provider.",
+ parameters={"provider": "intrinio", "query": "EUR"},
),
APIEx(
description="Search for terms using 'polygon' as provider.",
- parameters={"provider": "polygon", "search": "Euro zone"},
+ parameters={"provider": "polygon", "query": "Euro zone"},
),
],
)
diff --git a/openbb_platform/openbb/assets/reference.json b/openbb_platform/openbb/assets/reference.json
index 004e047344c..495c4e0b5ca 100644
--- a/openbb_platform/openbb/assets/reference.json
+++ b/openbb_platform/openbb/assets/reference.json
@@ -576,10 +576,17 @@
"message": null
},
"description": "Currency Search.\n\nSearch available currency pairs.\nCurrency pairs are the national currencies from two countries coupled for trading on\nthe foreign exchange (FX) marketplace.\nBoth currencies will have exchange rates on which the trade will have its position basis.\nAll trading within the forex market, whether selling, buying, or trading, will take place through currency pairs.\n(ref: Investopedia)\nMajor currency pairs include pairs such as EUR/USD, USD/JPY, GBP/USD, etc.",
- "examples": "\nExamples\n--------\n\n```python\nfrom openbb import obb\nobb.currency.search(provider='intrinio')\n# Search for 'EURUSD' currency pair using 'intrinio' as provider.\nobb.currency.search(provider='intrinio', symbol=EURUSD)\n# Search for actively traded currency pairs on the queried date using 'polygon' as provider.\nobb.currency.search(provider='polygon', date=2024-01-02, active=True)\n# Search for terms using 'polygon' as provider.\nobb.currency.search(provider='polygon', search=Euro zone)\n```\n\n",
+ "examples": "\nExamples\n--------\n\n```python\nfrom openbb import obb\nobb.currency.search(provider='fmp')\n# Search for 'EUR' currency pair using 'intrinio' as provider.\nobb.currency.search(provider='intrinio', query='EUR')\n# Search for terms using 'polygon' as provider.\nobb.currency.search(provider='polygon', query='Euro zone')\n```\n\n",
"parameters": {
"standard": [
{
+ "name": "query",
+ "type": "str",
+ "description": "Query to search for currency pairs.",
+ "default": null,
+ "optional": true
+ },
+ {
"name": "provider",
"type": "Literal['fmp', 'intrinio', 'polygon']",
"description": "The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default.",
@@ -589,57 +596,7 @@
],
"fmp": [],
"intrinio": [],
- "polygon": [
- {
- "name": "symbol",
- "type": "str",
- "description": "Symbol of the pair to search.",
- "default": null,
- "optional": true
- },
- {
- "name": "date",
- "type": "Union[date, str]",
- "description": "A specific date to get data for.",
- "default": null,
- "optional": true
- },
- {
- "name": "search",
- "type": "str",
- "description": "Search for terms within the ticker and/or company name.",
- "default": "",
- "optional": true
- },
- {
- "name": "active",
- "type": "bool",
- "description": "Specify if the tickers returned should be actively traded on the queried date.",
- "default": true,
- "optional": true
- },
- {
- "name": "order",
- "type": "Literal['asc', 'desc']",
- "description": "Order data by ascending or descending.",
- "default": "asc",
- "optional": true
- },
- {
- "name": "sort",
- "type": "Literal['ticker', 'name', 'market', 'locale', 'currency_symbol', 'currency_name', 'base_currency_symbol', 'base_currency_name', 'last_updated_utc', 'delisted_utc']",
- "description": "Sort field used for ordering.",
- "default": null,
- "optional": true
- },
- {
- "name": "limit",
- "type": "Annotated[int, Gt(gt=0)]",
- "description": "The number of data entries to return.",
- "default": 1000,
- "optional": true
- }
- ]
+ "polygon": []
},
"returns": {
"OBBject": [
@@ -673,22 +630,22 @@
"data": {
"standard": [
{
- "name": "name",
+ "name": "symbol",
"type": "str",
- "description": "Name of the currency pair.",
+ "description": "Symbol representing the entity requested in the data.",
"default": "",
"optional": false
+ },
+ {
+ "name": "name",
+ "type": "str",
+ "description": "Name of the currency pair.",
+ "default": null,
+ "optional": true
}
],
"fmp": [
{
- "name": "symbol",
- "type": "str",
- "description": "Symbol of the currency pair.",
- "default": "",
- "optional": false
- },
- {
"name": "currency",
"type": "str",
"description": "Base currency of the currency pair.",
@@ -712,13 +669,6 @@
],
"intrinio": [
{
- "name": "code",
- "type": "str",
- "description": "Code of the currency pair.",
- "default": "",
- "optional": false
- },
- {
"name": "base_currency",
"type": "str",
"description": "ISO 4217 currency code of the base currency.",
@@ -735,20 +685,6 @@
],
"polygon": [
{
- "name": "market",
- "type": "str",
- "description": "Name of the trading market. Always 'fx'.",
- "default": "",
- "optional": false
- },
- {
- "name": "locale",
- "type": "str",
- "description": "Locale of the currency pair.",
- "default": "",
- "optional": false
- },
- {
"name": "currency_symbol",
"type": "str",
"description": "The symbol of the quote currency.",
@@ -756,13 +692,6 @@
"optional": true
},
{
- "name": "currency_name",
- "type": "str",
- "description": "Name of the quote currency.",
- "default": null,
- "optional": true
- },
- {
"name": "base_currency_symbol",
"type": "str",
"description": "The symbol of the base currency.",
@@ -777,16 +706,30 @@
"optional": true
},
{
- "name": "last_updated_utc",
- "type": "datetime",
- "description": "The last updated timestamp in UTC.",
+ "name": "market",
+ "type": "str",
+ "description": "Name of the trading market. Always 'fx'.",
"default": "",
"optional": false
},
{
- "name": "delisted_utc",
- "type": "datetime",
- "description": "The delisted timestamp in UTC.",
+ "name": "locale",
+ "type": "str",
+ "description": "Locale of the currency pair.",
+ "default": "",
+ "optional": false
+ },
+ {
+ "name": "last_updated",
+ "type": "date",
+ "description": "The date the reference data was last updated.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "delisted",
+ "type": "date",
+ "description": "The date the item was delisted.",
"default": null,
"optional": true
}
diff --git a/openbb_platform/openbb/package/currency.py b/openbb_platform/openbb/package/currency.py
index b2a90cfa9bc..05c7b823969 100644
--- a/openbb_platform/openbb/package/currency.py
+++ b/openbb_platform/openbb/package/currency.py
@@ -31,6 +31,10 @@ class ROUTER_currency(Container):
@validate
def search(
self,
+ query: Annotated[
+ Optional[str],
+ OpenBBField(description="Query to search for currency pairs."),
+ ] = None,
provider: Annotated[
Optional[Literal["fmp", "intrinio", "polygon"]],
OpenBBField(
@@ -52,24 +56,12 @@ class ROUTER_currency(Container):
Parameters
----------
+ query : Optional[str]
+ Query to search for currency pairs.
provider : Optional[Literal['fmp', 'intrinio', 'polygon']]
The provider to use for the query, by default None.
If None, the provider specified in defaults is selected or 'fmp' if there is
no default.
- symbol : Optional[str]
- Symbol of the pair to search. (provider: polygon)
- date : Optional[datetime.date]
- A specific date to get data for. (provider: polygon)
- search : Optional[str]
- Search for terms within the ticker and/or company name. (provider: polygon)
- active : Optional[bool]
- Specify if the tickers returned should be actively traded on the queried date. (provider: polygon)
- order : Optional[Literal['asc', 'desc']]
- Order data by ascending or descending. (provider: polygon)
- sort : Optional[Literal['ticker', 'name', 'market', 'locale', 'currency_symbol', 'currency_name', 'base_currency_symbol', 'base_currency_name', 'last_updated_utc', 'delisted_utc']]
- Sort field used for ordering. (provider: polygon)
- limit : Optional[Annotated[int, Gt(gt=0)]]
- The number of data entries to return. (provider: polygon)
Returns
-------
@@ -87,49 +79,43 @@ class ROUTER_currency(Container):
CurrencyPairs
-------------
- name : str
+ symbol : str
+ Symbol representing the entity requested in the data.
+ name : Optional[str]
Name of the currency pair.
- symbol : Optional[str]
- Symbol of the currency pair. (provider: fmp)
currency : Optional[str]
Base currency of the currency pair. (provider: fmp)
stock_exchange : Optional[str]
Stock exchange of the currency pair. (provider: fmp)
exchange_short_name : Optional[str]
Short name of the stock exchange of the currency pair. (provider: fmp)
- code : Optional[str]
- Code of the currency pair. (provider: intrinio)
base_currency : Optional[str]
ISO 4217 currency code of the base currency. (provider: intrinio)
quote_currency : Optional[str]
ISO 4217 currency code of the quote currency. (provider: intrinio)
- market : Optional[str]
- Name of the trading market. Always 'fx'. (provider: polygon)
- locale : Optional[str]
- Locale of the currency pair. (provider: polygon)
currency_symbol : Optional[str]
The symbol of the quote currency. (provider: polygon)
- currency_name : Optional[str]
- Name of the quote currency. (provider: polygon)
base_currency_symbol : Optional[str]
The symbol of the base currency. (provider: polygon)
base_currency_name : Optional[str]
Name of the base currency. (provider: polygon)
- last_updated_utc : Optional[datetime]
- The last updated timestamp in UTC. (provider: polygon)
- delisted_utc : Optional[datetime]
- The delisted timestamp in UTC. (provider: polygon)
+ market : Optional[str]
+ Name of the trading market. Always 'fx'. (provider: polygon)
+ locale : Optional[str]
+ Locale of the currency pair. (provider: polygon)
+ last_updated : Optional[date]
+ The date the reference data was last updated. (provider: polygon)
+ delisted : Optional[date]
+ The date the item was delisted. (provider: polygon)
Examples
--------
>>> from openbb import obb
- >>> obb.currency.search(provider='intrinio')
- >>> # Search for 'EURUSD' currency pair using 'intrinio' as provider.
- >>> obb.currency.search(provider='intrinio', symbol='EURUSD')
- >>> # Search for actively traded currency pairs on the queried date using 'polygon' as provider.
- >>> obb.currency.search(provider='polygon', date='2024-01-02', active=True)
+ >>> obb.currency.search(provider='fmp')
+ >>> # Search for 'EUR' currency pair using 'intrinio' as provider.
+ >>> obb.currency.search(provider='intrinio', query='EUR')
>>> # Search for terms using 'polygon' as provider.
- >>> obb.currency.search(provider='polygon', search='Euro zone')
+ >>> obb.currency.search(provider='polygon', query='Euro zone')
""" # noqa: E501
return self._run(
@@ -142,7 +128,9 @@ class ROUTER_currency(Container):
("fmp", "intrinio", "polygon"),
)
},
- standard_params={},
+ standard_params={
+ "query": query,
+ },
extra_params=kwargs,
)
)
diff --git a/openbb_platform/providers/fmp/openbb_fmp/models/currency_pairs.py b/openbb_platform/providers/fmp/openbb_fmp/models/currency_pairs.py
index b5c3f2cd561..23c2d9b37a5 100644
--- a/openbb_platform/providers/fmp/openbb_fmp/models/currency_pairs.py
+++ b/openbb_platform/providers/fmp/openbb_fmp/models/currency_pairs.py
@@ -1,5 +1,7 @@
"""FMP Currency Available Pairs Model."""
+# pylint: disable=unused-argument
+
from typing import Any, Dict, List, Optional
from openbb_core.provider.abstract.fetcher import Fetcher
@@ -7,7 +9,9 @@ from openbb_core.provider.standard_models.currency_pairs import (
CurrencyPairsData,
CurrencyPairsQueryParams,
)
+from openbb_core.provider.utils.errors import EmptyDataError
from openbb_fmp.utils.helpers import get_data_many
+from pandas import DataFrame
from pydantic import Field
@@ -53,7 +57,6 @@ class FMPCurrencyPairsFetcher(
) -> List[Dict]:
"""Return the raw data from the FMP endpoint."""
api_key = credentials.get("fmp_api_key") if credentials else ""
-
base_url = "https://financialmodelingprep.com/api/v3"
url = f"{base_url}/symbol/available-forex-currency-pairs?apikey={api_key}"
@@ -64,4 +67,20 @@ class FMPCurrencyPairsFetcher(
query: FMPCurrencyPairsQueryParams, data: List[Dict], **kwargs: Any
) -> List[FMPCurrencyPairsData]:
"""Return the transformed data."""
- return [FMPCurrencyPairsData.model_validate(d) for d in data]
+ if not data:
+ raise EmptyDataError("The request was returned empty.")
+ df = DataFrame(data)
+ if query.query:
+ df = df[
+ df["name"].str.contains(query.query, case=False)
+ | df["symbol"].str.contains(query.query, case=False)
+ | df["currency"].str.contains(query.query, case=False)
+ | df["stockExchange"].str.contains(query.query, case=False)
+ | df["exchangeShortName"].str.contains(query.query, case=False)
+ ]
+ if len(df) == 0:
+ raise EmptyDataError(
+ f"No results were found with the query supplied. -> {query.query}"
+ + " Hint: Names and descriptions are not searchable from FMP, try 3-letter symbols."
+ )
+ return [FMPCurrencyPairsData.model_validate(d) for d in df.to_dict("records")]
diff --git a/openbb_platform/providers/intrinio/openbb_intrinio/models/currency_pairs.py b/openbb_platform/providers/intrinio/openbb_intrinio/models/currency_pairs.py
index fb99b5e5af2..9c418c166dd 100644
--- a/openbb_platform/providers/intrinio/openbb_intrinio/models/currency_pairs.py
+++ b/openbb_platform/providers/intrinio/openbb_intrinio/models/currency_pairs.py
@@ -7,7 +7,9 @@ from openbb_core.provider.standard_models.currency_pairs import (
CurrencyPairsData,
CurrencyPairsQueryParams,
)
+from openbb_core.provider.utils.errors import EmptyDataError
from openbb_intrinio.utils.helpers import get_data_many
+from pandas import DataFrame
from pydantic import Field
@@ -21,9 +23,8 @@ class IntrinioCurrencyPairsQueryParams(CurrencyPairsQueryParams):
class IntrinioCurrencyPairsData(CurrencyPairsData):
"""Intrinio Currency Available Pairs Data."""
- __alias_dict__ = {"name": "code"}
+ __alias_dict__ = {"symbol": "code"}
- code: str = Field(description="Code of the currency pair.", alias="name")
base_currency: str = Field(
description="ISO 4217 currency code of the base currency."
)
@@ -56,7 +57,6 @@ class IntrinioCurrencyPairsFetcher(
base_url = "https://api-v2.intrinio.com"
url = f"{base_url}/forex/pairs?api_key={api_key}"
-
return await get_data_many(url, "pairs", **kwargs)
@staticmethod
@@ -64,4 +64,21 @@ class IntrinioCurrencyPairsFetcher(
query: IntrinioCurrencyPairsQueryParams, data: List[Dict], **kwargs: Any
) -> List[IntrinioCurrencyPairsData]:
"""Return the transformed data."""
- return [IntrinioCurrencyPairsData.model_validate(d) for d in data]
+ if not data:
+ raise EmptyDataError("The request was returned empty.")
+ df = DataFrame(data)
+ if query.query:
+ df = df[
+ df["code"].str.contains(query.query, case=False)
+ | df["base_currency"].str.contains(query.query, case=False)
+ | df["quote_currency"].str.contains(query.query, case=False)
+ ]
+ if len(df) == 0:
+ raise EmptyDataError(
+ f"No results were found with the query supplied. -> {query.query}"
+ + " Hint: Names and descriptions are not searchable from Intrinio, try 3-letter symbols."
+ )
+ return [
+ IntrinioCurrencyPairsData.model_validate(d)
+ for d in df.to_dict(orient="records")
+ ]
diff --git a/openbb_platform/providers/polygon/openbb_polygon/models/currency_pairs.py b/openbb_platform/providers/polygon/openbb_polygon/models/currency_pairs.py
index 28ee909d701..83cb753b64c 100644
--- a/openbb_platform/providers/polygon/openbb_polygon/models/currency_pairs.py
+++ b/openbb_platform/providers/polygon/openbb_polygon/models/currency_pairs.py
@@ -1,19 +1,22 @@
"""Polygon Currency Available Pairs Model."""
+# pylint: disable=unused-argument
+
from datetime import (
date as dateType,
datetime,
)
-from typing import Any, Dict, List, Literal, Optional
+from typing import Any, Dict, List, Optional
from openbb_core.provider.abstract.fetcher import Fetcher
from openbb_core.provider.standard_models.currency_pairs import (
CurrencyPairsData,
CurrencyPairsQueryParams,
)
-from openbb_core.provider.utils.descriptions import QUERY_DESCRIPTIONS
+from openbb_core.provider.utils.errors import EmptyDataError
from openbb_polygon.utils.helpers import get_data
-from pydantic import Field, PositiveInt, field_validator
+from pandas import DataFrame
+from pydantic import Field, field_validator
class PolygonCurrencyPairsQueryParams(CurrencyPairsQueryParams):
@@ -22,75 +25,39 @@ class PolygonCurrencyPairsQueryParams(CurrencyPairsQueryParams):
Source: https://polygon.io/docs/forex/get_v3_reference_tickers
"""
- symbol: Optional[str] = Field(
- default=None, description="Symbol of the pair to search."
- )
- date: Optional[dateType] = Field(
- default=None, description=QUERY_DESCRIPTIONS.get("date", "")
- )
- search: Optional[str] = Field(
- default="",
- description="Search for terms within the ticker and/or company name.",
- )
- active: Optional[bool] = Field(
- default=True,
- description="Specify if the tickers returned should be actively traded on the queried date.",
- )
- order: Optional[Literal["asc", "desc"]] = Field(
- default="asc", description="Order data by ascending or descending."
- )
- sort: Optional[
- Literal[
- "ticker",
- "name",
- "market",
- "locale",
- "currency_symbol",
- "currency_name",
- "base_currency_symbol",
- "base_currency_name",
- "last_updated_utc",
- "delisted_utc",
- ]
- ] = Field(default=None, description="Sort field used for ordering.")
- limit: Optional[PositiveInt] = Field(
- default=1000, description=QUERY_DESCRIPTIONS.get("limit", "")
- )
-
class PolygonCurrencyPairsData(CurrencyPairsData):
"""Polygon Currency Available Pairs Data."""
- market: str = Field(description="Name of the trading market. Always 'fx'.")
- locale: str = Field(description="Locale of the currency pair.")
+ __alias_dict__ = {
+ "last_updated": "last_updated_utc",
+ "delisted": "delisted_utc",
+ "name": "currency_name",
+ "symbol": "ticker",
+ }
currency_symbol: Optional[str] = Field(
default=None, description="The symbol of the quote currency."
)
- currency_name: Optional[str] = Field(
- default=None, description="Name of the quote currency."
- )
base_currency_symbol: Optional[str] = Field(
default=None, description="The symbol of the base currency."
)
base_currency_name: Optional[str] = Field(
default=None, description="Name of the base currency."
)
- last_updated_utc: datetime = Field(description="The last updated timestamp in UTC.")
- delisted_utc: Optional[datetime] = Field(
- default=None, description="The delisted timestamp in UTC."
+ market: str = Field(description="Name of the trading market. Always 'fx'.")
+ locale: str = Field(description="Locale of the currency pair.")
+ last_updated: Optional[dateType] = Field(
+ default=None, description="The date the reference data was last updated."
+ )
+ delisted: Optional[dateType] = Field(
+ default=None, description="The date the item was delisted."
)
- @field_validator("last_updated_utc", mode="before", check_fields=False)
+ @field_validator("last_updated", "delisted", mode="before", check_fields=False)
@classmethod
def last_updated_utc_validate(cls, v): # pylint: disable=E0213
"""Return the parsed last updated timestamp in UTC."""
- return datetime.strptime(v, "%Y-%m-%dT%H:%M:%SZ")
-
- @field_validator("delisted_utc", mode="before", check_fields=False)
- @classmethod
- def delisted_utc_validate(cls, v): # pylint: disable=E0213
- """Return the parsed delisted timestamp in UTC."""
- return datetime.strptime(v, "%Y-%m-%dT%H:%M:%SZ")
+ return datetime.strptime(v, "%Y-%m-%dT%H:%M:%SZ").date() if v else None
class PolygonCurrencyPairsFetcher(
@@ -99,51 +66,36 @@ class PolygonCurrencyPairsFetcher(
List[PolygonCurrencyPairsData],
]
):
- """Transform the query, extract and transform the data from the Polygon endpoints."""
+ """Po