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

A venue's market data replayed from captured multicast, behind a control channel. More...

#include <md_feed/pcap_feed.hpp>

Inheritance diagram for slick::sim::md_feed::PcapFeedBase:
Collaboration diagram for slick::sim::md_feed::PcapFeedBase:

Public Member Functions

 PcapFeedBase (std::string name, Venue venue, const PcapFeedConfig &config, std::vector< PcapLine > lines, std::shared_ptr< ReplayGate > gate)
 gate is shared with the market-data publisher, which holds market data back until it opens.
 ~PcapFeedBase () override
void start () override
void stop () override
void poll (uint64_t now_ns)
 Exchange thread: serves control requests, advances the state machine and feeds the handler what is due.
FeedState state () const noexcept
const std::string & name () const noexcept
FeedKind feedKind () const noexcept override
std::string feedName () const override
 Its name, different from the venue's other feeds'. Empty for a feed without one.
uint16_t control_port () const noexcept
 The listening port of the control channel (0 before start()).
cli::CliEndpoint * cliEndpoint () noexcept override
 pcap/<venue>/<feed>: replay and status, served on the control channel's thread (by poll() if that never started).
uint64_t event_time_ns () const noexcept
 Wall time to stamp on the events of the packet being handled.
Public Member Functions inherited from slick::sim::md_feed::MDFeed
virtual ~MDFeed ()=default

Protected Member Functions

virtual void on_packet (uint8_t line, const uint8_t *data, size_t size, uint64_t now_ns)=0
 Hands one captured packet to the venue's protocol handler.
virtual void on_timer (uint64_t now_ns)=0
 The handler's timers (gap timeouts), while it is being fed.
virtual bool synchronized () const =0
 True once the handler holds a complete book.
virtual std::string describe () const
 What the handler has done so far, for the log at READY and at the end: packets, gaps, resting orders.

Detailed Description

A venue's market data replayed from captured multicast, behind a control channel.

The venue derives from this and supplies what is protocol: how a packet reaches its handler, and whether the handler has built the book. This class owns the rest:

LOADING open the capture files and read each line up to the window's begin SYNCING feed the handler at full speed until it reports the book built, which the snapshot capture does. No market data is published: the publisher's gate is closed. READY the book is held at that point. The capture is not read further. REPLAYING a client's START begins it: the gate opens, so the publisher sends every instrument from the held book on, and packets go to the handler paced by speed. A START that comes earlier is kept until READY. FINISHED the window is replayed out. (ERROR: a file or the sync failed.)

Every state change goes to the clients on the control channel, along with progress about once a second while the feed works.

Time: the sim runs on the wall clock. Pacing waits on it, and events are stamped with event_time_ns() - the wall time their capture time maps to - not the capture's own time. FeedStatusMessage::current_ns reports the capture time.

Threads: poll() and everything virtual run on the exchange thread, like every feed. The control channel and the capture reader have threads of their own.

Definition at line 80 of file pcap_feed.hpp.

Constructor & Destructor Documentation

◆ PcapFeedBase()

slick::sim::md_feed::PcapFeedBase::PcapFeedBase ( std::string name,
Venue venue,
const PcapFeedConfig & config,
std::vector< PcapLine > lines,
std::shared_ptr< ReplayGate > gate )

gate is shared with the market-data publisher, which holds market data back until it opens.

Definition at line 142 of file pcap_feed.cpp.

References slick::sim::md_feed::PcapFeedConfig::control_max_connections, slick::sim::md_feed::PcapFeedConfig::control_port, name(), and slick::sim::to_string().

◆ ~PcapFeedBase()

slick::sim::md_feed::PcapFeedBase::~PcapFeedBase ( )
override

Definition at line 162 of file pcap_feed.cpp.

References stop().

Member Function Documentation

◆ cliEndpoint()

cli::CliEndpoint * slick::sim::md_feed::PcapFeedBase::cliEndpoint ( )
inlineoverridevirtualnoexcept

pcap/<venue>/<feed>: replay and status, served on the control channel's thread (by poll() if that never started).

Reimplemented from slick::sim::md_feed::MDFeed.

Definition at line 102 of file pcap_feed.hpp.

◆ control_port()

uint16_t slick::sim::md_feed::PcapFeedBase::control_port ( ) const
inlinenodiscardnoexcept

The listening port of the control channel (0 before start()).

Definition at line 99 of file pcap_feed.hpp.

◆ describe()

virtual std::string slick::sim::md_feed::PcapFeedBase::describe ( ) const
inlinenodiscardprotectedvirtual

What the handler has done so far, for the log at READY and at the end: packets, gaps, resting orders.

Empty for nothing to say.

Definition at line 118 of file pcap_feed.hpp.

◆ event_time_ns()

uint64_t slick::sim::md_feed::PcapFeedBase::event_time_ns ( ) const
inlinenodiscardnoexcept

Wall time to stamp on the events of the packet being handled.

Meant to be read from the on_packet() callbacks the handler makes.

Definition at line 106 of file pcap_feed.hpp.

◆ feedKind()

FeedKind slick::sim::md_feed::PcapFeedBase::feedKind ( ) const
inlinenodiscardoverridevirtualnoexcept

Reimplemented from slick::sim::md_feed::MDFeed.

Definition at line 96 of file pcap_feed.hpp.

References slick::sim::md_feed::PCAP.

◆ feedName()

std::string slick::sim::md_feed::PcapFeedBase::feedName ( ) const
inlinenodiscardoverridevirtual

Its name, different from the venue's other feeds'. Empty for a feed without one.

Reimplemented from slick::sim::md_feed::MDFeed.

Definition at line 97 of file pcap_feed.hpp.

◆ name()

const std::string & slick::sim::md_feed::PcapFeedBase::name ( ) const
inlinenodiscardnoexcept

Definition at line 95 of file pcap_feed.hpp.

Referenced by PcapFeedBase().

◆ on_packet()

virtual void slick::sim::md_feed::PcapFeedBase::on_packet ( uint8_t line,
const uint8_t * data,
size_t size,
uint64_t now_ns )
protectedpure virtual

Hands one captured packet to the venue's protocol handler.

line is the value the venue gave its PcapLine. now_ns is the wall clock.

◆ on_timer()

virtual void slick::sim::md_feed::PcapFeedBase::on_timer ( uint64_t now_ns)
protectedpure virtual

The handler's timers (gap timeouts), while it is being fed.

◆ poll()

void slick::sim::md_feed::PcapFeedBase::poll ( uint64_t now_ns)

Exchange thread: serves control requests, advances the state machine and feeds the handler what is due.

Bounded work per call.

Definition at line 233 of file pcap_feed.cpp.

References slick::sim::ERROR, slick::sim::FINISHED, slick::sim::IDLE, and slick::sim::READY.

◆ start()

void slick::sim::md_feed::PcapFeedBase::start ( )
overridevirtual

Implements slick::sim::md_feed::MDFeed.

Definition at line 166 of file pcap_feed.cpp.

References slick::sim::ERROR, and slick::sim::LOADING.

◆ state()

FeedState slick::sim::md_feed::PcapFeedBase::state ( ) const
inlinenodiscardnoexcept

Definition at line 94 of file pcap_feed.hpp.

◆ stop()

void slick::sim::md_feed::PcapFeedBase::stop ( )
overridevirtual

Implements slick::sim::md_feed::MDFeed.

Definition at line 177 of file pcap_feed.cpp.

Referenced by ~PcapFeedBase().

◆ synchronized()

virtual bool slick::sim::md_feed::PcapFeedBase::synchronized ( ) const
nodiscardprotectedpure virtual

True once the handler holds a complete book.


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