Merging 2 Bars Objects
Author: chamoun
Creation Date: 9/12/2012 3:26 PM
profile picture

chamoun

#1
I would like to extend a Bars object in Global memory with data from a shorter Bars object from a streaming strategy. What is the best way to do this? Bars.Append or Bars.AppendWithCorrections? or other recommended approach.

Thanks.
profile picture

Eugene

#2
But what's the purpose? Can you elaborate?
profile picture

chamoun

#3
Running a computationally intensive multi-symbol strategy (500+) on 100K 1 minute bars. The strategy uses a very actively traded symbol as the primary symbol - it loads and synchronize all Bars objects for the remaining symbols. A second simple strategy running in strategy monitor collects 390 live bars for 500 symbols and places objects in Global memory (needs 6.4 to fully scale) - after a predetermined time delay the main strategy merges the live bars with the synchronized 100K bars object for each symbol. The new objects are synchronized again only if the length of a secondary symbol is different (ie no data for the current minute). This approach reduces the number of synchronizations I need to make and keeps the memory foot print of my data collection strategy very small so data updates are fast.

I tried operating on the original bars object created by the data collection strategy but I could not find a way to modify it after a synchronize which meant all 499 symbols had to be synchronized every minute.

On a related topic - how do I find out which bars in a series have been inserted by synchronize (Bars.IsSynthetic?) - I would like to set the volume to 0.

Thanks.
profile picture

Eugene

#4
Thanks for the clarification.

You don't need Bars.AppendWithCorrections which is used only by static data providers like Fidelity or Yahoo that support the feature (i.e. request the OHLC data for last N trading sessions from the vendor/backend, append corrections (if available), and then save). Bars.Append is enough to add some bars and then return the updated Bars object.
profile picture

chamoun

#5
Sounds good.

Is Bar.IsSynthetic the best way to identify Bars inserted or changed by Synchronize?

Thanks Again.
profile picture

Eugene

#6
Nope, that property is used for identifying Daily (only) bars inserted by the AddCalendarDays method.
profile picture

chamoun

#7
Ok

Is there a straight forward way to identify bars that have been inserted by synchronize?

Is there a way to have synchronize to apply 0 volume for inserted bars?
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).