In [1]:
import pandas as pd
import datetime
import numpy as np
import scipy as sp
import os
import matplotlib.pyplot as plt
import matplotlib
%matplotlib inline
matplotlib.rcParams['figure.figsize'] = (12.0, 6.0)

In [2]:
raw = pd.read_csv("./market.csv", header=False, names=['time', 'price', 'volume'], index_col='time', parse_dates=[0])
raw.head()


Out[2]:
price volume
time
2014-12-02 377.00 15.013600
2014-12-03 377.90 0.546608
2014-12-04 377.10 0.010000
2014-12-06 378.00 0.015000
2014-12-08 375.01 0.235000

In [3]:
data = raw['2015']
data.plot(secondary_y='volume', rot=0)


Out[3]:
<matplotlib.axes.AxesSubplot at 0x1075bf290>

try shifting volume to tomorrow's price


In [4]:
data['shifted_vol'] = data['volume'].shift(1)
data.head()


-c:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
Out[4]:
price volume shifted_vol
time
2015-01-08 360.00 10.350000 NaN
2015-01-13 260.00 1.000000 10.350000
2015-01-14 200.00 11.304638 1.000000
2015-01-15 191.99 2.977321 11.304638
2015-01-16 210.98 4.690000 2.977321

In [6]:
data.iloc[:,[0,2]].plot(secondary_y='price', rot=0)


Out[6]:
<matplotlib.axes.AxesSubplot at 0x107b35bd0>

check the percent change of two attribtues


In [7]:
pct_data = raw['2015'].pct_change()
pct_data.head()


Out[7]:
price volume
time
2015-01-08 NaN NaN
2015-01-13 -0.277778 -0.903382
2015-01-14 -0.230769 10.304638
2015-01-15 -0.040050 -0.736628
2015-01-16 0.098911 0.575242

In [8]:
pct_data.corr()


Out[8]:
price volume
price 1.000000 0.314698
volume 0.314698 1.000000

In [9]:
pct_data.ix[pct_data['volume'].argmax()] = 0
pct_data.plot(secondary_y='volume', rot=0)


Out[9]:
<matplotlib.axes.AxesSubplot at 0x107b68350>

In [10]:
pct_data['shifted_volume'] = pct_data['volume'].shift(1)
pct_data.head()


Out[10]:
price volume shifted_volume
time
2015-01-08 NaN NaN NaN
2015-01-13 -0.277778 -0.903382 NaN
2015-01-14 -0.230769 10.304638 -0.903382
2015-01-15 -0.040050 -0.736628 10.304638
2015-01-16 0.098911 0.575242 -0.736628

In [11]:
pct_data.corr()


Out[11]:
price volume shifted_volume
price 1.000000 0.114096 -0.095263
volume 0.114096 1.000000 -0.054928
shifted_volume -0.095263 -0.054928 1.000000

Comments

Seems volume and price has not obvious relationship?