Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
Loading...
Searching...
No Matches
coinbase_trade_encoder.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <common/messages.hpp>
5#include <nlohmann/json.hpp>
6
8
9// Encoders for Coinbase's `market_trades` channel, kept free of the socket layer
10// so the wire shape can be tested without standing up a WebSocket server.
11//
12// Every message carries the same envelope; only `sequence_num` differs per
13// socket, so the caller stamps that in before sending:
14//
15// {"channel":"market_trades","client_id":"","timestamp":"<iso8601>",
16// "sequence_num":N,
17// "events":[{"type":"update"|"snapshot","trades":[...]}]}
18//
19// Per-trade fields follow the venue: `price`, `size` and `trade_id` are strings,
20// `side` is the aggressor as "BUY"/"SELL", and `time` is microsecond ISO 8601.
21
23nlohmann::json encode_market_trade(const char* product_id, const TradeSummary& summary);
24
28nlohmann::json encode_market_trades(const char* product_id, const char* event_type,
29 const MDTrade* trades, uint32_t num_trades,
30 bool newest_first);
31
32} // end namespace slick::sim::md_publisher
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.