SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Sat Dec 07, 2019 8:09 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Sep 27, 2019 3:40 pm 
Offline

Joined: Wed Aug 07, 2019 7:49 am
Posts: 20
Hi,

I've noticed that when the StrategyManager starts a Strategy_ in StrategyMode.Backtest, Framework.Clock.DateTime is not set to DataSimulator.DateTime1 until after OnStrategyInit and OnStrategyStart are called, whereas when the StrategyManager starts a Strategy in StrategyMode.Backtest, Framework.Clock.DateTime is set to DataSimulator.DateTime1 before OnStrategyInit and OnStrategyStart are called.

See the code and output for an example:

public class MyStrategy : SmartQuant.Strategy_.Strategy_
{
public MyStrategy(Framework framework, string name)
: base(framework, name)
{
}

protected override void OnStrategyInit()
{
Console.WriteLine($"OnStrategyInit({Framework.Clock.DateTime})");
}
protected override void OnStrategyStart()
{
Console.WriteLine($"OnStrategyStart({Framework.Clock.DateTime})");
}
}
public partial class MyScenario : SmartQuant.Strategy_.Scenario_
{
public MyScenario(Framework framework)
: base(framework)
{
}

public override void Run()
{
strategy = new MyStrategy(framework, "Backtest");

Initialize();

strategy.DataSimulator.DateTime1 = new DateTime(2011,11,11);
strategy.DataSimulator.DateTime2 = new DateTime(2011,11,11);

Start(strategy, StrategyMode.Backtest);
}
}
Prints:
09/27/2019 21:52:13.341 Scenario::StartStrategy Backtest in Backtest
OnStrategyInit(01/01/0001 00:00:00.000)
OnStrategyStart(01/01/0001 00:00:00.000)
09/27/2019 21:52:13.349 Data simulator thread started
09/27/2019 21:52:13.363 Data simulator thread stopped
09/27/2019 21:52:13.365 Data run done[OpenQuant], count = 0 ms = 3 event/sec = 0
09/27/2019 21:52:13.370 Scenario::StartStrategy Done


VERSUS


public class MyStrategy : Strategy
{
public MyStrategy(Framework framework, string name)
: base(framework, name)
{
}
protected override void OnStrategyInit()
{
Console.WriteLine($"OnStrategyInit({framework.Clock.DateTime})");
}
protected override void OnStrategyStart()
{
Console.WriteLine($"OnStrategyStart({framework.Clock.DateTime})");
}
}

public partial class MyScenario : Scenario
{
public MyScenario(Framework framework)
: base(framework)
{
}

public override void Run()
{
strategy = new MyStrategy(framework, "Backtest");

Initialize();

strategy.DataSimulator.DateTime1 = new DateTime(2011,11,11);
strategy.DataSimulator.DateTime2 = new DateTime(2011,11,11);

StartStrategy(strategy, StrategyMode.Backtest);
}
}
Prints:
09/27/2019 22:01:17.096 Scenario::StartStrategy Backtest
09/27/2019 22:01:17.096 StrategyManager::StartStrategy Backtest
OnStrategyInit(11/11/2011 00:00:00.000)
OnStrategyStart(11/11/2011 00:00:00.000)
09/27/2019 22:01:17.098 StrategyManager::StartStrategy Backtest has no data requests in backtest mode, stopping...
09/27/2019 22:01:17.098 StrategyManager::StopStrategy Backtest
09/27/2019 22:01:17.098 Scenario::StartStrategy Done


This is a problem for me because I am using Strategy_ and programmatically selecting which futures contract to begin with based on Clock.DateTime. It appears to be a bug to me because logically I think OnStrategyInit and OnStrategyStart should be called on the DateTime that the backtest starts as it is with the Strategy class. Is this a bug or intentional by design of StrategyManager_?


Top
 Profile  
 
PostPosted: Mon Sep 30, 2019 9:43 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 562
Hi,
changes will be available in next release of OQ2014.


Top
 Profile  
 
PostPosted: Mon Sep 30, 2019 1:42 pm 
Offline

Joined: Wed Aug 07, 2019 7:49 am
Posts: 20
Great, Thankyou.


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: Bing [Bot] and 2 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