|
Slick Trader 0.11.0
Multi-broker algorithmic trading engine with plugin strategies and a live web dashboard
|
Maps a broker's config name (e.g. More...
#include <slick-trader/core/broker_registry.hpp>
Public Types | |
| using | Factory |
| A plain function pointer, not std::function - no allocation, no <functional>. | |
Public Member Functions | |
| bool | add (std::string_view key, Factory factory) |
| key is matched case-insensitively. | |
| Factory | find (std::string_view key) const noexcept |
| nullptr when no adapter for this key was built into the binary. | |
| std::shared_ptr< IBroker > | create (std::string_view key, const json &config, slick::stream_buffer_multiplexer &event_mux, slick::queue< uint8_t > &control_queue, slick::queue< uint8_t > &md_request_queue, slick::queue< uint8_t > &order_request_queue, std::string &error) const |
| Builds the broker registered under key. | |
| std::vector< std::string > | keys () const |
| Registered keys, lowercased, in registration order - for the startup log and for the error on an unknown key. | |
Static Public Member Functions | |
| static BrokerRegistry & | instance () |
Maps a broker's config name (e.g.
"coinbase") to the adapter that serves it, so no broker name appears in TradingEngine or in any core target. Each broker registers itself at static-init time with SLICK_TRADER_REGISTER_BROKER below, which is also how a broker kept out of tree (SLICK_TRADER_EXTERNAL_BROKERS) joins the build without editing it.
Populated once at startup and read once per configured broker, so nothing here is on a hot path: a flat vector is the right size.
Definition at line 24 of file broker_registry.hpp.
A plain function pointer, not std::function - no allocation, no <functional>.
Definition at line 27 of file broker_registry.hpp.
| bool slick::trader::BrokerRegistry::add | ( | std::string_view | key, |
| Factory | factory ) |
key is matched case-insensitively.
A second registration under the same key is refused and returns false; the first one stays. Returns a bool so a registration can initialise a namespace-scope constant.
Definition at line 24 of file broker_registry.cpp.
References find().
| std::shared_ptr< IBroker > slick::trader::BrokerRegistry::create | ( | std::string_view | key, |
| const json & | config, | ||
| slick::stream_buffer_multiplexer & | event_mux, | ||
| slick::queue< uint8_t > & | control_queue, | ||
| slick::queue< uint8_t > & | md_request_queue, | ||
| slick::queue< uint8_t > & | order_request_queue, | ||
| std::string & | error ) const |
Builds the broker registered under key.
nullptr, with the reason in error, when there is no such adapter or its constructor fails - a broker rejects a config it cannot run with by throwing, and that has to reach the log rather than end the process with nothing said.
Definition at line 47 of file broker_registry.cpp.
References find().
|
noexcept |
nullptr when no adapter for this key was built into the binary.
Definition at line 35 of file broker_registry.cpp.
|
static |
Definition at line 19 of file broker_registry.cpp.
Referenced by slick::trader::TradingEngine::initialize().
| std::vector< std::string > slick::trader::BrokerRegistry::keys | ( | ) | const |
Registered keys, lowercased, in registration order - for the startup log and for the error on an unknown key.
Definition at line 72 of file broker_registry.cpp.