mirror of
https://gitlab.com/simple-stock-bots/simple-stock-bot.git
synced 2025-06-16 07:16:40 +00:00
Closes #68
This commit is contained in:
parent
08f140af8e
commit
55bf78a57b
@ -476,17 +476,19 @@ class IEX_Symbol:
|
|||||||
return pd.DataFrame()
|
return pd.DataFrame()
|
||||||
|
|
||||||
def trending(self) -> list[str]:
|
def trending(self) -> list[str]:
|
||||||
"""Gets current coins trending on coingecko
|
"""Gets current coins trending on IEX. Only returns when market is open.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
list[str]
|
list[str]
|
||||||
list of $$ID: NAME
|
list of $ID: NAME
|
||||||
"""
|
"""
|
||||||
|
|
||||||
stocks = r.get(
|
stocks = r.get(
|
||||||
f"https://cloud.iexapis.com/stable/stock/market/list/mostactive?token={self.IEX_TOKEN}",
|
f"https://cloud.iexapis.com/stable/stock/market/list/mostactive?token={self.IEX_TOKEN}",
|
||||||
timeout=5,
|
timeout=5,
|
||||||
).json()
|
)
|
||||||
|
if stocks.status_code == 200:
|
||||||
return [f"${s['symbol']}: {s['companyName']}" for s in stocks]
|
return [f"${s['symbol']}: {s['companyName']}" for s in stocks.json()]
|
||||||
|
else:
|
||||||
|
return ["Trending Stocks Currently Unavailable."]
|
||||||
|
11
cg_Crypto.py
11
cg_Crypto.py
@ -291,9 +291,14 @@ class cg_Crypto:
|
|||||||
coins = r.get(
|
coins = r.get(
|
||||||
"https://api.coingecko.com/api/v3/search/trending",
|
"https://api.coingecko.com/api/v3/search/trending",
|
||||||
timeout=5,
|
timeout=5,
|
||||||
).json()["coins"]
|
)
|
||||||
|
if coins.status_code == 200:
|
||||||
return [f"$${c['item']['symbol'].upper()}: {c['item']['name']}" for c in coins]
|
return [
|
||||||
|
f"$${c['item']['symbol'].upper()}: {c['item']['name']}"
|
||||||
|
for c in coins.json()["coins"]
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
return ["Trending Coins Currently Unavailable."]
|
||||||
|
|
||||||
def batch_price(self, coins: list[Coin]) -> list[str]:
|
def batch_price(self, coins: list[Coin]) -> list[str]:
|
||||||
query = ",".join([c.id for c in coins])
|
query = ",".join([c.id for c in coins])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user