Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How to import data and decisions in CSV format and backtesting

Hi,

I created the following pandas dataframe the index are dates, and the columns are headers are symbols I am interested in. For each date in the set (row), each symbol is assigned a 'b', 'h', 's' label. These labels stand for buy, hold, and sell. I would like to iterate over the days and perform the correct order for that day. How can I go about doing this? Note. On day 1 I would buy 500 shares of each ticker and then start iterating over the df.

Once I get the dataframe into the IDE, I should be able to check the date and perform the correct action.

>>> print(df.head())  
           BK BMRN CHKP CHTR CMG CNP EQT ETN FITB MU NLY PAGS PPG PSX SBUX  
date  
2018-01-02  h    b    s    b   s   h   s   s    s  s   s    b   h   s    s  
2018-01-03  h    b    s    b   h   h   s   h    s  s   s    b   h   s    s  
2018-01-04  s    s    h    b   h   s   h   h    h  h   h    b   s   s    s  
2018-01-05  b    b    s    b   h   h   s   h    h  s   h    b   b   s    s  
2018-01-08  h    h    s    b   s   h   s   s    s  s   s    b   h   s    s