SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Fri Dec 13, 2019 4:26 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Thu Oct 03, 2019 7:36 pm 
Offline

Joined: Mon Sep 02, 2019 10:31 am
Posts: 27
Hi Team,

I am trying to run a sample strategy "BollingerBands" with IQFeed and IB set as Data Provider and Execution Provider respectively. I've changed the sample code in "Scenario.cs" file as below (I just changed the QuantRouter to IQFeed and IB):

Code:
namespace OpenQuant
{
  public class Realtime : Scenario
  {
    private long barSize = 300;

    public Realtime(Framework framework)
      : base(framework)
    {
    }

    public override void Run()
    {
      Instrument instrument1 = InstrumentManager.Instruments["AAPL"];
      Instrument instrument2 = InstrumentManager.Instruments["MSFT"];

      strategy = new MyStrategy(framework, "BollingerBands");

      strategy.AddInstrument(instrument1);
      strategy.AddInstrument(instrument2);

      strategy.DataProvider = ProviderManager.GetDataProvider("IQFeed");
      strategy.ExecutionProvider = ProviderManager.GetExecutionProvider("IB");

      BarFactory.Clear();
      BarFactory.Add(instrument1, BarType.Time, barSize);
      BarFactory.Add(instrument2, BarType.Time, barSize);

      StartStrategy();
    }
  }
}


I also added some debug statements (Console.WriteLine) in OnBar method just to make sure that the Strategy receives bars or not.

When I run Strategy in either Paper or Live mode, it never attempts to connect to IBTWS as I don't see the prompt in TWS which I see every time when any client establishes a connection IBTWS. From logs, it appears that it is trying to connect to QuantRouter. Please find logs below:

Code:
10/03/2019 21:24:01.419 Event manager started at 10/03/2019 21:24:01.419
10/03/2019 21:24:01.423 Scenario::StartStrategy Paper
10/03/2019 21:24:01.423 StrategyManager::StartStrategy BollingerBands
Provider::Connect timed out : QuantRouter
Trigerred: OnStrategyStart
Provider::Connect timed out : QuantRouter
Trigerred: OnStrategyStart
Provider::Connect timed out : QuantRouter
10/03/2019 21:24:09.395 StrategyManager::StopStrategy BollingerBands


Also, when I try to run Strategy directly from VS. It throws System.NullReferenceException: 'Object reference not set to an instance of an object.'. Stacktrace is below:

Code:
   at QuKTDmNpoDpJwOsU7nI.ifPTAQN8HGpPujgMuDv..ctor(IDataSeries  , DateTime  , DateTime  , EventQueue  , DataProcessor  )
   at SmartQuant.DataSimulator.fGduM51K96(Instrument  , DateTime  , DateTime  )
   at SmartQuant.DataSimulator.Subscribe(InstrumentList instruments)
   at SmartQuant.SubscriptionManager.Subscribe(IDataProvider provider, InstrumentList instruments)
   at SmartQuant.StrategyManager.StartStrategy(Strategy strategy, StrategyMode mode)
   at SmartQuant.Scenario.StartStrategy()
   at OpenQuant.Realtime.Run() in C:\xxx\OpenQuant 2014\Solutions\BollingerBands\Realtime\Scenario.cs:line 32
   at OpenQuant.Program.Main(String[] args) in C:\xxx\OpenQuant 2014\Solutions\BollingerBands\Realtime\Program.cs:line 13


Can you please help me to rectify the issue and what I am missing?

Note: I've added references for IB and IQFeed DLLs.

Thanks!


Top
 Profile  
 
PostPosted: Fri Oct 04, 2019 11:10 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 562
I checked this scenario, works properly, logs:
Code:
10/04/2019 11:05:56.376 Event manager started at 10/04/2019 11:05:56.376
10/04/2019 11:05:56.385 Scenario::StartStrategy Paper
10/04/2019 11:05:56.385 StrategyManager::StartStrategy BollingerBands
[IQFeed] Status: Disconnected -> Connecting


1)Please double check StartUp project.
2)In paper mode, Execution provider will be ignored, as I explain here:
http://www.smartquant.com/forums/viewtopic.php?f=41&t=14964


Top
 Profile  
 
PostPosted: Fri Oct 04, 2019 7:18 pm 
Offline

Joined: Mon Sep 02, 2019 10:31 am
Posts: 27
Thanks @skuvv,

I was able to run sample strategy and place orders to IB when I set Realtime as Startup Project. I thought that selecting Live from the dropdown will take care of it.

Also, can we run these samples (say "BollingerBands") from VS directly? Actually, I was trying to run BollingerBands and debugging in VS because there are several features available in VS for debugging. But I got a System.NullReferenceException: 'Object reference not set to an instance of an object.'. at StartStrategy() call Stacktrace is below:

Code:
   at QuKTDmNpoDpJwOsU7nI.ifPTAQN8HGpPujgMuDv..ctor(IDataSeries  , DateTime  , DateTime  , EventQueue  , DataProcessor  )
   at SmartQuant.DataSimulator.fGduM51K96(Instrument  , DateTime  , DateTime  )
   at SmartQuant.DataSimulator.Subscribe(InstrumentList instruments)
   at SmartQuant.SubscriptionManager.Subscribe(IDataProvider provider, InstrumentList instruments)
   at SmartQuant.StrategyManager.StartStrategy(Strategy strategy, StrategyMode mode)
   at SmartQuant.Scenario.StartStrategy()
   at OpenQuant.Realtime.Run() in C:\xxx\OpenQuant 2014\Solutions\BollingerBands\Realtime\Scenario.cs:line 32
   at OpenQuant.Program.Main(String[] args) in C:\xxx\OpenQuant 2014\Solutions\BollingerBands\Realtime\Program.cs:line 13


Top
 Profile  
 
PostPosted: Mon Oct 07, 2019 10:17 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 562
harsh wrote:
Thanks @skuvv,

I was able to run sample strategy and place orders to IB when I set Realtime as Startup Project. I thought that selecting Live from the dropdown will take care of it.

There is no magic, if you set the name of the project "123", how OQ will understand that this project is realtime?

harsh wrote:
System.NullReferenceException: 'Object reference not set to an instance of an object.'. at StartStrategy() call Stacktrace is below:

It looks like you have a series which have no elements inside, at this moment you can find it and delete.
We will add the check for this situation to avoid error.

PS if you have solution for reproduce null reference error, please let me know.


Top
 Profile  
 
PostPosted: Mon Oct 07, 2019 2:05 pm 
Offline

Joined: Mon Sep 02, 2019 10:31 am
Posts: 27
Thanks skuvv, for the clarification that I needed.

Which project should I select as a startup project for Paper Trading mode?


Top
 Profile  
 
PostPosted: Mon Oct 07, 2019 3:17 pm 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 562
harsh wrote:
Thanks skuvv, for the clarification that I needed.

Which project should I select as a startup project for Paper Trading mode?

For Paper/Live it is BollingerBands\Realtime


Top
 Profile  
 
PostPosted: Mon Oct 07, 2019 9:05 pm 
Offline

Joined: Mon Sep 02, 2019 10:31 am
Posts: 27
Thanks @skuvv,

I have manually defined Execution and Data provider in Scenario.cs for BollinderBands\Realtime.

Code:
strategy.DataProvider = ProviderManager.GetDataProvider("IQFeed");
strategy.ExecutionProvider = ProviderManager.GetExecutionProvider("IB");


You said, when I select Paper mode, the framework will send orders to ExecutationSimulator. I want to confirm that, framework will still use Data provider which I've specified in code in this case?

Also, how does OQ change/ignore providers? Can we specify Paper mode using VS? I see only modes available for framework object are Realtime and Simulation, not Paper.

Thanks,
Shashwat


Top
 Profile  
 
PostPosted: Tue Oct 08, 2019 9:59 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 562
harsh wrote:
Also, how does OQ change/ignore providers? Can we specify Paper mode using VS? I see only modes available for framework object are Realtime and Simulation, not Paper.

You can start strategy with necessary mode, for example:
Code:
StartStrategy(StrategyMode.Paper);


Top
 Profile  
 
PostPosted: Tue Oct 08, 2019 2:14 pm 
Offline

Joined: Mon Sep 02, 2019 10:31 am
Posts: 27
Please correct me if I am wrong.

I select Paper mode from OQ, the framework will override execution simulator setting and will send orders to ExecutationSimulator. I want to confirm that, framework will still use Data provider which I've specified in code in this case for both Realtime and Paper mode.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 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