Search code examples
algorithmarchitecturealgorithmic-trading

Algo software architecture


I have the components of a trading robot. This follows the architecture of:

  1. Data layer - streaming and formatting data
  2. Model layer - updates model and writes events to event queue
  3. Intelligence layer - fetch event, classify (buy, sell, null), filter, construct order (instrument, buy/sell, stop), write to order queue
  4. Order layer - fetch event, choose size (or reject), place order, write order to DB

My question is:

  • What is the best design pattern to co-ordinate all components involved in each layer?

For a (simplified) example, I do not feel the following would be good practice:

  1. Model M creates an instance of DataSource D
  2. M creates an instance of Intelligence I
  3. I creates an instance of Order O

The main point of the above being everything instantiates everything else, so nothing is operating independently (thus reduced redundancy).

But I also don't feel like one class which instantiates everything and manages the interactions is good practice.

Can anyone advise?


Solution

  • This is why people use IoC, it solves this problem. https://en.wikipedia.org/wiki/Inversion_of_control

    Look at your language/framework stack, and search for an IoC library, it will likely fix most of your issues.