From df510f0e3bfa6a76a0d9a16838d2e384e37e14f9 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 18 Jan 2023 10:55:00 -0500 Subject: [PATCH] Merge origin/spark_crypto.ccapi.fractional_qty_md --- .../MarketImpliedVol/VolSurfaceMDUnit.cs | 11 +- src/client/spark/Daemons/MergedMDDaemon.cs | 8 +- .../spark/NMSheets/Outside/BBOPacket.cs | 33 +- .../spark_api/MarketData/MDConsumerHandle.cs | 4 +- .../spark_api/MarketData/NativePriceLevel.cs | 7 +- .../spark_api/MarketData/NativePriceSize.cs | 23 +- src/client/spark_api/MarketData/PriceSize.cs | 9 +- src/data_files/documents/order_flow.txt | 1 - src/lib/CMakeDeps.cmake | 2 +- src/lib/md/Diag/MDPeriodicDumper.cpp | 4 +- src/lib/md/PriceSize.h | 14 +- src/lib/md/ccApi/CCMain.cpp | 2 - src/lib/md/ccApi/CCMarketDataListener.cpp | 7 +- src/lib/md/protos/co2.proto | 2 +- src/lib/orderman/IOrderMux.h | 0 .../orderman/ccapi/CCAPIDeribitOrderMux.cpp | 490 ++++++++++++++++++ src/lib/orderman/ccapi/CCAPIDeribitOrderMux.h | 63 +++ .../orderman/ccapi/CCAPIOrderCallbackMsgs.cpp | 21 + .../orderman/ccapi/CCAPIOrderCallbackMsgs.h | 186 +++++++ src/lib/orderman/ccapi/CCAPIOrderState.cpp | 1 + src/lib/orderman/ccapi/CCAPIOrderState.h | 72 +++ .../ccapi/CCAPISingleOrderManager.cpp | 278 ++++++++++ .../orderman/ccapi/CCAPISingleOrderManager.h | 51 ++ src/lib/orderman/ccapi/ICCAPIOrderMux.h | 81 +++ .../gateways/CCAPIExecutionGateway.cpp | 289 +++++++++++ .../orderman/gateways/CCAPIExecutionGateway.h | 58 +++ .../gateways/ExecutionGatewayFactory.cpp | 4 +- .../orders/algo/algo_orders/JoinAlgo.cpp | 12 +- .../algo/algo_orders/TASCounterAlgo.cpp | 8 +- .../algo/algo_orders/tests/dorman_tests.cpp | 2 +- .../orderman/tests/CCApiExecutionTests.cpp | 138 +++++ .../sparkd/exchange_sim/ExchangeSim.cpp | 3 +- .../md/platforms/emumba/EmMDListener.cpp | 2 +- src/web/CMakeDeps.cmake | 2 +- 34 files changed, 1810 insertions(+), 78 deletions(-) create mode 100644 src/lib/orderman/IOrderMux.h create mode 100644 src/lib/orderman/ccapi/CCAPIDeribitOrderMux.cpp create mode 100644 src/lib/orderman/ccapi/CCAPIDeribitOrderMux.h create mode 100644 src/lib/orderman/ccapi/CCAPIOrderCallbackMsgs.cpp create mode 100644 src/lib/orderman/ccapi/CCAPIOrderCallbackMsgs.h create mode 100644 src/lib/orderman/ccapi/CCAPIOrderState.cpp create mode 100644 src/lib/orderman/ccapi/CCAPIOrderState.h create mode 100644 src/lib/orderman/ccapi/CCAPISingleOrderManager.cpp create mode 100644 src/lib/orderman/ccapi/CCAPISingleOrderManager.h create mode 100644 src/lib/orderman/ccapi/ICCAPIOrderMux.h create mode 100644 src/lib/orderman/gateways/CCAPIExecutionGateway.cpp create mode 100644 src/lib/orderman/gateways/CCAPIExecutionGateway.h create mode 100644 src/lib/orderman/tests/CCApiExecutionTests.cpp diff --git a/src/client/spark/Analytics/MarketImpliedVol/VolSurfaceMDUnit.cs b/src/client/spark/Analytics/MarketImpliedVol/VolSurfaceMDUnit.cs index 760f3a06d..eeb5a21b6 100644 --- a/src/client/spark/Analytics/MarketImpliedVol/VolSurfaceMDUnit.cs +++ b/src/client/spark/Analytics/MarketImpliedVol/VolSurfaceMDUnit.cs @@ -3,15 +3,16 @@ using mbts.co2; namespace mbts.analytics { + using Size = System.Single; public class VolSurfaceMDUnit : IEquatable { public readonly double bid_price, ask_price; - public readonly uint bid_size, ask_size; + public readonly Size bid_size, ask_size; public readonly double mark_price = double.NaN; private static VolSurfaceMDUnit _empty = new VolSurfaceMDUnit(Double.NaN, 0, Double.NaN, 0, Double.NaN); - public VolSurfaceMDUnit(double this_bid_price, uint this_bid_size, - double this_ask_price, uint this_ask_size, + public VolSurfaceMDUnit(double this_bid_price, Size this_bid_size, + double this_ask_price, Size this_ask_size, double this_mark_price) { bid_price = this_bid_price; bid_size = this_bid_size; @@ -28,7 +29,7 @@ namespace mbts.analytics { public VolSurfaceMDUnit(NativePriceSize bid, NativePriceSize ask, double mark_price) - : this(bid.price, bid.size, ask.price, ask.size, mark_price) { + : this(bid.price, bid.size_f, ask.price, ask.size_f, mark_price) { } public bool is_two_sided() { return bid_size != 0 && ask_size != 0; } @@ -41,7 +42,7 @@ namespace mbts.analytics { } public double get_weighted_mid_price(bool get_one_sided_mid = true) { - uint sum_q = bid_size + ask_size; + Size sum_q = bid_size + ask_size; if (sum_q == 0) { return Double.NaN; } diff --git a/src/client/spark/Daemons/MergedMDDaemon.cs b/src/client/spark/Daemons/MergedMDDaemon.cs index 61619fd26..4ae563c26 100644 --- a/src/client/spark/Daemons/MergedMDDaemon.cs +++ b/src/client/spark/Daemons/MergedMDDaemon.cs @@ -52,10 +52,16 @@ namespace bts { string rv = "MergedMDDaemon Options:\n"; foreach (var kv in sec_map) { var sec = kv.Value.security; + var md = kv.Value.md; + ulong time = 0; + NativePriceSize bid, ask; + var has_md = md.get_bbo(ref time, out bid, out ask); if (sec.HasOption) { rv += $"id: {kv.Key} desc: {sec.security_desc()} sym: {sec.Symbol} " + $"exp: {sec.security_expiration()} " + - $"k: {sec.Option.Strike} cp: {sec.Option.CallPut}" + "\n"; + $"k: {sec.Option.Strike} cp: {sec.Option.CallPut} " + + $"bid: p: {bid.price} q: {bid.size} qf: {bid.size_f} ask: p: {ask.price} q: {ask.size} qf: {ask.size_f}" + + "\n"; } } Log.Gen.info(rv); diff --git a/src/client/spark/NMSheets/Outside/BBOPacket.cs b/src/client/spark/NMSheets/Outside/BBOPacket.cs index 74e8168ef..ca81dcd0e 100644 --- a/src/client/spark/NMSheets/Outside/BBOPacket.cs +++ b/src/client/spark/NMSheets/Outside/BBOPacket.cs @@ -1,12 +1,10 @@ using mbts.analytics; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; + namespace BCG { + using Size = System.Single; public enum BidAskAlertZone { buy, sell, none } public class BBOPacket { public enum MarketSide { @@ -15,8 +13,8 @@ namespace BCG { private double _bid_price => md.bid_price; private double _ask_price => md.ask_price; - private UInt32 _bid_size => md.bid_size; - private UInt32 _ask_size => md.ask_size; + private Size _bid_size => md.bid_size; + private Size _ask_size => md.ask_size; private static BBOPacket _null_pack = new BBOPacket(VolSurfaceMDUnit.empty); public readonly VolSurfaceMDUnit md; @@ -24,21 +22,6 @@ namespace BCG { this.md = md; } - public static bool bid_through_theo(BBOPacket md, mbts.spark.TheoPoint tp, bool is_call) { - return false; - // if (tp != null && md != null && md._md_row != null) - // return get_bid_price(md) > (is_call ? tp.call : tp.put); - // else - // return false; - } - - public static bool ask_through_theo(BBOPacket md, mbts.spark.TheoPoint tp, bool is_call) { - // if (tp != null && md != null && md._md_row != null) - // return get_ask_price(md) < (is_call ? tp.call : tp.put); - // else - return false; - } - public static double get_mid_price(BBOPacket md) { return (get_bid_price(md) + get_ask_price(md)) / 2.0; } @@ -47,16 +30,16 @@ namespace BCG { return md != null ? md._bid_price : Double.NaN; } - public static UInt32 get_bid_size(BBOPacket md) { - return md != null ? md._bid_size : (UInt32)0; + public static Size get_bid_size(BBOPacket md) { + return md != null ? md._bid_size : (Size)0; } public static double get_ask_price(BBOPacket md) { return md != null ? md._ask_price : Double.NaN; } - public static UInt32 get_ask_size(BBOPacket md) { - return md != null ? md._ask_size : (UInt32)0; + public static Size get_ask_size(BBOPacket md) { + return md != null ? md._ask_size : (Size)0; } } } diff --git a/src/client/spark_api/MarketData/MDConsumerHandle.cs b/src/client/spark_api/MarketData/MDConsumerHandle.cs index 4ed8cce4a..1241d5107 100644 --- a/src/client/spark_api/MarketData/MDConsumerHandle.cs +++ b/src/client/spark_api/MarketData/MDConsumerHandle.cs @@ -162,7 +162,7 @@ // Compare bids if (direct.int_price == implied.int_price) { - bid[x] = new NativePriceSize(direct.int_price, direct.size, implied.size); + bid[x] = new NativePriceSize(direct.int_price, direct.size_f, implied.size_f); dbid_idx++; ibid_idx++; } @@ -185,7 +185,7 @@ // Compare asks if (direct.int_price == implied.int_price) { - ask[x] = new NativePriceSize(direct.int_price, direct.size, implied.size); + ask[x] = new NativePriceSize(direct.int_price, direct.size_f, implied.size_f); dask_idx++; iask_idx++; } diff --git a/src/client/spark_api/MarketData/NativePriceLevel.cs b/src/client/spark_api/MarketData/NativePriceLevel.cs index b90ee4d0f..7b75ac17e 100644 --- a/src/client/spark_api/MarketData/NativePriceLevel.cs +++ b/src/client/spark_api/MarketData/NativePriceLevel.cs @@ -1,14 +1,15 @@ namespace mbts.co2 { using System.Runtime.InteropServices; + using Size = System.Single; [StructLayout(LayoutKind.Sequential)] public readonly struct NativePriceLevel { readonly IntPrice _bid; readonly IntPrice _ask; - readonly uint _bid_size; - readonly uint _ask_size; + readonly Size _bid_size; + readonly Size _ask_size; - public NativePriceLevel(IntPrice bid, uint bid_size, IntPrice ask, uint ask_size) { + public NativePriceLevel(IntPrice bid, Size bid_size, IntPrice ask, Size ask_size) { _bid = bid; _bid_size = bid_size; _ask = ask; diff --git a/src/client/spark_api/MarketData/NativePriceSize.cs b/src/client/spark_api/MarketData/NativePriceSize.cs index fa766ece6..0f838752c 100644 --- a/src/client/spark_api/MarketData/NativePriceSize.cs +++ b/src/client/spark_api/MarketData/NativePriceSize.cs @@ -5,27 +5,29 @@ namespace mbts.co2 { using System; using System.Runtime.InteropServices; + using Size = System.Single; + public readonly struct NativePriceSize : IEquatable { readonly IntPrice _price; - readonly uint _size; - readonly uint _direct_size; + readonly Size _size; + readonly Size _direct_size; static NativePriceSize() => Log.assert(Marshal.SizeOf() == 16); - public NativePriceSize(IntPrice price, uint size) { + public NativePriceSize(IntPrice price, Size size) { _price = price; _size = size; _direct_size = size; } - public NativePriceSize(long mantissa, sbyte exponent, uint size) { + public NativePriceSize(long mantissa, sbyte exponent, Size size) { _price = new IntPrice(mantissa, exponent); _size = size; _direct_size = size; } - public NativePriceSize(IntPrice price, uint direct_size, uint implied_size) { + public NativePriceSize(IntPrice price, Size direct_size, Size implied_size) { _price = price; _size = direct_size + implied_size; _direct_size = direct_size; @@ -36,15 +38,18 @@ namespace mbts.co2 { public IntPrice int_price => _price; public long mantissa => _price.mantissa; public sbyte exponent => _price.exponent; - public uint size => _size; - public uint direct_size => _direct_size; - public uint implied_size => _size - _direct_size; + public uint size => (uint)_size; + public uint direct_size => (uint)_direct_size; + public uint implied_size => (uint)(_size - _direct_size); + public Size size_f => _size; + public Size direct_size_f => _direct_size; + public Size implied_size_f => _size - _direct_size; public double price => _price.price(); public bool is_nan => _price.is_nan; public override string ToString() => - $"{price} {size} ({implied_size})"; + $"{price} {size_f} ({implied_size})"; public override bool Equals(object obj) => obj is NativePriceSize p ? Equals(p) : base.Equals(obj); diff --git a/src/client/spark_api/MarketData/PriceSize.cs b/src/client/spark_api/MarketData/PriceSize.cs index 621f225a2..95999d319 100644 --- a/src/client/spark_api/MarketData/PriceSize.cs +++ b/src/client/spark_api/MarketData/PriceSize.cs @@ -3,13 +3,14 @@ using mbts.co2; namespace bts.md { + using Size = System.Single; public class PriceSize { - public uint size { get; } - public uint direct_size { get; } - public uint implied_size { get; } + public Size size { get; } + public Size direct_size { get; } + public Size implied_size { get; } public double price { get; } - public PriceSize(uint sz, uint direct_sz, uint implied_sz, double prx) + public PriceSize(Size sz, Size direct_sz, Size implied_sz, double prx) { size = sz; direct_size = direct_sz; diff --git a/src/data_files/documents/order_flow.txt b/src/data_files/documents/order_flow.txt index 2c88fcb3a..3e11a102b 100644 --- a/src/data_files/documents/order_flow.txt +++ b/src/data_files/documents/order_flow.txt @@ -116,7 +116,6 @@ C++ - QueryServer set_mic, switch - VenueOption name(..) switch - --------------------------------------------------------------------------- adding security type --------------------------------------------------------------------------- diff --git a/src/lib/CMakeDeps.cmake b/src/lib/CMakeDeps.cmake index 77b987e4c..dc175d8a4 100644 --- a/src/lib/CMakeDeps.cmake +++ b/src/lib/CMakeDeps.cmake @@ -1 +1 @@ -set(sources api/analytics/ExpirationDriver.proto;api/analytics/TimeWeightedInterpolatedDriver.proto;api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/core/RegexFormatting.proto;api/domain/CallPut.proto;api/domain/Currency.proto;api/domain/SecurityCriteria.proto;api/domain/SecurityCriteriaClause.proto;api/domain/SecurityExpiration.proto;api/domain/SecurityMetadata.proto;api/domain/SecurityMetadataCollection.proto;api/domain/SecurityMetadataItem.proto;api/domain/SecurityType.proto;api/domain/TickDisplaySettings.proto;api/domain/TickFactors.proto;api/domain/Venue.proto;api/io/URL.proto;api/md/BinanceMarketDataConfig.proto;api/md/BinanceUsMarketDataConfig.proto;api/md/BinanceUsdsFuturesMarketDataConfig.proto;api/md/FTXMarketDataConfig.proto;api/md/MarketDataConfig.proto;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/AnalyticsService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MarketDataService.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;communincation/websockets/tests/WebsocketSyncClientTests.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/extensions/extensions.proto;config/invalid/invalid.proto;config/profiles/default/MarketData.conf;config/profiles/default/Ports.conf;config/profiles/default/SecurityMetadataCollection.conf;config/profiles/default/Symbols.conf;config/profiles/default/cme_reference_data.conf;config/profiles/default/edge.conf;config/profiles/default/jetfix.conf;config/profiles/default/keycode.conf;config/profiles/default/logging.conf;config/profiles/default/orderman_cfg.conf;config/profiles/default/orders_fills_cleanup.conf;config/profiles/default/position_cfg.conf;config/profiles/default/span.conf;config/profiles/default/spreader.conf;config/profiles/default/testkeys.conf;config/profiles/default/threads.conf;config/profiles/default/toggles.conf;config/protos/algo_types.proto;config/protos/cme_reference_data.proto;config/protos/exchange_sim_cfg.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/market_data.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/ports.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spartan.proto;config/protos/spreader.proto;config/protos/subprocess.proto;config/protos/symbols.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/protos/ui.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;core/TimeStamp.cpp;domain/DomainSecurityUtils.cpp;domain/NewOrder.cpp;domain/OrderDefinition.cpp;domain/OrderStatus.cpp;domain/OrderUpdate.cpp;domain/Security.cpp;domain/SecurityCriteria.cpp;domain/SecurityCriteriaClause.cpp;domain/Side.cpp;domain/TimeInForce.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/sod.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;io/JsonReader.cpp;io/QueryParams.cpp;io/URL.cpp;io/http/CurlHandle.cpp;io/http/HTTPClient.cpp;io/http/HTTPHeaders.cpp;io/http/HTTPRequest.cpp;io/http/HTTPResponse.cpp;io/websocket/WebsocketClient.cpp;io/websocket/WebsocketClientConfiguration.cpp;io/websocket/WebsocketError.cpp;io/websocket/WebsocketMessage.cpp;io/websocket/WebsocketSSLClientInternal.cpp;io/websocket/tests/WebsocketClientTests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/CCApiCompositeMessageHandler.cpp;md/CCApiDepthWalker.cpp;md/CCApiEventDemuxer.cpp;md/CCApiMarketDepthAdaptor.cpp;md/CCApiMessageLogger.cpp;md/CCApiSession.cpp;md/CCApiTradeAdaptor.cpp;md/CCApiTradeRecord.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/ICCApiMessageHandler.cpp;md/MBOProcessor.cpp;md/MBOServiceServer.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MarketDataError.cpp;md/MarketDataGateway.cpp;md/MarketDataRegistrationFactory.cpp;md/MarketDataSubscription.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/Product.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityMapper.cpp;md/SecurityMarketState.cpp;md/SecurityOracle.cpp;md/SecurityStore.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/binance/BinanceMiniTickerAdaptor.cpp;md/binance/BinanceMiniTickerUpdate.cpp;md/binance/BinancePriceStatistics.cpp;md/binance/BinancePriceStatisticsAdaptor.cpp;md/binance/BinanceSecurityRequestor.cpp;md/binance/BinanceSpot.cpp;md/binance/BinanceSubscription.cpp;md/binance_us/BinanceUsPriceStatistics.cpp;md/binance_us/BinanceUsPriceStatisticsAdaptor.cpp;md/binance_us/BinanceUsSecurityRequestor.cpp;md/binance_us/BinanceUsSubscription.cpp;md/binance_usds_futures/BinanceUsdsFuture.cpp;md/binance_usds_futures/BinanceUsdsFuturesPriceStatistics.cpp;md/binance_usds_futures/BinanceUsdsFuturesPriceStatisticsAdaptor.cpp;md/binance_usds_futures/BinanceUsdsFuturesSecurityRequestor.cpp;md/binance_usds_futures/BinanceUsdsFuturesSubscription.cpp;md/ccApi/CCDemoListener.cpp;md/ccApi/CCMain.cpp;md/ccApi/CCMarketDataListener.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ftx/FTXFuture.cpp;md/ftx/FTXHistoricalPriceAdaptor.cpp;md/ftx/FTXHistoricalPriceRecord.cpp;md/ftx/FTXMarket.cpp;md/ftx/FTXSecurityRequestor.cpp;md/ftx/FTXSubscription.cpp;md/ice/ICEUtils.cpp;md/listeners/LiveLadderPrinter.cpp;md/protos/co2.proto;md/recording/MDRecorder.cpp;md/recording/MDReplayer.cpp;md/recording/MDReplayerMain.cpp;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/service/MarketDataServiceServer.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/mbo_tests.cpp;md/test/md2_tests.cpp;md/test/md_test_utils.cpp;md/test/synthetic_book_merge_tests.cpp;md/vendor/OnixsUtils.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metrics/system_metrics.cpp;orderman/Governor.cpp;orderman/OrderBuilder.cpp;orderman/OrderRouter.cpp;orderman/OrderServiceServer.cpp;orderman/OrderServices.cpp;orderman/actors/AsyncFactory.cpp;orderman/actors/FillStore.cpp;orderman/actors/MDSupplementarySource.cpp;orderman/actors/OrderStore.cpp;orderman/actors/SODPosition.cpp;orderman/actors/SecuritySrc.cpp;orderman/actors/ServiceBridge.cpp;orderman/actors/order_manager/OrderManager.cpp;orderman/actors/order_manager/OrderServicesData.cpp;orderman/actors/order_manager/PositionIndex.cpp;orderman/calculations/TheoCalculator.cpp;orderman/events/CancelRejectEvent.cpp;orderman/events/FilledPositionEvent.cpp;orderman/events/NewExecutionReportEvent.cpp;orderman/events/TradeSignalEvent.cpp;orderman/gateways/EMExecutionGateway.cpp;orderman/gateways/ExecutionGatewayFactory.cpp;orderman/gateways/FakeExecutionGateway.cpp;orderman/gateways/GLBXExecutionGateway.cpp;orderman/gateways/GLBXiLink3ExecutionGateway.cpp;orderman/gateways/ICEExecutionGateway.cpp;orderman/gateways/SimExecutionGateway.cpp;orderman/ilink3/IL3ConnectionHandler.cpp;orderman/ilink3/IL3GW.cpp;orderman/ilink3/IL3Parser.cpp;orderman/ilink3/IL3Reactor.cpp;orderman/ilink3/ILink3Utils.cpp;orderman/ilink3/SessionStore.cpp;orderman/ilink3/test/ILinkGWTests.cpp;orderman/limiter/LimitStore.cpp;orderman/limiter/Limiter.cpp;orderman/limiter/ProductLimitNode.cpp;orderman/limiter/ProductLimitTree.cpp;orderman/limiter/SecurityLimitNode.cpp;orderman/limiter/SecurityLimitTree.cpp;orderman/limiter/tests/limit_tests.cpp;orderman/order_factory/DynamicOrderRegistry.cpp;orderman/order_factory/OrderFactory.cpp;orderman/orderman_utils/BookUtils.cpp;orderman/orderman_utils/ExecutionReport.cpp;orderman/orderman_utils/fix_order_codec.cpp;orderman/orderman_utils/orderman_utils.cpp;orderman/orders/CompositeOrder.cpp;orderman/orders/DynamicOrder.cpp;orderman/orders/EMNativeOrder.cpp;orderman/orders/GLBXNativeOrder.cpp;orderman/orders/ICENativeOrder.cpp;orderman/orders/Order.cpp;orderman/orders/TimeBoxOrder.cpp;orderman/orders/TriggerOrder.cpp;orderman/orders/algo/AlgoWrapperOrder.cpp;orderman/orders/algo/DynamicHelpers.cpp;orderman/orders/algo/IAlgoOrder.cpp;orderman/orders/algo/IAlgoServices.cpp;orderman/orders/algo/IBeforeLaunchAlgoServices.cpp;orderman/orders/algo/PositionUpdate.cpp;orderman/orders/algo/algo_orders/CoverAlgo.cpp;orderman/orders/algo/algo_orders/DeleteAndCoverAlgo.cpp;orderman/orders/algo/algo_orders/DormanAlgo.cpp;orderman/orders/algo/algo_orders/IcebergAlgo.cpp;orderman/orders/algo/algo_orders/JoinAlgo.cpp;orderman/orders/algo/algo_orders/LeanAlgo.cpp;orderman/orders/algo/algo_orders/LimitCoverAlgo.cpp;orderman/orders/algo/algo_orders/OffsetAlgo.cpp;orderman/orders/algo/algo_orders/OnSignalAlgo.cpp;orderman/orders/algo/algo_orders/ProRataAlgo.cpp;orderman/orders/algo/algo_orders/PyramidAlgo.cpp;orderman/orders/algo/algo_orders/RegisterDorman.cpp;orderman/orders/algo/algo_orders/ScratchAlgo.cpp;orderman/orders/algo/algo_orders/SniperAlgo.cpp;orderman/orders/algo/algo_orders/SplitterAlgo.cpp;orderman/orders/algo/algo_orders/TASAlgo.cpp;orderman/orders/algo/algo_orders/TASCounterAlgo.cpp;orderman/orders/algo/algo_orders/TaskingEyeAlgo.cpp;orderman/orders/algo/algo_orders/TopAlgo.cpp;orderman/orders/algo/algo_orders/limit_cover/LimitCoverAdapter.cpp;orderman/orders/algo/algo_orders/tests/AlgoTestDriver.cpp;orderman/orders/algo/algo_orders/tests/ExecutiontTesterAlgo.cpp;orderman/orders/algo/algo_orders/tests/LimitCoverTests.cpp;orderman/orders/algo/algo_orders/tests/dorman_tests.cpp;orderman/orders/algo/algo_orders/tests/limit_cover/LimitCoverState.cpp;orderman/orders/algo/algo_orders/tests/limit_cover/TestSteps.cpp;orderman/orders/algo/algo_orders/tests/splitter_tests.cpp;orderman/orders/book_algos/BookAlgo.cpp;orderman/orders/book_algos/BookOrderBase.cpp;orderman/orders/book_algos/OCOOrder.cpp;orderman/orders/book_algos/PricerOrder.cpp;orderman/orders/glbx/IGLBXOrderEncoder.cpp;orderman/orders/glbx/iLink2OrderEncoder.cpp;orderman/orders/glbx/iLink3OrderEncoder.cpp;orderman/orders/queue_holder/QueueHolderOrder.cpp;orderman/orders/queue_holder/state_workers/QHOEndStateWorker.cpp;orderman/orders/queue_holder/state_workers/QHOStartStateWorker.cpp;orderman/orders/queue_holder/state_workers/QHOWaitingForAckStateWorker.cpp;orderman/orders/queue_holder/state_workers/QHOWaitingForCancelAllStateWorker.cpp;orderman/orders/queue_holder/state_workers/QHOWorkingStateWorker.cpp;orderman/orders/spreader_orders/SpreaderOrder.cpp;orderman/orders/spreader_orders/spreader/LegFillState.cpp;orderman/orders/spreader_orders/spreader/LegPropertyData.cpp;orderman/orders/spreader_orders/spreader/NLegsHedgeRecompData.cpp;orderman/orders/spreader_orders/spreader/QuoteLegPriceQuantityState.cpp;orderman/orders/spreader_orders/spreader/SingleFillHedger.cpp;orderman/orders/spreader_orders/spreader/SingleLegQuoter.cpp;orderman/orders/spreader_orders/spreader/SpreaderBookkeepingData.cpp;orderman/orders/spreader_orders/spreader/SpreaderChildOrderState.cpp;orderman/orders/spreader_orders/spreader/SpreaderLegData.cpp;orderman/orders/spreader_orders/spreader/SpreaderUtils.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderBuilder.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderServices.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderPreActivationOrderServices.cpp;orderman/orders/spreader_orders/spreader/hedger/HedgerManager.cpp;orderman/orders/spreader_orders/spreader/hedger/UnhedgedDelta.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckCancelledStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSet.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSetHistory.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteLegDriver.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckCancelledWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForIOCWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForSizeStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderEndStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderStartStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForCancelAllStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForInitialDataStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWorkingStateWorker.cpp;orderman/orders/spreader_orders/tests/spreader_tests.cpp;orderman/tests/fat_wrapper_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;persistence/IDGenerator.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/persistence_utils.cpp;persistence/tests/PersistenceServiceTests.cpp;plugin/SparkServices.cpp;plugin/plugin.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;tracing/PerfLog.cpp;tracing/bts_trace.cpp;utils/AuthSessionManager.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/FileUtils.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/MathUtils.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/crypto/CipherType.cpp;utils/crypto/CryptoInit.cpp;utils/crypto/Digest.cpp;utils/crypto/KeyCodeHelper.cpp;utils/crypto/PasswordCallback.cpp;utils/crypto/PrivateKey.cpp;utils/crypto/PublicKey.cpp;utils/crypto/iostreambio.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/sftp.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/tests/IDGeneratorTests.cpp;utils/tests/MathUtilsTests.cpp;utils/tests/SingleWriterConcurrentVectorTests.cpp;utils/thread_manager.cpp) \ No newline at end of file +set(sources api/analytics/ExpirationDriver.proto;api/analytics/TimeWeightedInterpolatedDriver.proto;api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/core/RegexFormatting.proto;api/domain/CallPut.proto;api/domain/Currency.proto;api/domain/SecurityCriteria.proto;api/domain/SecurityCriteriaClause.proto;api/domain/SecurityExpiration.proto;api/domain/SecurityMetadata.proto;api/domain/SecurityMetadataCollection.proto;api/domain/SecurityMetadataItem.proto;api/domain/SecurityType.proto;api/domain/TickDisplaySettings.proto;api/domain/TickFactors.proto;api/domain/Venue.proto;api/io/URL.proto;api/md/BinanceMarketDataConfig.proto;api/md/BinanceUsMarketDataConfig.proto;api/md/BinanceUsdsFuturesMarketDataConfig.proto;api/md/FTXMarketDataConfig.proto;api/md/MarketDataConfig.proto;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/AnalyticsService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MarketDataService.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;communincation/websockets/tests/WebsocketSyncClientTests.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/extensions/extensions.proto;config/invalid/invalid.proto;config/profiles/default/MarketData.conf;config/profiles/default/Ports.conf;config/profiles/default/SecurityMetadataCollection.conf;config/profiles/default/Symbols.conf;config/profiles/default/cme_reference_data.conf;config/profiles/default/edge.conf;config/profiles/default/jetfix.conf;config/profiles/default/keycode.conf;config/profiles/default/logging.conf;config/profiles/default/orderman_cfg.conf;config/profiles/default/orders_fills_cleanup.conf;config/profiles/default/position_cfg.conf;config/profiles/default/span.conf;config/profiles/default/spreader.conf;config/profiles/default/testkeys.conf;config/profiles/default/threads.conf;config/profiles/default/toggles.conf;config/protos/algo_types.proto;config/protos/cme_reference_data.proto;config/protos/exchange_sim_cfg.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/market_data.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/ports.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spartan.proto;config/protos/spreader.proto;config/protos/subprocess.proto;config/protos/symbols.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/protos/ui.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;core/TimeStamp.cpp;domain/DomainSecurityUtils.cpp;domain/NewOrder.cpp;domain/OrderDefinition.cpp;domain/OrderStatus.cpp;domain/OrderUpdate.cpp;domain/Security.cpp;domain/SecurityCriteria.cpp;domain/SecurityCriteriaClause.cpp;domain/Side.cpp;domain/TimeInForce.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/sod.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;io/JsonReader.cpp;io/QueryParams.cpp;io/URL.cpp;io/http/CurlHandle.cpp;io/http/HTTPClient.cpp;io/http/HTTPHeaders.cpp;io/http/HTTPRequest.cpp;io/http/HTTPResponse.cpp;io/websocket/WebsocketClient.cpp;io/websocket/WebsocketClientConfiguration.cpp;io/websocket/WebsocketError.cpp;io/websocket/WebsocketMessage.cpp;io/websocket/WebsocketSSLClientInternal.cpp;io/websocket/tests/WebsocketClientTests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/CCApiCompositeMessageHandler.cpp;md/CCApiDepthWalker.cpp;md/CCApiEventDemuxer.cpp;md/CCApiMarketDepthAdaptor.cpp;md/CCApiMessageLogger.cpp;md/CCApiSession.cpp;md/CCApiTradeAdaptor.cpp;md/CCApiTradeRecord.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/ICCApiMessageHandler.cpp;md/MBOProcessor.cpp;md/MBOServiceServer.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MarketDataError.cpp;md/MarketDataGateway.cpp;md/MarketDataRegistrationFactory.cpp;md/MarketDataSubscription.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/Product.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityMapper.cpp;md/SecurityMarketState.cpp;md/SecurityOracle.cpp;md/SecurityStore.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/binance/BinanceMiniTickerAdaptor.cpp;md/binance/BinanceMiniTickerUpdate.cpp;md/binance/BinancePriceStatistics.cpp;md/binance/BinancePriceStatisticsAdaptor.cpp;md/binance/BinanceSecurityRequestor.cpp;md/binance/BinanceSpot.cpp;md/binance/BinanceSubscription.cpp;md/binance_us/BinanceUsPriceStatistics.cpp;md/binance_us/BinanceUsPriceStatisticsAdaptor.cpp;md/binance_us/BinanceUsSecurityRequestor.cpp;md/binance_us/BinanceUsSubscription.cpp;md/binance_usds_futures/BinanceUsdsFuture.cpp;md/binance_usds_futures/BinanceUsdsFuturesPriceStatistics.cpp;md/binance_usds_futures/BinanceUsdsFuturesPriceStatisticsAdaptor.cpp;md/binance_usds_futures/BinanceUsdsFuturesSecurityRequestor.cpp;md/binance_usds_futures/BinanceUsdsFuturesSubscription.cpp;md/ccApi/CCDemoListener.cpp;md/ccApi/CCMain.cpp;md/ccApi/CCMarketDataListener.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ftx/FTXFuture.cpp;md/ftx/FTXHistoricalPriceAdaptor.cpp;md/ftx/FTXHistoricalPriceRecord.cpp;md/ftx/FTXMarket.cpp;md/ftx/FTXSecurityRequestor.cpp;md/ftx/FTXSubscription.cpp;md/ice/ICEUtils.cpp;md/listeners/LiveLadderPrinter.cpp;md/protos/co2.proto;md/recording/MDRecorder.cpp;md/recording/MDReplayer.cpp;md/recording/MDReplayerMain.cpp;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/service/MarketDataServiceServer.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/mbo_tests.cpp;md/test/md2_tests.cpp;md/test/md_test_utils.cpp;md/test/synthetic_book_merge_tests.cpp;md/vendor/OnixsUtils.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metrics/system_metrics.cpp;orderman/Governor.cpp;orderman/OrderBuilder.cpp;orderman/OrderRouter.cpp;orderman/OrderServiceServer.cpp;orderman/OrderServices.cpp;orderman/actors/AsyncFactory.cpp;orderman/actors/FillStore.cpp;orderman/actors/MDSupplementarySource.cpp;orderman/actors/OrderStore.cpp;orderman/actors/SODPosition.cpp;orderman/actors/SecuritySrc.cpp;orderman/actors/ServiceBridge.cpp;orderman/actors/order_manager/OrderManager.cpp;orderman/actors/order_manager/OrderServicesData.cpp;orderman/actors/order_manager/PositionIndex.cpp;orderman/calculations/TheoCalculator.cpp;orderman/events/CancelRejectEvent.cpp;orderman/events/FilledPositionEvent.cpp;orderman/events/NewExecutionReportEvent.cpp;orderman/events/TradeSignalEvent.cpp;orderman/gateways/EMExecutionGateway.cpp;orderman/gateways/ExecutionGatewayFactory.cpp;orderman/gateways/FakeExecutionGateway.cpp;orderman/gateways/GLBXExecutionGateway.cpp;orderman/gateways/GLBXiLink3ExecutionGateway.cpp;orderman/gateways/ICEExecutionGateway.cpp;orderman/gateways/SimExecutionGateway.cpp;orderman/ilink3/IL3ConnectionHandler.cpp;orderman/ilink3/IL3GW.cpp;orderman/ilink3/IL3Parser.cpp;orderman/ilink3/IL3Reactor.cpp;orderman/ilink3/ILink3Utils.cpp;orderman/ilink3/SessionStore.cpp;orderman/ilink3/test/ILinkGWTests.cpp;orderman/limiter/LimitStore.cpp;orderman/limiter/Limiter.cpp;orderman/limiter/ProductLimitNode.cpp;orderman/limiter/ProductLimitTree.cpp;orderman/limiter/SecurityLimitNode.cpp;orderman/limiter/SecurityLimitTree.cpp;orderman/limiter/tests/limit_tests.cpp;orderman/order_factory/DynamicOrderRegistry.cpp;orderman/order_factory/OrderFactory.cpp;orderman/orderman_utils/BookUtils.cpp;orderman/orderman_utils/ExecutionReport.cpp;orderman/orderman_utils/fix_order_codec.cpp;orderman/orderman_utils/orderman_utils.cpp;orderman/orders/CompositeOrder.cpp;orderman/orders/DynamicOrder.cpp;orderman/orders/EMNativeOrder.cpp;orderman/orders/GLBXNativeOrder.cpp;orderman/orders/ICENativeOrder.cpp;orderman/orders/Order.cpp;orderman/orders/TimeBoxOrder.cpp;orderman/orders/TriggerOrder.cpp;orderman/orders/algo/AlgoWrapperOrder.cpp;orderman/orders/algo/DynamicHelpers.cpp;orderman/orders/algo/IAlgoOrder.cpp;orderman/orders/algo/IAlgoServices.cpp;orderman/orders/algo/IBeforeLaunchAlgoServices.cpp;orderman/orders/algo/PositionUpdate.cpp;orderman/orders/algo/algo_orders/CoverAlgo.cpp;orderman/orders/algo/algo_orders/DeleteAndCoverAlgo.cpp;orderman/orders/algo/algo_orders/DormanAlgo.cpp;orderman/orders/algo/algo_orders/IcebergAlgo.cpp;orderman/orders/algo/algo_orders/JoinAlgo.cpp;orderman/orders/algo/algo_orders/LeanAlgo.cpp;orderman/orders/algo/algo_orders/LimitCoverAlgo.cpp;orderman/orders/algo/algo_orders/OffsetAlgo.cpp;orderman/orders/algo/algo_orders/OnSignalAlgo.cpp;orderman/orders/algo/algo_orders/ProRataAlgo.cpp;orderman/orders/algo/algo_orders/PyramidAlgo.cpp;orderman/orders/algo/algo_orders/RegisterDorman.cpp;orderman/orders/algo/algo_orders/ScratchAlgo.cpp;orderman/orders/algo/algo_orders/SniperAlgo.cpp;orderman/orders/algo/algo_orders/SplitterAlgo.cpp;orderman/orders/algo/algo_orders/TASAlgo.cpp;orderman/orders/algo/algo_orders/TASCounterAlgo.cpp;orderman/orders/algo/algo_orders/TaskingEyeAlgo.cpp;orderman/orders/algo/algo_orders/TopAlgo.cpp;orderman/orders/algo/algo_orders/limit_cover/LimitCoverAdapter.cpp;orderman/orders/algo/algo_orders/tests/AlgoTestDriver.cpp;orderman/orders/algo/algo_orders/tests/ExecutiontTesterAlgo.cpp;orderman/orders/algo/algo_orders/tests/LimitCoverTests.cpp;orderman/orders/algo/algo_orders/tests/dorman_tests.cpp;orderman/orders/algo/algo_orders/tests/limit_cover/LimitCoverState.cpp;orderman/orders/algo/algo_orders/tests/limit_cover/TestSteps.cpp;orderman/orders/algo/algo_orders/tests/splitter_tests.cpp;orderman/orders/book_algos/BookAlgo.cpp;orderman/orders/book_algos/BookOrderBase.cpp;orderman/orders/book_algos/OCOOrder.cpp;orderman/orders/book_algos/PricerOrder.cpp;orderman/orders/glbx/IGLBXOrderEncoder.cpp;orderman/orders/glbx/iLink2OrderEncoder.cpp;orderman/orders/glbx/iLink3OrderEncoder.cpp;orderman/orders/queue_holder/QueueHolderOrder.cpp;orderman/orders/queue_holder/state_workers/QHOEndStateWorker.cpp;orderman/orders/queue_holder/state_workers/QHOStartStateWorker.cpp;orderman/orders/queue_holder/state_workers/QHOWaitingForAckStateWorker.cpp;orderman/orders/queue_holder/state_workers/QHOWaitingForCancelAllStateWorker.cpp;orderman/orders/queue_holder/state_workers/QHOWorkingStateWorker.cpp;orderman/orders/spreader_orders/SpreaderOrder.cpp;orderman/orders/spreader_orders/spreader/LegFillState.cpp;orderman/orders/spreader_orders/spreader/LegPropertyData.cpp;orderman/orders/spreader_orders/spreader/NLegsHedgeRecompData.cpp;orderman/orders/spreader_orders/spreader/QuoteLegPriceQuantityState.cpp;orderman/orders/spreader_orders/spreader/SingleFillHedger.cpp;orderman/orders/spreader_orders/spreader/SingleLegQuoter.cpp;orderman/orders/spreader_orders/spreader/SpreaderBookkeepingData.cpp;orderman/orders/spreader_orders/spreader/SpreaderChildOrderState.cpp;orderman/orders/spreader_orders/spreader/SpreaderLegData.cpp;orderman/orders/spreader_orders/spreader/SpreaderUtils.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderBuilder.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderServices.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderPreActivationOrderServices.cpp;orderman/orders/spreader_orders/spreader/hedger/HedgerManager.cpp;orderman/orders/spreader_orders/spreader/hedger/UnhedgedDelta.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckCancelledStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSet.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSetHistory.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteLegDriver.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckCancelledWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForIOCWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForSizeStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderEndStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderStartStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForCancelAllStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForInitialDataStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWorkingStateWorker.cpp;orderman/orders/spreader_orders/tests/spreader_tests.cpp;orderman/tests/fat_wrapper_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;persistence/IDGenerator.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/persistence_utils.cpp;persistence/tests/PersistenceServiceTests.cpp;plugin/SparkServices.cpp;plugin/plugin.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;tracing/PerfLog.cpp;tracing/bts_trace.cpp;utils/AuthSessionManager.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/FileUtils.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/MathUtils.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/crypto/CipherType.cpp;utils/crypto/CryptoInit.cpp;utils/crypto/Digest.cpp;utils/crypto/KeyCodeHelper.cpp;utils/crypto/PasswordCallback.cpp;utils/crypto/PrivateKey.cpp;utils/crypto/PublicKey.cpp;utils/crypto/iostreambio.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/sftp.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/tests/IDGeneratorTests.cpp;utils/tests/MathUtilsTests.cpp;utils/tests/SingleWriterConcurrentVectorTests.cpp;utils/thread_manager.cpp) diff --git a/src/lib/md/Diag/MDPeriodicDumper.cpp b/src/lib/md/Diag/MDPeriodicDumper.cpp index 71386cf18..83e8cb943 100644 --- a/src/lib/md/Diag/MDPeriodicDumper.cpp +++ b/src/lib/md/Diag/MDPeriodicDumper.cpp @@ -60,7 +60,7 @@ std::string print_book( auto a = ask[x - 1]; if (!os::is_nan(a.price())) { snprintf( - buffer, 512, "%5s %14s | %14.7f %5d\n", "", "", a.price(), + buffer, 512, "%5s %14s | %14.7f %5.5f\n", "", "", a.price(), a.size()); ss << buffer; } @@ -69,7 +69,7 @@ std::string print_book( for (uint32_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { auto b = bid[x]; if (!os::is_nan(b.price())) { - snprintf(buffer, 512, "%5d %14.7f | \n", b.size(), b.price()); + snprintf(buffer, 512, "%5.5f %14.7f | \n", b.size(), b.price()); ss << buffer; } } diff --git a/src/lib/md/PriceSize.h b/src/lib/md/PriceSize.h index ca8c7ac82..ee7041872 100644 --- a/src/lib/md/PriceSize.h +++ b/src/lib/md/PriceSize.h @@ -19,15 +19,15 @@ namespace bts { namespace md { typedef double Price; -typedef uint32_t Size; +typedef float Size; int to_exponent(double value); class PriceSize { IntPrice _price; // merged size - uint32_t _size; - uint32_t _direct_size; + Size _size; + Size _direct_size; public: PriceSize(IntPrice price, Size size) @@ -92,13 +92,13 @@ struct PriceLevel { IntPrice _bid; IntPrice _ask; - uint32_t _bid_size; - uint32_t _ask_size; + Size _bid_size; + Size _ask_size; const IntPrice &bid_price() const { return _bid; } const IntPrice &ask_price() const { return _ask; } - uint32_t bid_size() const { return _bid_size; } - uint32_t ask_size() const { return _ask_size; } + Size bid_size() const { return _bid_size; } + Size ask_size() const { return _ask_size; } bool operator==(const PriceLevel &other) const { return _ask_size == other._ask_size && _bid_size == other._bid_size && diff --git a/src/lib/md/ccApi/CCMain.cpp b/src/lib/md/ccApi/CCMain.cpp index 163ed63d9..23f6398ae 100644 --- a/src/lib/md/ccApi/CCMain.cpp +++ b/src/lib/md/ccApi/CCMain.cpp @@ -70,9 +70,7 @@ void CCMain::run() { const auto &md_config = config::get(); me->gw.subscribe(md_config, &me->cc_listener); - size_t n = 0; while (true) { - std::cout << "Main loop iter " << n++ << std::endl << std::endl; std::this_thread::sleep_for(std::chrono::seconds(1)); } std::cout << "Exiting run_ccapi" << std::endl; diff --git a/src/lib/md/ccApi/CCMarketDataListener.cpp b/src/lib/md/ccApi/CCMarketDataListener.cpp index 006549767..c0c9db318 100644 --- a/src/lib/md/ccApi/CCMarketDataListener.cpp +++ b/src/lib/md/ccApi/CCMarketDataListener.cpp @@ -134,8 +134,9 @@ void copy_books( } size_t i = 0; for (const auto &b : book[side]) { - to[i++] = - bts::md::PriceSize{convert_price(b.price), b.total_quantity.value()}; + to[i++] = bts::md::PriceSize{ + convert_price(b.price), + static_cast(b.total_quantity.value())}; if (i >= COCONUT_MAX_DEPTH) return; } @@ -151,6 +152,8 @@ CCMarketDataListener::~CCMarketDataListener() {} void CCMarketDataListener::on_securities( const std::vector &complete_security_list) { + LOG(md, Info, "CCMarketDataListener::on_securities n_secs: {}", + complete_security_list.size()); for (auto s_ptr : complete_security_list) { domain::Security sec = *s_ptr; const auto &s_comm = sec.security_common; diff --git a/src/lib/md/protos/co2.proto b/src/lib/md/protos/co2.proto index 4f433925b..5d49689cf 100644 --- a/src/lib/md/protos/co2.proto +++ b/src/lib/md/protos/co2.proto @@ -99,7 +99,7 @@ message PriceMessage { message PriceSizeMessage { int64 mantissa = 1; sint32 exponent = 2; - uint32 size = 3; + float size = 3; } message TopBookMessage { diff --git a/src/lib/orderman/IOrderMux.h b/src/lib/orderman/IOrderMux.h new file mode 100644 index 000000000..e69de29bb diff --git a/src/lib/orderman/ccapi/CCAPIDeribitOrderMux.cpp b/src/lib/orderman/ccapi/CCAPIDeribitOrderMux.cpp new file mode 100644 index 000000000..21bb47afb --- /dev/null +++ b/src/lib/orderman/ccapi/CCAPIDeribitOrderMux.cpp @@ -0,0 +1,490 @@ +#include "CCAPIDeribitOrderMux.h" +#include "CCAPIOrderState.h" +#include "CCAPISingleOrderManager.h" +#include "ccapi_cpp/ccapi_session.h" +#include "lib/api/services/OrderService.pb.h" +#include "lib/domain_model/Security.pb.h" +#include "lib/logging/logging.h" +#include "lib/md/SecurityOracle.h" +#include "lib/orderman/CancelOrderMsg.h" +#include "lib/orderman/CancelReplaceOrderMsg.h" +#include "lib/orderman/CreateOrderMsg.h" +#include "lib/orderman/RFQMsg.h" +#include "lib/orderman/ccapi/CCAPIOrderCallbackMsgs.h" +#include "lib/orderman/orderman_utils/orderman_common.h" +#include "lib/utils/PBUtils.h" +#include "lib/utils/bts_assert.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +namespace bts::orderman { + +class OrderEventHandler : public ccapi::EventHandler { + boost::lockfree::spsc_queue &event_queue; + std::set event_types; + + public: + OrderEventHandler( + boost::lockfree::spsc_queue &event_queue, + const std::vector &event_types) + : event_queue(event_queue), + event_types(event_types.begin(), event_types.end()) {} + bool processEvent( + const ccapi::Event &event, ccapi::Session *session) override { + bts_assert(session != nullptr); + bool processing = event_types.find(event.getType()) != event_types.end(); + LOG(OrderMan, Info, + "CCAPIDeribitOrderMux::OrderEventHandler::processEvent tid: {} " + "processing: {} " + "event: {}", + os::get_thread_id(), processing, event.toStringPretty(2, 2)); + if (processing) + event_queue.push(event); + return true; + } +}; + +struct SubscriptionStatus { + const uint32_t sec_id; + const std::string order_sub_corr_id; + const std::string trade_sub_corr_id; + bool order_sub_confirmed = false; + bool trade_sub_confirmed = false; + bool fully_subscribed() const { + return order_sub_confirmed && trade_sub_confirmed; + } + bool update_status(const std::string &corr_id, bool status) { + if (order_sub_corr_id == corr_id) { + order_sub_confirmed = status; + } else if (trade_sub_corr_id == corr_id) { + trade_sub_confirmed = status; + } + return order_sub_confirmed && trade_sub_confirmed; + } +}; + +struct CCAPIDeribitOrderMux::PImpl { + md::SecurityOracle md_oracle; + ccapi::SessionOptions session_options = {}; + ccapi::SessionConfigs session_configs; + ccapi::Session *session; + OnCCAPIOrderUpdate order_update_cb; + OnCCAPIExchangePositionUpdate exchange_position_update_cb; + OnCCAPIExchangeOpenOrderUpdate exchange_open_orders_update_cb; + size_t corr_id = 0; + std::map order_map = {}; + // std::set subscribed_sec_map = {}; + boost::lockfree::spsc_queue event_queue; + OrderEventHandler event_handler; + google::protobuf::Timestamp last_sec_check_time = + google::protobuf::util::TimeUtil::GetCurrentTime(); + uint32_t sec_check_period = 10; + // map of subscription confirmation for a security + std::unordered_map sub_map = {}; + // if we get a new order for a security that we hve not subscribed to yet + // (order updates and trades), we buffer the create message and send it once + // we get subcriptions confirmation + std::vector buffered_creates = {}; + PImpl(const md::SecurityOracle &md_oracle) + : md_oracle(md_oracle), event_queue(100), + event_handler( + event_queue, + {ccapi::Event::Type::RESPONSE, + ccapi::Event::Type::SUBSCRIPTION_DATA, + ccapi::Event::Type::SUBSCRIPTION_STATUS}) { + // Test + session_configs.setCredential({ + {"grant_type", "client_signature"}, + {CCAPI_DERIBIT_CLIENT_ID, "ZmIKL6fb"}, + {CCAPI_DERIBIT_CLIENT_SECRET, + "_FY2PcXYNc8VdlfkZO5c-pkFJQFhn8P9z4_p8YA2fS0"}, + }); + session = new ccapi::Session( + ccapi::Session(session_options, session_configs, &event_handler)); + } + std::string get_new_corrid() { return std::to_string(corr_id++); } +}; + +CCAPIDeribitOrderMux::CCAPIDeribitOrderMux(const md::SecurityOracle &sec_oracle) + : me(new PImpl(sec_oracle)) { + LOG(OrderMan, Info, + "CCAPIDeribitOrderMux::CCAPIDeribitOrderMux constructor t_id: {} " + "t_name: {} ", + os::get_thread_id(), os::get_application_name()); + // TODO: subscribe to orders/trade en masse, so we dont have to do it per sec + // at the time of the order + // This can be achieved by the /private/subscribe method, for channels + // "user.orders.any.any.raw" + // https://test.deribit.com/api_console/?method=%2Fprivate%2Funsubscribe + // The payload will look like this: + // { + // "method": "private/subscribe", + // "params": { + // "channels": [ + // "user.orders.any.any.raw" + // ] + // }, + // "jsonrpc": "2.0", + // "id": 9 + // } +} + +CCAPIDeribitOrderMux::~CCAPIDeribitOrderMux() {} + +void CCAPIDeribitOrderMux::on_securities( + const bts::mercury::Update &update) { + LOG(OrderMan, Info, + "CCAPIDeribitOrderMux::on_securities t_id: {} t_name: {} n_secs: {}", + os::get_thread_id(), os::get_thread_name(), + update.events == nullptr ? 0 : update.events->size()); +} + +CCAPIOpResult CCAPIDeribitOrderMux::launch_new_order( + const CreateOrderMsg &cr_msg) { + LOG(OrderMan, Info, + "CCAPIDeribitOrderMux::launch_new_order tid: {} sec: {} ok: {} p: {} q: " + "{}", + os::get_thread_id(), utils::pb::to_string(*cr_msg.security), + cr_msg.key.value(), cr_msg.price, cr_msg.quantity); + // order update subscription + bool alread_subbed = _check_and_add_subscription(*cr_msg.security); + if (alread_subbed) { + LOG(OrderMan, Warn, + "CCAPIDeribitOrderMux::launch_new_order sending order ok: {} right " + "away since subcriptions are ready", + cr_msg.key); + _send_order(cr_msg); + } else { + LOG(OrderMan, Warn, + "CCAPIDeribitOrderMux::launch_new_order buffering order ok: {} " + "until subscriptions are confirmed", + cr_msg.key); + // buffer the order and send it once we get the sub confirmed + me->buffered_creates.push_back(cr_msg); + } + // TODO, fire an ex report of waiting + CCAPIOpResult res{}; + res.is_success = true; + return res; +} + +bool CCAPIDeribitOrderMux::update_order( + const CancelReplaceOrderMsg &cxl_repl_msg) { + OrderKey order_key = cxl_repl_msg.create_fields.key; + LOG(OrderMan, Info, "CCAPIDeribitOrderMux::update_order order_key: {}", + order_key); + // CCAPI does not have update/edit/cxl-replace so we have to use custom + // request for it. The custom GET request URL looks like this + // "https://test.deribit.com/api/v2/private/edit?advanced=implv&amount=4&order_id=438994&price=222" + // (https://docs.deribit.com/?shell#private-edit) + const auto &sec_desc = + cxl_repl_msg.create_fields.security->deribit().security_desc(); + auto it = me->order_map.find(order_key); + if (it == me->order_map.end()) { + LOG(OrderMan, Error, + "CCAPIDeribitOrderMux::update_order could not find order_key: " + "{} sec_desc: {}", + order_key, sec_desc); + return false; + } + const CCAPIOrderState &ord_state = it->second.order_state(); + double new_qty = cxl_repl_msg.create_fields.quantity.full_value(); + double new_price = cxl_repl_msg.create_fields.price.value(); + std::string query = "amount=" + std::to_string(new_qty) + + "&order_id=" + ord_state.cc_order_key + + "&price=" + std::to_string(new_price); + ccapi::Request request( + ccapi::Request::Operation::GENERIC_PRIVATE_REQUEST, + CCAPI_EXCHANGE_NAME_DERIBIT, sec_desc); + request.appendParam( + {// {CCAPI_HTTP_PROTOCOL, "https"}, + {CCAPI_HTTP_METHOD, "GET"}, + {CCAPI_HTTP_PATH, "/api/v2/private/edit"}, + {CCAPI_HTTP_QUERY_STRING, query}, + {CCAPI_HTTP_HEADERS, "Content-Type: application/json"}}); + me->session->sendRequest(request); + return true; +} + +void send_cancel_generic_private_request( + ccapi::Session *session, + const std::string &cc_order_key, + const std::string &sec_desc) { + LOG(OrderMan, Info, + "send_cancel_generic_private_request cc_order_key: {} sec_desc: {}", + cc_order_key, sec_desc); + + //"https://test.deribit.com/api/v2/private/cancel?order_id=ETH-SLIS-12" + + // std::string query = "cancel?order_id=" + cc_order_key; + std::string query = "order_id=" + cc_order_key; + ccapi::Request request( + ccapi::Request::Operation::GENERIC_PRIVATE_REQUEST, + CCAPI_EXCHANGE_NAME_DERIBIT, sec_desc); + request.appendParam( + {// {CCAPI_HTTP_PROTOCOL, "https"}, + {CCAPI_HTTP_METHOD, "GET"}, + {CCAPI_HTTP_PATH, "/api/v2/private/cancel"}, + {CCAPI_HTTP_QUERY_STRING, query}, + {CCAPI_HTTP_HEADERS, "Content-Type: application/json"}}); + session->sendRequest(request); +} + +bool CCAPIDeribitOrderMux::cancel_order(const CancelOrderMsg &cxl_msg) { + LOG(OrderMan, Info, + "CCAPIDeribitOrderMux::cancel_order order_key: {} cc_order_key: {}", + cxl_msg.key, cxl_msg.exchange_order_id); + auto it = me->order_map.find(cxl_msg.key); + if (it == me->order_map.end()) { + return false; + } + CCAPISingleOrderManager &man = it->second; + const auto &sec_desc = man.order_state().security.deribit().security_desc(); + if (man.order_state().security.has_option()) { + send_cancel_generic_private_request( + me->session, man.order_state().cc_order_key, sec_desc); + return true; + } + ccapi::Request request( + ccapi::Request::Operation::CANCEL_ORDER, CCAPI_EXCHANGE_NAME_DERIBIT, + sec_desc); + request.appendParam({{CCAPI_EM_ORDER_ID, man.order_state().cc_order_key}}); + LOG(OrderMan, Info, + "CCAPIDeribitOrderMux::cancel_order order_key: {} cc_order_key: {}", + man.order_state().order_key, man.order_state().cc_order_key); + me->session->sendRequest(request); + return true; +} + +void CCAPIDeribitOrderMux::send_rfq(const RFQMsg &rfq) { + LOG(OrderMan, Info, "CCAPIDeribitOrderMux::send_rfq rfq: {}", + utils::pb::to_string(rfq.rfq)); +} + +OnCCAPIOrderUpdate &CCAPIDeribitOrderMux::order_update_cb() { + return me->order_update_cb; +} + +// this gets called in the main thread, the events have already been queue'd +// from the CCAPI callback thread +void CCAPIDeribitOrderMux::dispatch_incoming_messages() { + auto n_items = me->event_queue.read_available(); + if (n_items > 0) { + for (auto &kv : me->order_map) + kv.second.dispatch_start(); + LOG(OrderMan, Info, + "CCAPIDeribitOrderMux::dispatch_incoming_messages n_items: {}", + n_items); + me->event_queue.consume_all( + [this](const ccapi::Event &ev) { _handle_event(ev); }); + for (auto &kv : me->order_map) { + auto ord_ch = kv.second.dispatch_end(); + if (ord_ch) { + me->order_update_cb(kv.second.order_state()); + } + } + // TODO, remove orders in end state + } + // _check_subs(); +} + +// Position + +void CCAPIDeribitOrderMux::query_positions() {} + +OnCCAPIExchangePositionUpdate & +CCAPIDeribitOrderMux::exchange_position_update_cb() { + return me->exchange_position_update_cb; +} + +// Open orders + +void CCAPIDeribitOrderMux::query_open_orders() {} + +OnCCAPIExchangeOpenOrderUpdate & +CCAPIDeribitOrderMux::exchange_open_orders_update_cb() { + return me->exchange_open_orders_update_cb; +} + +bool CCAPIDeribitOrderMux::_check_and_add_subscription( + const api::Security &sec) { + auto it = me->sub_map.find(sec.id()); + if (it == me->sub_map.end()) { + auto order_status_sub_corrid = me->get_new_corrid(); + auto trade_sub_corrid = me->get_new_corrid(); + SubscriptionStatus new_status{ + sec.id(), order_status_sub_corrid, trade_sub_corrid}; + me->sub_map.insert({sec.id(), new_status}); + const auto &sec_desc = sec.deribit().security_desc(); + LOG(OrderMan, Info, + "CCAPIDeribitOrderMux::_check_and_add_subscription " + "CCAPI_EM_ORDER_UPDATE and CCAPI_EM_PRIVATE_TRADE subscriptions for " + "sec: {} order_status_sub_corrid: {} trade_sub_corrid: {}", + sec_desc, order_status_sub_corrid, trade_sub_corrid); + std::vector subs = {}; + subs.emplace_back( + CCAPI_EXCHANGE_NAME_DERIBIT, sec_desc, CCAPI_EM_ORDER_UPDATE, "", + order_status_sub_corrid); + subs.emplace_back( + CCAPI_EXCHANGE_NAME_DERIBIT, sec_desc, CCAPI_EM_PRIVATE_TRADE, "", + trade_sub_corrid); + me->session->subscribe(subs); + return false; + } else { + return it->second.fully_subscribed(); + } +} + +void CCAPIDeribitOrderMux::_handle_element( + ccapi::Message::Type msg_type, + const NVMap &map, + const std::string &corr_id) { + switch (msg_type) { + case ccapi::Message::Type::CREATE_ORDER: { + CCAPICreateOrderMsg cr_ord_msg(map, corr_id); + for (auto &kv : me->order_map) + kv.second.handle_create(cr_ord_msg); + break; + } + case ccapi::Message::Type::EXECUTION_MANAGEMENT_EVENTS_ORDER_UPDATE: { + CCAPIOrderUpdateMsg ord_update_msg(map); + for (auto &kv : me->order_map) + kv.second.handle_order_update(ord_update_msg); + break; + } + case ccapi::Message::Type::EXECUTION_MANAGEMENT_EVENTS_PRIVATE_TRADE: { + CCAPITradeMsg tr_msg(map); + for (auto &kv : me->order_map) + kv.second.handle_trade(tr_msg); + break; + } + case ccapi::Message::Type::SUBSCRIPTION_STARTED: { + CCAPISubscriptionStatusMsg sub_status_msg{true, corr_id}; + _handle_subscription_status(sub_status_msg); + break; + } + case ccapi::Message::Type::SUBSCRIPTION_FAILURE: { + CCAPISubscriptionStatusMsg sub_status_msg{false, corr_id}; + _handle_subscription_status(sub_status_msg); + break; + } + default: + break; + } +} + +void CCAPIDeribitOrderMux::_handle_event(const ccapi::Event &event) { + ccapi::Event::Type event_type = event.getType(); + bts_assert( + event_type == ccapi::Event::Type::RESPONSE || + event_type == ccapi::Event::Type::SUBSCRIPTION_DATA || + event_type == ccapi::Event::Type::SUBSCRIPTION_STATUS); + // switch here to throw out + for (const auto &msg : event.getMessageList()) { + ccapi::Message::Type msg_type = msg.getType(); + size_t i = 0; + for (const auto &elem : msg.getElementList()) { + // TODO: not sure about this, why isnt corr id a part of Element (def + // not right) + const std::string &corr_id = msg.getCorrelationIdList().at(i++); + const NVMap &map = elem.getNameValueMap(); + _handle_element(msg_type, map, corr_id); + } + } +} + +void CCAPIDeribitOrderMux::_handle_subscription_status( + const CCAPISubscriptionStatusMsg &ss_msg) { + LOG(OrderMan, Info, + "CCAPIDeribitOrderMux::_handle_subscription_status status: {} corr_id: " + "{}", + ss_msg.is_success, ss_msg.corr_id); + if (ss_msg.is_success) { + // 1. update the subscription state + // 2. find the orders for the secs that are fully subscribed now + // 3. send the orders + // 4. remove them from cached orders + for (auto &kv : me->sub_map) { + SubscriptionStatus &ss = kv.second; + auto subbed = ss.update_status(ss_msg.corr_id, ss_msg.is_success); + if (subbed) { + _send_buffered_orders(ss.sec_id); + } + } + } else { + // will figure this out later + LOG(OrderMan, Error, + "CCAPIDeribitOrderMux::_handle_subscription_status corr_id: {} " + "is_success: {}", + ss_msg.corr_id, ss_msg.is_success); + } +} + +// void CCAPIDeribitOrderMux::_check_subs() { +// google::protobuf::Timestamp now = +// google::protobuf::util::TimeUtil::GetCurrentTime(); +// int diff = now.seconds() - me->last_sec_check_time.seconds(); +// if (diff > (int)me->sec_check_period) { +// LOG(OrderMan, Info, "CCAPIDeribitOrderMux::_check_subs diff: {}", +// diff); me->last_sec_check_time = now; +// _add_subscriptions(me->md_oracle.get_securities()); +// } +// } + +void CCAPIDeribitOrderMux::_send_order(const CreateOrderMsg &cr_msg) { + const auto &sec_desc = cr_msg.security->deribit().security_desc(); + ccapi::Request request( + ccapi::Request::Operation::CREATE_ORDER, CCAPI_EXCHANGE_NAME_DERIBIT, + sec_desc); + std::string corr_id = me->get_new_corrid(); + me->order_map.insert( + {cr_msg.key, CCAPISingleOrderManager( + *cr_msg.security, cr_msg.key, corr_id, cr_msg.side, + cr_msg.price.value(), cr_msg.quantity.full_value())}); + request.setCorrelationId(corr_id); + request.appendParam( + {{CCAPI_EM_ORDER_SIDE, cr_msg.side == api::SIDE_BUY + ? CCAPI_EM_ORDER_SIDE_BUY + : CCAPI_EM_ORDER_SIDE_SELL}, + {CCAPI_EM_ORDER_QUANTITY, std::to_string(cr_msg.quantity.full_value())}, + {CCAPI_EM_ORDER_LIMIT_PRICE, std::to_string(cr_msg.price.value())}}); + LOG(OrderMan, Info, "CCAPIDeribitOrderMux::_send_order sec: {} p: {} q: {}", + sec_desc, cr_msg.price, cr_msg.quantity); + me->session->sendRequest(request); +} + +void CCAPIDeribitOrderMux::_send_buffered_orders(uint32_t sec_id) { + for (auto &cr_msg : me->buffered_creates) { + if (cr_msg.security->id() == sec_id) { + LOG(OrderMan, Info, + "CCAPIDeribitOrderMux::_send_buffered_orders sending buffered " + "order"); + _send_order(cr_msg); + } + } + me->buffered_creates.erase( + std::remove_if( + me->buffered_creates.begin(), me->buffered_creates.end(), + [sec_id](const CreateOrderMsg &c) { + return c.security->id() == sec_id; + }), + me->buffered_creates.end()); + LOG(OrderMan, Info, + "CCAPIDeribitOrderMux::_send_buffered_orders n_buffered_orders: {}", + me->buffered_creates.size()); +} + +} // namespace bts::orderman \ No newline at end of file diff --git a/src/lib/orderman/ccapi/CCAPIDeribitOrderMux.h b/src/lib/orderman/ccapi/CCAPIDeribitOrderMux.h new file mode 100644 index 000000000..d126fa8b5 --- /dev/null +++ b/src/lib/orderman/ccapi/CCAPIDeribitOrderMux.h @@ -0,0 +1,63 @@ +#pragma once +#include "ICCAPIOrderMux.h" +#include "lib/md/SecurityOracle.h" +#include "lib/orderman/CreateOrderMsg.h" +#include "lib/orderman/ccapi/CCAPIOrderCallbackMsgs.h" +//#include "lib/domain_model/Security.pb.h" +#include +#include +#include + +namespace bts::api { +class Security; +} + +namespace bts::orderman { + +class CCAPIDeribitOrderMux : public ICCAPIOrderMux { + public: + CCAPIDeribitOrderMux(const md::SecurityOracle &); + ~CCAPIDeribitOrderMux(); + // System + void on_securities( + const bts::mercury::Update &update) override; + // Orders + CCAPIOpResult launch_new_order(const CreateOrderMsg &cr_msg) override; + bool update_order(const CancelReplaceOrderMsg &cxl_repl_msg) override; + bool cancel_order(const CancelOrderMsg &) override; + void send_rfq(const RFQMsg &rfq) override; + OnCCAPIOrderUpdate &order_update_cb() override; + // Dispatching incoming messages + void dispatch_incoming_messages() override; + // Position + // //////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + // This queries the exchange for the positions. the position is returned + // on the exchange_position_update_cb callback (below) + // TODO: account as a paremter + void query_positions() override; + OnCCAPIExchangePositionUpdate &exchange_position_update_cb() override; + // Mass orders + // ///////////////////////////////////////////////////////////// + void query_open_orders() override; + OnCCAPIExchangeOpenOrderUpdate &exchange_open_orders_update_cb() override; + + private: + struct PImpl; + std::unique_ptr me; + + private: + bool _check_and_add_subscription(const api::Security &sec); + void _handle_event(const ccapi::Event &event); + void _handle_element( + ccapi::Message::Type msg_type, + const std::map &, + const std::string &corr_id); + void _handle_subscription_status( + const CCAPISubscriptionStatusMsg &sub_status); + // void _check_subs(); + void _send_order(const CreateOrderMsg &); + void _send_buffered_orders(uint32_t sec_id); +}; + +} // namespace bts::orderman \ No newline at end of file diff --git a/src/lib/orderman/ccapi/CCAPIOrderCallbackMsgs.cpp b/src/lib/orderman/ccapi/CCAPIOrderCallbackMsgs.cpp new file mode 100644 index 000000000..70492def6 --- /dev/null +++ b/src/lib/orderman/ccapi/CCAPIOrderCallbackMsgs.cpp @@ -0,0 +1,21 @@ +#include "CCAPIOrderCallbackMsgs.h" +#include "lib/utils/bts_assert.h" + +namespace bts::orderman { + +const std::string &getm(const NVMap &map, char const *key_name) { + auto it = map.find(key_name); + bts_assert_msg( + it != map.end(), "Could not find key_name" + std::string(key_name)); + return it->second; +} + +bts::api::orderman::OrderStatus convert_ccapi_status( + const std::string &status) { + // TODO, find the other status'es + if (status == "open") + return bts::api::orderman::OrderStatus::ORDER_STATUS_WORKING; + return bts::api::orderman::OrderStatus::ORDER_STATUS_COMPLETED; +} + +} // namespace bts::orderman \ No newline at end of file diff --git a/src/lib/orderman/ccapi/CCAPIOrderCallbackMsgs.h b/src/lib/orderman/ccapi/CCAPIOrderCallbackMsgs.h new file mode 100644 index 000000000..4d799fa43 --- /dev/null +++ b/src/lib/orderman/ccapi/CCAPIOrderCallbackMsgs.h @@ -0,0 +1,186 @@ +#pragma once + +#include "ccapi_cpp/ccapi_session.h" +#include "lib/api/services/OrderService.pb.h" +#include "lib/domain_model/Security.pb.h" +#include "lib/logging/logging.h" +#include "lib/orderman/orderman_utils/orderman_common.h" +#include "lib/utils/PBUtils.h" +#include "lib/utils/bts_assert.h" +#include +#include +#include +#include +// #include +// #include +// #include +#include + +using namespace std; +namespace bts::orderman { + +using NVMap = std::map; + +const std::string &getm(const NVMap &map, char const *key_name); +bts::api::orderman::OrderStatus convert_ccapi_status(const std::string &status); + +// 1. +// Event [ +// type = RESPONSE, +// messageList = [ +// Message [ +// type = CREATE_ORDER, +// recapType = UNKNOWN, +// time = 1970-01-01T00:00:00.000000000Z, +// timeReceived = 2022-11-03T02:54:53.655916565Z, +// elementList = [ +// Element [ +// nameValueMap = { +// CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY = 1224720.000000, +// CUMULATIVE_FILLED_QUANTITY = 60.0, +// INSTRUMENT = BTC-30JUN23, +// LIMIT_PRICE = 20412.0, +// ORDER_ID = 14636988474, +// QUANTITY = 100.0, +// SIDE = SELL, +// STATUS = open +// } +// ] +// ], +// correlationIdList = [ 0 ] +// ] +// ] +// ] + +struct CCAPICreateOrderMsg { + std::string order_id; + std::string instrument; + api::Side side; + double price; + double qty; + double cumm_filled_price; + double cumm_filled_qty; + bts::api::orderman::OrderStatus status; + // TODO + std::string corr_id; + CCAPICreateOrderMsg(const NVMap &map, const std::string &corr_id) + : order_id(getm(map, CCAPI_EM_ORDER_ID)), + instrument(getm(map, CCAPI_INSTRUMENT)), + side( + getm(map, CCAPI_EM_ORDER_SIDE) == CCAPI_EM_ORDER_SIDE_BUY + ? api::SIDE_BUY + : api::SIDE_SELL), + // TODO, market orders? + price(std::stod(getm(map, CCAPI_EM_ORDER_LIMIT_PRICE))), + qty(std::stod(getm(map, CCAPI_EM_ORDER_QUANTITY))), + cumm_filled_price(std::stod( + getm(map, CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY))), + cumm_filled_qty( + std::stod(getm(map, CCAPI_EM_ORDER_CUMULATIVE_FILLED_QUANTITY))), + status(convert_ccapi_status(getm(map, CCAPI_EM_ORDER_STATUS))), + corr_id(corr_id) {} +}; +// 2. +// Event [ +// type = SUBSCRIPTION_DATA, +// messageList = [ +// Message [ +// type = EXECUTION_MANAGEMENT_EVENTS_ORDER_UPDATE, +// recapType = UNKNOWN, +// time = 2022-11-03T02:57:34.853000000Z, +// timeReceived = 2022-11-03T02:57:34.906199444Z, +// elementList = [ +// Element [ +// nameValueMap = { +// CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY = 1428840.000000, +// CUMULATIVE_FILLED_QUANTITY = 70.0, +// LIMIT_PRICE = 20412.0, +// ORDER_ID = 14636988474, +// QUANTITY = 100.0, +// SIDE = SELL, +// STATUS = open +// } +// ] +// ], +// correlationIdList = [ pJFeZrln ] +// ] +// ] +// ] +// at the end, we can receive EXECUTION_MANAGEMENT_EVENTS_ORDER_UPDATE first +// with STATUS = completed, and then the trade(s) +struct CCAPIOrderUpdateMsg { + std::string order_id; + api::Side side; + double price; + double qty; + double cumm_filled_price; + double cumm_filled_qty; + api::orderman::OrderStatus status; + CCAPIOrderUpdateMsg(const NVMap &map) + : order_id(getm(map, CCAPI_EM_ORDER_ID)), + side( + getm(map, CCAPI_EM_ORDER_SIDE) == CCAPI_EM_ORDER_SIDE_BUY + ? api::SIDE_BUY + : api::SIDE_SELL), + // TODO, market orders? + price(std::stod(getm(map, CCAPI_EM_ORDER_LIMIT_PRICE))), + qty(std::stod(getm(map, CCAPI_EM_ORDER_QUANTITY))), + cumm_filled_price(std::stod( + getm(map, CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY))), + cumm_filled_qty( + std::stod(getm(map, CCAPI_EM_ORDER_CUMULATIVE_FILLED_QUANTITY))), + status(convert_ccapi_status(getm(map, CCAPI_EM_ORDER_STATUS))) {} +}; +// 3. Event [ +// type = SUBSCRIPTION_DATA, +// messageList = [ +// Message [ +// type = EXECUTION_MANAGEMENT_EVENTS_PRIVATE_TRADE, +// recapType = UNKNOWN, +// time = 2022-11-03T02:57:34.853000000Z, +// timeReceived = 2022-11-03T02:57:34.907237094Z, +// elementList = [ +// Element [ +// nameValueMap = { +// FEE_ASSET = BTC, +// FEE_QUANTITY = 0.0, +// INSTRUMENT = BTC-30JUN23, +// IS_MAKER = 1, +// LAST_EXECUTED_PRICE = 20412.0, +// LAST_EXECUTED_SIZE = 10.0, +// ORDER_ID = 14636988474, +// SEQUENCE_NUMBER = 898679, +// SIDE = SELL, +// TRADE_ID = 130273180 +// } +// ] +// ], +// correlationIdList = [ 83Rzbkvs ] +// ] +// ] +// ] +struct CCAPITradeMsg { + std::string order_id; + api::Side side; + double last_exec_price; + double last_exec_qty; + std::string trade_id; + CCAPITradeMsg(const NVMap &map) + : order_id(getm(map, CCAPI_EM_ORDER_ID)), + side( + getm(map, CCAPI_EM_ORDER_SIDE) == CCAPI_EM_ORDER_SIDE_BUY + ? api::SIDE_BUY + : api::SIDE_SELL), + last_exec_price( + std::stod(getm(map, CCAPI_EM_ORDER_LAST_EXECUTED_PRICE))), + last_exec_qty(std::stod(getm(map, CCAPI_EM_ORDER_LAST_EXECUTED_SIZE))), + trade_id(getm(map, CCAPI_TRADE_ID)) {} +}; + +struct CCAPISubscriptionStatusMsg { + bool is_success; + std::string corr_id; + // maybe add info message here +}; + +} // namespace bts::orderman \ No newline at end of file diff --git a/src/lib/orderman/ccapi/CCAPIOrderState.cpp b/src/lib/orderman/ccapi/CCAPIOrderState.cpp new file mode 100644 index 000000000..c92346d12 --- /dev/null +++ b/src/lib/orderman/ccapi/CCAPIOrderState.cpp @@ -0,0 +1 @@ +#include "CCAPIOrderState.h" \ No newline at end of file diff --git a/src/lib/orderman/ccapi/CCAPIOrderState.h b/src/lib/orderman/ccapi/CCAPIOrderState.h new file mode 100644 index 000000000..95c9c2466 --- /dev/null +++ b/src/lib/orderman/ccapi/CCAPIOrderState.h @@ -0,0 +1,72 @@ +#pragma once +#include "CCAPIOrderCallbackMsgs.h" +#include "lib/api/services/OrderService.pb.h" +#include "lib/domain/OrderStatus.h" +#include "lib/domain_model/Security.h" +#include "lib/domain_model/Security.pb.h" +#include "lib/domain_model/SecurityKey.h" +#include "lib/orderman/orderman_utils/orderman_common.h" +#include "lib/os/os.h" +#include +#include +#include + +namespace bts::orderman { + +typedef std::string CCAPIOrderKey; + +// this is the data returned from the Mux callback to the gateway +struct CCAPIOrderState { + + struct CCAPITradeRecord {}; + + struct CCAPISpreadLegFill {}; + + const api::Security &security; + const OrderKey order_key; + const std::string cc_create_corr_id; + const bts::api::Side side; + CCAPIOrderKey cc_order_key = ""; + bts::api::orderman::OrderStatus status = + bts::api::orderman::OrderStatus::ORDER_STATUS_PENDING_WORKING; + double order_px = + os::nan(); // copied only when qty > 0 (might not ne needed anymore) + double order_qty = 0; + double total_fills = 0; + double avg_filled_price = 0; + double last_filled_qty = 0; + double last_filled_price = 0; + // these are not the accumulated trades but trades that happened bw last + // callback and now + boost::container::small_vector cb_trades = {}; + // leg fills corresponding to the above trades (optional) (lifecycle is the + // same as above + boost::container::small_vector cb_leg_trades = {}; + size_t n_cbs = 0; + + CCAPIOrderState( + const api::Security &security, + OrderKey order_key, + const std::string &cc_create_corr_id, + bts::api::Side side, + double order_px, + double order_qty) + : security(security), order_key(order_key), + cc_create_corr_id(cc_create_corr_id), side(side), order_px(order_px), + order_qty(order_qty) {} +}; + +inline std::ostream &operator<<(std::ostream &out, CCAPIOrderState const &s) { + out << "sec_key: " << s.security.id() << " order_key: " << s.order_key + << " cc_create_corr_id: " << s.cc_create_corr_id + << " side: " << securities::side_name(s.side) + << " cc_order_key: " << s.cc_order_key + << " status: " << api::orderman::OrderStatus_Name(s.status) + << " order_px: " << s.order_px << " order_qty: " << s.order_qty + << " total_fills: " << s.total_fills + << " avg_filled_price: " << s.avg_filled_price + << " n_trades: " << s.cb_trades.size(); + return out; +} + +} // namespace bts::orderman diff --git a/src/lib/orderman/ccapi/CCAPISingleOrderManager.cpp b/src/lib/orderman/ccapi/CCAPISingleOrderManager.cpp new file mode 100644 index 000000000..bd7e31151 --- /dev/null +++ b/src/lib/orderman/ccapi/CCAPISingleOrderManager.cpp @@ -0,0 +1,278 @@ +#include "CCAPISingleOrderManager.h" +#include "CCAPIOrderCallbackMsgs.h" +#include "CCAPIOrderState.h" +#include "lib/api/services/OrderService.pb.h" +#include "lib/domain_model/Security.h" +#include "lib/domain_model/Security.pb.h" +#include "lib/logging/logging.h" +#include "lib/orderman/orderman_utils/orderman_common.h" +#include "lib/utils/bts_assert.h" + +namespace bts::orderman { + +enum class CCAPISingleOrderManager::State { + WaitingForID, + Working, + EndWaitingForFills, + End +}; + +bool eq(double p1, double p2) { return securities::eq(p1, p2); } + +bool gr_eq(double p1, double p2) { return securities::gr_than_eq(p1, p2); } + +void copy_order_update(CCAPIOrderState &to, const CCAPIOrderUpdateMsg &from) { + to.status = from.status; + to.order_px = from.price; + to.order_qty = from.qty; + to.total_fills = from.cumm_filled_qty; + to.avg_filled_price = from.cumm_filled_price; +} + +struct PreviousState { + double order_px = os::nan(); + double order_qty = 0; + double total_fills = 0; + double avg_filled_price = 0; + bts::api::orderman::OrderStatus status = + bts::api::orderman::OrderStatus::ORDER_STATUS_PENDING_WORKING; + void udpate(const CCAPIOrderState &ostate) { + order_px = ostate.order_px; + order_qty = ostate.order_qty; + total_fills = ostate.total_fills; + avg_filled_price = ostate.avg_filled_price; + status = ostate.status; + } + bool changed(const CCAPIOrderState &ostate) const { + bool unchanged = eq(order_px, ostate.order_px) && + eq(order_qty, ostate.order_qty) && + eq(total_fills, ostate.total_fills) && + eq(avg_filled_price, ostate.avg_filled_price) && + status == ostate.status; + return !unchanged; + } +}; + +struct CCAPISingleOrderManager::PImpl { + CCAPIOrderState order; + PreviousState prev_state = {}; + State state = State::WaitingForID; + std::vector buffered_order_updates = {}; + std::vector buffered_trades = {}; + double accumulated_fills = 0; + + PImpl( + const api::Security &security, + OrderKey order_key, + const std::string &cc_create_corr_id, + bts::api::Side side, + double order_px, + double order_qty) + : order( + security, + order_key, + cc_create_corr_id, + side, + order_px, + order_qty) {} + bool fills_accounted() const { + return eq(accumulated_fills, order.total_fills); + } +}; + +CCAPISingleOrderManager::CCAPISingleOrderManager( + const api::Security &security, + OrderKey order_key, + const std::string &cc_create_corr_id, + bts::api::Side side, + double order_px, + double order_qty) + : me(new PImpl( + security, order_key, cc_create_corr_id, side, order_px, order_qty)) { + LOG(OrderMan, Info, + "CCAPISingleOrderManager::cons order_key: {} sec_id: {} corr_id: {} p: " + "{} q: {} side: {}", + order_key, security.id(), cc_create_corr_id, order_px, order_qty, + (int)side); +} + +CCAPISingleOrderManager::~CCAPISingleOrderManager() {} + +void CCAPISingleOrderManager::handle_create( + const CCAPICreateOrderMsg &create_order_msg) { + LOG(OrderMan, Info, + "CCAPISingleOrderManager::handle_create ok: {} corr_id: {} " + "cc_order_key: {} state: {}", + me->order.order_key, me->order.cc_create_corr_id, me->order.cc_order_key, + state_msg(me->state)); + switch (me->state) { + case State::WaitingForID: + // copy create state + me->order.cc_order_key = create_order_msg.order_id; + me->order.status = create_order_msg.status; + me->order.order_px = create_order_msg.price; + me->order.order_qty = create_order_msg.qty; + me->order.total_fills = create_order_msg.cumm_filled_qty; + me->order.avg_filled_price = create_order_msg.cumm_filled_price; + me->order.last_filled_price = create_order_msg.cumm_filled_price; + me->order.last_filled_qty = create_order_msg.cumm_filled_qty; + // copy trades + for (const auto &tr : me->buffered_trades) { + if (tr.order_id == me->order.cc_order_key) { + me->accumulated_fills += tr.last_exec_qty; + me->order.cb_trades.emplace_back(tr); + } + } + me->buffered_trades.clear(); + // order state: in case order_update is ahead of the create message + // (filled qty can not go down and status can not go from final state to + // non-final state) + for (const auto &ord_up : me->buffered_order_updates) { + if (ord_up.order_id == me->order.cc_order_key) { + if (gr_eq(ord_up.cumm_filled_qty, me->order.total_fills) || + (!in_terminal_state(me->order.status) && + in_terminal_state(ord_up.status))) { + copy_order_update(me->order, ord_up); + } + } + } + me->buffered_order_updates.clear(); + if (in_terminal_state(me->order.status)) { + if (me->fills_accounted()) { + _switch_state(State::End); + } else { + _switch_state(State::EndWaitingForFills); + } + } else { + _switch_state(State::Working); + } + break; + case State::Working: + if (me->order.cc_order_key == create_order_msg.order_id) + LOG(OrderMan, Error, + "CCAPISingleOrderManager::handle_create ok: {} state: {}", + me->order.order_key, state_msg(me->state)); + break; + case State::EndWaitingForFills: + if (me->order.cc_order_key == create_order_msg.order_id) + LOG(OrderMan, Error, + "CCAPISingleOrderManager::handle_create ok: {} state: {}", + me->order.order_key, state_msg(me->state)); + break; + case State::End: + if (me->order.cc_order_key == create_order_msg.order_id) + LOG(OrderMan, Error, + "CCAPISingleOrderManager::handle_create ok: {} state: {}", + me->order.order_key, state_msg(me->state)); + break; + } +} + +void CCAPISingleOrderManager::handle_order_update( + const CCAPIOrderUpdateMsg &order_update_msg) { + if (!_relevent_update(order_update_msg.order_id)) + return; + LOG(OrderMan, Info, + "CCAPISingleOrderManager::handle_order_update ok: {} corr_id: {} " + "cc_order_key: {} state: {} order_update_msg.order_id: {}", + me->order.order_key, me->order.cc_create_corr_id, me->order.cc_order_key, + state_msg(me->state), order_update_msg.order_id); + switch (me->state) { + case State::WaitingForID: + me->buffered_order_updates.push_back(order_update_msg); + break; + case State::Working: + if (me->order.cc_order_key != order_update_msg.order_id) + return; + copy_order_update(me->order, order_update_msg); + if (in_terminal_state(me->order.status)) { + if (me->fills_accounted()) { + _switch_state(State::End); + } else { + _switch_state(State::EndWaitingForFills); + } + } + break; + case State::EndWaitingForFills: + break; + case State::End: + break; + } +} + +void CCAPISingleOrderManager::handle_trade(const CCAPITradeMsg &trade_msg) { + if (!_relevent_update(trade_msg.order_id)) + return; + LOG(OrderMan, Info, + "CCAPISingleOrderManager::handle_trade ok: {} corr_id: {} " + "cc_order_key: {} state: {} trade_id: {} " + "p: {} q: {}", + me->order.order_key, me->order.cc_create_corr_id, me->order.cc_order_key, + state_msg(me->state), trade_msg.trade_id, trade_msg.last_exec_price, + trade_msg.last_exec_qty); + switch (me->state) { + case State::WaitingForID: + me->buffered_trades.push_back(trade_msg); + break; + case State::Working: + if (me->order.cc_order_key != trade_msg.order_id) + return; + me->accumulated_fills += trade_msg.last_exec_qty; + me->order.cb_trades.emplace_back(trade_msg); + break; + case State::EndWaitingForFills: + me->accumulated_fills += trade_msg.last_exec_qty; + me->order.cb_trades.emplace_back(trade_msg); + if (me->fills_accounted()) { + _switch_state(State::End); + } + break; + case State::End: + break; + } +} + +void CCAPISingleOrderManager::dispatch_start() { + me->prev_state.udpate(me->order); + me->order.cb_trades.clear(); +} + +bool CCAPISingleOrderManager::dispatch_end() { + return me->prev_state.changed(me->order); +} + +const CCAPIOrderState &CCAPISingleOrderManager::order_state() const { + return me->order; +} + +void CCAPISingleOrderManager::_switch_state(State new_state) { + LOG(OrderMan, Info, + "CCAPISingleOrderManager::_switch_state ok: {} cc_api_key: {} {} -> {}", + me->order.order_key, me->order.cc_order_key, state_msg(me->state), + state_msg(new_state)); + me->state = new_state; +} + +std::string CCAPISingleOrderManager::state_msg( + CCAPISingleOrderManager::State state) { + switch (state) { + case State::WaitingForID: + return "WaitingForID"; + case State::Working: + return "Working"; + case State::EndWaitingForFills: + return "EndWaitingForFills"; + case State::End: + return "End"; + } + bts_assert(false); + return ""; +} + +bool CCAPISingleOrderManager::_relevent_update( + const std::string &cc_ord_key) const { + return me->state == State::WaitingForID || + me->order.cc_order_key == cc_ord_key; +} + +} // namespace bts::orderman \ No newline at end of file diff --git a/src/lib/orderman/ccapi/CCAPISingleOrderManager.h b/src/lib/orderman/ccapi/CCAPISingleOrderManager.h new file mode 100644 index 000000000..f91543e91 --- /dev/null +++ b/src/lib/orderman/ccapi/CCAPISingleOrderManager.h @@ -0,0 +1,51 @@ +#pragma once + +#include "lib/domain_model/Security.pb.h" +#include "lib/orderman/orderman_utils/orderman_common.h" +#include + +namespace bts::orderman { + +struct CCAPICreateOrderMsg; +struct CCAPIOrderUpdateMsg; +struct CCAPITradeMsg; +struct CCAPIOrderState; + +class CCAPISingleOrderManager { + + public: + CCAPISingleOrderManager( + const api::Security &security, + OrderKey order_key, + const std::string &cc_create_corr_id, + bts::api::Side side, + double order_px, + double order_qty); + + ~CCAPISingleOrderManager(); + bool inited() const; + + void handle_create(const CCAPICreateOrderMsg &create_order_msg); + + void handle_order_update(const CCAPIOrderUpdateMsg &order_update_msg); + + void handle_trade(const CCAPITradeMsg &trade_msg); + + void dispatch_start(); + + // if there is a change return true + bool dispatch_end(); + + const CCAPIOrderState &order_state() const; + + private: + struct PImpl; + // std::unique_ptr me; + PImpl *me; + enum class State; + void _switch_state(State new_state); + std::string state_msg(State new_state); + bool _relevent_update(const std::string &cc_ord_key) const; +}; + +} // namespace bts::orderman \ No newline at end of file diff --git a/src/lib/orderman/ccapi/ICCAPIOrderMux.h b/src/lib/orderman/ccapi/ICCAPIOrderMux.h new file mode 100644 index 000000000..0f3ea9711 --- /dev/null +++ b/src/lib/orderman/ccapi/ICCAPIOrderMux.h @@ -0,0 +1,81 @@ +#pragma once +//#include "CCAPIOrderCallbackMsgs.h" +//#include "CCAPIOrderState.h" +//#include "lib/api/services/OrderService.pb.h" +//#include "lib/domain_model/Security.pb.h" +//#include "lib/logging/logging.h" +//#include "lib/md/common.h" +// #include "lib/orderman/CancelOrderMsg.h" +// #include "lib/orderman/CancelReplaceOrderMsg.h" +// #include "lib/orderman/CreateOrderMsg.h" +//#include "lib/orderman/RFQMsg.h" +//#include "lib/os/os.h" +//#include +//#include +#include "CCAPIOrderCallbackMsgs.h" +#include "lib/md/SecurityOracle.h" +#include "lib/mercury/events/Update.h" +#include "lib/orderman/events/NewSecuritiesEvent.h" +#include + +namespace bts::orderman { + +struct RFQMsg; +struct CCAPIOrderState; +struct CancelOrderMsg; +struct CancelReplaceOrderMsg; +struct CreateOrderMsg; + +struct CCAPIOpResult { + bool is_success; + std::string err_msg; +}; + +struct CCAPIPosition { + uint32_t bts_sec_key; // bts sec key + double position; // +ve for long + std::string sub_account; +}; + +struct CCAPIExchangeOpenOrder {}; + +using OnCCAPIExchangePositionUpdate = + std::function &)>; + +using OnCCAPIExchangeOpenOrderUpdate = + std::function &)>; + +using OnCCAPIOrderUpdate = std::function; + +class ICCAPIOrderMux { + public: + // System Data + virtual void on_securities( + const bts::mercury::Update &update) = 0; + // Orders + // ////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + // These calls enter, update and cancel a single order respectively. + // Their results are corresponded in the order_update_cb callback + virtual CCAPIOpResult launch_new_order(const CreateOrderMsg &cr_msg) = 0; + virtual bool update_order(const CancelReplaceOrderMsg &cxl_repl_msg) = 0; + virtual bool cancel_order(const CancelOrderMsg &) = 0; + virtual void send_rfq(const RFQMsg &rfq) = 0; + virtual OnCCAPIOrderUpdate &order_update_cb() = 0; + // Dispatching incoming messages + virtual void dispatch_incoming_messages() = 0; + // Position + // //////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + // This queries the exchange for the positions. the position is returned + // on the exchange_position_update_cb callback (below) + // TODO: account as a paremter + virtual void query_positions() = 0; + virtual OnCCAPIExchangePositionUpdate &exchange_position_update_cb() = 0; + // Mass orders + // ///////////////////////////////////////////////////////////// + virtual void query_open_orders() = 0; + virtual OnCCAPIExchangeOpenOrderUpdate &exchange_open_orders_update_cb() = 0; +}; + +} // namespace bts::orderman diff --git a/src/lib/orderman/gateways/CCAPIExecutionGateway.cpp b/src/lib/orderman/gateways/CCAPIExecutionGateway.cpp new file mode 100644 index 000000000..a6e7e2ee8 --- /dev/null +++ b/src/lib/orderman/gateways/CCAPIExecutionGateway.cpp @@ -0,0 +1,289 @@ +#include "CCAPIExecutionGateway.h" +#include "lib/api/service_helpers/AdminServiceUtils.h" +#include "lib/api/services/AdminService.pb.h" +#include "lib/api/services/OrderService.pb.h" +#include "lib/domain_model/Security.pb.h" +#include "lib/domain_model/SecurityKey.h" +//#include "lib/domain_model/common.h" +#include "lib/logging/logging.h" +#include "lib/md/SecurityOracle.h" +#include "lib/orderman/CancelOrderMsg.h" +#include "lib/orderman/CancelReplaceOrderMsg.h" +#include "lib/orderman/CreateOrderMsg.h" +#include "lib/orderman/OrderMsg.h" +#include "lib/orderman/RFQMsg.h" +#include "lib/orderman/ccapi/CCAPIDeribitOrderMux.h" +#include "lib/orderman/events/NewAdminDataEvent.h" +#include "lib/orderman/events/NewExecutionReportEvent.h" +#include "lib/orderman/events/NewSecuritiesEvent.h" +#include "lib/orderman/orderman_utils/CancelReject.h" +#include "lib/orderman/orderman_utils/ExchangeOpenOrders.h" +#include "lib/orderman/orderman_utils/ExchangePosition.h" +#include "lib/orderman/orderman_utils/ExecutionReport.h" +#include "lib/orderman/orderman_utils/orderman_common.h" +#include "lib/os/os.h" +//#include "lib/tracing/bts_trace.h" +#include "lib/utils/bts_assert.h" +#include "lib/utils/datetime.h" +//#include "lib/utils/helper_macros.h" + +#include "lib/api/service_helpers/AdminServiceUtils.h" +#include "lib/config/config.h" +#include "lib/config/protos/toggles.pb.h" +#include "lib/domain_model/Security.h" +#include "lib/orderman/ccapi/CCAPIOrderState.h" +#include "lib/orderman/ccapi/ICCAPIOrderMux.h" +#include "lib/utils/PBUtils.h" +#include "lib/utils/Uuid.h" +#include +#include +//#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace bts::orderman { + +api::orderman::NativeOrderStatus native_order_status(const CCAPIOrderState &s) { + switch (s.status) { + case api::orderman::OrderStatus::ORDER_STATUS_INACTIVE: + return api::orderman::NativeOrderStatus:: + NATIVE_ORDER_STATUS_UNACKNOWLEDGED; + case api::orderman::OrderStatus::ORDER_STATUS_WORKING: + return api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_NEW; + case api::orderman::OrderStatus::ORDER_STATUS_COMPLETED: + return api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_FILLED; + case api::orderman::OrderStatus::ORDER_STATUS_CANCELED: + return api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_CANCELED; + case api::orderman::OrderStatus::ORDER_STATUS_ERROR: + return api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_STOPPED; + case api::orderman::OrderStatus::ORDER_STATUS_DISCONNECTED: + return api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_UNDEFINED; + case api::orderman::OrderStatus::ORDER_STATUS_PENDING_WORKING: + return api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_PENDING_NEW; + case api::orderman::OrderStatus::ORDER_STATUS_REJECTED_BY_SPARK: + return api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_REJECTED; + case api::orderman::OrderStatus::OrderStatus_INT_MIN_SENTINEL_DO_NOT_USE_: + case api::orderman::OrderStatus::OrderStatus_INT_MAX_SENTINEL_DO_NOT_USE_: + bts_assert(false); + return api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_UNDEFINED; + } + bts_assert(false); + return api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_UNDEFINED; +} + +struct CCAPIExecutionGateway::PImpl { + PImpl(md::SecurityOracle o) + : sec_oracle(o), order_mux(new CCAPIDeribitOrderMux(o)) { + LOG(OrderMan, Info, "CCAPIExecutionGateway::PImpl constructor"); + } + admin::AdminServiceUtils::ExchangeSubAccountResolver subaccount_resolver = + {}; + // callback cashed data + api::admin::AdminData admin_data = {}; + md::SecurityOracle sec_oracle; + // interface (IExecutionGateway) callbacks + OnExeReport on_exe_report; + OnGwStatusChange on_gw_status_change; + OnCancelReject on_cancel_reject; + OnExchangePositionState on_exchange_position_state; + OnExchangeOpenOrdersState on_exchange_open_orders; + // orders are sent out and callbacks received via IEMOrderMuxer + ICCAPIOrderMux *order_mux; + size_t msg_seq_num = 0; + boost::object_pool exe_report_pool; + std::unordered_map order_map = {}; + // this is updated as we get exchange positions + ExchangePosition exchange_position; + ExchangeOpenOrders exchange_open_orders; + // periodic query (temporary) + bts::datetime::PTime last_pos_fire_time = bts::datetime::now(); + uint32_t pos_fire_period_ms = 5000; + size_t dispatch_idx = 0; +}; + +CCAPIExecutionGateway::CCAPIExecutionGateway(md::SecurityOracle o) + : IExecutionGateway(), me(new PImpl(o)) { + LOG(OrderMan, Info, + "CCAPIExecutionGateway::CCAPIExecutionGateway constructor t_id: {} " + "t_name: {}", + os::get_thread_id(), os::get_application_name()); +} + +CCAPIExecutionGateway::~CCAPIExecutionGateway() {} + +void CCAPIExecutionGateway::start() { + _init(); + LOG(OrderMan, Info, + "CCAPIExecutionGateway::start t_id: {} " + "t_name: {}", + os::get_thread_id(), os::get_thread_name()); +} + +// this is a periodic timer +void CCAPIExecutionGateway::dispatch_incoming_fix_messages() { + me->order_mux->dispatch_incoming_messages(); +} + +void CCAPIExecutionGateway::on_securities( + const mercury::Update &update) { + LOG(OrderMan, Info, + "CCAPIExecutionGateway::on_securities t_id: {} t_name: {} n_secs: {}", + os::get_thread_id(), os::get_thread_name(), + update.events == nullptr ? 0 : update.events->size()); + me->order_mux->on_securities(update); +} + +void CCAPIExecutionGateway::on_admin_data( + const mercury::Update &update) { + LOG(OrderMan, Info, + "CCAPIExecutionGateway::on_admin_data t_id: {} t_name: {}", + os::get_thread_id(), os::get_thread_name()); + if (update.events) { + for (auto const &ev : *(update.events)) + me->admin_data.CopyFrom(*ev.admin_data); + } +} + +void CCAPIExecutionGateway::send_fix(const jetfix::OutFIXPtr &, trace::CorID) { + bts_assert_msg(false, "CCAPIExecutionGateway does not support fix"); +} + +void CCAPIExecutionGateway::send_msgs( + std::vector const &msg_vec, trace::CorID) { + LOG(OrderMan, Info, "CCAPIExecutionGateway::send_msgs count: {}", + msg_vec.size()); + for (const auto &m : msg_vec) { + LOG(OrderMan, Info, "CCAPIExecutionGateway::send_msgs {}", m); + if (std::holds_alternative(m)) { + const CreateOrderMsg &cr_msg = std::get(m); + LOG(OrderMan, Info, + "CCAPIExecutionGateway::send_msgs Create sec: {} order_key", + cr_msg.security->id(), cr_msg.key); + me->order_map.insert({cr_msg.key, cr_msg}); + me->order_mux->launch_new_order(cr_msg); + } else if (std::holds_alternative(m)) { + const CancelReplaceOrderMsg &cxl_repl_msg = + std::get(m); + LOG(OrderMan, Info, + "CCAPIExecutionGateway::send_msgs CancelReplace sec: {} " + "order_key: {}", + cxl_repl_msg.create_fields.security->id(), + cxl_repl_msg.create_fields.key); + me->order_mux->update_order(cxl_repl_msg); + } else if (std::holds_alternative(m)) { + const CancelOrderMsg &cxl_msg = std::get(m); + LOG(OrderMan, Info, + "CCAPIExecutionGateway::send_msgs Cancel order_key: {}", + cxl_msg.key); + me->order_mux->cancel_order(cxl_msg); + } else if (std::holds_alternative(m)) { + const RFQMsg &rfq_msg = std::get(m); + LOG(OrderMan, Info, "CCAPIExecutionGateway::send_msgs RFQ: {}", + utils::pb::to_string(rfq_msg.rfq)); + // me->order_mux->send_rfq(rfq_msg); + } + } +} + +OnExeReport &CCAPIExecutionGateway::on_exe_report() { + return me->on_exe_report; +} +OnGwStatusChange &CCAPIExecutionGateway::on_gw_status_change() { + return me->on_gw_status_change; +} +OnCancelReject &CCAPIExecutionGateway::on_cancel_reject() { + return me->on_cancel_reject; +} +OnExchangePositionState &CCAPIExecutionGateway::on_exchange_position_state() { + LOG(OrderMan, Info, + "CCAPIExecutionGateway::on_exchange_position_state subscribed"); + return me->on_exchange_position_state; +} +OnExchangeOpenOrdersState &CCAPIExecutionGateway::on_exchange_open_orders() { + LOG(OrderMan, Info, + "CCAPIExecutionGateway::on_exchange_open_orders subscribed"); + return me->on_exchange_open_orders; +} + +void CCAPIExecutionGateway::_init() { + me->order_mux->order_update_cb() = + [this](const CCAPIOrderState &order_state) { + _on_order_cb(order_state); + }; +} + +void CCAPIExecutionGateway::_on_order_cb(const CCAPIOrderState &s) { + LOG(OrderMan, Info, "CCAPIExecutionGateway::_on_order_cb order_state: {}", + s); + auto it = me->order_map.find(s.order_key); + if (it == me->order_map.end()) { + LOG(OrderMan, Error, + "CCAPIExecutionGateway::_process_cb_and_fire_er key: {} not found", + s.order_key); + } + const auto &cr_msg = it->second; + + // cant create one on the stack + ExecutionReport *er_p = me->exe_report_pool.construct(); + ExecutionReport &er = *er_p; + // length of these have to be <= 12 + to_array(cr_msg.routing_record->account(), &er.account_name.value()); + to_array(cr_msg.routing_record->operator_id(), &er.operator_id.value()); + er.order_key = cr_msg.key; + er.msg_seq_num = + me->msg_seq_num++; // this is needed for fix, here we just ++ it + er.security = cr_msg.security; + er.leg_security = nullptr; + er.side = cr_msg.side; + er.time_in_force = cr_msg.time_in_force; + er.order_type = cr_msg.order_type; + er.exec_type = api::orderman::ExecType::EXEC_TYPE_NEW; // TODO + er.order_status = native_order_status(s); + er.manual_order_indicator = + api::orderman::ManualOrderIndicator::MANUAL_ORDER_INDICATOR_NO; + auto &er_exch_oid = std::get(er.exchange_order_id).value(); + to_array(s.cc_order_key, &er_exch_oid); + er.price.value() = s.order_px; + er.quantity = s.order_qty; + // fractional qty + // fills + er.avg_price.value() = s.avg_filled_price; + er.filled_quantity = s.total_fills; + if (!s.cb_trades.empty()) { + if (s.cb_trades.size() > 1) { + LOG(OrderMan, Error, + "CCAPIExecutionGateway::_on_order_cb multiple trade fills for " + "order_key: {}", + s.order_key); + } + er.exec_type = api::orderman::ExecType::EXEC_TYPE_PARTIAL_FILL; + if (s.status == api::orderman::ORDER_STATUS_COMPLETED) { + er.exec_type = api::orderman::ExecType::EXEC_TYPE_FILL; + } + auto &tr = s.cb_trades.back(); + er.last_price = Price(tr.last_exec_price); + er.last_shares = Quantity::create_new(tr.last_exec_qty); + to_array(tr.trade_id, &er.exchange_fill_id.value()); + } else { + er.last_shares = Quantity(0); + } + er.max_show = Quantity(0); + er.exchange = cr_msg.security->exchange(); + ExchangeTimeStamp64 now = ExchangeTimeStamp64(datetime::unix_nano_now()); + er.transact_time = now; + LOG(OrderMan, Info, + "CCAPIExecutionGateway::_process_cb_and_fire_er firing er: {}", + er.to_string()); + me->on_exe_report(er, {}); + // _fire_leg_er(em_cb, er); +} + +} // namespace bts::orderman \ No newline at end of file diff --git a/src/lib/orderman/gateways/CCAPIExecutionGateway.h b/src/lib/orderman/gateways/CCAPIExecutionGateway.h new file mode 100644 index 000000000..3bda96ca4 --- /dev/null +++ b/src/lib/orderman/gateways/CCAPIExecutionGateway.h @@ -0,0 +1,58 @@ +#pragma once + +#include "IExecutionGateway.h" +#include "lib/api/services/AdminService.pb.h" +#include "lib/orderman/CancelOrderMsg.h" +#include "lib/orderman/CancelReplaceOrderMsg.h" +#include "lib/orderman/CreateOrderMsg.h" +#include "lib/orderman/RFQMsg.h" +#include "lib/orderman/ccapi/CCAPIOrderState.h" +#include "server/sparkd/md/platforms/emumba/IEMOrderMuxer.h" +#include +#include + +// CCAPIExecutionGateway is created by the ExecutionGatewayFactory. It is +// contained in SessionServicesData. + +// Order place/cxl/cxl-repls are cummunicated via send_msgs, by OrderManager +// (OrderManager::after_event). CCAPIExecutionGateway holds a pointer to +// IEMOrderMuxer through which all orders are sent out and callbacks reveived to +// the and from the outside world. + +// Callbacks are sent back to the OrderManager via the 4 callback functions. + +namespace bts { +namespace orderman { + +class ExecutionReport; +struct RFQMsg; + +class CCAPIExecutionGateway : public IExecutionGateway { + public: + CCAPIExecutionGateway(md::SecurityOracle); + virtual ~CCAPIExecutionGateway(); + + void start() override; + void dispatch_incoming_fix_messages() override; + void on_securities(const mercury::Update &) override; + void on_admin_data(const mercury::Update &) override; + void send_fix(const jetfix::OutFIXPtr &fix, trace::CorID trace) override; + void send_msgs(std::vector const &, trace::CorID) override; + + OnExeReport &on_exe_report() override; + OnGwStatusChange &on_gw_status_change() override; + OnCancelReject &on_cancel_reject() override; + OnExchangePositionState &on_exchange_position_state() override; + OnExchangeOpenOrdersState &on_exchange_open_orders() override; + + private: + struct PImpl; + std::unique_ptr me; + + private: + void _init(); + void _on_order_cb(const CCAPIOrderState &); +}; + +} // namespace orderman +} // namespace bts diff --git a/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp b/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp index d0f018577..f0a4f0b6a 100644 --- a/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp +++ b/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp @@ -1,5 +1,6 @@ #include "ExecutionGatewayFactory.h" #include "lib/md/SecurityOracle.h" +#include "lib/orderman/gateways/CCAPIExecutionGateway.h" #include "lib/orderman/gateways/EMExecutionGateway.h" #include "lib/orderman/gateways/FakeExecutionGateway.h" #include "lib/orderman/gateways/GLBXExecutionGateway.h" @@ -27,7 +28,8 @@ std::unique_ptr ExecutionGatewayFactory::create_gateway( conn, pl, o); return std::make_unique(conn, pl, o); } else - return std::make_unique(o); + return std::make_unique(o); + // return std::make_unique(o); // return std::make_unique(o); // return std::make_unique(conn, pl, o); } diff --git a/src/lib/orderman/orders/algo/algo_orders/JoinAlgo.cpp b/src/lib/orderman/orders/algo/algo_orders/JoinAlgo.cpp index 4c16119eb..75950d0da 100644 --- a/src/lib/orderman/orders/algo/algo_orders/JoinAlgo.cpp +++ b/src/lib/orderman/orders/algo/algo_orders/JoinAlgo.cpp @@ -1,4 +1,5 @@ #include "lib/orderman/orders/algo/algo_orders/JoinAlgo.h" +#include "lib/logging/logging.h" #include "lib/orderman/orders/algo/IAlgoServices.h" #include "lib/orderman/order_factory/IOrderFactory.h" @@ -73,7 +74,7 @@ void JoinAlgo::do_launch_attached( } void JoinAlgo::do_update(api::orderman::Update const &update) { - LOG(OrderMan, Diag, "JoinOrder order {} receiving update: {}", + LOG(OrderMan, Info, "JoinOrder order {} receiving update: {}", algo().order_key().value(), utils::pb::to_string(update)); if (update.has_custom() && !update.custom().has_join()) { @@ -101,10 +102,11 @@ void JoinAlgo::do_update(api::orderman::Update const &update) { void JoinAlgo::on_book(SecurityKey, Book const &b) { me->last_book = b; - LOG(OrderMan, Diag, "JoinOrder order {} on book. BID: {}@{} ASK: {}@{}", - algo().order_key().value(), b.side(api::SIDE_BUY)[0].size(), - b.side(api::SIDE_BUY)[0].price(), b.side(api::SIDE_SELL)[0].size(), - b.side(api::SIDE_SELL)[0].price()); + LOG(OrderMan, Diag, + "JoinOrder::on_book order: {} BID: p: {} q: {} ASK: p: {} q: {}", + algo().order_key().value(), b.side(api::SIDE_BUY)[0].price(), + b.side(api::SIDE_BUY)[0].size(), b.side(api::SIDE_SELL)[0].price(), + b.side(api::SIDE_SELL)[0].size()); switch (me->status) { case Status::WAITING_FOR_MD: { diff --git a/src/lib/orderman/orders/algo/algo_orders/TASCounterAlgo.cpp b/src/lib/orderman/orders/algo/algo_orders/TASCounterAlgo.cpp index f81febc82..9ae7ef763 100644 --- a/src/lib/orderman/orders/algo/algo_orders/TASCounterAlgo.cpp +++ b/src/lib/orderman/orders/algo/algo_orders/TASCounterAlgo.cpp @@ -9,6 +9,7 @@ #include "lib/os/os.h" #include "lib/utils/PBUtils.h" #include "lib/utils/datetime.h" +#include #include #include #include @@ -98,8 +99,8 @@ TASCounterAlgo::TASCounterAlgo() : me(new PImpl()) {} TASCounterAlgo::~TASCounterAlgo() {} // initialization ///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -OrderOpResult -TASCounterAlgo::do_before_launch(IBeforeLaunchAlgoServices &serv) { +OrderOpResult TASCounterAlgo::do_before_launch( + IBeforeLaunchAlgoServices &serv) { if (_setup_data(serv, me->data, me->md_map)) return {}; return { @@ -243,7 +244,8 @@ void TASCounterAlgo::_check_and_send_order() { double c_price = c_same_top.price(); if ((is_buy && tas_delv_price <= c_price) || (!is_buy && tas_delv_price >= c_price)) { - out_qty = std::min(o.qty, tas_opp_top.size()); + out_qty = std::min( + o.qty, static_cast(std::abs(tas_opp_top.size()))); out_price = tas_opp_top.price(); return true; } diff --git a/src/lib/orderman/orders/algo/algo_orders/tests/dorman_tests.cpp b/src/lib/orderman/orders/algo/algo_orders/tests/dorman_tests.cpp index 91b0bd27b..343058d45 100644 --- a/src/lib/orderman/orders/algo/algo_orders/tests/dorman_tests.cpp +++ b/src/lib/orderman/orders/algo/algo_orders/tests/dorman_tests.cpp @@ -207,7 +207,7 @@ TEST_CASE("dorman_order_size", "[algo][dorman]") { Book book(secid); // order size is driven by the available market size - book.bid()[0] = {some_price, s.input}; + book.bid()[0] = {some_price, static_cast(s.input)}; state.update_book(book); REQUIRE(state.before_launch().ok()); diff --git a/src/lib/orderman/tests/CCApiExecutionTests.cpp b/src/lib/orderman/tests/CCApiExecutionTests.cpp new file mode 100644 index 000000000..51574ea59 --- /dev/null +++ b/src/lib/orderman/tests/CCApiExecutionTests.cpp @@ -0,0 +1,138 @@ + +#include "catch/catch.hpp" +#include "lib/api/service_helpers/AdminServiceUtils.h" +#include "lib/api/services/AdminService.server.pb.h" +#include "lib/config/config.h" +#include "lib/logging/logging.h" +#include "lib/utils/bts_assert.h" +#include "lib/utils/bts_chrono.h" +#include "lib/utils/helper_macros.h" +#include +#include +#include +#include +#include +#include + +#include "ccapi_cpp/ccapi_session.h" +#include + +namespace bts::orderman { + +class MyEventHandler : public ccapi::EventHandler { + public: + std::string order_id = ""; + bool processEvent( + const ccapi::Event &event, ccapi::Session *session) override { + bts_assert(session != nullptr); + std::cout << "Received an event:\n" + event.toStringPretty(2, 2) + << std::endl; + const auto &msg_list = event.getMessageList(); + for (const auto &m : msg_list) { + if (m.getType() == ccapi::Message::Type::CREATE_ORDER) { + for (const auto &e : m.getElementList()) { + const auto &nv_map = e.getNameValueMap(); + if (nv_map.find("ORDER_ID") != nv_map.end()) { + order_id = nv_map.find("ORDER_ID")->second; + order_id = nv_map.find("ORDER_ID")->second; + std::cout << "Received order: " << std::endl; + break; + } + } + } + } + return true; + } +}; + +class Bootstrapper { + public: + void send_binance_order() { + setenv( + CCAPI_BINANCE_USDS_FUTURES_API_KEY, + "02740f1255c574657845080083d5e86dcb65af915fbb0ef3c48d9ca20ddace95", + 1); + std::cout << ccapi::UtilSystem::getEnvAsString( + CCAPI_BINANCE_USDS_FUTURES_API_KEY) + << std::endl; + setenv( + CCAPI_BINANCE_USDS_FUTURES_API_SECRET, + "092fbd8242a25a5efe4298f799af1147318268711d3e6e4d2ad21941ff655f15", + 1); + std::cout << ccapi::UtilSystem::getEnvAsString( + CCAPI_BINANCE_USDS_FUTURES_API_SECRET) + << std::endl; + ccapi::SessionOptions sessionOptions; + ccapi::SessionConfigs sessionConfigs; + MyEventHandler eventHandler; + ccapi::Session session(sessionOptions, sessionConfigs, &eventHandler); + ccapi::Request request( + ccapi::Request::Operation::CREATE_ORDER, + CCAPI_EXCHANGE_NAME_BINANCE_USDS_FUTURES, "BTCUSD"); + request.appendParam( + {{"SIDE", "BUY"}, {"QUANTITY", "1"}, {"LIMIT_PRICE", "19000"}}); + } + void send_deribit_order() { + char ssl_cert_file[] = "SSL_CERT_FILE=/etc/ssl/cert/ca-certificates.crt"; + putenv(ssl_cert_file); + ccapi::SessionOptions sessionOptions; + ccapi::SessionConfigs sessionConfigs; + sessionConfigs.setCredential({ + {"grant_type", "client_signature"}, + // test + {CCAPI_DERIBIT_CLIENT_ID, "ZmIKL6fb"}, + {CCAPI_DERIBIT_CLIENT_SECRET, + "_FY2PcXYNc8VdlfkZO5c-pkFJQFhn8P9z4_p8YA2fS0"}, + }); + MyEventHandler eventHandler; + ccapi::Session session(sessionOptions, sessionConfigs, &eventHandler); + ccapi::Request request( + ccapi::Request::Operation::CREATE_ORDER, CCAPI_EXCHANGE_NAME_DERIBIT, + "BTC-29SEP23"); + request.appendParam( + {{"SIDE", "BUY"}, {"QUANTITY", "100"}, {"LIMIT_PRICE", "20670.0"}}); + // ccapi::Request request( + // ccapi::Request::Operation::CANCEL_ORDER, + // CCAPI_EXCHANGE_NAME_DERIBIT, "BTC-29SEP23"); + // request.appendParam({ + // {"ORDER_ID", "14622153226"}, + // }); + session.sendRequest(request); + // requesting callbacks + ccapi::Request request_cb( + ccapi::Request::Operation::GET_ORDER, CCAPI_EXCHANGE_NAME_DERIBIT, + "BTC-29SEP23"); + int sleep_time_ms = 100; + bool cb_recvd = false; + for (int i = 0; i < 30000;) { + i += sleep_time_ms; + std::this_thread::sleep_for(std::chrono::milliseconds(sleep_time_ms)); + if (!cb_recvd) { + if (!eventHandler.order_id.empty()) { + std::string order_id = eventHandler.order_id; + cb_recvd = true; + std::cout << "Subscribing to get_order for order: " << order_id + << std::endl; + request_cb.appendParam({ + {"ORDER_ID", order_id}, + }); + session.sendRequest(request_cb); + } + } + } + + std::this_thread::sleep_for(std::chrono::seconds(300)); + session.stop(); + } +}; + +TEST_CASE("Simple", "[ccapi]") { + SECTION("execution_test") { + size_t i = 0; + REQUIRE(i == 0); + Bootstrapper bstrapper = {}; + bstrapper.send_deribit_order(); + } +} + +} // namespace bts::orderman \ No newline at end of file diff --git a/src/server/sparkd/exchange_sim/ExchangeSim.cpp b/src/server/sparkd/exchange_sim/ExchangeSim.cpp index 3c4a0d775..abad66e12 100644 --- a/src/server/sparkd/exchange_sim/ExchangeSim.cpp +++ b/src/server/sparkd/exchange_sim/ExchangeSim.cpp @@ -16,6 +16,7 @@ #include "lib/domain_model/Security.pb.h" #include "lib/logging/logging.h" +#include "lib/md/PriceSize.h" #include "lib/os/os.h" #include "lib/domain_model/Security.pb.h" @@ -50,7 +51,7 @@ auto cfg = "[DEFAULT]\n" md::PriceSize coerce_precision(const co2::PriceSizeMessage &p) { md::IntPrice raw = {p.mantissa(), (int8_t)p.exponent()}; auto price = md::IntPrice_from_double(raw.price()); - return {price, p.size()}; + return {price, static_cast(p.size())}; } struct MDPlayer : md::IRelayWriter { diff --git a/src/server/sparkd/md/platforms/emumba/EmMDListener.cpp b/src/server/sparkd/md/platforms/emumba/EmMDListener.cpp index d4c6e6502..dc41ac945 100644 --- a/src/server/sparkd/md/platforms/emumba/EmMDListener.cpp +++ b/src/server/sparkd/md/platforms/emumba/EmMDListener.cpp @@ -76,7 +76,7 @@ IntPrice convert_price(const emumba::market_data::price &pr) { } // Used for time/sales and book (seiling the book till we make the qtys double) -md::Size convert_qty(double qty) { return static_cast(std::ceil(qty)); } +md::Size convert_qty(double qty) { return static_cast(qty); } inline bts::utils::TimeStamp convert_timestamp( emumba::market_data::exchange_timestamp ts) { diff --git a/src/web/CMakeDeps.cmake b/src/web/CMakeDeps.cmake index addc0a4a3..f07f94250 100644 --- a/src/web/CMakeDeps.cmake +++ b/src/web/CMakeDeps.cmake @@ -1 +1 @@ -set(sources ../../externals/linux/include/google/protobuf/descriptor.proto;../../externals/linux/include/google/protobuf/timestamp.proto;../lib/api/analytics/ExpirationDriver.proto;../lib/api/analytics/TimeWeightedInterpolatedDriver.proto;../lib/api/apicore.proto;../lib/api/apigateway.proto;../lib/api/apioptions.proto;../lib/api/core/RegexFormatting.proto;../lib/api/domain/CallPut.proto;../lib/api/domain/Currency.proto;../lib/api/domain/SecurityCriteria.proto;../lib/api/domain/SecurityCriteriaClause.proto;../lib/api/domain/SecurityExpiration.proto;../lib/api/domain/SecurityMetadata.proto;../lib/api/domain/SecurityMetadataCollection.proto;../lib/api/domain/SecurityMetadataItem.proto;../lib/api/domain/SecurityType.proto;../lib/api/domain/TickDisplaySettings.proto;../lib/api/domain/TickFactors.proto;../lib/api/domain/Venue.proto;../lib/api/io/URL.proto;../lib/api/md/BinanceMarketDataConfig.proto;../lib/api/md/BinanceUsMarketDataConfig.proto;../lib/api/md/BinanceUsdsFuturesMarketDataConfig.proto;../lib/api/md/FTXMarketDataConfig.proto;../lib/api/md/MarketDataConfig.proto;../lib/api/services/AdminService.proto;../lib/api/services/AlgoDefinitionService.proto;../lib/api/services/AlgoService.proto;../lib/api/services/AnalyticsService.proto;../lib/api/services/ApiUnitTestService.proto;../lib/api/services/AuthService.proto;../lib/api/services/BasePositionService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MBOService.proto;../lib/api/services/MarginService.proto;../lib/api/services/MarketDataAuxiliaryService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/MarketDataService.proto;../lib/api/services/MoneyFileService.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/PositionService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/ShellLatencyService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;../lib/sparkproto/SparkProtos.proto;/home/taha/spark/.venv/bin/python;/home/taha/spark/src/lib/api/service_compiler/templates/fs/fable.fs;/home/taha/spark/src/web/api/package-lock.json;/home/taha/spark/src/web/api/tsconfig.release-gcc.g.json;/home/taha/spark/src/web/ui/src/ui.fsproj;/home/taha/spark/src/web/ui/webpack.config.js;/home/taha/spark/tools/py/build_web.py;/home/taha/spark/tools/venv_exec.sh;api/src/DynamicService.ts;api/src/ServiceContext.ts;api/src/bts_assert.ts;ui/src/Access.fs;ui/src/Accounts/ClipLimits.fs;ui/src/Accounts/ProductLimits.fs;ui/src/Accounts/SecurityLimits.fs;ui/src/Accounts/State.fs;ui/src/Accounts/Types.fs;ui/src/Accounts/View.fs;ui/src/App.fs;ui/src/Cmd.fs;ui/src/Controls/Button.fs;ui/src/Controls/DataGrid.fs;ui/src/Controls/Fields.fs;ui/src/Controls/Modal.fs;ui/src/Controls/ReactGrid.fs;ui/src/Controls/Table.fs;ui/src/Controls/nbsp.fs;ui/src/Global.fs;ui/src/Imports.fs;ui/src/Lens.fs;ui/src/Login/Login.fs;ui/src/Nav.fs;ui/src/State.fs;ui/src/Types.fs;ui/src/Users/State.fs;ui/src/Users/Types.fs;ui/src/Users/View.fs;ui/src/Util/EnumUtils.fs;ui/src/Util/JSMap.fs;ui/src/Util/StreamUtils.fs;ui/src/obj/Debug/net6.0/ui.AssemblyInfo.fs;ui/src/obj/Debug/netstandard2.0/ui.AssemblyInfo.fs) \ No newline at end of file +set(sources ../../externals/linux/include/google/protobuf/descriptor.proto;../../externals/linux/include/google/protobuf/timestamp.proto;../lib/api/analytics/ExpirationDriver.proto;../lib/api/analytics/TimeWeightedInterpolatedDriver.proto;../lib/api/apicore.proto;../lib/api/apigateway.proto;../lib/api/apioptions.proto;../lib/api/core/RegexFormatting.proto;../lib/api/domain/CallPut.proto;../lib/api/domain/Currency.proto;../lib/api/domain/SecurityCriteria.proto;../lib/api/domain/SecurityCriteriaClause.proto;../lib/api/domain/SecurityExpiration.proto;../lib/api/domain/SecurityMetadata.proto;../lib/api/domain/SecurityMetadataCollection.proto;../lib/api/domain/SecurityMetadataItem.proto;../lib/api/domain/SecurityType.proto;../lib/api/domain/TickDisplaySettings.proto;../lib/api/domain/TickFactors.proto;../lib/api/domain/Venue.proto;../lib/api/io/URL.proto;../lib/api/md/BinanceMarketDataConfig.proto;../lib/api/md/BinanceUsMarketDataConfig.proto;../lib/api/md/BinanceUsdsFuturesMarketDataConfig.proto;../lib/api/md/FTXMarketDataConfig.proto;../lib/api/md/MarketDataConfig.proto;../lib/api/services/AdminService.proto;../lib/api/services/AlgoDefinitionService.proto;../lib/api/services/AlgoService.proto;../lib/api/services/AnalyticsService.proto;../lib/api/services/ApiUnitTestService.proto;../lib/api/services/AuthService.proto;../lib/api/services/BasePositionService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MBOService.proto;../lib/api/services/MarginService.proto;../lib/api/services/MarketDataAuxiliaryService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/MarketDataService.proto;../lib/api/services/MoneyFileService.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/PositionService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/ShellLatencyService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;../lib/sparkproto/SparkProtos.proto;/home/taha/spark/.venv/bin/python;/home/taha/spark/src/lib/api/service_compiler/templates/fs/fable.fs;/home/taha/spark/src/web/api/package-lock.json;/home/taha/spark/src/web/api/tsconfig.release-gcc.g.json;/home/taha/spark/src/web/ui/src/ui.fsproj;/home/taha/spark/src/web/ui/webpack.config.js;/home/taha/spark/tools/py/build_web.py;/home/taha/spark/tools/venv_exec.sh;api/src/DynamicService.ts;api/src/ServiceContext.ts;api/src/bts_assert.ts;ui/src/Access.fs;ui/src/Accounts/ClipLimits.fs;ui/src/Accounts/ProductLimits.fs;ui/src/Accounts/SecurityLimits.fs;ui/src/Accounts/State.fs;ui/src/Accounts/Types.fs;ui/src/Accounts/View.fs;ui/src/App.fs;ui/src/Cmd.fs;ui/src/Controls/Button.fs;ui/src/Controls/DataGrid.fs;ui/src/Controls/Fields.fs;ui/src/Controls/Modal.fs;ui/src/Controls/ReactGrid.fs;ui/src/Controls/Table.fs;ui/src/Controls/nbsp.fs;ui/src/Global.fs;ui/src/Imports.fs;ui/src/Lens.fs;ui/src/Login/Login.fs;ui/src/Nav.fs;ui/src/State.fs;ui/src/Types.fs;ui/src/Users/State.fs;ui/src/Users/Types.fs;ui/src/Users/View.fs;ui/src/Util/EnumUtils.fs;ui/src/Util/JSMap.fs;ui/src/Util/StreamUtils.fs;ui/src/obj/Debug/net6.0/ui.AssemblyInfo.fs;ui/src/obj/Debug/netstandard2.0/ui.AssemblyInfo.fs)