Get a glimpse of which cryptocurrencies you should have bought a week ago at Poloniex

environment

- MacOS Sierra 10.12.6
- Python 3.5.3 :: Anaconda 4.4.0 (x86_64)
- Jupyter 4.3.0

background

――For the past few months, I have been buying and selling various altcoins (virtual currencies other than Bitcoin) in the hope that the price will be higher than Bitcoin, but looking back, those who bought ** Bitcoin first and left it as it is I realized that I was making money **.

problem

――There are many types of virtual currencies, and most of them can only be purchased in pairs with Bitcoin, not Japanese yen or US dollars, so performance is difficult to understand. --Since the price range of virtual currencies is different (as of September 2017, Bitcoin is around 450,000 yen, Ripple is around 22 yen, etc.), it is difficult to compare performance side by side.

Solution

――In order to focus on the rate of increase / decrease rather than the price, we set the price at a certain point to 0 for multiple virtual currencies whose performances we want to compare, and charted the rate of increase / decrease from there. -** Click here for the created one (chart is updated every 10 minutes): ** https://cryptocurrencynews.hatenablog.com/

specification

--Import required modules such as pandas, matplotlib, poloniex, etc.

import pandas as pd
from pandas import Series,DataFrame
from datetime import datetime
import time
import matplotlib.pyplot as plt
from matplotlib.pylab import rcParams
%matplotlib inline
import seaborn as sns
sns.set_style('whitegrid')
rcParams['figure.figsize'] = 20, 10
#Module for using Poloniex API
import poloniex

--Get the price every 30 minutes for the past week using Poloniex's API (BTC only described below, same for other virtual currencies)

polo = poloniex.Poloniex()
#Get prices for the last 7 days
d = 7
#Get the price every 30 minutes (in seconds)
p = 1800
#Get price from Poloniex
btc_chart_data = polo.returnChartData('USDT_BTC', period=p, start=time.time()-polo.DAY*d, end=time.time())
btc_df = pd.DataFrame(btc_chart_data)

--Calculate the rate of increase / decrease from the acquired price (The following describes only BTC, the same applies to other virtual currencies)

#Calculate the rate of increase / decrease from the previous value
btc_list = [0]
j = len(btc_df.index) - 1
for i in range(j ):
    l = (float(btc_df['close'].iloc[i + 1]) / float(btc_df['close'].iloc[i ]) -1) * 100
    btc_list.append(l)
#Calculate the rate of increase / decrease from the beginning
m = 0
btc0_list = []
for i in range(j):
    m = m + float(btc_list[i])
    btc0_list.append(m)
btc_losers_df = pd.DataFrame(btc0_list)

--Display the rate of increase / decrease of each virtual currency from one week ago on one chart (The following describes only BTC, the same applies to other virtual currencies)

#Display the rate of increase / decrease of BTC on the chart
plt.plot(btc_losers_df.astype(float), label = 'BTC')
#Describe other virtual currencies in the same way (plt.plot(eth_losers_df.astype(float), label = 'ETH') ...Such)
plt.legend(loc='best',
           fontsize=14,
           borderaxespad=0.,)
plt.tick_params(labelsize=14)
#Save the generated chart as an image
plt.savefig("/var/www/html/all.png ")
plt.show()

--Displayed chart (when comparing the rate of increase / decrease from one week ago of 12 types of virtual currencies that are paired with USDT on Poloniex) チャート

Summary

――From the example in the chart above, you can see that if you purchased ** BCH or LTC a week ago, you could get a profit of around 10 to 15% . ――Depending on the time of year, the relative price movements between BTC and Altcoin are intense, so by buying and selling in BTC with this in mind, you can increase the number of BTC you already have without investing Japanese yen. there is a possibility. - Click here for the current chart (the chart is updated every 10 minutes): ** http://www.cryptocurrencies.tokyo/

Recommended Posts

Get a glimpse of which cryptocurrencies you should have bought a week ago at Poloniex
Get a lot of Twitter tweets at once
Which day of the week do you buy gold?