mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
Fix Quote (#5752)
* Fix Quote * fixed return type and model validation --------- Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user