SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Sat Jan 25, 2020 10:03 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Nov 06, 2013 3:53 am 
Offline

Joined: Sat Jul 13, 2013 3:57 am
Posts: 52
Up to this point I haven't used OpenQuant for simulation/back testing. I would now like to implement simulation/back testing in my strategy and I don't fully understand how the simulator works. In my strategy, I build my own bars from trades so that I can accommodate any time frame (i.e. 5 hour, 7 hour, 4:30 hour, 5:40 hour, etc.). I do this by pulling 5 minute historical bars and then combining them to the desired time frame using a custom method. I add/update using Bars.Add (so they are plotted) and my indicator is based off of those bars. If the time frames don't evenly divide into 24 hours, I'll typically start a new bar at 00:00:00 to keep things uniform.

If I add 5 minute bars to "Market Data" and run the simulation, OpenQuant plots 5 minute bars. Is there a way to add bars with custom (and possibly non-uniform) time frames into the Data Manager for the simulator to run against? If so, how? If not, what is the best way to accomplish this? Should I run the simulator with 5 minute bars, but create a separate BarSeries with my custom time frames by calling my custom method in the OnBar() method? Then, use my separate BarSeries as my indicator input? If this is required, is there a way to plot my BarSeries rather than have the 5 minute bars plotted (since I'm not using them for anything other than creating my own bars)?


Top
 Profile  
 
PostPosted: Wed Nov 06, 2013 10:59 am 
Offline

Joined: Wed Oct 08, 2003 1:06 pm
Posts: 833
Hi,

OQ doesn't build uniform bars by default, but yes, you can build them in the strategy code if you need. The best way to do what you need is to create a BarSeries in OnStrategyStart handler, like:
Code:
myCustomBarSeries=GetBars((5 * 60 + 40) * 60);
(for 5:40 bars), use this series as your indicators input and add bars to this series in the strategy code. In this case this series will be plotted on the BarChart. There is no way to remove 5 min bar series from the BarChart if 5 min bars are subscribed in the MarketData section, though you can clear this series in OnStrategyStop handler if you need:
Code:
GetBars(300).Clear();

Regards,
Sergey.


Top
 Profile  
 
PostPosted: Wed Nov 06, 2013 3:21 pm 
Offline

Joined: Sat Jul 13, 2013 3:57 am
Posts: 52
Okay, so I already have everything working in Live/Paper mode using Trade data only. It sounds like for simulation to work properly, I need to subscribe to 5 min bars in simulation mode, build my own custom bars in a new BarSeries, and use that BarSeries for my indicator. When simulation runs, it will run against the 5 minute bars, but my strategy code will only reference my BarSeries and indicator for the logic. At this point all back testing data should be correct, but just the chart will be incorrect.

Am I understanding all of this properly?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group