nautechsystems / nautilus_trader

A high-performance algorithmic trading platform and event-driven backtester
https://nautilustrader.io
GNU Lesser General Public License v3.0
1.96k stars 448 forks source link

Factories for configuration constructables #1228

Open pontus-lund opened 1 year ago

pontus-lund commented 1 year ago

Feature Request

This comes from my own effort at a cheapskate persistent cache (driven by gdbm, as I don't like the cost of redis on AWS).

Many implementations of configurable components in the code base leave little room for adding custom implementations. This could be relieved by introducing factories where the user can register a new implementation of a component.

Right now I have to edit kernel.py to make use of my cheapskate cachedb, which is less than ideal, and it allows package users no non-cowboyish recourse if they want to introduce custom components.

cjdsellers commented 1 year ago

Hi @pontus-lund

Thanks for the feedback here. Were you aware of the CacheDatabase facade/interface, which just needs implementing to add different underlying technologies, I think then all we would need is a way to register this alternative impl which I think is what you're getting at with the factories? Then the CacheDatabaseConfig could name it as a type.

There's several places where we do have extension hook points, allow custom component registration and use factories, Account is one example of this.

pontus-lund commented 1 year ago

Correct, that is what I am looking for. And good pointer on Account, I have been wondering about that one a bit lately!