Files
spark/src/lib/md/CCApiMessageHandler.h
T
John Colvin abf0d45784 improvement: Refactor mdgw/ftx to use SecurityCriteria
So we can subscribe to depth for "FTX Options" or "FTX BTC Futures",
rather than having to list each security explicitly.

This commit also unhooks binance from MarketDataGateway. A new paradigm
is emerging with the FTX impl, and it'll be easier to redo Binance than
try to make the existing impl fit the new mold.

Unfortunately, ccapi doesn't provide all the security metadata we need, such as
the security type and expiration date/time, so we get the list of FTX
securities directly from the exchange.
2023-01-04 13:35:38 -05:00

47 lines
1.4 KiB
C++

#pragma once
#ifdef SPARK_ENABLE_CCAPI
#include "lib/md/CCApiCorrelationID.h"
#include "lib/md/ICCApiMessageHandler.h"
#include "lib/utils/Delegate.h"
#include <ccapi_cpp/ccapi_event.h>
#include <ccapi_cpp/ccapi_message.h>
#include <ccapi_cpp/ccapi_session.h>
namespace bts::md {
/**
* @brief A proxy handler that emits messages to a bindable callback delegate.
* It is designed to be used with a CCApiSession.
*
* @details This class is useful for creating handlers without the overhead of
* defining a new class. It's especially convenient for cases where a 'master'
* class handles callbacks for multiple message types. If a proxy handler is
* used for each message type, rather than a single handler for all message
* types, one avoids the need to parse the message-type from the correlation id
* and demux the callback with switch cases.
*/
class CCApiMessageHandler : public ICCApiMessageHandler {
public:
using Callback = core::Delegate<bool(
const ccapi::Event &,
ccapi::Session *,
const std::vector<const ccapi::Message *> &,
const CCApiCorrelationID &)>;
void on_messages(
const ccapi::Event &event,
ccapi::Session *session,
const std::vector<const ccapi::Message *> &msgs,
const CCApiCorrelationID &corr_id) override {
callback_(event, session, msgs, corr_id);
}
Callback &callback() { return callback_; }
private:
Callback callback_;
};
} // namespace bts::md
#endif