forex_algotrading icon indicating copy to clipboard operation
forex_algotrading copied to clipboard

error when running create-ohlc.py

Open yusuf81 opened this issue 8 years ago • 2 comments

I got error when running create-ohlc.py. Here the message:

**>


Traceback (most recent call last): File "create_OHLC.py", line 36, in main(sys.argv[1]) File "create_OHLC.py", line 12, in main df = pandas.read_csv(filename, parse_dates={'DateTime'}, index_col='DateTime', names=['Tid', 'Dealable', 'Pair', 'DateTime', 'Buy', 'Sell'], date_parser=parse) File "/Users/yusuf81/anaconda/envs/forex27/lib/python2.7/site-packages/pandas/io/parsers.py", line 646, in parser_f return _read(filepath_or_buffer, kwds) File "/Users/yusuf81/anaconda/envs/forex27/lib/python2.7/site-packages/pandas/io/parsers.py", line 389, in _read parser = TextFileReader(filepath_or_buffer, **kwds) File "/Users/yusuf81/anaconda/envs/forex27/lib/python2.7/site-packages/pandas/io/parsers.py", line 730, in init self._make_engine(self.engine) File "/Users/yusuf81/anaconda/envs/forex27/lib/python2.7/site-packages/pandas/io/parsers.py", line 923, in _make_engine self._engine = CParserWrapper(self.f, self.options) File "/Users/yusuf81/anaconda/envs/forex27/lib/python2.7/site-packages/pandas/io/parsers.py", line 1378, in init ParserBase.init(self, kwds) File "/Users/yusuf81/anaconda/envs/forex27/lib/python2.7/site-packages/pandas/io/parsers.py", line 1032, in init kwds.pop('parse_dates', False)) File "/Users/yusuf81/anaconda/envs/forex27/lib/python2.7/site-packages/pandas/io/parsers.py", line 1015, in _validate_parse_dates_arg raise TypeError(msg) TypeError: Only booleans, lists, and dictionaries are accepted for the 'parse_dates' parameter ---------------------------------------------------------------------------

I think "def parse" output rejected by parse_dates.

yusuf81 avatar Jan 21 '17 20:01 yusuf81

change these this line of code

df = pandas.read_csv(filename, parse_dates={'DateTime'}, index_col='DateTime', names=['Tid', 'Dealable', 'Pair', 'DateTime', 'Buy', 'Sell'], date_parser=parse)

to that

df = pandas.read_csv(filename, parse_dates=[3], index_col='DateTime', names=['Tid', 'Dealable', 'Pair', 'DateTime', 'Buy', 'Sell'], date_parser=parse, skiprows=1)

and you will be ok run the script

binary-signal avatar Apr 21 '17 22:04 binary-signal

Hi,

Can anyone please explain what happens towards the end of the code in line " print 'create_OHLC.py <inputfile.csv>' " are we supposed to replace this portion of the code? How is data written to inputfile.csv

mustejab avatar Oct 22 '17 11:10 mustejab