Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Replace Optional[bool] with bool as type in Equity Search #6633

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ class EquitySearchQueryParams(QueryParams):
is_symbol: bool = Field(
description="Whether to search by ticker symbol.", default=False
)
use_cache: Optional[bool] = Field(
default=True,
description="Whether to use the cache or not.",
)


class EquitySearchData(Data):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ def test_equity_fundamental_latest_attributes(params, headers):
[
({"query": "AAPl", "is_symbol": True, "provider": "cboe", "use_cache": False}),
({"query": "Apple", "provider": "sec", "use_cache": False, "is_fund": False}),
({"query": "", "provider": "nasdaq", "use_cache": False, "is_etf": True}),
({"query": "", "provider": "nasdaq", "is_etf": True}),
({"query": "gold", "provider": "tmx", "use_cache": False}),
({"query": "gold", "provider": "tradier", "is_symbol": False}),
(
Expand All @@ -1400,7 +1400,6 @@ def test_equity_fundamental_latest_attributes(params, headers):
"provider": "intrinio",
"active": True,
"limit": 100,
"use_cache": None,
}
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ def test_equity_fundamental_latest_attributes(params, obb):
[
({"query": "AAPL", "is_symbol": True, "provider": "cboe", "use_cache": False}),
({"query": "Apple", "provider": "sec", "use_cache": False, "is_fund": False}),
({"query": "", "provider": "nasdaq", "use_cache": False, "is_etf": True}),
({"query": "", "provider": "nasdaq", "is_etf": True}),
({"query": "gold", "provider": "tmx", "use_cache": False}),
({"query": "gold", "provider": "tradier", "is_symbol": False}),
(
Expand All @@ -1338,7 +1338,6 @@ def test_equity_fundamental_latest_attributes(params, obb):
"provider": "intrinio",
"active": True,
"limit": 100,
"use_cache": None,
}
),
],
Expand Down
16 changes: 8 additions & 8 deletions openbb_platform/openbb/assets/reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -25749,14 +25749,6 @@
"default": false,
"optional": true,
"choices": null
},
{
"name": "use_cache",
"type": "bool",
"description": "Whether to use the cache or not.",
"default": true,
"optional": true,
"choices": null
}
],
"intrinio": [
Expand All @@ -25778,6 +25770,14 @@
}
],
"sec": [
{
"name": "use_cache",
"type": "bool",
"description": "Whether to use the cache or not.",
"default": true,
"optional": true,
"choices": null
},
{
"name": "is_fund",
"type": "bool",
Expand Down
10 changes: 3 additions & 7 deletions openbb_platform/openbb/package/equity.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,9 +662,6 @@ def search(
is_symbol: Annotated[
bool, OpenBBField(description="Whether to search by ticker symbol.")
] = False,
use_cache: Annotated[
Optional[bool], OpenBBField(description="Whether to use the cache or not.")
] = True,
provider: Annotated[
Optional[Literal["intrinio", "sec"]],
OpenBBField(
Expand All @@ -681,14 +678,14 @@ def search(
Search query.
is_symbol : bool
Whether to search by ticker symbol.
use_cache : Optional[bool]
Whether to use the cache or not.
provider : Optional[Literal['intrinio', 'sec']]
The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: intrinio, sec.
active : Optional[bool]
active : bool
When true, return companies that are actively traded (having stock prices within the past 14 days). When false, return companies that are not actively traded or never have been traded. (provider: intrinio)
limit : Optional[int]
The number of data entries to return. (provider: intrinio)
use_cache : bool
Whether to use the cache or not. (provider: sec)
is_fund : bool
Whether to direct the search to the list of mutual funds and ETFs. (provider: sec)

Expand Down Expand Up @@ -739,7 +736,6 @@ def search(
standard_params={
"query": query,
"is_symbol": is_symbol,
"use_cache": use_cache,
},
extra_params=kwargs,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class CboeEquitySearchQueryParams(EquitySearchQueryParams):
Source: https://www.cboe.com/
"""

use_cache: bool = Field(
default=True,
description="Whether to use the cache or not.",
)


class CboeEquitySearchData(EquitySearchData):
"""CBOE Equity Search Data."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class IntrinioEquitySearchQueryParams(EquitySearchQueryParams):
"limit": "page_size",
}

active: Optional[bool] = Field(
active: bool = Field(
default=True,
description="When true, return companies that are actively traded (having stock prices within the past 14 days)."
+ " When false, return companies that are not actively traded or never have been traded.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interactions:
Connection:
- keep-alive
method: GET
uri: https://api-v2.intrinio.com/companies/search?active=True&api_key=MOCK_API_KEY&page_size=100&query=gold&use_cache=True
uri: https://api-v2.intrinio.com/companies/search?active=True&api_key=MOCK_API_KEY&page_size=100&query=gold
response:
body:
string: !!binary |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interactions:
Connection:
- keep-alive
method: GET
uri: https://api-v2.intrinio.com/companies/search?active=True&api_key=MOCK_API_KEY&page_size=100&query=gold&use_cache=True
uri: https://api-v2.intrinio.com/companies/search?active=True&api_key=MOCK_API_KEY&page_size=100&query=gold
response:
body:
string: !!binary |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# pylint: disable=unused-argument

from typing import Any, Dict, List, Optional
from typing import Any, Dict, List, Optional, Union

from openbb_core.app.model.abstract.error import OpenBBError
from openbb_core.provider.abstract.fetcher import Fetcher
Expand All @@ -19,7 +19,7 @@ class NasdaqEquitySearchQueryParams(EquitySearchQueryParams):
Source: https://www.nasdaqtrader.com/dynamic/SymDir/nasdaqtraded.txt
"""

is_etf: Optional[bool] = Field(
is_etf: Union[bool, None] = Field(
default=None,
description="If True, returns ETFs.",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class SecEquitySearchQueryParams(EquitySearchQueryParams):
Source: https://sec.gov/
"""

use_cache: bool = Field(
default=True,
description="Whether to use the cache or not.",
)
is_fund: bool = Field(
default=False,
description="Whether to direct the search to the list of mutual funds and ETFs.",
Expand Down
Loading