SmartQuant Discussion
http://www.smartquant.com/forums/

DataSimulator Subscribe
http://www.smartquant.com/forums/viewtopic.php?f=60&t=14878
Page 1 of 1

Author:  abasqd [ Thu Dec 20, 2018 8:19 am ]
Post subject:  DataSimulator Subscribe

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

Author:  ericwang [ Fri Feb 22, 2019 10:50 am ]
Post subject:  Re: DataSimulator Subscribe

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

Author:  skuvv [ Fri Feb 22, 2019 11:36 am ]
Post subject:  Re: DataSimulator Subscribe

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);

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/