Multiple Symbols in one CSV file
-
Hi All. I know this may sound very easy but does anyone have any idea how to load multiple symbols with multiple time frames from only one csv file? I have been looking around for a while now and I cant seem to find a suitable example for this application. I usually come across examples using either an external feed and/or multiple symbols coming from different files. Im a bit new to this library and it would be very helpful for me to at least load my own data so that I can start exploring more of the library. please see below sample format (it has more symbols/timeframe in the csv file.
$FORMAT Ticker,Date_YMD,Time,Open,High,Low,Close,Volume ETHBTC,2020-01-01,08:00:00,0.01795400,0.01796900,0.01792000,0.01795700,2000.67400000 ETHBTC,2020-01-01,09:00:00,0.01795800,0.01810500,0.01794500,0.01810500,4823.82000000 DNTETH,2020-01-10,22:00:00,0.00003640,0.00003683,0.00003640,0.00003683,1797.00000000 DNTETH,2020-01-10,23:00:00,0.00003615,0.00003615,0.00003547,0.00003554,358291.00000000 DNTETH,2020-01-11,00:00:00,0.00003561,0.00003576,0.00003544,0.00003544,37519.00000000
-
Are you expecting multiple time frames for the same symbol to be in the same CSV file ? ( in that case how do you know which time frame each line is associated with ?
-
I think the easiest way is to separate tickets with the external script and get set of files/DatsFrames suitable for
bt
. Otherwise it requires writing of the new data feed class. -
Your best approach:
-
Load it with
pandas.read_csv
-
Separate by symbol by using, for example, the clause
where
(that is, you create a mask that considers only the name of a ticker) -
Write the result of each mask to a separate
csv
file.
The last step can actually be forfeited, because you end up with several
pandas.DataFrames
which can be directly fed tocerebro
viaPandasData
-