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] Pre-Release Bug Fixes #6869

Merged
merged 2 commits into from
Oct 25, 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
1 change: 1 addition & 0 deletions openbb_platform/providers/imf/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""IMF Provoider Extension."""
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,15 @@ async def aextract_data(

base_url = "https://api.tiingo.com/tiingo/crypto/prices"
query_str = get_querystring(query.model_dump(by_alias=True), ["interval"])
frequency = query.interval

if frequency.endswith("m"):
frequency = f"{frequency[:-1]}min"
elif frequency == "h":
frequency = f"{frequency[:-1]}hour"
elif frequency.endswith("d"):
frequency = f"{frequency[:-1]}day"

if query.interval.endswith("m"):
frequency = f"{query.interval[:-1]}min"
elif query.interval.endswith("h"):
frequency = f"{query.interval[:-1]}hour"
elif query.interval.endswith("d"):
frequency = f"{query.interval[:-1]}day"
else:
frequency = "1day"

results: list = []
url = f"{base_url}?{query_str}&resampleFreq={frequency}&token={api_key}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,19 @@ async def aextract_data(
query_str = get_querystring(
query.model_dump(by_alias=True), ["symbol", "interval"]
)
frequency = query.interval

if frequency.endswith("m"):
frequency = f"{frequency[:-1]}min"
elif frequency == "h":
frequency = f"{frequency[:-1]}hour"
elif frequency.endswith("d"):
frequency = f"{frequency[:-1]}day"
if query.interval.endswith("m"):
frequency = f"{query.interval[:-1]}min"
elif query.interval.endswith("h"):
frequency = f"{query.interval[:-1]}hour"
elif query.interval.endswith("d"):
frequency = f"{query.interval[:-1]}day"
else:
frequency = "1day"

results: list = []
messages: list = []
symbols = query.symbol.split(",")

async def get_one(symbol):
"""Get data for one symbol."""
Expand All @@ -149,16 +151,17 @@ async def get_one(symbol):

if isinstance(data, list):
for d in data:
if "," in query.symbol:
d["symbol"] = symbol
ticker = d.pop("ticker", None)
if ticker and len(symbols) > 1:
d["ticker"] = d["ticker"].upper()

if query.interval.endswith("d"):
d["date"] = to_datetime(d["date"]).date()
else:
d["date"] = to_datetime(d["date"], utc=True)

results.extend(data)

symbols = query.symbol.split(",")
await asyncio.gather(*[get_one(symbol) for symbol in symbols])

if not results and messages:
Expand Down
Loading