Skip to content

Commit

Permalink
[BugFix] Fix Currency Search (#6380)
Browse files Browse the repository at this point in the history
* fix currency search

* test artifact

* static files
  • Loading branch information
deeleeramone authored May 9, 2024
1 parent 1a49dfd commit 4d6074d
Show file tree
Hide file tree
Showing 11 changed files with 562 additions and 631 deletions.
Original file line number Diff line number Diff line change
@@ -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.")
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,14 @@
@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"},
),
],
)
Expand Down
133 changes: 38 additions & 95 deletions openbb_platform/openbb/assets/reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,16 @@
"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']",
Expand All @@ -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": [
Expand Down Expand Up @@ -673,21 +630,21 @@
"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",
Expand All @@ -711,13 +668,6 @@
}
],
"intrinio": [
{
"name": "code",
"type": "str",
"description": "Code of the currency pair.",
"default": "",
"optional": false
},
{
"name": "base_currency",
"type": "str",
Expand All @@ -734,34 +684,13 @@
}
],
"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.",
"default": null,
"optional": true
},
{
"name": "currency_name",
"type": "str",
"description": "Name of the quote currency.",
"default": null,
"optional": true
},
{
"name": "base_currency_symbol",
"type": "str",
Expand All @@ -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
}
Expand Down
Loading

0 comments on commit 4d6074d

Please sign in to comment.