For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
struggling to resample csv file
-
this is my code :
data = bt.feeds.GenericCSVData( dataname='USDJPY_H1.csv', fromdate=datetime.datetime(2014, 4, 2), todate=datetime.datetime(2014, 4, 4), nullvalue=0.0, dateformat='%Y-%m-%d %H:%M:%S', datetime=0, time=-1, open=1, high=2, low=3, close=4, adjclose=5, volume=6, openinterest=-1, timeframe=bt.TimeFrame.Minutes, compression=60)
and this is a part of my cvs file
Date,Open,High,Low,Close,AdjClose,Volume 2014-04-02 16:00:00 103.819 103.821 103.745 103.767 1854 2014-04-02 17:00:00 103.767 103.839 103.732 103.775 1777 2014-04-02 18:00:00 103.776 103.794 103.734 103.747 1072 2014-04-02 19:00:00 103.749 103.867 103.748 103.852 1837 2014-04-02 20:00:00 103.851 103.882 103.826 103.881 985 2014-04-02 21:00:00 103.882 103.894 103.846 103.865 577
Im getting this error : raise ValueError("unconverted data remains: %s" %
ValueError: unconverted data remains: 103.819 103.821 103.745 103.767 1854can anyone tell me whats wrong?
-
@aalli you may want to define the seperator for your csv data by providing the separator param.
data = bt.feeds.GenericCSVData( dataname='USDJPY_H1.csv', fromdate=datetime.datetime(2014, 4, 2), todate=datetime.datetime(2014, 4, 4), nullvalue=0.0, dateformat='%Y-%m-%d %H:%M:%S', datetime=0, time=-1, open=1, high=2, low=3, close=4, adjclose=5, volume=6, openinterest=-1, seperator='\t', timeframe=bt.TimeFrame.Minutes, compression=60)
-
@dasch how about I put in a class?
-
@dasch thanks I tried this but it didnt work
-
@aalli If the separator is set to
tab
orspace
, the date and time will become a separate columns. In this case thedtformat
andtmformat
need to be specified as well asdatetime
andtime
columns should have valid column indexes.