Skip to content

Commit b1d9155

Browse files
authored
fix some bugs before release (#6869)
1 parent a4914a2 commit b1d9155

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""IMF Provoider Extension."""

openbb_platform/providers/tiingo/openbb_tiingo/models/crypto_historical.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,15 @@ async def aextract_data(
136136

137137
base_url = "https://api.tiingo.com/tiingo/crypto/prices"
138138
query_str = get_querystring(query.model_dump(by_alias=True), ["interval"])
139-
frequency = query.interval
140-
141-
if frequency.endswith("m"):
142-
frequency = f"{frequency[:-1]}min"
143-
elif frequency == "h":
144-
frequency = f"{frequency[:-1]}hour"
145-
elif frequency.endswith("d"):
146-
frequency = f"{frequency[:-1]}day"
139+
140+
if query.interval.endswith("m"):
141+
frequency = f"{query.interval[:-1]}min"
142+
elif query.interval.endswith("h"):
143+
frequency = f"{query.interval[:-1]}hour"
144+
elif query.interval.endswith("d"):
145+
frequency = f"{query.interval[:-1]}day"
146+
else:
147+
frequency = "1day"
147148

148149
results: list = []
149150
url = f"{base_url}?{query_str}&resampleFreq={frequency}&token={api_key}"

openbb_platform/providers/tiingo/openbb_tiingo/models/currency_historical.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,19 @@ async def aextract_data(
117117
query_str = get_querystring(
118118
query.model_dump(by_alias=True), ["symbol", "interval"]
119119
)
120-
frequency = query.interval
121120

122-
if frequency.endswith("m"):
123-
frequency = f"{frequency[:-1]}min"
124-
elif frequency == "h":
125-
frequency = f"{frequency[:-1]}hour"
126-
elif frequency.endswith("d"):
127-
frequency = f"{frequency[:-1]}day"
121+
if query.interval.endswith("m"):
122+
frequency = f"{query.interval[:-1]}min"
123+
elif query.interval.endswith("h"):
124+
frequency = f"{query.interval[:-1]}hour"
125+
elif query.interval.endswith("d"):
126+
frequency = f"{query.interval[:-1]}day"
127+
else:
128+
frequency = "1day"
128129

129130
results: list = []
130131
messages: list = []
132+
symbols = query.symbol.split(",")
131133

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

150152
if isinstance(data, list):
151153
for d in data:
152-
if "," in query.symbol:
153-
d["symbol"] = symbol
154+
ticker = d.pop("ticker", None)
155+
if ticker and len(symbols) > 1:
156+
d["ticker"] = d["ticker"].upper()
157+
154158
if query.interval.endswith("d"):
155159
d["date"] = to_datetime(d["date"]).date()
156160
else:
157161
d["date"] = to_datetime(d["date"], utc=True)
158162

159163
results.extend(data)
160164

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

164167
if not results and messages:

0 commit comments

Comments
 (0)