Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
Loading...
Searching...
No Matches
exchange_registry.hpp File Reference
#include <common/types.hpp>
#include <memory>
#include <string>
#include <string_view>
#include <vector>
#include <nlohmann/json_fwd.hpp>
Include dependency graph for exchange_registry.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  slick::sim::exch::ExchangeRegistry
 Maps a key under the config's exchanges object (e.g. More...

Namespaces

namespace  slick
namespace  slick::sim
namespace  slick::sim::exch
 Helpers for a venue whose one config entry describes several independent exchange instances, such as CME's market segments or ICE's silos.

Concepts

concept  slick::sim::exch::MultiInstanceVenue
 A venue whose one config entry can describe several exchanges.

Macros

#define SLICK_SIM_REGISTER_VENUE(key, venue_enum, ExchangeType)
 Defines a venue's factory and registers it.

Functions

template<typename T, typename Base = Exchange>
std::vector< std::unique_ptr< Base > > slick::sim::exch::make_exchanges (const nlohmann::json &config)
 The factory body SLICK_SIM_REGISTER_VENUE registers.

Macro Definition Documentation

◆ SLICK_SIM_REGISTER_VENUE

#define SLICK_SIM_REGISTER_VENUE ( key,
venue_enum,
ExchangeType )
Value:
namespace { \
::std::vector<::std::unique_ptr<::slick::sim::exch::Exchange>> \
slick_sim_make_##ExchangeType(const ::nlohmann::json &config) { \
return ::slick::sim::exch::make_exchanges<ExchangeType>(config); \
} \
[[maybe_unused]] const bool slick_sim_registered_##ExchangeType = \
::slick::sim::exch::ExchangeRegistry::instance().add( \
key, venue_enum, &slick_sim_make_##ExchangeType); \
} \
static_assert(true, "require a trailing semicolon")

Defines a venue's factory and registers it.

Place at namespace scope in exactly one translation unit of the venue library:

SLICK_SIM_REGISTER_VENUE("coinbase", Venue::COINBASE, CoinbaseExchange);

The factory builds one ExchangeType from the venue's config entry, unless ExchangeType declares

static std::vector<std::unique_ptr<Exchange>> create_instances(const nlohmann::json &);

in which case that decides how many instances the entry describes.

That TU must live in an OBJECT library - see cmake/slick_sim_venue.cmake for why a static library would let the linker drop this registration entirely.

Definition at line 100 of file exchange_registry.hpp.