Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Multiple Symbols in one CSV file

    General Code/Help
    4
    4
    269
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • *
      *Jenel Videos* last edited by

      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
      
      1 Reply Last reply Reply Quote 0
      • vladisld
        vladisld last edited by

        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 ?

        1 Reply Last reply Reply Quote 0
        • A
          ab_trader last edited by

          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.

          • If my answer helped, hit reputation up arrow at lower right corner of the post.
          • Python Debugging With Pdb
          • New to python and bt - check this out
          1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators last edited by

            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 to cerebro via PandasData

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors