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()
top of page
MAKING ABSTRACT REALITY
Search
Recent Posts
See AllExempt on leveraging real-time events and batch processing engine for enabling hybrid use cases i.e. Backup replication & ETL processing....
170
One of important things of having users to upload documents is to ability verify & check that the document is of the expected type and...
10
#ProdOPS mission is to harmonize relations between product enablement processes, products value creation, and products experience....
10
Post: Blog2_Post
bottom of page
Comments