|
1 | 1 | #pragma once |
| 2 | +#include "aos/best_ask/best_ask.h" |
| 3 | +#include "aos/best_bid/best_bid.h" |
| 4 | +#include "aos/trading_pair/trading_pair.h" |
| 5 | +namespace aoe { |
| 6 | +namespace bybit { |
| 7 | +namespace spot { |
| 8 | +namespace main_net { |
| 9 | +class InfrastructureInterface { |
| 10 | + public: |
| 11 | + virtual ~InfrastructureInterface() = default; |
| 12 | + virtual void Register(aos::TradingPair trading_pair) = 0; |
| 13 | +}; |
2 | 14 |
|
3 | | -// namespace aoe { |
4 | | -// namespace binance { |
5 | | -// class InfrastructureInterface { |
6 | | -// public: |
7 | | -// virtual ~InfrastructureInterface() = default; |
8 | | -// }; |
9 | | -// }; // namespace binance |
10 | | -// }; // namespace aoe |
| 15 | +template <typename Price, typename Qty> |
| 16 | +class InfrastructureNotifierOnBestBidChangeInterface { |
| 17 | + public: |
| 18 | + virtual ~InfrastructureNotifierOnBestBidChangeInterface() = default; |
| 19 | + /** |
| 20 | + * @brief Sets a callback to be invoked on best bid changes for a trading |
| 21 | + * pair. |
| 22 | + * |
| 23 | + * If a context exists for the specified trading pair, the callback will be |
| 24 | + * registered and the method returns true. Otherwise, no callback is |
| 25 | + * registered and the method returns false. |
| 26 | + * |
| 27 | + * @param cb The callback function to be called when the best bid changes. |
| 28 | + * It receives the trading pair and the updated best bid as |
| 29 | + * arguments. |
| 30 | + * @return true if the context for the trading pair exists and the callback |
| 31 | + * was set; false otherwise. |
| 32 | + */ |
| 33 | + virtual bool SetCallbackOnBestBidChange( |
| 34 | + aos::TradingPair trading_pair, |
| 35 | + std::function<void(aos::BestBid<Price, Qty>& new_bid)> cb) = 0; |
| 36 | +}; |
| 37 | + |
| 38 | +template <typename Price, typename Qty> |
| 39 | +class InfrastructureNotifierOnBestAskChangeInterface { |
| 40 | + public: |
| 41 | + virtual ~InfrastructureNotifierOnBestAskChangeInterface() = default; |
| 42 | + /** |
| 43 | + * @brief Sets a callback to be invoked on best ask changes for a trading |
| 44 | + * pair. |
| 45 | + * |
| 46 | + * If a context exists for the specified trading pair, the callback will be |
| 47 | + * registered and the method returns true. Otherwise, no callback is |
| 48 | + * registered and the method returns false. |
| 49 | + * |
| 50 | + * @param cb The callback function to be called when the best ask changes. |
| 51 | + * It receives the trading pair and the updated best ask as |
| 52 | + * arguments. |
| 53 | + * @return true if the context for the trading pair exists and the callback |
| 54 | + * was set; false otherwise. |
| 55 | + */ |
| 56 | + virtual bool SetCallbackOnBestAskChange( |
| 57 | + aos::TradingPair trading_pair, |
| 58 | + std::function<void(aos::BestAsk<Price, Qty>& new_ask)> cb) = 0; |
| 59 | +}; |
| 60 | + |
| 61 | +template <typename Price, typename Qty> |
| 62 | +class InfrastructureNotifierInterface |
| 63 | + : public InfrastructureNotifierOnBestBidChangeInterface<Price, Qty>, |
| 64 | + public InfrastructureNotifierOnBestAskChangeInterface<Price, Qty> { |
| 65 | + public: |
| 66 | + virtual ~InfrastructureNotifierInterface() = default; |
| 67 | +}; |
| 68 | +}; // namespace main_net |
| 69 | +}; // namespace spot |
| 70 | + |
| 71 | +namespace linear { |
| 72 | +namespace main_net { |
| 73 | +class InfrastructureInterface { |
| 74 | + public: |
| 75 | + virtual ~InfrastructureInterface() = default; |
| 76 | + virtual void Register(aos::TradingPair trading_pair) = 0; |
| 77 | +}; |
| 78 | + |
| 79 | +template <typename Price, typename Qty> |
| 80 | +class InfrastructureNotifierOnBestBidChangeInterface { |
| 81 | + public: |
| 82 | + virtual ~InfrastructureNotifierOnBestBidChangeInterface() = default; |
| 83 | + /** |
| 84 | + * @brief Sets a callback to be invoked on best bid changes for a trading |
| 85 | + * pair. |
| 86 | + * |
| 87 | + * If a context exists for the specified trading pair, the callback will be |
| 88 | + * registered and the method returns true. Otherwise, no callback is |
| 89 | + * registered and the method returns false. |
| 90 | + * |
| 91 | + * @param cb The callback function to be called when the best bid changes. |
| 92 | + * It receives the trading pair and the updated best bid as |
| 93 | + * arguments. |
| 94 | + * @return true if the context for the trading pair exists and the callback |
| 95 | + * was set; false otherwise. |
| 96 | + */ |
| 97 | + virtual bool SetCallbackOnBestBidChange( |
| 98 | + aos::TradingPair trading_pair, |
| 99 | + std::function<void(aos::BestBid<Price, Qty>& new_bid)> cb) = 0; |
| 100 | +}; |
| 101 | + |
| 102 | +template <typename Price, typename Qty> |
| 103 | +class InfrastructureNotifierOnBestAskChangeInterface { |
| 104 | + public: |
| 105 | + virtual ~InfrastructureNotifierOnBestAskChangeInterface() = default; |
| 106 | + /** |
| 107 | + * @brief Sets a callback to be invoked on best ask changes for a trading |
| 108 | + * pair. |
| 109 | + * |
| 110 | + * If a context exists for the specified trading pair, the callback will be |
| 111 | + * registered and the method returns true. Otherwise, no callback is |
| 112 | + * registered and the method returns false. |
| 113 | + * |
| 114 | + * @param cb The callback function to be called when the best ask changes. |
| 115 | + * It receives the trading pair and the updated best ask as |
| 116 | + * arguments. |
| 117 | + * @return true if the context for the trading pair exists and the callback |
| 118 | + * was set; false otherwise. |
| 119 | + */ |
| 120 | + virtual bool SetCallbackOnBestAskChange( |
| 121 | + aos::TradingPair trading_pair, |
| 122 | + std::function<void(aos::BestAsk<Price, Qty>& new_ask)> cb) = 0; |
| 123 | +}; |
| 124 | + |
| 125 | +template <typename Price, typename Qty> |
| 126 | +class InfrastructureNotifierInterface |
| 127 | + : public InfrastructureNotifierOnBestBidChangeInterface<Price, Qty>, |
| 128 | + public InfrastructureNotifierOnBestAskChangeInterface<Price, Qty> { |
| 129 | + public: |
| 130 | + virtual ~InfrastructureNotifierInterface() = default; |
| 131 | +}; |
| 132 | +}; // namespace main_net |
| 133 | +}; // namespace futures |
| 134 | +}; // namespace binance |
| 135 | +}; // namespace aoe |
0 commit comments