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

Fix Quote #5752

Merged
merged 4 commits into from
Nov 17, 2023
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
@@ -1,5 +1,6 @@
"""Intrinio Equity Quote fetcher."""

from concurrent.futures import ThreadPoolExecutor
from datetime import datetime
from typing import Any, Dict, List, Optional

Expand Down Expand Up @@ -103,7 +104,7 @@ def date_validate(cls, v): # pylint: disable=E0213
class IntrinioEquityQuoteFetcher(
Fetcher[
IntrinioEquityQuoteQueryParams,
IntrinioEquityQuoteData,
List[IntrinioEquityQuoteData],
]
):
"""Transform the query, extract and transform the data from the Intrinio endpoints."""
Expand All @@ -118,18 +119,26 @@ def extract_data(
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]
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
Loading