-
Notifications
You must be signed in to change notification settings - Fork 1
/
monedas.py
38 lines (29 loc) · 1.19 KB
/
monedas.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
import requests
from bs4 import BeautifulSoup
url = "https://yfapi.net/v6/finance/quote"
query_usd = {"symbols": "USDCOP=X"}
query_eur = {"symbols":"EURCOP=X"}
headers = {'x-api-key': "TfRyNUCEEP4YWm2TcaJAe6kWbw6aqgYe2HtBICpK"}
class Monedas_Peticiones():
def precio_btc():
url = 'https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1h&limit=1'
r = requests.get(url)
data = r.json()
precio_btc = data[0:3][0]
precio_hora = float(precio_btc[1])
return precio_hora
def precio_dolar():
response = requests.request("GET", url, headers=headers, params=query_usd)
json_response = response.json()
for i in json_response['quoteResponse']['result']:
precio_usd = i['regularMarketPrice']
return precio_usd
def precio_euro():
response = requests.request("GET", url, headers=headers, params=query_eur)
json_response = response.json()
for i in json_response['quoteResponse']['result']:
precio_eur = i['regularMarketPrice']
return precio_eur
print(Monedas_Peticiones.precio_euro())
print(Monedas_Peticiones.precio_btc())
print(Monedas_Peticiones.precio_dolar())