1 #ifndef MARKETDATASTREAMSERVICE_H
2 #define MARKETDATASTREAMSERVICE_H
7 #include <grpcpp/grpcpp.h>
8 #include "customservice.h"
9 #include "marketdata.grpc.pb.h"
10 #include "servicereply.h"
11 #include "rpchandler.h"
14 using grpc::ClientAsyncReaderWriter;
15 using grpc::CompletionQueue;
17 using namespace tinkoff::public_::invest::api::contract::v1;
34 MarketDataStream(std::shared_ptr<Channel> channel,
const std::string &token);
38 void SubscribeCandles(
const std::vector<std::pair<std::string, SubscriptionInterval>> &candleInstruments, CallbackFunc callback);
40 void SubscribeOrderBook(
const std::string &figi, int32_t depth, CallbackFunc callback);
42 void SubscribeTrades(
const std::vector<std::string> &figis, CallbackFunc callback);
44 void SubscribeInfo(
const std::vector<std::string> &figis, CallbackFunc callback);
46 void SubscribeLastPrice(
const std::vector<std::string> &figis, CallbackFunc callback);
49 void SubscribeCandlesAsync(
const std::vector<std::pair<std::string, SubscriptionInterval>> &candleInstruments, CallbackFunc callback);
51 void SubscribeOrderBookAsync(
const std::string &figi, int32_t depth, CallbackFunc callback);
53 void SubscribeTradesAsync(
const std::vector<std::string> &figis, CallbackFunc callback);
55 void SubscribeInfoAsync(
const std::vector<std::string> &figis, CallbackFunc callback);
57 void SubscribeLastPriceAsync(
const std::vector<std::string> &figis, CallbackFunc callback);
60 void UnSubscribeCandles();
62 void UnSubscribeOrderBook();
64 void UnSubscribeTrades();
66 void UnSubscribeLastPrice();
68 void UnSubscribeInfo();
72 std::unique_ptr<MarketDataStreamService::Stub> m_marketDataStreamService;
73 std::unique_ptr<std::thread> m_grpcThread;
74 std::set<std::shared_ptr<MarketDataHandler>> m_currentHandlers;
76 void SendRequest(
const MarketDataRequest &request, CallbackFunc callback);
80 #endif // MARKETDATASTREAMSERVICE_H