RightEdge Forums
Main     Home          Members     Calendar     Who's On

Welcome Guest
        



Aggregate bars to lower frequency to reduce... Expand / Collapse
Message
Posted 4/1/2011 01:38:34 Post #13029
 

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being
Is there a way to aggregate bars during simulation to reduce the memory required? For example, I have 1 min data which I run a daily system against; however, RE appears to load all minute data even when the Frequency (under General properties) is set to Daily. This obviously results in a larger memory footprint, which additionally reduces the number of symbols I can execute against, and a much slower simulation.

Thanks, Duane
Posted 4/1/2011 16:42:16 Post #13030
 

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being
If the above is not possible by simple means, I can always develop a DataStorage plugin to aggregate. I should note that I actually need aggregation from minute to hourly data even though the system is run on a daily basis.

For the DataStorage plugin I noticed a BarAggregator.AggregateBars method which works nicely; however, the method is obsolete. Is there a different way that I should accomplish aggregation?

Note, the preferred method to aggregate data would be in the symbol script to avoid duplication of data in the db.

Thanks, Duane
Posted 4/4/2011 14:01:56 Post #13038
 

DeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloper
RE appears to load all minute data even when the Frequency (under General properties) is set to Daily.


Well, to convert the minute data to daily data, it has to read all of the minute data, which means it all gets loaded into memory at one point or the other. However, it doesn't need to load it all at once. RightEdge does it in batches of 5000 bars per symbol. In .NET, memory that isn't needed anymore isn't necessarily garbage collected immediately. So the memory usage of a process isn't always a good indication of how the program is actually using memory-- if it's not actually running out of memory.

RightEdge breaks each of the bars from the data source into ticks. The ticks are then re-aggregated to the frequencies requested by the system. The ticks are also sent to the system as events. So using higher frequency data will be slower because there are more ticks to process. If you aggregate it into hourly data, the simulation will be faster, but the accuracy of the simulation will be less because there are only 1/60th as many price data points.

I hope this helps.

Thanks,
Daniel
Posted 4/4/2011 16:09:35 Post #13041
 

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being
The memory usage is too much on a minute basis so I converted to hourly data which will work. In order to do so, I’m using BarAggregator.AggregateBars but noticed that this is method is obsolete. Can you elaborate on why this is obsolete? Also, is there a different method to accomplish the same?

Thanks, Duane
Posted 4/6/2011 01:04:35 Post #13048
 

DeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloper
The old AggregateBars method was from before we added the multiple frequency support.  The new way to do it would be to create a TimeFrequency and feed it the bar data.  There's a BarUtils.ProcessRListInBarGenerator method which makes this a bit easier.  Here's how you can use it:

RList<BarData> AggregateBars(Symbol symbol, RList<BarData> sourceData, DateTime lastBarEnd, FrequencyPlugin targetFrequency)
{
RList<BarData> ret = new RList<BarData>();
IFrequencyGenerator generator = targetFrequency.CreateFrequencyGenerator();

// Bar construction type isn't important because we are aggregating bars, not ticks
generator.Initialize(symbol, BarConstructionType.Default);
generator.NewBar += delegate(object sender, SingleBarEventArgs e)
{
ret.Add(e.Bar);
};

generator.NewTick += delegate(object sender, NewTickEventArgs e)
{
ret.PartialItem = e.PartialBar;
};

BarUtils.ProcessRListInBarGenerator(generator, symbol, sourceData, lastBarEnd);

return ret;
}

You say the memory usage is too much.  What exactly is happening?  Is it throwing out of memory exceptions, running to slow, or what?

Thanks,
Daniel

Posted 4/6/2011 01:44:50 Post #13049
 

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being
Thank you for the code. Regarding the memory consumption, 2 things are occurring: the combination of RE and SQL server memory consumes a large amount of memory and the simulation runs slow due to the amount of minute bar data that needs to be processed (> 30 minutes for a 4 year sim on 1000 symbols).

I appreciate your support.

Duane
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: billb, young, dplaisted

Permissions Expand / Collapse

All times are GMT -5:00, Time now is 5:12pm

2005-2007 © RightEdge Systems