<jupyter_start><jupyter_text>Data extraction for differrent Cryptocurruncies<jupyter_code>file_content = {}
coin = ['bitcoin','ripple', 'ethereum', 'tether', 'stellar', 'cardano', 'monero',  'dash', 'ontology', 'tezos']
for i in coin:
        url = "https://api.coingecko.com/api/v3/coins/{}/market_chart?vs_currency=usd&days=20".format(i)
        result = requests.get(url)

        file_content[i] = result.json()
data = []
for j in coin:
    test_df = pd.DataFrame(data=file_content[j], columns = file_content[j].keys())
    test_df = pd.DataFrame(test_df['prices'].values.tolist(), columns=['date','price'])
    test_df['coin'] = j
    test_df['time'] = pd.to_datetime(test_df['date'], unit='ms').dt.round('1h')
    test_df.set_index('date',inplace=True)
    data.append(test_df)
    
final_data = pd.concat(data)

final_data.sort_values(by='time',inplace=True)
final_data.head()

final_data.sort_values(by = ['time', 'coin'], inplace = True)
df2 =final_data.groupby(['time', 'coin'])['price'].first()
df3 =df2.unstack()
df4 = df3.resample('1h').first()
df4.head()<jupyter_output><empty_output><jupyter_text>Bitcoin price trends<jupyter_code>df5 =  df4[['bitcoin']]
df5.plot()<jupyter_output><empty_output><jupyter_text>Compute the correlation between bitcoin and ethereum<jupyter_code>df6 = df4['bitcoin'].pct_change()
df7 = df4['ethereum'].pct_change()
plt.scatter(df6,df7)
plt.xlabel('Percentage chanege of Bitcoin prices')
plt.ylabel('Percentage chanege of Ethereum prices')
correlation = df6.corr(df7)
print("Correlation of Bitcoin and Ethereum prices: ", correlation)<jupyter_output>Correlation of Bitcoin and Ethereum prices:  0.8561146824896186<jupyter_text>Seasonal trends of Bitcoin<jupyter_code>from statsmodels.tsa.seasonal import seasonal_decompose

sdr = seasonal_decompose(df4['bitcoin'], model='additive')

sdr.plot()<jupyter_output><empty_output><jupyter_text>Normalizing Bitcoin Price<jupyter_code>first_price = df5['bitcoin'].iloc[0]
normalized_bitcoin = df5['bitcoin'].div(first_price).mul(100)
normalized_bitcoin.plot(title='Normalized Bitcoin Price')<jupyter_output><empty_output><jupyter_text>Normalized prices of Bitcoin, Ethereum and Dash<jupyter_code>df7 = df4[['bitcoin','ethereum','dash']]
df7_first = df7.iloc[0]
df7_normalized = df7.div(df7_first).mul(100)
df7_normalized.plot()<jupyter_output><empty_output><jupyter_text>Bitcoin predictions<jupyter_code>from statsmodels.tsa.holtwinters import ExponentialSmoothing

m = ExponentialSmoothing(df5, damped=True, trend='additive')

result = m.fit()

result

m.params

xpred = df4.index
ypred = m.predict(m.params, start=1, end=len(df5.index))
xpred = pd.date_range(str(xpred[0]), freq='2h', periods=len(df5.index))
#xpred = df3.index
#xpred
xpred

str(xpred[0])

ypred

pred = pd.Series(ypred, index=xpred)
pred.head(20)


total = pd.DataFrame({'ytrue': df4['bitcoin'], 'ypred': pred})
total.loc['2019-01-26 19:00:00'], total.loc['2019-01-27 19:00:00']
total.plot()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16330645161290322, 'fraction_numerical': 0.03293010752688172, 'mean_word_length': 7.481481481481482, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '342395', 'license': 'MIT', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1133, 'n_words': 172, 'path': 'bitcoin_predictions.ipynb', 'repo_name': 'ahsansana1/Bitcoin', 'size': '2976'}