Heerozh / spectre

GPU-accelerated Factors analysis library and Backtester
GNU General Public License v3.0
642 stars 108 forks source link

CsvDirLoader questions/features #1

Closed jibanes closed 4 years ago

jibanes commented 4 years ago

Do you have an example of read_csv arguments to pass to CsvDirLoader to parse this date format, or is parse_dates=True sufficient here?

Does spectre supports intraday data (aka minute-data here), and how should it be loaded?

Thank you.

Heerozh commented 4 years ago

CsvDirLoader was not designed to cover all situations when designing (too difficult), you can refer to QuandlLoader (It has fewer lines) to rewrite one for your needs.

Answer your questions:

My broker provides me data feeds named (for instance) AAPL.txt (read: not .csv); can CsvDirLoader access those (without having to rename/link them?)

No, you need rename to *.csv. I will add a parameter in the future.

My broker "csv" data doesn't have a csv header, how can I tell CsvDirLoader which column is what?

This can be done by passing the pandas.read_csv parameters, as an example:

loader = CsvDirLoader('path_to_files', parse_dates=True, prices_index='date', header=None, names=['date','open','high','low','close','volume'])
print(loader._load())
date asset open high low close volume _time_cat_id
12/31/1980 TEST 0.4891 0.4891 0.4873 0.4873 11177100 0
12/31/1980 TEST 0.4926 0.4962 0.4926 0.4926 6772100 1
12/31/1980 TEST 0.4837 0.4837 0.4819 0.4819 11170100 2

Does spectre supports intraday data

Yes. But CsvDirLoader needs time and date in one column. For your data, you may have to rewrite a DataLoader.

jibanes commented 4 years ago

Thank you, very useful, I have reformatted the data accordingly.