diff --git a/openbb_platform/providers/intrinio/openbb_intrinio/models/equity_quote.py b/openbb_platform/providers/intrinio/openbb_intrinio/models/equity_quote.py index b41de65ef35..64ae93f2a0c 100644 --- a/openbb_platform/providers/intrinio/openbb_intrinio/models/equity_quote.py +++ b/openbb_platform/providers/intrinio/openbb_intrinio/models/equity_quote.py @@ -1,5 +1,6 @@ """Intrinio Equity Quote fetcher.""" +from concurrent.futures import ThreadPoolExecutor from datetime import datetime from typing import Any, Dict, List, Optional @@ -103,7 +104,7 @@ class IntrinioEquityQuoteData(EquityQuoteData): class IntrinioEquityQuoteFetcher( Fetcher[ IntrinioEquityQuoteQueryParams, - IntrinioEquityQuoteData, + List[IntrinioEquityQuoteData], ] ): """Transform the query, extract and transform the data from the Intrinio endpoints.""" @@ -118,18 +119,26 @@ class IntrinioEquityQuoteFetcher( query: IntrinioEquityQuoteQueryParams, credentials: Optional[Dict[str, str]], **kwargs: Any, - ) -> Dict: + ) -> List[Dict]: """Return the raw data from the Intrinio endpoint.""" api_key = credentials.get("intrinio_api_key") if credentials else "" + results: List[Dict] = [] - base_url = "https://api-v2.intrinio.com" - url = f"{base_url}/securities/{query.symbol}/prices/realtime?source={query.source}&api_key={api_key}" + def get_data(symbol): + base_url = "https://api-v2.intrinio.com" + url = f"{base_url}/securities/{symbol}/prices/realtime?source={query.source}&api_key={api_key}" + data = get_data_one(url, **kwargs) + data["symbol"] = symbol + results.append(data) - return get_data_one(url, **kwargs) + with ThreadPoolExecutor() as executor: + executor.map(get_data, [s.strip() for s in query.symbol.split(",")]) + + return results @staticmethod def transform_data( query: IntrinioEquityQuoteQueryParams, data: dict, **kwargs: Any - ) -> IntrinioEquityQuoteData: + ) -> List[IntrinioEquityQuoteData]: """Return the transformed data.""" - return IntrinioEquityQuoteData.model_validate(data) + return [IntrinioEquityQuoteData.model_validate(d) for d in data] diff --git a/openbb_platform/providers/intrinio/tests/record/http/test_intrinio_fetchers/test_intrinio_equity_quote_fetcher.yaml b/openbb_platform/providers/intrinio/tests/record/http/test_intrinio_fetchers/test_intrinio_equity_quote_fetcher.yaml index 2e1792cc16d..e3b93f77ad0 100644 --- a/openbb_platform/providers/intrinio/tests/record/http/test_intrinio_fetchers/test_intrinio_equity_quote_fetcher.yaml +++ b/openbb_platform/providers/intrinio/tests/record/http/test_intrinio_fetchers/test_intrinio_equity_quote_fetcher.yaml @@ -13,13 +13,13 @@ interactions: response: body: string: !!binary | - H4sIADYrLWUAA3xRTU/CQBD9K5s5F7ItFLQ3OGhMPBij8TvN2h3KwLJbu1sQjf/daQQDNfE4782b - eTPvE1bovSrRQ/YEK1UvMeQF2oB1JAz5QLbM12gbjIRXBn1eOKspkLM+Espq8da4gAeoUDUKZ81W - qLUio14Nig2FuXBNLTQatUUtPFVihqj78BKBUT7kVU0FQhaPx/3ByQ4LtGIIEpkMerHsxaObOMni - NBum/dM0fYRdm6ePVikjeCW9HyT7u/qH5UL55RHZ1r+kq9AeekhGERTGeewam1M5/2PWbbpafC/m - ypaYr51p2ivGvGT33j1kG2MiaCqtAurc2f9P9fy/dgMQvreXH2azn9VNiLufGyljPBOCNd2o9rKj - 2JnX7ZoLFpDPNXOVcwaymTIeeQcWTU1hC9knkOZGBnJVLupywYpAxRJrRieTq0s4+MMRkd3eMTej - khiYTs+llNPTh/Q+YbRwq8p5YqMd/v76YQhfX98AAAD//wMAZWV9XLICAAA= + H4sIAIiFV2UAA2yRT0/CQBDFv8pmzrVpC0Xam1yMiQdjNIrGNGt3KCPLbu1uESR8d6cBtBCvv/fm + zb8tLNE5WaGD/BWWslmgL0o0HptAaHKeTFWs0LQYCCc1uqK0RpEna1wgpFHis7Uee1TIBoU1eiPk + SpKW7xrFF/m5sG0jFGq5QSUc1WKGqEJ4C0BL54u6oRIhj8dZOBgfmKclI0iiZHARxxfx5UOc5skg + H16GSZq8wMHm6LurjKIA3kn9JY3CbE96BukWJ61Ge7R3jDqHrdH8WrIojIcBlNo6PB9xTtW8bxyk + PI/9+rONw5RtuC7n0lRYrKxuu33ilCUOPRz7iE2rdQBtraRHVVjz3+JpHGZZ1i3u+JpdFyBcd3fo + f+qYdf6vIz//2JGffJ911eXfcDq5QrFWW6shn0ntkMOxbBvyG8i3QIqNDApZfTTVB1d4KhfYML26 + uruF3hFOhPzxibUZVcRgMrmOomiSTdPnhGlpl7V1xIOe6c/30yHsdj8AAAD//wMAkHlpYrkCAAA= headers: Connection: - keep-alive @@ -28,7 +28,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Oct 2023 12:23:18 GMT + - Fri, 17 Nov 2023 15:23:52 GMT Transfer-Encoding: - chunked Vary: