SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Wed Dec 11, 2019 4:02 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: DataSimulator Subscribe
PostPosted: Thu Dec 20, 2018 8:19 am 
Offline

Joined: Thu Dec 06, 2018 1:57 am
Posts: 28
Hi. Having a problem with DataSimulator.Subscribe. What I need is historical exchange rates to use in my strategy. So I don't wish to trade these instruments but rather be using them for calculations in my backtest. When i use DataSimulator.Subscribe more than once I get the error:

DataSeriesObject synch error. skipping.

Here is an example code which leads to my error:

Code:
using System;

using SmartQuant;

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

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

            strategy.AddInstrument("CME_ES1");
           
            DataSimulator.Subscribe(InstrumentManager.Instruments["EUR"]);
            DataSimulator.Subscribe(InstrumentManager.Instruments["CAD"]);

            StartStrategy();
        }
    }
   
}


In the above CME_ES1 is the instrument i wish to trade,daily bars (OHLC), whilst my currency data is daily trades. For each new usage of DataSimulator.Subscribe i get the another synch error.

Am I going about this the correct way?

Cheers


Top
 Profile  
 
PostPosted: Fri Feb 22, 2019 10:50 am 
Offline

Joined: Thu Feb 05, 2015 11:15 am
Posts: 39
same error

abasqd wrote:
Hi. Having a problem with DataSimulator.Subscribe. What I need is historical exchange rates to use in my strategy. So I don't wish to trade these instruments but rather be using them for calculations in my backtest. When i use DataSimulator.Subscribe more than once I get the error:

DataSeriesObject synch error. skipping.

Here is an example code which leads to my error:

Code:
using System;

using SmartQuant;

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

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

            strategy.AddInstrument("CME_ES1");
           
            DataSimulator.Subscribe(InstrumentManager.Instruments["EUR"]);
            DataSimulator.Subscribe(InstrumentManager.Instruments["CAD"]);

            StartStrategy();
        }
    }
   
}


In the above CME_ES1 is the instrument i wish to trade,daily bars (OHLC), whilst my currency data is daily trades. For each new usage of DataSimulator.Subscribe i get the another synch error.

Am I going about this the correct way?

Cheers


Top
 Profile  
 
PostPosted: Fri Feb 22, 2019 11:36 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 562
DataSimulator.Subscribe() was not designed for usage in this case.
Nevertheless, it can be used here with this trick:
Code:
         DataSimulator.RunOnSubscribe = false;
         DataSimulator.Subscribe(InstrumentManager.Instruments["MSFT"]);
         DataSimulator.Subscribe(InstrumentManager.Instruments["CSCO"]);
         DataSimulator.RunOnSubscribe = true;


Other way to subscribe data directly in DataSimulator is adding data series:
Code:
         DataSeries series = framework.DataManager.GetDataSeries(instrument, DataObjectType.Trade);

         if (series != null && !DataSimulator.Series.Exists(x => x.Name == series.Name))
            DataSimulator.Series.Add(series);


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 4 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:  
Powered by phpBB® Forum Software © phpBB Group