SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Nov 30, 2020 4:56 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon May 14, 2012 6:54 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
Hello,

I have ported over a strategy to OQ from another platform. The code compiles and runs without incident, and I just want to run the strategy in parallel on both platforms concurrently to ensure I did properly captured all of my trading rules.

Each day, my strategy imports historical data as of the beginning of the prior day for 4 instruments from NFIQFeed.

I am attempting to run a simple backtest of my code and have added the following code to my Scenario file:

Code:
      this.Solution.StartDate = new DateTime(2012, 5, 1);
      this.Solution.StopDate = new DateTime(2012, 5, 11);       
      
      Start();


However, when I run this, it begins running in realtime instead of from May 1st. Can someone please explain what I need to do to have the backtest run on my selected dates?

Do I need to first add the historical data from NFIQFeed to OQ's DataManager in order to run the backtest? If so, should I then remove the strategy code that retrieves the historical data from NFIQFeed?

Thank you.


Top
 Profile  
 
PostPosted: Tue May 15, 2012 7:29 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
Hello - can someone please advise on my question above regarding backtesting while using historical data from a provider? Thank you.


Top
 Profile  
 
PostPosted: Wed May 16, 2012 5:55 pm 
Offline

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

Yes, you should have some data in OQ local database in order to backtest you strategy on it. You can download it with your code (call DataManager.Add(...) to add the data to the local database) or right from OQ GUI.

Quote:
However, when I run this, it begins running in realtime instead of from May 1st. Can someone please explain what I need to do to have the backtest run on my selected dates?


Are you sure OQ is in the Simulation mode?

Regards,
Sergey.


Top
 Profile  
 
PostPosted: Wed May 16, 2012 6:03 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
As I want to run the test for the period May 1-14, I assume I will need to add data from the historical provider for the period from April 30-May 14 as my strategy requires importing bar data from the prior day.

Some questions:

1. Should I load trade data for the period and let my code strategy code create the 15 minute bars from trades? Or should I add the 15M bars to the OQ database?

2. Since my strategy contains code to pull historical data from a provider, do I need to make any code changes to the strategy in order to run the backtest? Or will it simply ignore that line of code when in simulation mode and pull from the OQ database?

Yes - I ran this in Simulation mode.

Thank you.


Top
 Profile  
 
PostPosted: Thu May 17, 2012 9:13 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
I am now able to load historical data from my provider to the OQ DB and read the trades into my strategy for backtesting. When I initially run the backtest, the timestamp in the lower right corner of the OQ window correctly shows the start time of the backtest. However, as soon as the backtest preloads the historical DB data, the timestamp immediately reverts to the current local time and it does not appear as though the backtest ran properly.

As a simple test, I added a line of code that outputs the value of a selected indicator to the console window at the close of each 15M bar. During the backtest run, nothing ever gets written to the console. Any suggestions on what I am doing incorrectly?

I know the code works in live trading and simply want to run it in parallel versus another platform for some prior days but cannot seem to make this work.

Are there any samples of backtesting strategies that require historical data?

Another question: In several places in my strategy, I reference the current UTC time to record when events ocurred. If I set the backtest dates from May 13-15, does the backtest adjust DateTime.UtcNow to be the time which the backtest is supposedly simulating (i.e. May 13 at 10:30 am) or will I need to change my strategy code in some way?


Top
 Profile  
 
PostPosted: Mon May 21, 2012 7:42 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
Any suggestions regarding my questions from May 17? Thank you.


Top
 Profile  
 
PostPosted: Tue May 22, 2012 10:28 am 
Offline

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

I am not sure what you are trying to acheive:

a) preload the data and backtest on it in Simulation mode
b) preload the data, run your system on this data (calculate indicators and some system parameters) and then start Live trading.
c) something else.

Normally for backtests you should first load the data (by a script, or a project or through the GUI), make sure the data exists in your local database and then run a usual backtest in Simulation mode.

If you need to preload data, calculate some values and then go Live - it is another story and here are some links that might be helpfull:
viewtopic.php?f=64&t=6227
viewtopic.php?f=64&t=8763

Please tell me exactly what you are trying to do and I will try to help you.

Quote:
Another question: In several places in my strategy, I reference the current UTC time to record when events ocurred. If I set the backtest dates from May 13-15, does the backtest adjust DateTime.UtcNow to be the time which the backtest is supposedly simulating (i.e. May 13 at 10:30 am) or will I need to change my strategy code in some way?


You should use Clock.Now property instead of DateTime.UtcNow. Clock.Now shows the timestamp of the latest emitted object in Simulation and DateTime.Now in Live/Paper.

Regards,
Sergey.


Top
 Profile  
 
PostPosted: Tue May 22, 2012 4:55 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
Perhaps I wasn't as clear as I should have been. I want to run a simple backtest over a short period. I do not need to run live. I have loaded historical data into the OQ DB for the dates on which I wish to run the backtest.

The issue was that my strategy requires preloading data before it can run as it must have some indicator values at the onStrategy Start event. I wasn't clear how to deal with this in the backtest, but I have figured it out.

The timestamp issue was the problem that I could not solve. I will try using Clock.Now. Thanks.


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

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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