For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

How to combine or merge different data sources?



  • What is the easiest way to combine different data sources?

    I realise that we can call cerebro.adddata() multiple times to add multiple "data" objects to cerebro (usually used to handle multiple stocks, as one stock is one "data" object).

    However, what if we have 2 (or more) data sources for each stock? E.g. we want to use data from YahooFinancialData, and at the same time, for the same set of stocks, we want to load some other data from a CSV.

    I suppose we could simply just keep calling cerebro.adddata() for these as well, but then each of these would be a new "data" object. We would end up with 2 data objects for each stock. What if we want to keep it at one stock - one data? How would we combine two data sources and merge them into one data object in cerebro?


  • administrators

    You obviously create your own data feed which combines whatever you want from the 2 data sources.



  • @backtrader how do you recommend doing this merge in Live mode?
    Meaning, I have IB as the store and broker, and I have two data sources: SPY and VIX, both with daily resampling. How do you recommend merging both bars so we can do calculations on that resulting merged row?



  • @pablomarin check out backfill_from parameter for IB Data.

    An additional data source can be passed to do an initial layer of backfilling. Once the data source is depleted and if requested, backfilling from IB will take place. This is ideally meant to backfill from already stored sources like a file on disk, but not limited to.

    Docs - Interactive Brokers - IBData


  • administrators

    I assume that @ab_trader has nailed it and you are looking to backfill a live data.

    If not, I then fail to understand what the actual goal is.


Log in to reply
 

});