Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
Loading...
Searching...
No Matches
slick::sim::exch::ExchangeRegistry Class Reference

Maps a key under the config's exchanges object (e.g. More...

#include <exchange/exchange_registry.hpp>

Collaboration diagram for slick::sim::exch::ExchangeRegistry:

Public Types

using Factory = std::vector<std::unique_ptr<Exchange>> (*)(const nlohmann::json &config)
 A plain function pointer, not std::function - no allocation, no <functional>.

Public Member Functions

bool add (std::string_view key, Venue venue, Factory factory)
 key is matched case-insensitively, the same way to_venue matches a venue name.
Factory find (std::string_view key) const noexcept
 nullptr when no adapter for this key was built into the binary.
std::vector< std::string > keys () const
 Registered keys, in registration order - for the startup banner and for the error message on an unknown key.

Static Public Member Functions

static ExchangeRegistry & instance ()

Detailed Description

Maps a key under the config's exchanges object (e.g.

"coinbase") to the adapter that serves it, so no venue name appears in main.cpp or in any core target. Each venue library registers itself at static-init time via SLICK_SIM_REGISTER_VENUE below.

Populated once at startup and read once per configured exchange, so nothing here is on a hot path: a flat vector beats a hash map at this size and keeps the header free of <unordered_map>.

Definition at line 25 of file exchange_registry.hpp.

Member Typedef Documentation

◆ Factory

using slick::sim::exch::ExchangeRegistry::Factory = std::vector<std::unique_ptr<Exchange>> (*)(const nlohmann::json &config)

A plain function pointer, not std::function - no allocation, no <functional>.

One config entry can build several exchanges: a venue split into independent instances (an exchange's market segments) returns one per instance. Every other venue returns exactly one.

Definition at line 32 of file exchange_registry.hpp.

Member Function Documentation

◆ add()

bool ExchangeRegistry::add ( std::string_view key,
Venue venue,
Factory factory )

key is matched case-insensitively, the same way to_venue matches a venue name.

Returns true so a registration can initialise a namespace-scope constant.

Definition at line 13 of file exchange_registry.cpp.

◆ find()

ExchangeRegistry::Factory ExchangeRegistry::find ( std::string_view key) const
noexcept

nullptr when no adapter for this key was built into the binary.

Definition at line 18 of file exchange_registry.cpp.

References slick::sim::detail::iequals().

◆ instance()

ExchangeRegistry & ExchangeRegistry::instance ( )
static

Definition at line 6 of file exchange_registry.cpp.

Referenced by main().

◆ keys()

std::vector< std::string > ExchangeRegistry::keys ( ) const

Registered keys, in registration order - for the startup banner and for the error message on an unknown key.

Definition at line 29 of file exchange_registry.cpp.


The documentation for this class was generated from the following files: