import datetime
import matplotlib.pyplot as plt
import matplotlib.dates as dates
from pycoingecko import CoinGeckoAPI
import statistics
import pandas as nd
cg = CoinGeckoAPI()
btcprice = cg.get_price(ids='bitcoin', vs_currencies='usd')
mult = cg.get_price(ids='bitcoin,litecoin,ethereum', vs_currencies='usd')
history = cg.get_coin_market_chart_range_by_id(id='bitcoin', vs_currency='usd', from_timestamp='1604906000',
to_timestamp='1605099600')
vmax = max(list(zip(*history['prices']))[1])
vmin = min(list(zip(*history['prices']))[1])
delta = vmax - vmin
# dfObj = nd.DataFrame(history['prices'], columns=['date', 'normalized'])
dfObj = nd.DataFrame.from_records(history['prices'],
columns=['date', 'normalized'])
dfObj['normalized'] = dfObj['normalized'].apply(lambda x: (x - vmin) / delta)
dfObj['date'] = dfObj['date'].apply(lambda x: datetime.datetime.fromtimestamp(x / 1000).strftime("%d/%m-%H:%M"))
print(dfObj)
formatter = dates.DateFormatter('%H:%M')
dfObj.plot(style='k.', subplots=True)
plt.gcf().axes[0].xaxis.set_major_formatter(formatter)
lines = dfObj.plot.line(y='normalized', x='date')
plt.show()
![](https://static.wixstatic.com/media/b5f26b_a2049c5d636c4f6283210fd9e4991509~mv2.png/v1/fill/w_640,h_480,al_c,q_85,enc_auto/b5f26b_a2049c5d636c4f6283210fd9e4991509~mv2.png)
Comments