FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
strategy_harness.hpp File Reference

StrategyHarness<S>: test a strategy's hooks against the real engine (ADR-0012, section 8). More...

#include "fastmm/core/engine.hpp"
#include "fastmm/core/instrument.hpp"
#include "fastmm/core/messages.hpp"
#include "fastmm/core/time.hpp"
#include "fastmm/sim/matching_engine.hpp"
#include "fastmm/sim/sim_transport.hpp"
#include "fastmm/strategies/param_publisher.hpp"
#include "fastmm/strategies/strategy.hpp"
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <memory>
#include <stdexcept>
#include <string>
#include <string_view>
#include <vector>

Go to the source code of this file.

Classes

struct  fastmm::sim::HarnessOptions
 
class  fastmm::sim::StrategyHarness< S >
 

Namespaces

namespace  fastmm
 
namespace  fastmm::sim
 

Functions

InstrumentTable fastmm::sim::harness_instruments ()
 BTCUSDT on venue 0: tick 0.01, lot 0.001.
 

Detailed Description

StrategyHarness<S>: test a strategy's hooks against the real engine (ADR-0012, section 8).

The harness owns an Engine<S, SimClock, SimTransport, InlineFeed>, a simulated venue (the matching engine, fixed order and ack latency) and a virtual clock. Market data goes straight to the engine; the venue only sees orders, so our orders fill only through fill(). Every call runs the engine until it is idle, so the strategy's reaction is visible when the call returns:

fastmm::sim::StrategyHarness<MyMM> h({{"half_spread_bps", "10"}}); h.book("100.00", "100.02"); // snapshot: on_book runs, quotes go out h.advance(milliseconds(1)); // the orders reach the venue and their acks come back REQUIRE(h.working_orders().size() == 2); h.fill(Side::Buy); // a taker at the venue fills our best bid; on_fill runs CHECK(h.engine().position(h.instrument()).qty.is_positive()); h.pull_quotes(); // on_quoting(false); resume_quotes() gives on_quoting(true) h.publish({{"half_spread_bps", "7.5"}}); // a ParamUpdate: new values, then on_params

Not for the hot path: the helpers allocate, and the harness is single-threaded.