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

The CLI commands that switch a gateway's business rejects per ID: REJECT_LOGON, REJECT_NEW_ORDERS and LIST_REJECTS. More...

Classes

struct  Command
 One command, as the CLI server hands it to the thread that runs it. More...
class  CliEndpoint
 Where the CLI server's commands reach a thread that owns some state (the main thread, or a venue's order gateway), and where that thread's answers come back. More...
class  CliServer
 The simulator's command port: a small TCP server on its own thread that takes CliRequestMessages (common/control_messages.hpp) and hands each one, through a lock-free CliEndpoint, to the thread that owns what it changes. More...

Functions

std::string instance_path (std::string_view venue, std::string_view instance)
 <venue>/<instance>, or <venue> alone for the one instance of a venue configured without a list of them, which exch::expand_instances names after the venue.
std::string venue_path (std::string_view venue, std::string_view rest={})
 <venue>[/<rest>], the venue lowercased (CME -> cme).
std::string pcap_feed_path (std::string_view venue, std::string_view feed)
 pcap/<venue>/<feed>.
constexpr std::string_view cut_text (std::string_view text, size_t size) noexcept
 text cut to size bytes, backing off up to 3 so as not to split a UTF-8 character.
bool refuse_unserved (const Command &command, std::string &out)
 A handler's answer to a command it doesn't serve: says so in out, false.
constexpr slick::logger::LogLevel log_level (CliCommandType command) noexcept
 What a command and its answer are logged at: DEBUG for what clients poll.
template<typename Set>
bool toggle_id (Set &ids, const Command &command, std::string &out)
 Adds the command's ID to ids (flag 1) or removes it (flag 0), and says so in out.
template<typename Set>
void list_ids (const Set &ids, std::string_view name, std::string &out)
 "<name>: a b c", sorted, or "<name>: (none)".
template<typename Set, typename OnNewOrders>
bool serve_rejects (const Command &command, Set &reject_logon, Set &reject_new_orders, OnNewOrders &&on_new_orders, std::string &out)
 Serves the reject commands against a gateway's two lists.

Detailed Description

The CLI commands that switch a gateway's business rejects per ID: REJECT_LOGON, REJECT_NEW_ORDERS and LIST_REJECTS.

Shared by the venues that offer them.

Function Documentation

◆ cut_text()

std::string_view slick::sim::cli::cut_text ( std::string_view text,
size_t size )
nodiscardconstexprnoexcept

text cut to size bytes, backing off up to 3 so as not to split a UTF-8 character.

Definition at line 44 of file cli_endpoint.hpp.

Referenced by slick::sim::md_feed::PcapControlServer::publish_status().

◆ instance_path()

std::string slick::sim::cli::instance_path ( std::string_view venue,
std::string_view instance )
inline

<venue>/<instance>, or <venue> alone for the one instance of a venue configured without a list of them, which exch::expand_instances names after the venue.

Definition at line 15 of file cli_endpoint.hpp.

Referenced by slick::sim::exch::Exchange::feedInfo().

◆ list_ids()

template<typename Set>
void slick::sim::cli::list_ids ( const Set & ids,
std::string_view name,
std::string & out )

"<name>: a b c", sorted, or "<name>: (none)".

Definition at line 41 of file reject_commands.hpp.

Referenced by serve_rejects().

◆ log_level()

slick::logger::LogLevel slick::sim::cli::log_level ( CliCommandType command)
nodiscardconstexprnoexcept

What a command and its answer are logged at: DEBUG for what clients poll.

Definition at line 73 of file cli_endpoint.hpp.

References slick::sim::LIST_FEEDS, and slick::sim::PCAP_STATUS.

Referenced by slick::sim::cli::CliEndpoint::serve().

◆ pcap_feed_path()

std::string slick::sim::cli::pcap_feed_path ( std::string_view venue,
std::string_view feed )
inline

pcap/<venue>/<feed>.

Every pcap feed is under pcap, so a venue's own targets still reach only its gateways.

Definition at line 39 of file cli_endpoint.hpp.

References venue_path().

◆ refuse_unserved()

bool slick::sim::cli::refuse_unserved ( const Command & command,
std::string & out )
inline

A handler's answer to a command it doesn't serve: says so in out, false.

Definition at line 66 of file cli_endpoint.hpp.

References slick::sim::cli::Command::command, and slick::sim::to_string().

Referenced by serve_rejects().

◆ serve_rejects()

template<typename Set, typename OnNewOrders>
bool slick::sim::cli::serve_rejects ( const Command & command,
Set & reject_logon,
Set & reject_new_orders,
OnNewOrders && on_new_orders,
std::string & out )

Serves the reject commands against a gateway's two lists.

on_new_orders(id, on) hears every REJECT_NEW_ORDERS, so sessions already open can follow it. A logon refusal needs no such call: it is checked at each logon. False, with the reason in out, for any other command.

Definition at line 60 of file reject_commands.hpp.

References slick::sim::cli::Command::arg_view(), slick::sim::cli::Command::command, slick::sim::cli::Command::flag, list_ids(), slick::sim::LIST_REJECTS, refuse_unserved(), slick::sim::REJECT_LOGON, slick::sim::REJECT_NEW_ORDERS, slick::sim::to_string(), and toggle_id().

◆ toggle_id()

template<typename Set>
bool slick::sim::cli::toggle_id ( Set & ids,
const Command & command,
std::string & out )

Adds the command's ID to ids (flag 1) or removes it (flag 0), and says so in out.

False when there is no ID. Set is an unordered_set<std::string> with a transparent hash, as the gateways keep their lists in.

Definition at line 18 of file reject_commands.hpp.

References slick::sim::cli::Command::arg_view(), slick::sim::cli::Command::command, slick::sim::cli::Command::flag, and slick::sim::to_string().

Referenced by serve_rejects().

◆ venue_path()

std::string slick::sim::cli::venue_path ( std::string_view venue,
std::string_view rest = {} )
inline

<venue>[/<rest>], the venue lowercased (CME -> cme).

Definition at line 25 of file cli_endpoint.hpp.

Referenced by slick::sim::exch::Exchange::feedInfo(), and pcap_feed_path().