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] FMP Screener - Convert sector param choices to lower_snake_case #6432

Merged
merged 8 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -1421,7 +1421,7 @@ def test_equity_search(params, headers):
(
{
"industry": "REIT",
"sector": "Real Estate",
"sector": "real_estate",
"mktcap_min": None,
"mktcap_max": None,
"price_min": None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ def test_equity_search(params, obb):
(
{
"industry": "REIT",
"sector": "Real Estate",
"sector": "real_estate",
"mktcap_min": None,
"mktcap_max": None,
"price_min": None,
Expand Down
18 changes: 9 additions & 9 deletions openbb_platform/openbb/assets/reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -5794,24 +5794,24 @@
},
{
"name": "analyst_ids",
"type": "Union[List[str], str]",
"description": "Comma-separated list of analyst (person) IDs. Omitting will bring back all available analysts.",
"type": "Union[Union[List[str], str], List[Union[List[str], str]]]",
"description": "Comma-separated list of analyst (person) IDs. Omitting will bring back all available analysts. Multiple items allowed for provider(s): benzinga.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "firm_ids",
"type": "Union[List[str], str]",
"description": "Comma-separated list of firm IDs.",
"type": "Union[Union[List[str], str], List[Union[List[str], str]]]",
"description": "Comma-separated list of firm IDs. Multiple items allowed for provider(s): benzinga.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "fields",
"type": "Union[List[str], str]",
"description": "Comma-separated list of fields to include in the response. See https://docs.benzinga.io/benzinga-apis/calendar/get-ratings to learn about the available fields.",
"type": "Union[Union[List[str], str], List[Union[List[str], str]]]",
"description": "Comma-separated list of fields to include in the response. See https://docs.benzinga.io/benzinga-apis/calendar/get-ratings to learn about the available fields. Multiple items allowed for provider(s): benzinga.",
"default": null,
"optional": true,
"choices": null
Expand Down Expand Up @@ -18380,7 +18380,7 @@
},
{
"name": "form_type",
"type": "Literal['1', '1-A', '1-A POS', '1-A-W', '1-E', '1-E AD', '1-K', '1-SA', '1-U', '1-Z', '1-Z-W', '10-12B', '10-12G', '10-D', '10-K', '10-KT', '10-Q', '10-QT', '11-K', '11-KT', '13F-HR', '13F-NT', '13FCONP', '144', '15-12B', '15-12G', '15-15D', '15F-12B', '15F-12G', '15F-15D', '18-12B', '18-K', '19B-4E', '2-A', '2-AF', '2-E', '20-F', '20FR12B', '20FR12G', '24F-2NT', '25', '25-NSE', '253G1', '253G2', '253G3', '253G4', '3', '305B2', '34-12H', '4', '40-17F1', '40-17F2', '40-17G', '40-17GCS', '40-202A', '40-203A', '40-206A', '40-24B2', '40-33', '40-6B', '40-8B25', '40-8F-2', '40-APP', '40-F', '40-OIP', '40FR12B', '40FR12G', '424A', '424B1', '424B2', '424B3', '424B4', '424B5', '424B7', '424B8', '424H', '425', '485APOS', '485BPOS', '485BXT', '486APOS', '486BPOS', '486BXT', '487', '497', '497AD', '497H2', '497J', '497K', '497VPI', '497VPU', '5', '6-K', '6B NTC', '6B ORDR', '8-A12B', '8-A12G', '8-K', '8-K12B', '8-K12G3', '8-K15D5', '8-M', '8F-2 NTC', '8F-2 ORDR', '9-M', 'ABS-15G', 'ABS-EE', 'ADN-MTL', 'ADV-E', 'ADV-H-C', 'ADV-H-T', 'ADV-NR', 'ANNLRPT', 'APP NTC', 'APP ORDR', 'APP WD', 'APP WDG', 'ARS', 'ATS-N', 'ATS-N-C', 'ATS-N/UA', 'AW', 'AW WD', 'C', 'C-AR', 'C-AR-W', 'C-TR', 'C-TR-W', 'C-U', 'C-U-W', 'C-W', 'CB', 'CERT', 'CERTARCA', 'CERTBATS', 'CERTCBO', 'CERTNAS', 'CERTNYS', 'CERTPAC', 'CFPORTAL', 'CFPORTAL-W', 'CORRESP', 'CT ORDER', 'D', 'DEF 14A', 'DEF 14C', 'DEFA14A', 'DEFA14C', 'DEFC14A', 'DEFC14C', 'DEFM14A', 'DEFM14C', 'DEFN14A', 'DEFR14A', 'DEFR14C', 'DEL AM', 'DFAN14A', 'DFRN14A', 'DOS', 'DOSLTR', 'DRS', 'DRSLTR', 'DSTRBRPT', 'EFFECT', 'F-1', 'F-10', 'F-10EF', 'F-10POS', 'F-1MEF', 'F-3', 'F-3ASR', 'F-3D', 'F-3DPOS', 'F-3MEF', 'F-4', 'F-4 POS', 'F-4MEF', 'F-6', 'F-6 POS', 'F-6EF', 'F-7', 'F-7 POS', 'F-8', 'F-8 POS', 'F-80', 'F-80POS', 'F-9', 'F-9 POS', 'F-N', 'F-X', 'FOCUSN', 'FWP', 'G-405', 'G-405N', 'G-FIN', 'G-FINW', 'IRANNOTICE', 'MA', 'MA-A', 'MA-I', 'MA-W', 'MSD', 'MSDCO', 'MSDW', 'N-1', 'N-14', 'N-14 8C', 'N-14MEF', 'N-18F1', 'N-1A', 'N-2', 'N-2 POSASR', 'N-23C-2', 'N-23C3A', 'N-23C3B', 'N-23C3C', 'N-2ASR', 'N-2MEF', 'N-30B-2', 'N-30D', 'N-4', 'N-5', 'N-54A', 'N-54C', 'N-6', 'N-6F', 'N-8A', 'N-8B-2', 'N-8F', 'N-8F NTC', 'N-8F ORDR', 'N-CEN', 'N-CR', 'N-CSR', 'N-CSRS', 'N-MFP', 'N-MFP1', 'N-MFP2', 'N-PX', 'N-Q', 'N-VP', 'N-VPFS', 'NO ACT', 'NPORT-EX', 'NPORT-NP', 'NPORT-P', 'NRSRO-CE', 'NRSRO-UPD', 'NSAR-A', 'NSAR-AT', 'NSAR-B', 'NSAR-BT', 'NSAR-U', 'NT 10-D', 'NT 10-K', 'NT 10-Q', 'NT 11-K', 'NT 20-F', 'NT N-CEN', 'NT N-MFP', 'NT N-MFP1', 'NT N-MFP2', 'NT NPORT-EX', 'NT NPORT-P', 'NT-NCEN', 'NT-NCSR', 'NT-NSAR', 'NTFNCEN', 'NTFNCSR', 'NTFNSAR', 'NTN 10D', 'NTN 10K', 'NTN 10Q', 'NTN 20F', 'OIP NTC', 'OIP ORDR', 'POS 8C', 'POS AM', 'POS AMI', 'POS EX', 'POS462B', 'POS462C', 'POSASR', 'PRE 14A', 'PRE 14C', 'PREC14A', 'PREC14C', 'PREM14A', 'PREM14C', 'PREN14A', 'PRER14A', 'PRER14C', 'PRRN14A', 'PX14A6G', 'PX14A6N', 'QRTLYRPT', 'QUALIF', 'REG-NR', 'REVOKED', 'RW', 'RW WD', 'S-1', 'S-11', 'S-11MEF', 'S-1MEF', 'S-20', 'S-3', 'S-3ASR', 'S-3D', 'S-3DPOS', 'S-3MEF', 'S-4', 'S-4 POS', 'S-4EF', 'S-4MEF', 'S-6', 'S-8', 'S-8 POS', 'S-B', 'S-BMEF', 'SBSE', 'SBSE-A', 'SBSE-BD', 'SBSE-C', 'SBSE-W', 'SC 13D', 'SC 13E1', 'SC 13E3', 'SC 13G', 'SC 14D9', 'SC 14F1', 'SC 14N', 'SC TO-C', 'SC TO-I', 'SC TO-T', 'SC13E4F', 'SC14D1F', 'SC14D9C', 'SC14D9F', 'SD', 'SDR', 'SE', 'SEC ACTION', 'SEC STAFF ACTION', 'SEC STAFF LETTER', 'SF-1', 'SF-3', 'SL', 'SP 15D2', 'STOP ORDER', 'SUPPL', 'T-3', 'TA-1', 'TA-2', 'TA-W', 'TACO', 'TH', 'TTW', 'UNDER', 'UPLOAD', 'WDL-REQ', 'X-17A-5']",
"type": "Literal['1', '1-A', '1-A_POS', '1-A-W', '1-E', '1-E_AD', '1-K', '1-SA', '1-U', '1-Z', '1-Z-W', '10-12B', '10-12G', '10-D', '10-K', '10-KT', '10-Q', '10-QT', '11-K', '11-KT', '13F-HR', '13F-NT', '13FCONP', '144', '15-12B', '15-12G', '15-15D', '15F-12B', '15F-12G', '15F-15D', '18-12B', '18-K', '19B-4E', '2-A', '2-AF', '2-E', '20-F', '20FR12B', '20FR12G', '24F-2NT', '25', '25-NSE', '253G1', '253G2', '253G3', '253G4', '3', '305B2', '34-12H', '4', '40-17F1', '40-17F2', '40-17G', '40-17GCS', '40-202A', '40-203A', '40-206A', '40-24B2', '40-33', '40-6B', '40-8B25', '40-8F-2', '40-APP', '40-F', '40-OIP', '40FR12B', '40FR12G', '424A', '424B1', '424B2', '424B3', '424B4', '424B5', '424B7', '424B8', '424H', '425', '485APOS', '485BPOS', '485BXT', '486APOS', '486BPOS', '486BXT', '487', '497', '497AD', '497H2', '497J', '497K', '497VPI', '497VPU', '5', '6-K', '6B_NTC', '6B_ORDR', '8-A12B', '8-A12G', '8-K', '8-K12B', '8-K12G3', '8-K15D5', '8-M', '8F-2_NTC', '8F-2_ORDR', '9-M', 'ABS-15G', 'ABS-EE', 'ADN-MTL', 'ADV-E', 'ADV-H-C', 'ADV-H-T', 'ADV-NR', 'ANNLRPT', 'APP_NTC', 'APP_ORDR', 'APP_WD', 'APP_WDG', 'ARS', 'ATS-N', 'ATS-N-C', 'ATS-N/UA', 'AW', 'AW_WD', 'C', 'C-AR', 'C-AR-W', 'C-TR', 'C-TR-W', 'C-U', 'C-U-W', 'C-W', 'CB', 'CERT', 'CERTARCA', 'CERTBATS', 'CERTCBO', 'CERTNAS', 'CERTNYS', 'CERTPAC', 'CFPORTAL', 'CFPORTAL-W', 'CORRESP', 'CT ORDER', 'D', 'DEF_14A', 'DEF_14C', 'DEFA14A', 'DEFA14C', 'DEFC14A', 'DEFC14C', 'DEFM14A', 'DEFM14C', 'DEFN14A', 'DEFR14A', 'DEFR14C', 'DEL_AM', 'DFAN14A', 'DFRN14A', 'DOS', 'DOSLTR', 'DRS', 'DRSLTR', 'DSTRBRPT', 'EFFECT', 'F-1', 'F-10', 'F-10EF', 'F-10POS', 'F-1MEF', 'F-3', 'F-3ASR', 'F-3D', 'F-3DPOS', 'F-3MEF', 'F-4', 'F-4_POS', 'F-4MEF', 'F-6', 'F-6_POS', 'F-6EF', 'F-7', 'F-7_POS', 'F-8', 'F-8_POS', 'F-80', 'F-80POS', 'F-9', 'F-9_POS', 'F-N', 'F-X', 'FOCUSN', 'FWP', 'G-405', 'G-405N', 'G-FIN', 'G-FINW', 'IRANNOTICE', 'MA', 'MA-A', 'MA-I', 'MA-W', 'MSD', 'MSDCO', 'MSDW', 'N-1', 'N-14', 'N-14_8C', 'N-14MEF', 'N-18F1', 'N-1A', 'N-2', 'N-2_POSASR', 'N-23C-2', 'N-23C3A', 'N-23C3B', 'N-23C3C', 'N-2ASR', 'N-2MEF', 'N-30B-2', 'N-30D', 'N-4', 'N-5', 'N-54A', 'N-54C', 'N-6', 'N-6F', 'N-8A', 'N-8B-2', 'N-8F', 'N-8F_NTC', 'N-8F_ORDR', 'N-CEN', 'N-CR', 'N-CSR', 'N-CSRS', 'N-MFP', 'N-MFP1', 'N-MFP2', 'N-PX', 'N-Q', 'N-VP', 'N-VPFS', 'NO_ACT', 'NPORT-EX', 'NPORT-NP', 'NPORT-P', 'NRSRO-CE', 'NRSRO-UPD', 'NSAR-A', 'NSAR-AT', 'NSAR-B', 'NSAR-BT', 'NSAR-U', 'NT_10-D', 'NT_10-K', 'NT_10-Q', 'NT_11-K', 'NT_20-F', 'NT_N-CEN', 'NT_N-MFP', 'NT_N-MFP1', 'NT_N-MFP2', 'NT_NPORT-EX', 'NT_NPORT-P', 'NT-NCEN', 'NT-NCSR', 'NT-NSAR', 'NTFNCEN', 'NTFNCSR', 'NTFNSAR', 'NTN_10D', 'NTN_10K', 'NTN_10Q', 'NTN_20F', 'OIP_NTC', 'OIP_ORDR', 'POS_8C', 'POS_AM', 'POS_AMI', 'POS_EX', 'POS462B', 'POS462C', 'POSASR', 'PRE_14A', 'PRE_14C', 'PREC14A', 'PREC14C', 'PREM14A', 'PREM14C', 'PREN14A', 'PRER14A', 'PRER14C', 'PRRN14A', 'PX14A6G', 'PX14A6N', 'QRTLYRPT', 'QUALIF', 'REG-NR', 'REVOKED', 'RW', 'RW_WD', 'S-1', 'S-11', 'S-11MEF', 'S-1MEF', 'S-20', 'S-3', 'S-3ASR', 'S-3D', 'S-3DPOS', 'S-3MEF', 'S-4', 'S-4_POS', 'S-4EF', 'S-4MEF', 'S-6', 'S-8', 'S-8_POS', 'S-B', 'S-BMEF', 'SBSE', 'SBSE-A', 'SBSE-BD', 'SBSE-C', 'SBSE-W', 'SC_13D', 'SC_13E1', 'SC_13E3', 'SC_13G', 'SC_14D9', 'SC_14F1', 'SC_14N', 'SC_TO-C', 'SC_TO-I', 'SC_TO-T', 'SC13E4F', 'SC14D1F', 'SC14D9C', 'SC14D9F', 'SD', 'SDR', 'SE', 'SEC_ACTION', 'SEC_STAFF_ACTION', 'SEC_STAFF_LETTER', 'SF-1', 'SF-3', 'SL', 'SP_15D2', 'STOP_ORDER', 'SUPPL', 'T-3', 'TA-1', 'TA-2', 'TA-W', 'TACO', 'TH', 'TTW', 'UNDER', 'UPLOAD', 'WDL-REQ', 'X-17A-5']",
"description": "Type of the SEC filing form.",
"default": null,
"optional": true,
Expand Down Expand Up @@ -19741,7 +19741,7 @@
"fmp": [
{
"name": "transaction_type",
"type": "Literal[None, 'award', 'conversion', 'return', 'expire_short', 'in_kind', 'gift', 'expire_long', 'discretionary', 'other', 'small', 'exempt', 'otm', 'purchase', 'sale', 'tender', 'will', 'itm', 'trust']",
"type": "Literal['award', 'conversion', 'return', 'expire_short', 'in_kind', 'gift', 'expire_long', 'discretionary', 'other', 'small', 'exempt', 'otm', 'purchase', 'sale', 'tender', 'will', 'itm', 'trust']",
"description": "Type of the transaction.",
"default": null,
"optional": true,
Expand Down Expand Up @@ -22325,7 +22325,7 @@
},
{
"name": "sector",
"type": "Literal['Consumer Cyclical', 'Energy', 'Technology', 'Industrials', 'Financial Services', 'Basic Materials', 'Communication Services', 'Consumer Defensive', 'Healthcare', 'Real Estate', 'Utilities', 'Industrial Goods', 'Financial', 'Services', 'Conglomerates']",
"type": "Literal['consumer_cyclical', 'energy', 'technology', 'industrials', 'financial_services', 'basic_materials', 'communication_services', 'consumer_defensive', 'healthcare', 'real_estate', 'utilities', 'industrial_goods', 'financial', 'services', 'conglomerates']",
"description": "Filter by sector.",
"default": null,
"optional": true,
Expand Down
2 changes: 1 addition & 1 deletion openbb_platform/openbb/package/equity.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def screener(
If true, returns only ETFs. (provider: fmp)
is_active : Optional[bool]
If false, returns only inactive tickers. (provider: fmp)
sector : Optional[Literal['Consumer Cyclical', 'Energy', 'Technology', 'Industrials', 'Financial Services', 'Basic Materials', 'Communication Services', 'Consumer Defensive', 'Healthcare', 'Real Estate', 'Utilities', 'Industrial Goods', 'Financial', 'Services', 'Conglomerates']]
sector : Optional[Literal['consumer_cyclical', 'energy', 'technology', 'industrials', 'financial_services', 'basic_materials', 'communication_services', 'consumer_defensive', 'healthcare', 'real_estate', 'utilities', 'industrial_goods', 'financial', 'services', 'conglomerates']]
Filter by sector. (provider: fmp)
industry : Optional[str]
Filter by industry. (provider: fmp)
Expand Down
13 changes: 8 additions & 5 deletions openbb_platform/openbb/package/equity_estimates.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,11 +849,11 @@ def price_target(
action : Optional[Literal['downgrades', 'maintains', 'reinstates', 'reiterates', 'upgrades', 'assumes', 'initiates', 'terminates', 'removes', 'suspends', 'firm_dissolved']]
Filter by a specific action_company. (provider: benzinga)
analyst_ids : Optional[Union[List[str], str]]
Comma-separated list of analyst (person) IDs. Omitting will bring back all available analysts. (provider: benzinga)
Comma-separated list of analyst (person) IDs. Omitting will bring back all available analysts. Multiple comma separated items allowed. (provider: benzinga)
firm_ids : Optional[Union[List[str], str]]
Comma-separated list of firm IDs. (provider: benzinga)
Comma-separated list of firm IDs. Multiple comma separated items allowed. (provider: benzinga)
fields : Optional[Union[List[str], str]]
Comma-separated list of fields to include in the response. See https://docs.benzinga.io/benzinga-apis/calendar/get-ratings to learn about the available fields. (provider: benzinga)
Comma-separated list of fields to include in the response. See https://docs.benzinga.io/benzinga-apis/calendar/get-ratings to learn about the available fields. Multiple comma separated items allowed. (provider: benzinga)
with_grade : bool
Include upgrades and downgrades in the response. (provider: fmp)

Expand Down Expand Up @@ -955,9 +955,12 @@ def price_target(
extra_params=kwargs,
info={
"symbol": {
"benzinga": {"multiple_items_allowed": True},
"benzinga": ["multiple_items_allowed"],
"fmp": {"multiple_items_allowed": True},
}
},
"analyst_ids": {"benzinga": ["multiple_items_allowed"]},
"firm_ids": {"benzinga": ["multiple_items_allowed"]},
"fields": {"benzinga": ["multiple_items_allowed"]},
},
)
)
2 changes: 1 addition & 1 deletion openbb_platform/openbb/package/equity_ownership.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def insider_trading(
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.
transaction_type : Literal[None, 'award', 'conversion', 'return', 'expire_short', 'in_kind', 'gift', 'expire_long', 'discretionary', 'other', 'small', 'exempt', 'otm', 'purchase', 'sale', 'tender', 'will', 'itm', 'trust']
transaction_type : Optional[Literal['award', 'conversion', 'return', 'expire_short', 'in_kind', 'gift', 'expire_long', 'discretionary', 'other', 'small', 'exempt', 'otm', 'purchase', 'sale', 'tender', 'will', 'itm', 'trust']]
Type of the transaction. (provider: fmp)
start_date : Optional[datetime.date]
Start date of the data, in YYYY-MM-DD format. (provider: intrinio)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,21 @@ class BenzingaPriceTargetQueryParams(PriceTargetQueryParams):
__alias_dict__ = {
"limit": "pagesize",
"symbol": "parameters[tickers]",
"date": "parameters[date]",
"start_date": "parameters[date_from]",
"end_date": "parameters[date_to]",
"updated": "parameters[updated]",
"importance": "parameters[importance]",
"action": "parameters[action]",
"analyst_ids": "parameters[analyst_id]",
"firm_ids": "parameters[firm_id]",
}
__json_schema_extra__ = {
"symbol": ["multiple_items_allowed"],
"analyst_ids": ["multiple_items_allowed"],
"firm_ids": ["multiple_items_allowed"],
"fields": ["multiple_items_allowed"],
}
__json_schema_extra__ = {"symbol": {"multiple_items_allowed": True}}

page: Optional[int] = Field(
default=0,
Expand All @@ -60,31 +73,26 @@ class BenzingaPriceTargetQueryParams(PriceTargetQueryParams):
date: Optional[dateType] = Field(
default=None,
description="Date for calendar data, shorthand for date_from and date_to.",
alias="parameters[date]",
)
start_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("start_date", ""),
alias="parameters[date_from]",
)
end_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("end_date", ""),
alias="parameters[date_to]",
)
updated: Optional[Union[dateType, int]] = Field(
default=None,
description="Records last Updated Unix timestamp (UTC)."
+ " This will force the sort order to be Greater Than or Equal to the timestamp indicated."
+ " The date can be a date string or a Unix timestamp."
+ " The date string must be in the format of YYYY-MM-DD.",
alias="parameters[updated]",
)
importance: Optional[int] = Field(
default=None,
description="Importance level to filter by."
+ " Uses Greater Than or Equal To the importance indicated",
alias="parameters[importance]",
)
action: Optional[
Literal[
Expand All @@ -103,18 +111,15 @@ class BenzingaPriceTargetQueryParams(PriceTargetQueryParams):
] = Field(
default=None,
description="Filter by a specific action_company.",
alias="parameters[action]",
)
analyst_ids: Optional[Union[List[str], str]] = Field(
default=None,
description="Comma-separated list of analyst (person) IDs."
+ " Omitting will bring back all available analysts.",
alias="parameters[analyst_id]",
)
firm_ids: Optional[Union[List[str], str]] = Field(
default=None,
description="Comma-separated list of firm IDs.",
alias="parameters[firm_id]",
)
fields: Optional[Union[List[str], str]] = Field(
default=None,
Expand Down
14 changes: 10 additions & 4 deletions openbb_platform/providers/fmp/openbb_fmp/models/equity_screener.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""FMP Equity Screener Model."""

# pylint: disable=unused-argument
from copy import deepcopy
from typing import Any, Dict, List, Literal, Optional

import pandas as pd
Expand All @@ -8,6 +10,7 @@
EquityScreenerData,
EquityScreenerQueryParams,
)
from openbb_core.provider.utils.errors import EmptyDataError
from openbb_fmp.utils.definitions import EXCHANGES, SECTORS
from openbb_fmp.utils.helpers import create_url, get_data
from pydantic import Field
Expand Down Expand Up @@ -162,23 +165,26 @@ async def aextract_data(
) -> List[Dict]:
"""Return the raw data from the FMP endpoint."""
api_key = credentials.get("fmp_api_key") if credentials else ""
_query = deepcopy(query)
if _query.sector is not None:
_query.sector = _query.sector.replace("_", " ").title()
url = create_url(
version=3,
endpoint="stock-screener",
api_key=api_key,
query=query,
query=_query,
exclude=["query", "is_symbol", "industry"],
).replace(" ", "%20")
return await get_data(url, **kwargs)
return await get_data(url, **kwargs) # type: ignore

@staticmethod
def transform_data(
query: FMPEquityScreenerQueryParams, data: List[Dict], **kwargs: Any
) -> List[FMPEquityScreenerData]:
"""Return the transformed data."""
if not data:
raise EmptyDataError("The request was returned empty.")
results = pd.DataFrame(data)
if len(results) == 0:
return []
if query.industry:
results = results[
results["sector"].str.contains(query.industry, case=False)
Expand Down
Loading
Loading