<jupyter_start><jupyter_text>Project Stage 2: Data Analysis Analysis on cryptocurrency with PandasCryptocurrencies have always been one of the greatest fascinations of many tech geeks, speculators and so called investors themselves. This notebook aims to encourage that speculation and that adrenaline rush with cryptocurrency data from the 2014-2016 era in order to show that no one in hindsight could have predicted such a rise that we have now been seeing today in the year 2017.This analysis is primarily focused on displaying the graphs of Litecoin and Bitcoin during 2014-2016, their mean, median, max, correlation between the two values, and many other analysis of data that is useful from a financial point of view.Those who are reaping the rewards must remain humble as "Nullus sum ludum". Cogito ergo sum<jupyter_code># Importing the libraries needed
import pandas as pd
from ipykernel import kernelapp as app
import os
import math
import matplotlib
import numpy as np
import datetime as dt
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
from matplotlib.finance import candlestick_ohlc
pass
import matplotlib.dates as mdates
import seaborn as sns
%matplotlib inline 
# I want to know the available fonts
print(plt.style.available)
# The file and path to locate the dataset
ltc_btc = ('mergeLBAUD.csv')
file = os.path.join(ltc_btc)

# The csv file is stored as a dataframe in pandas.
file_opened = pd.read_csv(ltc_btc)
dataframe = pd.DataFrame(file_opened)
# Rows, columns
dataframe.shape
# The column names of the file
dataframe.columns
# The mean values of each attribute in the dataset
dataframe.mean()
# The median (middle) values of each attribute in the dataset
dataframe.median()
# The maximum values of each attribute in the dataset
dataframe.max()
# The total volumns of BTC and AUD respectively
vol_col = dataframe.loc[:,['vol_btc','vol_aud']]
vol_col.sum()
# Displays the data where date is the index
dataframe.set_index('Date')[:3]
# Find the ten highest LTCBTC prices
# If ascending is false, that means that descending is true
dataframe.sort_values(by='LTCBTC',ascending=False)[:10]
# Removes the grid in all the graphs
sns.set_style("whitegrid", {'axes.grid' : False})
# Plot the ten highest LTCBTC prices
# If ascending is false, that means that descending is true
ltc_highs = dataframe.sort_values(by='weighted_price',ascending=False)[:10]
ltc_highs.set_index('Date').plot(y = 'LTCBTC', lw = 3, kind = 'line', style='b-', figsize=(18,10))
plt.xlabel('Date', fontsize=25, fontname='DejaVu Sans')
plt.ylabel('Price', fontsize=25, fontname='DejaVu Sans')
plt.title('Ten highest LTC prices', fontsize=30, fontname='DejaVu Sans')
plt.setp(plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right', fontsize=18)
plt.setp(plt.gca().get_yticklabels(), fontsize=18)
plt.style.use('ggplot')

# Groups specific columns of the data by the weighted_price 
# Finds the sum of the BTC volume
# This allows us to know where BTC trades occurred the most.

columns = dataframe.loc[:,['vol_aud', 'weighted_price']]
columns = (columns / 100)
columns = columns.round(0) * 100
btc_occurrences = columns.groupby(['weighted_price']).sum()

# Point of control: aka most voluminous areas of the BTC prices
fig, ax = plt.subplots()
ax.plot(btc_occurrences)
ax.set_facecolor('white')
ax.ticklabel_format(useOffset=False, style='plain')
plt.xlabel('Weighted Price of BTC', fontsize=25, fontname='DejaVu Sans')
plt.ylabel('Volume in AUD', fontsize=25, fontname='DejaVu Sans')
plt.title('Total AUD volume at different BTC prices between 2014-2016', fontsize=30, fontname='DejaVu Sans')
plt.setp(plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right', fontsize=18)
plt.setp(plt.gca().get_yticklabels(), fontsize=18)
btc_occurrences.plot(style='b', ax=ax, kind = 'bar', figsize=(18,10))
plt.style.use('ggplot')
graph = dataframe.set_index('Date').plot(y = 'weighted_price', lw = 2, style='black', figsize=(18,10))
plt.xlabel('Date', fontsize=25, fontname='DejaVu Sans')
plt.ylabel('Price', fontsize=25, fontname='DejaVu Sans')
plt.title('BTC vs AUD between 2014-2016', fontsize=30, fontname='DejaVu Sans')
plt.setp(plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right', fontsize=18)
plt.setp(plt.gca().get_yticklabels(), fontsize=18)
plt.style.use('ggplot')

# LTCBTC graph
ltc_graphed = dataframe.set_index('Date')
ltc_graphed.plot(y = 'LTCBTC', kind = 'area', color = 'purple', figsize=(18,10))
plt.setp(plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right', fontsize=18)
plt.setp(plt.gca().get_yticklabels(), fontsize=18)
pass
plt.xlabel('Date', fontsize=25, fontname='DejaVu Sans')
plt.ylabel('Price', fontsize=25, fontname='DejaVu Sans')
plt.title('The price of LTC vs BTC between 2014-2016', fontsize=30, fontname='DejaVu Sans')
plt.style.use('ggplot')

candles_btc = dataframe.drop(['LTCBTC','vol_aud','vol_btc', 'weighted_price'], 1)[250:591]

candles_btc.columns = ['Date', 'Open', 'High', 'Low', 'Close']
candles_btc['Date'] = candles_btc['Date'].map(lambda x: pd.to_datetime(x, dayfirst=True)).map(mdates.date2num)

fig = plt.figure(figsize=(18,10))
ax1 = plt.subplot2grid((6,1), (0,0), rowspan=6, colspan=1)

#Converts raw mdate numbers to dates
ax1.xaxis_date()
ax1.set_facecolor('white')
#Making candlestick plot
candlestick_ohlc(ax1,candles_btc.values,width=3, colorup='g', colordown='r',alpha=0.75)
#plt.legend('BTCAUD')
plt.xlabel('Date', fontsize=25, fontname='DejaVu Sans')
plt.ylabel('Price', fontsize=25, fontname='DejaVu Sans')
plt.title('BTC vs AUD between 2015-2016', fontsize=30, fontname='DejaVu Sans')
plt.style.use('ggplot')
#plt.text(1.1,12, r'$y = x^2$', fontsize=15, bbox={'facecolor':'yellow'})
plt.setp(plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right', fontsize=18)
plt.setp(plt.gca().get_yticklabels(), fontsize=18)
pass<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13235794487921063, 'fraction_numerical': 0.03011228308948622, 'mean_word_length': 6.766182298546895, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '28622', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2208, 'n_tokens_neox': 1985, 'n_words': 573, 'path': 'Project Stage 2/Python/Project Stage 2.ipynb', 'repo_name': 'kbgoda/Bitcoin-Informatics-Project', 'size': '5878'}