Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6772413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:32:47+00:00 2026-05-26T15:32:47+00:00

I delved into C# but came across a problem that I seem unable to

  • 0

I delved into C# but came across a problem that I seem unable to solve:

I designed a financial back test and trading engine and as part of that I like to implement a “Strategy Container”. This strategy container should serve two purposes. (1) hold instances of different strategies that perform mathematical computations, and (2) provide accessors in order to pass new tick data into the strategy instances and to receive certain information back from the strategy instances.

The different strategies I mentioned above should be unique classes which, however, derive from a base class. I want to perform completely different operations within those strategies thus I thought designing them as separate classes that derive from one base class would be feasible. One complication is that I need multiple instances of each strategy class that is contained in the Strategy Container. Each strategy class also holds a list of stock symbols and each symbol should get its on strategy instance.

Another important point of the Strategy container is that it can create, instantiate, and later also invoke each strategy instance.

I wanted to ask some of you what kind of ideas you have how I could go about designing and implementing this:

  • what would be the overall best design pattern?
  • as described if I create different classes for each strategy then I would obviously end up with different types as well, how could I hold all those in one container/collection within the Strategy Container?
  • How can I either through reflection or other means create, instantiate, and invoke methods of each single strategy instance without knowing how many I would end up with. I do know the names and types of the strategies and I know the names of the stock symbols.
  • I simply want to supply which strategies I want to hook up (I supply the strategy names = class names?) and for each strategy a list of stock symbols. The Strategy Container would create instances for each symbol in each strategy of the strategy type that the list was supplied for and would subsequently invoke a “RunStrategy(Quote quote)” method that feeds new quotes into each instance so that computations can be performed.
  • One goal would be to keep the interface of each strategy class as clean as possible, with most of the standard (repetitive) functionality being implemented in the derived-from base class.

I do not ask for full source code but for ideas what you think how I should design this thing and how I could accomplish each of above points. This is something for myself and wont turn into any commercial product. I am very comfortable with writing code that implements the mathematical bits and pieces but I am less familiar with design patterns and system architecture.

Edit:
Graymatter, I played a bit around and seems you provided exactly what I was looking for. Thanks a lot.

class Program
{
    static void Main(string[] args)
    {
        List<IStrategy> container = new List<IStrategy>();

        container.Add(new StrategyOne());

        container[0].AddValue(50);

        Console.ReadLine();
    }




}

public interface IStrategy
{
    void AddValue(int value);  
}


public class StrategyOne : StrategyBase
{
    public override void Calculates()
    {
        Console.WriteLine("This is my value: " + myValue);
    }

}

public class StrategyBase : IStrategy
{
    protected int myValue;

    public void AddValue(int value)
    {
        Console.WriteLine("Run Strategy in Base");

        myValue = value;

        Calculates();
    }

    public virtual void Calculates()
    {

    }  
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:32:48+00:00Added an answer on May 26, 2026 at 3:32 pm

    You should really look at using interfaces for this type of system. The interface is your contract with the strategy and you can any number of different implementations for the interface. Your container would then contain interfaces.

    Something like:

    public interface IStrategy
    {
      void RunStrategy(Quote quote);
    }
    

    Then your implementations would be something like this:

    public class StrategyOne : IStrategy
    {
      void RunStrategy(Quote quote)
      {
      }
    }
    

    The container could be:

    List<IStrategy> container = new List<IStrategy>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've only used XML RPC and I haven't really delved into SOAP but I'm
I haven't delved much into comet programming, but it interests me and I want
I have recently delved into creating custom ViewGroups and have encountered a problem I
Given this code snippet that can be readily pasted into Linqpad (or slightly modified
I've never really delved into the amazing cache techniques Rails provides until now. One
In order to gain more experience in Wordpress I delved into its code base
I've been programming for a while in objective-c, but I've unfortunately never delved very
Professionally I am a back-end Java developer, but recently I've been interested in writing
I am beginning to delve deeper into Perl, but am having trouble writing Perl-ly
I'm someone who writes code just for fun and haven't really delved into it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.