-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuscarCrypto.py
66 lines (55 loc) · 1.91 KB
/
buscarCrypto.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from logging import error
import mandarTelegram
import telegram
import ast
from pycoingecko import CoinGeckoAPI
import apiCoingecko
import pandas as pd
import plotly.graph_objects as go
from pprint import pprint as print
import time
import reloj
cg = CoinGeckoAPI()
token = ''
bot = telegram.Bot(token=token)
def investigarPrecio(coin):
try:
price= cg.get_price(ids=coin, vs_currencies='usd')
precioCrypto = price[coin]['usd']
return True
except:
return False
def investigarPrecioParaNewCryto(coin):
try:
price= cg.get_price(ids=coin, vs_currencies='usd')
precioCrypto = price[coin]['usd']
return precioCrypto
except:
return 0
def investigarYmandarPrecio(id,coin,quiereGrafico,dias):
try:
price= cg.get_price(ids=coin, vs_currencies='usd')
precioCrypto = price[coin]['usd']
text = apiCoingecko.dataCrypto(coin)
mandarTelegram.send_message(id,"The price of " + str(coin).capitalize() + " is " + str(precioCrypto) + " usd" + text)
if quiereGrafico == 1:
grafico = apiCoingecko.graficarCoin(coin,dias)
mandarTelegram.mandarImagen(id, grafico)
except Exception as e:
print(e)
enviado = False
return enviado
def investigarYmandarPrecioConCantidad(id,coin,cantidad,quiereGrafico,dias):
try:
price= cg.get_price(ids=coin, vs_currencies='usd')
precioCrypto = price[coin]['usd']
total = float(cantidad) * float(precioCrypto)
total = '{0:,}'.format(total)
total = str(total.replace(",","."))
mandarTelegram.send_message(id,"The price of "+ str(cantidad)+" "+ str(coin).capitalize() + " is " + str(total) + " usd")
if quiereGrafico == 1:
grafico = apiCoingecko.graficarCoin(coin,dias)
mandarTelegram.mandarImagen(id, grafico)
return True
except:
return False