-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathploting_btc
42 lines (29 loc) · 1.18 KB
/
ploting_btc
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
import pandas as pd
import mplfinance as mpf
import matplotlib.animation as animation
import json as j
import requests
from datetime import datetime
token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
def histoMinute(e="CCCAGG", fsym="BTC", tsym="USD", toTs=None, limit=100, aggregate=1, allData="true"):
url = "https://min-api.cryptocompare.com/data/v2/histominute"
params = {"api-key" : token, "e" : e, "fsym" : fsym, "tsym" : tsym, "allData" : allData,
"toTs" : toTs, "limit" : limit, "aggregate" : aggregate}
r = requests.get(url, params=params)
js = r.json()["Data"]["Data"]
df = pd.DataFrame(js)
df.time = pd.to_datetime(df.time, unit="s")
df = df.set_index("time").drop(["conversionType", "conversionSymbol"], axis=1)
return df
pkwargs=dict(type='candle',style="yahoo", mav=(20,5))
data = histoMinute()
fig, axes = mpf.plot(data,returnfig=True,volume=False,
figsize=(10,5),
title='\n\nBitcoin Live con Medias',**pkwargs)
ax1 = axes[0]
def animate(ival):
data = histoMinute()
ax1.clear()
mpf.plot(data,ax=ax1,**pkwargs)
ani = animation.FuncAnimation(fig, animate, interval=0)
mpf.show()