Slick Trader 0.11.0
Multi-broker algorithmic trading engine with plugin strategies and a live web dashboard
Loading...
Searching...
No Matches
broker_registry.hpp File Reference
#include <slick-trader/brokers/ibroker.hpp>
#include <slick/stream_buffer_multiplexer.hpp>
#include <nlohmann/json.hpp>
#include <cstdint>
#include <memory>
#include <string>
#include <string_view>
#include <vector>
Include dependency graph for broker_registry.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  slick::trader::BrokerRegistry
 Maps a broker's config name (e.g. More...

Namespaces

namespace  slick
namespace  slick::trader

Macros

#define SLICK_TRADER_REGISTER_BROKER(key, BrokerType)
 Defines a broker's factory and registers it.

Macro Definition Documentation

◆ SLICK_TRADER_REGISTER_BROKER

#define SLICK_TRADER_REGISTER_BROKER ( key,
BrokerType )
Value:
namespace { \
::std::shared_ptr<::slick::trader::IBroker> slick_trader_make_##BrokerType( \
const ::nlohmann::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) { \
return ::std::make_shared<BrokerType>( \
config, event_mux, control_queue, md_request_queue, order_request_queue); \
} \
[[maybe_unused]] const bool slick_trader_registered_##BrokerType = \
::slick::trader::BrokerRegistry::instance().add(key, &slick_trader_make_##BrokerType); \
} \
static_assert(true, "require a trailing semicolon")

Defines a broker's factory and registers it.

Place it once, at namespace scope, in a translation unit of the broker's library:

SLICK_TRADER_REGISTER_BROKER("coinbase", CoinbaseBroker);

That TU must live in an OBJECT library - slick_trader_add_broker() makes one - because nothing references the registration by name, and out of a static library the linker would drop it and the broker would silently vanish.

Definition at line 79 of file broker_registry.hpp.