Hello I am trying to plot the chart of some crypto currencies. I am trying to plot the chart BTC/USD but it does not work. Here is my code :
from urllib.request import Request, urlopen
import json
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import datetime as dt
from mpl_finance import candlestick_ohlc
import matplotlib.dates as mdates
url = "https://api.binance.com/api/v1/klines?symbol=BTCTUSD&interval=1h"
reponse = urlopen(url)
data = json.load(reponse)
df = pd.DataFrame(data)
df.columns = ['open_time', 'o', 'h', 'l',
'c', 'v', 'close_time',
'qav', 'num_trades', 'taker_base_', 'taker_quote_vol',
'ignore']
df['close_time'] = pd.to_datetime(df['close_time'], unit='ms')
df['close_time'] = df['close_time'].apply(mdates.date2num)
df['o'] = df['o'].astype('float')
df['h'] = df['h'].astype('float')
df['l'] = df['l'].astype('float')
df['c'] = df['c'].astype('float')
df['v'] = df['v'].astype('float')
ax1 = plt.subplot2grid((1,1), (0,0))
ohlc = [df['close_time'], df['o'], df['h'], df['l'], df['c'], df['v']]
candlestick_ohlc(ax1, ohlc)
But when I try to execute this code I get this nothing just a white screen but without chart it is very strange !
Could you help me please ?
Thank you very much !