Profile Picture

Questions on MySystemBase, MySymbolScriptBase refererencing their child class

Posted By neo 4 Years Ago

Questions on MySystemBase, MySymbolScriptBase refererencing their...

Message
neo
Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)
Posted Sunday May 05 2013
MySystemBase, MySymbolScriptBase are both the base class of actual strategy class MySymbolScript, MySystem.

Yet, these two base classes contains references of its derived classes.

// this is base class
public abstract class MySystemBase : SystemBase
{
...
// this is derived class
private SymbolScriptCollection _symbolScripts = new SymbolScriptCollection();
...
}

// this is base class
public class MySymbolScriptBase : SymbolScriptBase
{
// this is derived class
   public MySystem TradingSystem;
// this is derived class
   public SymbolScriptCollection OtherSymbols
   {
      get { return TradingSystem.SymbolScripts; }
   }
}

I just feel a bit weird of this approach, because generally the parent aren't really supposed to depends on its child class implementation, it is sort of violating the Inheritance design.

Is there any specific reason for this design?

Thanks.
Posted Monday May 06 2013
We want to make RightEdge as easy to use as possible for people who don't have much programming experience and definitely don't have any idea about object oriented design principles. So we're just using inheritance as a way to provide APIs that people can easily call from their system code, not as a way to encapsulate functionality that is reused in multiple derived classes.

Of course, more advanced programmers can set up things however they like. See for example the Multiple Frequency Logic and Multiple Systems example systems.

Thanks,
Daniel
neo
Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)
Posted Tuesday May 07 2013
Thanks for pointing out these systems.

I guess the real question is about circular reference. It seems not able to put the base classes to a different assembly because of this.
Imagine some common functionalities that can be used by different strategies, there won't be one place to override and applies to all different strategies.
Multiple system under one "meta" strategy seems to be a way, but it needs all strategies residing in one assembly. Is there a way to create different assembly for different strategies, while still refering to the same base class?
For example,

Project 1
Strategy 1 : StrategyBase
--
Project 2
Strategy 2 : StrategyBase
--
Project 3
StrategyBase

Thanks,

Edited: Tuesday May 07 2013 by neoaries
Posted Wednesday May 08 2013
Yes, you can have MySystemBase and MySymbolScriptBase derive from your own classes instead of directly from SystemBase and SymbolScriptBase. Right click on your trading system in the project tree, and in the compiler tab you can set a custom system base class and custom script base class.

You could also skip the generated classes entirely and have your MySystem and MySymbolScript derive from your own class. Then of course you wouldn't get the functionality that those generated classes add.

Thanks,
Daniel
neo
Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)Supreme Being (4,009 reputation)
Posted Saturday May 11 2013
It takes some trials and errors. Among other little things, noted that the namespace for strategy and its base classes is all blank. But I eventually got it work just like you said. Thanks!

Edited: Saturday May 11 2013 by neoaries


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems