|
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
|
#include <fastmm/venues/venue.hpp>
Public Member Functions | |
| virtual | ~Venue ()=default |
| virtual VenueId | id () const noexcept=0 |
| virtual std::string_view | name () const noexcept=0 |
| virtual VenueCaps | caps () const noexcept=0 |
| virtual Result< void, std::string > | load_reference_data (InstrumentTable &instruments)=0 |
Fetches exchangeInfo / instruments-info for every instrument of this venue and overwrites tick/lot/min_qty/max_qty/min_notional with the venue's values (config values are a fallback when the venue is unreachable and allow_offline is set). | |
| virtual Result< std::vector< VenueFee >, std::string > | account_fees (const InstrumentTable &) |
The account's fee rates on this venue's instruments in instruments, fetched from the venue (Binance Spot with fetch_fees = true: GET /api/v3/account/commission per symbol). | |
| virtual bool | refused_account_settings () const noexcept |
| After load_reference_data() failed: true when it refused a setting of the account (a position mode the connector does not trade in), which a retry does not fix. | |
| virtual void | attach (const SymbolTable &symbols, const InstrumentTable &instruments, EventSink &md_sink, EventSink &order_sink, MsgRing *outbound)=0 |
| Wires the sinks (md: lossy, orders: never dropped) and the outbound ring the engine writes Out*Msg into. | |
| virtual void | connect (net::Reactor &reactor)=0 |
Opens every channel (market data, user stream, order entry) on reactor. | |
| virtual void | disconnect ()=0 |
| virtual bool | defer_private () |
| Warm standby (fastmm-live --standby while another process holds the instance lock). | |
| virtual void | enable_private () |
| virtual void | subscribe (std::span< const InstrumentId > instruments)=0 |
| virtual void | on_timer (std::int64_t now_ns)=0 |
| Periodic housekeeping (listenKey keepalive, app-level pings, clock offset refresh, snapshot retries). | |
| virtual void | on_wake ()=0 |
| The engine pushed Out*Msg into the outbound ring: drain, encode, send. | |
| virtual void | send_now (std::span< const EventHeader *const > batch)=0 |
| Run-to-completion ([engine] threading = "single"): the engine runs on the reactor thread and hands its Out*Msg batch over here instead of the outbound ring. | |
| virtual void | poll () noexcept |
| Called by the network thread after every reactor iteration. | |
| virtual void | resync_books () |
| Every book starts over from a fresh snapshot: a ConnectionState{Resyncing} or Stale on the md sink, then a snapshot per instrument. | |
| virtual void | request_open_orders ()=0 |
| Venue view of open orders -> ReconcileMsg Begin/OpenOrder*/End into the order sink. | |
| virtual bool | request_executions (std::int64_t=0) |
The account's executions from since_venue_ms (the venue's clock, inclusive) onwards, for every subscribed instrument: the venue's trade-history query (myTrades / userTrades / execution/list / get_user_trades_by_currency_and_time). | |
| virtual void | resume_executions (std::int64_t, const std::vector< std::string > &) |
Where the first execution replay starts, for a session that carries a position over from an earlier one (fastmm-live restores it from the store before connect()): executions from since_venue_ms onwards are booked, except those whose venue trade id is in known, which the earlier session booked already. | |
| virtual void | resume_trade_ids (const std::vector< std::pair< InstrumentId, std::int64_t > > &) |
| An exact start where the venue's trade ids increase per instrument (Binance): the first trade id to ask for, per instrument - one past the last the earlier session booked. | |
| virtual void | resume_known_trade_ids (const std::vector< std::pair< InstrumentId, std::vector< std::int64_t > > > &) |
| The trade ids at or after an instrument's start (resume_trade_ids) that are booked already, ascending: a session that died inside its replay stored them, and the start stays before them because that replay had not read everything below them. | |
| virtual bool | audit_executions (std::int64_t, std::int64_t, std::function< void(bool, std::vector< AuditFill >)>) |
| Fill audit (live/fill_auditor.hpp): the account's executions with the venue's time in [start_ms, end_ms] on every subscribed instrument, read from the same trade history as request_executions() but apart from it (venues/execution_audit.hpp): nothing is emitted into the order sink, and the replay's watermark does not move. | |
| virtual bool | can_audit_executions () const noexcept |
| Whether audit_executions() is implemented. Any thread. | |
| virtual TransferResult | transfer (const TransferRequest &) |
| Moves req.amount of req.asset from account req.from_account to req.to_account, both accounts of this exchange (the venues of one pool), under req.client_id. | |
| virtual TransferResult | transfer_status (const TransferRequest &) |
| The state of the transfer named req.client_id (the same request transfer() was given). | |
| virtual std::string | transfer_account () const |
| This account's name in a transfer request (a Binance sub-account's email; empty for the exchange's master account). | |
| virtual void | request_balances () |
| Asks the venue for the account's balances now, emitted as a BalanceMsg snapshot on the order sink (the balance leg of the reconciliation). | |
| virtual bool | cancel_all ()=0 |
| Kill switch: cancel every open order on every subscribed symbol via an independent REST connection. | |
| virtual VenueStatus | status () const noexcept=0 |
| void | set_tsc_calibration_source (const Seqlocked< TscCalibration > *src) noexcept |
| Published TSC calibrations used to convert the network thread's cycle histograms to ns when the status is published. | |
| const Seqlocked< OrderBudget > & | budget_source () const noexcept |
| The order budget the connector publishes from its rate limiter (core/order_budget.hpp): its reactor thread writes it with the status and after each response that reported the venue's counts; the engine reads it through LiveTransport (ctx.order_budget). | |
Protected Member Functions | |
| TscCalibration | tsc_calibration () const noexcept |
| Latest published calibration, or a calibration with use_tsc == false without a source. | |
| void | note_taken (const OrderCommand &cmd) noexcept |
Protected Attributes | |
| Seqlocked< OrderBudget > | budget_pub_ |
| std::uint64_t | orders_taken_ = 0 |
| New orders and replaces taken off the engine's ring (send_command), sent or refused: published with the budget (OrderBudget::orders_taken). | |
|
virtualdefault |
|
pure virtualnoexcept |
|
pure virtualnoexcept |
|
pure virtualnoexcept |
|
pure virtual |
Fetches exchangeInfo / instruments-info for every instrument of this venue and overwrites tick/lot/min_qty/max_qty/min_notional with the venue's values (config values are a fallback when the venue is unreachable and allow_offline is set).
Fatal on mismatch of a required symbol.
|
inlinevirtual |
The account's fee rates on this venue's instruments in instruments, fetched from the venue (Binance Spot with fetch_fees = true: GET /api/v3/account/commission per symbol).
Main thread, after load_reference_data(), blocking REST allowed. Empty when the connector does not fetch them; an error when it was asked to and could not.
|
inlinevirtualnoexcept |
After load_reference_data() failed: true when it refused a setting of the account (a position mode the connector does not trade in), which a retry does not fix.
fastmm-live then exits 3, like a configuration error, instead of 4.
|
pure virtual |
Wires the sinks (md: lossy, orders: never dropped) and the outbound ring the engine writes Out*Msg into.
Must be called before connect().
|
pure virtual |
Opens every channel (market data, user stream, order entry) on reactor.
|
pure virtual |
|
inlinevirtual |
Warm standby (fastmm-live --standby while another process holds the instance lock).
Called before connect(); true when the connector takes it: connect() then opens only what public market data needs (a pool member, which reads none, opens nothing), and enable_private(), on the network thread, opens the rest: order entry, the private stream, the execution replay and the start-up sweep of open orders. Nothing in between sends, cancels or reads anything of the account. False: the connector cannot split, and the session waits for the lock before it connects at all.
|
inlinevirtual |
|
pure virtual |
|
pure virtual |
Periodic housekeeping (listenKey keepalive, app-level pings, clock offset refresh, snapshot retries).
The backend calls it about once per second; venues may also arm their own reactor timers.
|
pure virtual |
The engine pushed Out*Msg into the outbound ring: drain, encode, send.
|
pure virtual |
Run-to-completion ([engine] threading = "single"): the engine runs on the reactor thread and hands its Out*Msg batch over here instead of the outbound ring.
Encode and write them now, as on_wake() does; a message that cannot go out is refused through the order sink. Called from inside the venue's own callbacks (a market-data event reaches the engine as it is decoded).
|
inlinevirtualnoexcept |
Called by the network thread after every reactor iteration.
Venues whose sockets are not registered with the reactor poll them here (nasdaq_itch with [engine] spin_mode = "busy").
|
inlinevirtual |
Every book starts over from a fresh snapshot: a ConnectionState{Resyncing} or Stale on the md sink, then a snapshot per instrument.
fastmm-gateway calls it when its own copies of the books were lost (an attaching strategy gets snapshots of those copies instead). Reactor thread. The default does nothing: a venue that cannot resync on demand (nasdaq_itch) leaves the books to its next natural resync.
|
pure virtual |
Venue view of open orders -> ReconcileMsg Begin/OpenOrder*/End into the order sink.
A connector that can fetch executions (VenueCapabilities::executions) replays everything the account traded since the watermark first, as ordinary OrderFillMsg carrying the venue's execution id and OrderFillMsg::kReplayed, and only then emits the snapshot with ReconcileMsg::kExecutionsExact on its Begin. That order is what closes the hole: a fill that finished an order is booked from the execution itself, so the snapshot - which no longer mentions the order at all - has nothing left to explain.
|
inlinevirtual |
The account's executions from since_venue_ms (the venue's clock, inclusive) onwards, for every subscribed instrument: the venue's trade-history query (myTrades / userTrades / execution/list / get_user_trades_by_currency_and_time).
Each one is emitted into the order sink as an ordinary OrderFillMsg carrying the venue's execution id and OrderFillMsg::kReplayed, so the OMS books only the ones it has not seen. Zero means "from wherever this connector last got to", which is what a reconciliation uses; a caller that knows better - the time of the last execution the engine booked, which the store and the journal both hold - passes it.
Asynchronous and part of a reconciliation: the connector runs it before the open-order snapshot and stamps ReconcileMsg::kExecutionsExact on the snapshot's Begin when every instrument answered in full. Returns false when this connector cannot ask (VenueCapabilities::executions is false) or has nowhere to send the query, which is the only case where a fill the private stream missed stays an estimate.
|
inlinevirtual |
Where the first execution replay starts, for a session that carries a position over from an earlier one (fastmm-live restores it from the store before connect()): executions from since_venue_ms onwards are booked, except those whose venue trade id is in known, which the earlier session booked already.
A connector that cannot replay executions ignores it, and the session does not restore a position for it (VenueCapabilities::executions).
|
inlinevirtual |
An exact start where the venue's trade ids increase per instrument (Binance): the first trade id to ask for, per instrument - one past the last the earlier session booked.
Called after resume_executions(); an instrument listed here replays from its id and ignores the time and the known ids, the others go on from since_venue_ms. Connectors without such ids ignore it.
|
inlinevirtual |
The trade ids at or after an instrument's start (resume_trade_ids) that are booked already, ascending: a session that died inside its replay stored them, and the start stays before them because that replay had not read everything below them.
Called after resume_trade_ids(); the replay skips them.
|
inlinevirtual |
Fill audit (live/fill_auditor.hpp): the account's executions with the venue's time in [start_ms, end_ms] on every subscribed instrument, read from the same trade history as request_executions() but apart from it (venues/execution_audit.hpp): nothing is emitted into the order sink, and the replay's watermark does not move.
AuditFill::symbol is the instrument's symbol. done runs once on the reactor thread, complete = false when a query failed or the connection went down. Returns false, and never calls done, when the connector has no such read, is not connected, or one is running. Reactor thread. By value: a connector keeps it.
|
inlinevirtualnoexcept |
Whether audit_executions() is implemented. Any thread.
|
inlinevirtual |
Moves req.amount of req.asset from account req.from_account to req.to_account, both accounts of this exchange (the venues of one pool), under req.client_id.
Blocking, over a REST connection of its own: callable from any thread but the venue's reactor thread (the pool treasury calls it from its own). Pending or Done: the venue took it; Failed: it refused, nothing moved; Unknown: no usable answer, ask transfer_status(). The default refuses (Failed).
|
inlinevirtual |
The state of the transfer named req.client_id (the same request transfer() was given).
A transfer the connector carries out in several steps is finished from here when an earlier call left a step unsent. Blocking, like transfer().
|
inlinevirtual |
This account's name in a transfer request (a Binance sub-account's email; empty for the exchange's master account).
|
inlinevirtual |
Asks the venue for the account's balances now, emitted as a BalanceMsg snapshot on the order sink (the balance leg of the reconciliation).
Reactor thread. The default does nothing.
|
pure virtual |
Kill switch: cancel every open order on every subscribed symbol via an independent REST connection.
Blocking; safe from any thread. Returns false if the venue refused.
|
pure virtualnoexcept |
|
inlinenoexcept |
Published TSC calibrations used to convert the network thread's cycle histograms to ns when the status is published.
Set before connect(); the source must outlive the venue's reactor thread.
|
inlinenoexcept |
The order budget the connector publishes from its rate limiter (core/order_budget.hpp): its reactor thread writes it with the status and after each response that reported the venue's counts; the engine reads it through LiveTransport (ctx.order_budget).
Lives with the venue.
|
inlineprotectednoexcept |
Latest published calibration, or a calibration with use_tsc == false without a source.
|
inlineprotectednoexcept |
|
protected |
|
protected |
New orders and replaces taken off the engine's ring (send_command), sent or refused: published with the budget (OrderBudget::orders_taken).
Reactor thread only.