SmartQuant Discussion
http://www.smartquant.com/forums/

Using Middle Priced Bars During Optimization
http://www.smartquant.com/forums/viewtopic.php?f=86&t=14602
Page 1 of 1

Author:  M101 [ Tue Aug 09, 2016 2:57 am ]
Post subject:  Using Middle Priced Bars During Optimization

Hi SQ,

I'm able to use Middle priced bars during a traditional backtest, but can't get them to work during an Optimization.

For instance, you'll see in the attached Solution file's Scenario.cs file I used
Quote:
BarFactory.Add(instrument1, BarType.Time, barSize, BarInput.Middle);

which got middle bars to work in the traditional backtest. However you'll see in the Optimization.cs file that the similar BarInput.Middle code I added did not get middle bars to work.

Any idea what I did wrong in the Optimization.cs file (or any other according files)?

Thanks

Attachments:
SMACrossover (Midbar Optimization).zip [15.4 KiB]
Downloaded 243 times

Author:  skuvv [ Tue Aug 09, 2016 1:54 pm ]
Post subject:  Re: Using Middle Priced Bars During Optimization

You can add BarFactoryItem with any parameters directly in OptimizationParameterSet:
Code:
               OptimizationParameterSet parameter = new OptimizationParameterSet();

               parameter.Add("Length1", length1);
               parameter.Add("Length2", length2);
               //parameter.Add("Bar", (long)60);

               BarFactoryItem barFactoryItem1 = new BarFactoryItem(instrument1, BarType.Time, 60, BarInput.Middle);
               BarFactoryItem barFactoryItem2 = new BarFactoryItem(instrument2, BarType.Time, 60, BarInput.Middle);
               
               parameter.Add("any name1", barFactoryItem1);
               parameter.Add("any name2", barFactoryItem2);
               
               universe.Add(parameter);

Updated solution:
Attachment:
SMACrossover (Midbar Optimization).zip [16.4 KiB]
Downloaded 257 times


PS you should update OpenQuant2014

Author:  M101 [ Wed Aug 10, 2016 2:59 am ]
Post subject:  Re: Using Middle Priced Bars During Optimization

Thanks.

Is the solution file you posted supposed to work as is with the latest version of OQ2014 (Version 1.0.6065.25132)?

I just tried it with that version of 0Q2014 and found the backtest results and optimization results to be inconsistent.

Author:  skuvv [ Wed Aug 10, 2016 11:37 am ]
Post subject:  Re: Using Middle Priced Bars During Optimization

M101 wrote:
Thanks.

Is the solution file you posted supposed to work as is with the latest version of OQ2014 (Version 1.0.6065.25132)?

I just tried it with that version of 0Q2014 and found the backtest results and optimization results to be inconsistent.

I slightly modified a solution.
1)usage TimeBarFactoryItem instead BarFactoryItem
2)a filtering of initial data series for make sure that existing data series(eg other bar series) will not interfere.
Attachment:
SMACrossover (Midbar Optimization).zip [16.44 KiB]
Downloaded 278 times

Author:  M101 [ Thu Aug 11, 2016 1:48 am ]
Post subject:  Re: Using Middle Priced Bars During Optimization

That Solution file in your last post gives consistent results between the backtest and optimization, which is great.

However it consumes a gigantic amount of memory when I broaden the optimization parameters. For instance, as a test in the Optimization.cs file I changed the 12 to a 60 and the 16 to an 80 (as shown below), which caused the my computer to use 28 gigs of Ram then freeze about 50% through the optimization.

Code:
//   for (int length1 = 10; length1 < 12; length1++)
//    for (int length2 = length1 + 1; length2 < 16; length2++)
   for (int length1 = 10; length1 < 60; length1++)
    for (int length2 = length1 + 1; length2 < 80; length2++)



Also, I tried using similar logic from your last post's Optimization.cs file on the SMAcrossover that came with OQ2014 Version 1.0.6065.25132 (see my new version attached) and the same issue with memory came up.


Is OQ2014 Version 1.0.6065.25132 the main release of your new Optimizer?
If not, I'll wait for a more official/permanent release of the new Optimizer before I continue trying to get this to work.

Attachments:
SMACrossover.zip [14.6 KiB]
Downloaded 257 times

Author:  skuvv [ Fri Aug 12, 2016 1:45 pm ]
Post subject:  Re: Using Middle Priced Bars During Optimization

We are working currently with memory leakage during optimization.

Author:  M101 [ Tue Aug 16, 2016 5:37 pm ]
Post subject:  Re: Using Middle Priced Bars During Optimization

Hi,

I just tried Optimizing Midbars in version 1.0.6072.27724 and am the memory issue is still coming up. However, the SMAcrossover solution that came with this version does not give me the memory issue.

Have you been able to Optimize Midbars is this version without the memory issue coming up?

Author:  skuvv [ Wed Aug 17, 2016 10:16 am ]
Post subject:  Re: Using Middle Priced Bars During Optimization

Can you please send me your solution which causes leakage?

Author:  M101 [ Wed Aug 17, 2016 8:10 pm ]
Post subject:  Re: Using Middle Priced Bars During Optimization

the leakage is caused by the solution file attached to post 4 of this thread when I change its parameters to 60 and 80 as explained in post 5 of this thread.

The leakage issue is also caused by the solution file attached to post 5 of this thread.

Author:  skuvv [ Thu Aug 18, 2016 12:38 pm ]
Post subject:  Re: Using Middle Priced Bars During Optimization

M101 wrote:
the leakage is caused by the solution file attached to post 4 of this thread when I change its parameters to 60 and 80 as explained in post 5 of this thread.

The leakage issue is also caused by the solution file attached to post 5 of this thread.

Fixed, new setup file already available.

Author:  M101 [ Fri Aug 19, 2016 1:29 am ]
Post subject:  Re: Using Middle Priced Bars During Optimization

Thanks Skuvv.

The memory issue went away, however the solution file(s) posted in this thread no longer fully work with the new Optimizer due to all the new updates.

Is the new Optimizer still in Beta?
If not can you please post an updated version of the Midbar Optimization solution file example that will work with the current version (1.0.6074.22566) of OQ2014?

P.S.
The current version of OQ2014's SMAcrossover example has the symbols AAPL and MSFT in its Scenario.cs file(s) and the symbols AMD and IBM in its Optimization.cs files. I'm guessing this is a mistake?

Author:  Dr. Anton Fokin [ Sat Aug 20, 2016 10:45 am ]
Post subject:  Re: Using Middle Priced Bars During Optimization

M101 wrote:
P.S.
The current version of OQ2014's SMAcrossover example has the symbols AAPL and MSFT in its Scenario.cs file(s) and the symbols AMD and IBM in its Optimization.cs files. I'm guessing this is a mistake?


There is no hidden meaning, the only reason is that AMD and IBM are better suitable for optimization demo and give a smoother objective curve during optimization, that's it.

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/