SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Tue Dec 10, 2019 6:39 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Sep 30, 2019 7:56 am 
Offline

Joined: Wed Aug 07, 2019 7:49 am
Posts: 20
I am inheriting from Strategy NOT InstrumentStrategy.

Calling Strategy.AddInstrument after DataProvider has been set to a SellSideStrategy produces the follwing exception in StrategyManager.StartStrategy.

System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at SmartQuant.StrategyManager.RegisterMarketDataRequest(IDataProvider dataProvider, InstrumentList instrumentList)
at SmartQuant.Strategy.IyAIcbAxSQ(Instrument , IDataProvider )
at SmartQuant.Strategy.HFVIbfPbhv(Subscription )
at SmartQuant.Strategy.PV4EBvLfD13()
at SmartQuant.StrategyManager.StartStrategy(Strategy strategy, StrategyMode mode)
at StrategyTests.RollerTests.TestScenario.Run() in C:\home\source\csharp\lib\Murphys\StrategyTests\RollerTests.cs:line 118
at StrategyTests.RollerTests.RollSellSide() in C:\home\source\csharp\lib\Murphys\StrategyTests\RollerTests.cs:line 93
at StrategyTests.RollerTests.Run() in C:\home\source\csharp\lib\Murphys\StrategyTests\RollerTests.cs:line 39

I have tested 5 cases:

(1)
To reproduce the exception:

// This produces the error when StrategyManager.StartStrategy is called
public class MyStrategy : Strategy
{
public SellSideStrategy sellSide;

public MyStrategy(Framework framework, string name) : base(framework, name)
{

sellSide = new SellSideStrategy(framework, "SellSide");
DataProvider = sellSide;
AddInstrument(InstrumentManager.Instruments["USDCAD"]);

} // throws exception

}

(2)
Aslo reproduces the exception:

// adding the instrument with specifying the DataProvider=sellSide also produces the exception
public MyStrategy(Framework framework, string name) : base(framework, name)
{

sellSide = new SellSideStrategy(framework, "SellSide");
// DataProvider = sellSide;
AddInstrument(InstrumentManager.Instruments["USDCAD"], sellSide);

} // throws exception

(3)

// If we swap the order of setting DataProvider and AddInstrument the error is bypassed:
public MyStrategy(Framework framework, string name) : base(framework, name)
{

sellSide = new SellSideStrategy(framework, "SellSide");
AddInstrument(InstrumentManager.Instruments["USDCAD"]);
DataProvider = sellSide;

} // works
(4)

// adding the instrument with specifying the DataProvider=DataSimulator avoids the error
public MyStrategy(Framework framework, string name) : base(framework, name)
{

sellSide = new SellSideStrategy(framework, "SellSide");
DataProvider = sellSide;
AddInstrument(InstrumentManager.Instruments["USDCAD"], DataSimulator);

} // works

(5)

// Setting DataProvider of the instrument to SellSideStrategy also throws exception:
public MyStrategy(Framework framework, string name) : base(framework, name)
{

sellSide = new SellSideStrategy(framework, "SellSide");
Instrument instrument = InstrumentManager.Instruments["USDCAD"];
instrument.DataProvider = sellSide;
AddInstrument(instrument);

} // throws exception

From the results of these test cases it is clear to me that adding an instrument with DataProvider=SellSideStrategy is broken. Please let me know if you agree this is an bug and if it will be fixed.


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

Joined: Wed May 05, 2010 9:49 pm
Posts: 562
Hi, thanks for details.
1-5) error fixed,
I also recommend using AddStrategy()
Code:
         SellSideStrategy sellSide = new SellSideStrategy(framework, "SellSide");
         
         GetRootStrategy().AddStrategy(sellSide);

         DataProvider = sellSide;
         
         AddInstrument(InstrumentManager.Instruments["IBM"]);


Update will be available on next release of OQ2014.


Top
 Profile  
 
PostPosted: Mon Sep 30, 2019 1:41 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: No registered users and 5 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