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

Classes

class  MarketDataPublisher
class  SequencedMessage
 One fan-out payload, serialised once and stamped per subscriber. More...
class  WebsocketMarketDataPublisher
struct  PerSocketData
class  CoinbasePublisher
struct  L2Diff
struct  HyperliquidPerSocketData
class  HyperliquidPublisher

Typedefs

using json = nlohmann::json
using L2Levels = std::vector<std::pair<price_t, qty_t>>
using HyperliquidChannel = slick::sim::exch::HyperliquidChannel

Functions

json encode_market_trade (const char *product_id, const TradeSummary &summary)
 One executed trade, as a "type":"update" event.
json encode_market_trades (const char *product_id, const char *event_type, const MDTrade *trades, uint32_t num_trades, bool newest_first)
 A run of trades as a single event of the given type.
void split_book_snapshot (const MDLevel *levels, uint32_t num_bid, uint32_t num_ask, nlohmann::json::array_t &bids, nlohmann::json::array_t &asks, L2Levels &curr_bid, L2Levels &curr_ask)
L2Diff compute_l2_diff (const L2Levels &prev_bid, const L2Levels &prev_ask, const L2Levels &curr_bid, const L2Levels &curr_ask)
std::string encode_l2_diff (const nlohmann::json &payload)
json encode_trade_message (const char *coin, const TradeSummary &summary)
 One executed trade.
json encode_trade_message (const char *coin, const MDTrade *trades, uint32_t num_trades)
 A run of trades in the order given.
std::string to_hyperliquid_number (int_fast64_t value)
 Formats a fixed-point price or size as Hyperliquid does on the wire.

Variables

constexpr uint32_t L2_PUBLISH_DEPTH = 20

Typedef Documentation

◆ HyperliquidChannel

◆ json

using slick::sim::md_publisher::json = nlohmann::json

Definition at line 20 of file coinbase_publisher.hpp.

◆ L2Levels

using slick::sim::md_publisher::L2Levels = std::vector<std::pair<price_t, qty_t>>

Definition at line 14 of file hyperliquid_l2_diff.hpp.

Function Documentation

◆ compute_l2_diff()

L2Diff slick::sim::md_publisher::compute_l2_diff ( const L2Levels & prev_bid,
const L2Levels & prev_ask,
const L2Levels & curr_bid,
const L2Levels & curr_ask )

◆ encode_l2_diff()

std::string slick::sim::md_publisher::encode_l2_diff ( const nlohmann::json & payload)

Definition at line 138 of file hyperliquid_l2_diff.cpp.

◆ encode_market_trade()

nlohmann::json slick::sim::md_publisher::encode_market_trade ( const char * product_id,
const TradeSummary & summary )

◆ encode_market_trades()

nlohmann::json slick::sim::md_publisher::encode_market_trades ( const char * product_id,
const char * event_type,
const MDTrade * trades,
uint32_t num_trades,
bool newest_first )

A run of trades as a single event of the given type.

newest_first reverses the iteration: the venue orders snapshot trades newest first, while updates stay chronological. Emits an empty trades array when num_trades is zero.

Definition at line 53 of file coinbase_trade_encoder.cpp.

◆ encode_trade_message() [1/2]

nlohmann::json slick::sim::md_publisher::encode_trade_message ( const char * coin,
const MDTrade * trades,
uint32_t num_trades )

A run of trades in the order given.

Emits an empty data array when num_trades is zero.

Definition at line 42 of file hyperliquid_trade_encoder.cpp.

◆ encode_trade_message() [2/2]

nlohmann::json slick::sim::md_publisher::encode_trade_message ( const char * coin,
const TradeSummary & summary )

◆ split_book_snapshot()

void slick::sim::md_publisher::split_book_snapshot ( const MDLevel * levels,
uint32_t num_bid,
uint32_t num_ask,
nlohmann::json::array_t & bids,
nlohmann::json::array_t & asks,
L2Levels & curr_bid,
L2Levels & curr_ask )

◆ to_hyperliquid_number()

std::string slick::sim::md_publisher::to_hyperliquid_number ( int_fast64_t value)
inline

Formats a fixed-point price or size as Hyperliquid does on the wire.

The venue uses shortest-round-trip floats with at least one fractional digit: 77052 becomes "77052.0", while 0.73245 and 1.915 keep their existing digits. Use to_fixed_string with a one-digit minimum. In a session capture, all 201 distinct prices ended in ".0" and none of the 8807 distinct sizes had a trailing zero.

This matters for clients that key levels by the received price string. Coinbase uses to_price_string/to_qty_string instead and renders whole values without the fractional digit, such as "99".

Definition at line 19 of file hyperliquid_wire_format.hpp.

References slick::sim::to_fixed_string().

Variable Documentation

◆ L2_PUBLISH_DEPTH

uint32_t slick::sim::md_publisher::L2_PUBLISH_DEPTH = 20
inlineconstexpr

Definition at line 20 of file hyperliquid_l2_diff.hpp.

Referenced by split_book_snapshot().