FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
fastmm::sim::StrategyHarness< S > Class Template Reference

#include <fastmm/testing/strategy_harness.hpp>

Public Types

using EngineType = Engine< S, SimClock, SimTransport, InlineFeed >
 

Public Member Functions

 StrategyHarness (const ParamMap &params={}, const HarnessOptions &options={})
 Configures the strategy with params (std::invalid_argument on a bad value), then warms up and starts the engine (on_start runs here).
 
void book (Price bid, Price ask, Qty size=Qty::from_int(1), InstrumentId id=InstrumentId{0})
 A one-level snapshot each side.
 
void book (std::string_view bid, std::string_view ask, InstrumentId id=InstrumentId{0})
 
void trade (Price px, Qty qty, Side aggressor, InstrumentId id=InstrumentId{0})
 
bool fill (Side side, Qty qty=Qty{}, InstrumentId id=InstrumentId{0})
 Fills our best working order on side (quantity 0: its whole remainder) with a taker order at the venue, then advances by the ack latency so the fill reaches the strategy.
 
std::vector< Order > working_orders (InstrumentId id=InstrumentId{0}) const
 Our working orders (Live or PartiallyFilled): bids best first, then asks best first.
 
void disconnect (std::uint8_t channel=0, VenueId v=VenueId{0})
 Channel 0 is market data (the engine clears the venue's books), 1 is order entry.
 
void reconnect (std::uint8_t channel=0, VenueId v=VenueId{0})
 
void pull_quotes ()
 
void resume_quotes ()
 
void publish (const std::vector< ParamPublisher::ParamValue > &values)
 A ParamUpdate of values (names and values as in [strategy.params]) for all instruments, at the current time: the strategy's parameters change and on_params runs.
 
void push (EventHeader &h)
 Any other message, delivered to the engine at the current time.
 
void advance (Duration d)
 Moves virtual time forward by d, delivering orders to the venue, acks and fills to the engine and firing timers in time order.
 
Timestamp now () const noexcept
 
EngineType & engine () noexcept
 
S & strategy () noexcept
 
SimTransport & venue_transport () noexcept
 

Static Public Member Functions

static InstrumentId instrument () noexcept
 
static Price price (std::string_view s)
 
static Qty quantity (std::string_view s)
 

Member Typedef Documentation

◆ EngineType

template<class S >
using fastmm::sim::StrategyHarness< S >::EngineType = Engine<S, SimClock, SimTransport, InlineFeed>

Constructor & Destructor Documentation

◆ StrategyHarness()

template<class S >
fastmm::sim::StrategyHarness< S >::StrategyHarness ( const ParamMap &  params = {},
const HarnessOptions &  options = {} 
)
inlineexplicit

Configures the strategy with params (std::invalid_argument on a bad value), then warms up and starts the engine (on_start runs here).

Member Function Documentation

◆ book() [1/2]

template<class S >
void fastmm::sim::StrategyHarness< S >::book ( Price  bid,
Price  ask,
Qty  size = Qty::from_int(1),
InstrumentId  id = InstrumentId{0} 
)
inline

A one-level snapshot each side.

◆ book() [2/2]

template<class S >
void fastmm::sim::StrategyHarness< S >::book ( std::string_view  bid,
std::string_view  ask,
InstrumentId  id = InstrumentId{0} 
)
inline

◆ trade()

template<class S >
void fastmm::sim::StrategyHarness< S >::trade ( Price  px,
Qty  qty,
Side  aggressor,
InstrumentId  id = InstrumentId{0} 
)
inline

◆ fill()

template<class S >
bool fastmm::sim::StrategyHarness< S >::fill ( Side  side,
Qty  qty = Qty{},
InstrumentId  id = InstrumentId{0} 
)
inline

Fills our best working order on side (quantity 0: its whole remainder) with a taker order at the venue, then advances by the ack latency so the fill reaches the strategy.

False when there is no working order on that side.

◆ working_orders()

template<class S >
std::vector< Order > fastmm::sim::StrategyHarness< S >::working_orders ( InstrumentId  id = InstrumentId{0}) const
inline

Our working orders (Live or PartiallyFilled): bids best first, then asks best first.

◆ disconnect()

template<class S >
void fastmm::sim::StrategyHarness< S >::disconnect ( std::uint8_t  channel = 0,
VenueId  v = VenueId{0} 
)
inline

Channel 0 is market data (the engine clears the venue's books), 1 is order entry.

◆ reconnect()

template<class S >
void fastmm::sim::StrategyHarness< S >::reconnect ( std::uint8_t  channel = 0,
VenueId  v = VenueId{0} 
)
inline

◆ pull_quotes()

template<class S >
void fastmm::sim::StrategyHarness< S >::pull_quotes ( )
inline

◆ resume_quotes()

template<class S >
void fastmm::sim::StrategyHarness< S >::resume_quotes ( )
inline

◆ publish()

template<class S >
void fastmm::sim::StrategyHarness< S >::publish ( const std::vector< ParamPublisher::ParamValue > &  values)
inline

A ParamUpdate of values (names and values as in [strategy.params]) for all instruments, at the current time: the strategy's parameters change and on_params runs.

Validated against the strategy's current parameters; std::invalid_argument when a publisher would reject it.

◆ push()

template<class S >
void fastmm::sim::StrategyHarness< S >::push ( EventHeader &  h)
inline

Any other message, delivered to the engine at the current time.

◆ advance()

template<class S >
void fastmm::sim::StrategyHarness< S >::advance ( Duration  d)
inline

Moves virtual time forward by d, delivering orders to the venue, acks and fills to the engine and firing timers in time order.

< the wheel fires on its next tick

◆ now()

template<class S >
Timestamp fastmm::sim::StrategyHarness< S >::now ( ) const
inlinenoexcept

◆ engine()

template<class S >
EngineType & fastmm::sim::StrategyHarness< S >::engine ( )
inlinenoexcept

◆ strategy()

template<class S >
S & fastmm::sim::StrategyHarness< S >::strategy ( )
inlinenoexcept

◆ venue_transport()

template<class S >
SimTransport & fastmm::sim::StrategyHarness< S >::venue_transport ( )
inlinenoexcept

◆ instrument()

template<class S >
static InstrumentId fastmm::sim::StrategyHarness< S >::instrument ( )
inlinestaticnoexcept

◆ price()

template<class S >
static Price fastmm::sim::StrategyHarness< S >::price ( std::string_view  s)
inlinestatic

◆ quantity()

template<class S >
static Qty fastmm::sim::StrategyHarness< S >::quantity ( std::string_view  s)
inlinestatic