In [1]:
ls


dma.pickle  generate_new_sample_saved_state.py  run_algo.py*  Untitled0.ipynb

In [2]:
import pandas as pd
perf = pd.read_pickle('dma.pickle') # read in perf DataFrame
perf.head()


Out[2]:
capital_used ending_cash ending_value orders period_close period_open pnl portfolio_value positions returns starting_cash starting_value transactions
2011-01-03 21:00:00 0 10000000 0 [] 2011-01-03 21:00:00+00:00 2011-01-03 14:31:00+00:00 0 10000000 [] 0 10000000 0 []
2011-01-04 21:00:00 0 10000000 0 [] 2011-01-04 21:00:00+00:00 2011-01-04 14:31:00+00:00 0 10000000 [] 0 10000000 0 []
2011-01-05 21:00:00 0 10000000 0 [] 2011-01-05 21:00:00+00:00 2011-01-05 14:31:00+00:00 0 10000000 [] 0 10000000 0 []
2011-01-06 21:00:00 0 10000000 0 [] 2011-01-06 21:00:00+00:00 2011-01-06 14:31:00+00:00 0 10000000 [] 0 10000000 0 []
2011-01-07 21:00:00 0 10000000 0 [] 2011-01-07 21:00:00+00:00 2011-01-07 14:31:00+00:00 0 10000000 [] 0 10000000 0 []

In [3]:
%pylab inline
figsize(12, 12)
import matplotlib.pyplot as plt

ax1 = plt.subplot(211)
perf.portfolio_value.plot(ax=ax1)
ax1.set_ylabel('portfolio value')
ax2 = plt.subplot(212, sharex=ax1)
perf.AAPL.plot(ax=ax2)
ax2.set_ylabel('AAPL stock price')


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-d6151efac463> in <module>()
      7 ax1.set_ylabel('portfolio value')
      8 ax2 = plt.subplot(212, sharex=ax1)
----> 9 perf.AAPL.plot(ax=ax2)
     10 ax2.set_ylabel('AAPL stock price')

/usr/local/lib/python2.7/dist-packages/pandas/core/generic.pyc in __getattr__(self, name)
   2148                 return self[name]
   2149             raise AttributeError("'%s' object has no attribute '%s'" %
-> 2150                                  (type(self).__name__, name))
   2151 
   2152     def __setattr__(self, name, value):

AttributeError: 'DataFrame' object has no attribute 'AAPL'
Populating the interactive namespace from numpy and matplotlib

In [1]:
import pandas as pd
perf = pd.read_pickle('dma.pickle') # read in perf DataFrame
perf.head()


Out[1]:
AAPL capital_used ending_cash ending_value long_mavg orders period_close period_open pnl portfolio_value positions returns short_mavg starting_cash starting_value transactions
2009-01-02 21:00:00 NaN 0 10000000 0 NaN [] 2009-01-02 21:00:00+00:00 2009-01-02 14:31:00+00:00 0 10000000 [] 0 NaN 10000000 0 []
2009-01-05 21:00:00 NaN 0 10000000 0 NaN [] 2009-01-05 21:00:00+00:00 2009-01-05 14:31:00+00:00 0 10000000 [] 0 NaN 10000000 0 []
2009-01-06 21:00:00 NaN 0 10000000 0 NaN [] 2009-01-06 21:00:00+00:00 2009-01-06 14:31:00+00:00 0 10000000 [] 0 NaN 10000000 0 []
2009-01-07 21:00:00 NaN 0 10000000 0 NaN [] 2009-01-07 21:00:00+00:00 2009-01-07 14:31:00+00:00 0 10000000 [] 0 NaN 10000000 0 []
2009-01-08 21:00:00 NaN 0 10000000 0 NaN [] 2009-01-08 21:00:00+00:00 2009-01-08 14:31:00+00:00 0 10000000 [] 0 NaN 10000000 0 []

In [2]:
%pylab inline
figsize(12, 12)
import matplotlib.pyplot as plt

ax1 = plt.subplot(211)
perf.portfolio_value.plot(ax=ax1)
ax1.set_ylabel('portfolio value')
ax2 = plt.subplot(212, sharex=ax1)
perf.AAPL.plot(ax=ax2)
ax2.set_ylabel('AAPL stock price')


Populating the interactive namespace from numpy and matplotlib
Out[2]:
<matplotlib.text.Text at 0x7fd6c50b3310>

In [ ]: