1
0
mirror of https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git synced 2025-07-25 07:31:48 +00:00

#31 just need to fix bugs from Main

This commit is contained in:
2021-03-27 17:31:23 -07:00
parent e1ed5fbf57
commit 6ab7f2c25d
5 changed files with 19 additions and 20 deletions

View File

@@ -1,5 +1,4 @@
import requests as r
from cg_Crypto import cg_Crypto
class Symbol:
@@ -28,10 +27,11 @@ class Stock(Symbol):
def __init__(self, symbol: str) -> None:
self.symbol = symbol
self.id = symbol
self.name = "$" + symbol.upper()
# This is so every Coin instance doesnt have to download entire list of coin symbols and id's
cg = cg_Crypto()
# Used by Coin to change symbols for ids
coins = r.get("https://api.coingecko.com/api/v3/coins/list").json()
class Coin(Symbol):
@@ -40,7 +40,9 @@ class Coin(Symbol):
self.get_data()
def get_data(self) -> None:
self.id = cg.symbol_id(self.symbol)
self.id = list(filter(lambda coin: coin["symbol"] == self.symbol, coins))[0][
"id"
]
data = r.get("https://api.coingecko.com/api/v3/coins/" + self.id).json()
self.data = data