Ejemplo n.º 1
0
btc_usd_price_kraken = ctl.get_quandl_data('BCHARTS/KRAKENUSD', dataDir)

# Pull pricing data for 3 more BTC exchanges
exchanges = ['COINBASE', 'BITSTAMP', 'ITBIT']

# Storing Pandas DF in dict (data from KRAKEN + other exchanges):
exchange_data = {}  # dict
exchange_data['KRAKEN'] = btc_usd_price_kraken  # Pandas DF
for exchange in exchanges:
    exchange_code = 'BCHARTS/{}USD'.format(exchange)
    btc_exchange_df = ctl.get_quandl_data(exchange_code, dataDir)  # Pandas DF
    exchange_data[exchange] = btc_exchange_df

# Now we will merge all of the dataframes together on their "Weighted
# Price" column (merge the BTC price dataseries' into a single dataframe)
btc_usd_datasets = ctl.merge_dfs_on_column(  # def merge_dfs_on_column(dataframes, labels, col):
    list(exchange_data.values()), list(exchange_data.keys()), 'Weighted Price')

# Remove "0" values
btc_usd_datasets.replace(0, np.nan, inplace=True)

# We can now calculate a new column, containing the average daily
# Bitcoin price across all of the exchanges.
btc_usd_datasets['avg_btc_price_usd'] = btc_usd_datasets.mean(axis=1)

# Step 3 - Retrieve Altcoin Pricing Data
# --------------------------------------

# Step 3.2 - Download Trading Data From Poloniex
# ----------------------------------------------
# We'll download exchange data for nine of the top cryptocurrencies -
# Ethereum, Litecoin, Ripple, Ethereum Classic, Stellar, Dashcoin,
Ejemplo n.º 2
0
exchanges = ['COINBASE', 'BITSTAMP', 'ITBIT']

exchange_data = {}

exchange_data['KRAKEN'] = btc_usd_price_kraken

for exchange in exchanges:
    exchange_code = 'BCHARTS/{}USD'.format(exchange)
    btc_exchange_df = ctl.get_quandl_data(exchange_code, dataDir)
    exchange_data[exchange] = btc_exchange_df

# Now we will merge all of the dataframes together on their "Weighted
# Price" column (merge the BTC price dataseries' into a single dataframe)

btc_usd_datasets = ctl.merge_dfs_on_column( \
    list(exchange_data.values()), \
    list(exchange_data.keys()), 'Weighted Price' )
#print("btc_usd_datasets = ")
#print( btc_usd_datasets.tail() )

# Step 2.5 - Visualize The Pricing Datasets
# -----------------------------------------
# For this, we'll define a helper function to provide a single-line
# command to generate a graph from the dataframe.

# We can now easily generate a graph for the Bitcoin pricing data.
# # Plot all of the BTC exchange prices
ctl.df_scatter(btc_usd_datasets, 'Bitcoin Price (USD) By Exchange')

# Step 2.6 - Clean and Aggregate the Pricing Data
# -----------------------------------------------