Compare commits

..
Author SHA1 Message Date
John Colvin ddcc85bbc0 webapp check pt? 2024-09-18 14:02:40 +00:00
John Colvin 1b9c4fba2f refactor: Move logging into its own lib
Also moved a few logging deps from lib_spark -> system:
* bts_chrono.h
* bts_no_copy.h
* defer.h
* dispatcher.h/cpp
* file_utils.h/cpp
* type_name.h
2024-09-18 14:02:40 +00:00
John Colvin 49c7683d58 refactor: Move system_config.proto to lib_system 2024-09-18 14:02:40 +00:00
John Colvin a8a474dd7f refactor: Move thread_manager to lib_system 2024-09-18 14:02:40 +00:00
John Colvin 19450f4029 cleanup: Remove unnecessary includes 2024-09-18 14:02:40 +00:00
John Colvin 86d54fdd68 refactor: Move threads.proto to lib_system 2024-09-18 14:02:40 +00:00
John Colvin b413f519b5 refactor: Move warn_ctrl.h into lib_system
This is another logging dep
2024-09-18 14:02:40 +00:00
John Colvin 9f3e0898b9 build: Link boost_filesystem in lib_system 2024-09-18 14:02:40 +00:00
John Colvin 7709f250f6 refactor: Move os.h/cpp and deps to lib_system
This is a prerequisite for the next objective: move logging into its own lib.
As logging is a core dependency for so much of our system, this will enable
us to move more complex services (like md providers) into smaller libs.
2024-09-18 14:02:40 +00:00
John Colvin dc31b4919d cleanup: Remove unused code 2024-09-18 14:02:40 +00:00
John Colvin 0f8f7f3adc cleanup: Remove more unnecessary includes 2024-09-18 14:02:40 +00:00
John Colvin eae4f571ee refactor: Rename InstallBasicConfig -> InstallBasic 2024-09-18 14:02:40 +00:00
John Colvin e85cdcb453 refactor: Move SecurityMarketDataStatistics to lib_domain 2024-09-18 14:02:40 +00:00
John Colvin 2c7f47ef17 cleanup: Remove unnecessary code 2024-09-18 14:02:40 +00:00
John Colvin b9f7d0b1a2 cleanup: Remove empty header FTXSecurity.h 2024-09-18 14:02:40 +00:00
John Colvin 7feed957a3 cleanup: Remove temporary redirect headers
These were used to make code migration smoother (to the new lib_system and lib_domain)

* spark/algorithm/TryCatch.h -> system/algorithm/try_catch.h
* spark/core/BoolName.h -> system/bool_name.h
* spark/core/EnumMacros.h -> system/enum_macros.h
* spark/core/FMT.h -> system/FMT.h
* spark/core/FMT_IMPL.h -> system/FMT_IMPL.h
* spark/core/TimeSpan.h -> system/time_span.h
* spark/core/TimeStamp.h -> system/time_stamp.h
* spark/domain/Price.h -> domain/price.h
* spark/io/JsonReader.h -> system/json/json_reader.h
* spark/io/JsonDumper.h -> system/json/json_dumper.h
2024-09-18 14:02:40 +00:00
John Colvin 14031da8eb refactor: Move RFQ to lib_domain 2024-09-18 14:02:39 +00:00
John Colvin 6fee0d99d9 refactor: Move AggressorSide proto to lib_domain
Get rid of non-proto AggressorSide enum while we're at it (consolidate to 1 type)
2024-09-18 14:02:39 +00:00
John Colvin 5db7a20a41 cleanup: Remove more unused code 2024-09-18 14:02:39 +00:00
John Colvin 250f7d4b6d refactor: Move a few Order types to lib_domain 2024-09-18 14:02:39 +00:00
John Colvin dd02b83bc1 refactor: Move TimeInForce to lib_domain 2024-09-18 14:02:39 +00:00
John Colvin 26c3af44e0 cleanup: Remove unused code 2024-09-18 14:02:39 +00:00
John Colvin 90a59b764e refactor: Move TradeRecord into lib_domain 2024-09-18 14:02:39 +00:00
John Colvin df750c4dd0 refactor: Move TradingStatus enum to lib_domain 2024-09-18 14:02:39 +00:00
John Colvin c35d7c90f6 build: Update webpack-cli in admin webapp 2024-09-18 14:02:39 +00:00
John Colvin 1c2dc2c39c build: Configure admin webapp build entirely in CMakeLists
Get rid of build_admin_web_app.py
2024-09-18 14:02:39 +00:00
John Colvin 3faffbe22a refactor: Move domain types into new lib_domain
Also rename files in snake_case (standard naming convention for protos)
https://protobuf.dev/programming-guides/style/
2024-09-18 14:02:39 +00:00
John Colvin 7864c3238c refactor: Move collections into lib_system 2024-09-18 14:02:39 +00:00
John Colvin cf4a8599e7 refactor: Move a handful of types/utils to lib_system 2024-09-18 14:02:39 +00:00
John Colvin 7459a4f224 build: Add preset to build with 6 jobs (-j 6)
Otherwise the devcontainer may hog too much cpu and cause the container to freeze
2024-09-18 14:02:39 +00:00
John Colvin f1451b102d cleanup: Remove unused includes
Mostly collection macro headers
2024-09-18 14:02:39 +00:00
John Colvin 23b2758a05 cleanup (build): Move protobuf service generation cmake into lib_spark
Because lib_spark owns all the services
2024-09-18 14:02:39 +00:00
John Colvin 5c3a57ceb5 refactor: Rename protobuf out dir "include" -> "protobufs"
This is a more accurate and precise name. The dir contains c++ code generated
from .proto files - both sources (.cc) and headers (.pb.h).
2024-09-18 14:02:39 +00:00
John Colvin 888a6bc536 refactor: Move ValueWrapper into lib_system
So other projects can use it
2024-09-18 14:02:39 +00:00
John Colvin 0514d8f434 Include bts_assert.h in bts_fatal.h
We shouldn't have to include bts_assert.h when we're already including bts_fatal.h
2024-09-18 14:02:39 +00:00
John Colvin cf0adfd910 refactor: Split MarketDataGateway up into providers/sources
MarketDataGateway still exists, but is greatly simplified. It creates
several `IMarketDataProvider`s, each of which generates a list of
`IMarketDataSource`s. The market data sources provide market data to an
`IMarketDataListener`.

* EmumbaMarketDataProvider
* CCApiMarketDataProvider
* PyMarketDataProvider
* OnixsMarketDataProvider
* ReplayMarketDataProvider

As a side effect, individual py market data sources are now explicitly
limited to a single venue (it probably should have been this way all
along, since the shared memory writers do not expect updates to involve
multiple venues).
2024-09-18 14:02:39 +00:00
John Colvin bfc87bfdf0 fix build: Remove leftover cmake setup
From before recent build refactoring.
2024-09-18 14:02:39 +00:00
John Colvin d9c8c61e47 fix build: Remove old install target
Leftover from before recent build refactoring.
2024-09-18 14:02:39 +00:00
John Colvin 3398f44b33 fix: Include GNUInstallDirs in InstallBasicConfig
We reference variables defined therein (otherwise the burden of
inclusion falls to the caller).
2024-09-18 14:02:39 +00:00
John Colvin f4cef5aadb cleanup: Remove superfluous code 2024-09-18 14:02:39 +00:00
John Colvin e12769df8e improvement: Set SHARED_MEMORY_PREFIX to an environment variable
So we can effectively define it at runtime. We don't want to have to
produce different builds just to change the shared mem prefix.
2024-09-18 14:02:39 +00:00
John Colvin 6e5ddb734f fix: Always prepend proc name to shared mem prefix
Our shared memory model isn't really designed to be shared across processes.
Maybe some day it will.
2024-09-18 14:02:39 +00:00
John Colvin b4345cfa24 cleanup: Remove redundant macro def 2024-09-18 14:02:39 +00:00
John Colvin 54566ade60 Skip md recording thread loop if no recorders configured to run 2024-09-18 14:02:39 +00:00
John Colvin 06a80040ff Handle signal interrupts explicitly in sparkd
Otherwise the python interpretter, which is instantiated when we load
python md plugins, prevents the application from exiting.
2024-09-18 14:02:39 +00:00
John Colvin 2e9b4c78f3 feat: Add support for python md plugins 2024-09-18 14:02:39 +00:00
John Colvin 2b62668df8 fix build: Ensure py scripts use unix line endings
I'm not sure why, but my sparkd build (linux) suddenly began failing to
generate cpp headers for protos. The error message indicated it was due
to an unexpected carriage return (\r) in plugin.py:

/usr/bin/env: ‘python\r’: No such file or directory
2024-09-18 14:02:39 +00:00
John Colvin 17ca432f87 refactor: Add lib_system proj for common utils
Migrates the following:
* Delegate.h
* bts_array_size.h
* string_utils.h

Note: File names in the new lib are snake_case (this seems to be the
standard naming convention for c++).
2024-09-18 14:02:39 +00:00
John Colvin 2c8833bdfe vscode: Fix sparkd path in launch.json 2024-09-18 14:02:39 +00:00
John Colvin e0ab5713b6 build: Clean up libspark CMakeLists 2024-09-18 14:02:39 +00:00
John Colvin c31b52e1df cleanup: Trivial whitespace cleanup in sparkd CMakeLists 2024-09-18 14:02:39 +00:00
John Colvin 2e7478629f build: Add cmake fns to symlink and install local libs
The code needed to do this (inline) is ugly and verbose
2024-09-18 14:02:39 +00:00
John Colvin 3afc447538 cleanup: Use conventional UPPER_CASE var names in sparkd CMakeLists 2024-09-18 14:02:39 +00:00
John Colvin 56887327e1 cleanup: Trivial whitespace cleanup in Protobuf.cmake 2024-09-18 14:02:39 +00:00
John Colvin 6c89cd6717 build: Remove explicit targets from sparkd build preset
So it builds the default targets (all). They were only listed explicitly
in the first place so we could build specific targets in vs code using
the dropdown
2024-09-18 14:02:39 +00:00
John Colvin 5243490d5f build: Set up necessary paths, symlinks for sparkd in sparkd cmake proj
Rather than performing this step in the root CMakeLists, as we previously did
in the "server_layout" target. This effectively replaces the "server_layout" target.
2024-09-18 14:02:39 +00:00
John Colvin 0d04eea483 build: Clean up data_files cmake proj (support --target clean) 2024-09-18 14:02:39 +00:00
John Colvin 3abfac1a20 fix build: Generate proto hdrs in "include" dir (child of proj's bin dir)
Reorganizing the sparkd proj with stuttering dirs broke the build because
the generated protos were being dumped into a dir with the same name
as the "sparkd" executable.
2024-09-18 14:02:38 +00:00
John Colvin 574694e06e fix build: Update sparkd & risk webapp after moving libspark 2024-09-18 14:02:38 +00:00
John Colvin c30bba7d5c refactor: Parse input args in Protobuf_Generate_cpp
So we can be more precise when generating protobufs. For example, now we
can specify different include dirs when generating code for different
group of proto messages - an obvious improvement over the previous
system, which relied on a hardcoded superset of include dirs that would
support every proto message in our code base.
2024-09-18 14:02:38 +00:00
John Colvin 48695d3f7f refactor: Orgnaize libspark proj w/ stuttering include 2024-09-18 14:02:38 +00:00
John Colvin 3ef40387f3 build: Add install targets for libspark 2024-09-18 14:02:38 +00:00
John Colvin 776625891e vscode: Add debug cfg to skip sparkd build 2024-09-18 14:02:38 +00:00
John Colvin fcdd869831 fix build: Add ShmSegmentName.cpp to windows client sources 2024-09-18 14:02:38 +00:00
John Colvin 6a7efacac9 Make a few timestamp fns const
They should have been const in the first place
2024-09-18 14:02:38 +00:00
John Colvin 489b289a6d Add config profiles to libspark (check pt)
This is part of a larger effort to unify the libspark build, and eliminate
compile time differences between the builds used by our various services
2024-09-18 14:02:38 +00:00
John Colvin e75cc05137 Add api server to docker compose 2024-09-18 14:02:38 +00:00
John Colvin f75fe665c1 Rename pingtest "sparkd-ping-test", make it depend on sparkd
Add it to a "ping-test" profile, as we may add similar tests for other services
2024-09-18 14:02:38 +00:00
John Colvin 58bd35be01 cleanup: Remove unnecessary env vars from webapp docker compose 2024-09-18 14:02:38 +00:00
John Colvin 89143b25c7 Change api server ports so they don't conflict w/ ds webapp 2024-09-18 14:02:38 +00:00
John Colvin aec005505f vscode: Fix sparkd debug config 2024-09-18 14:02:38 +00:00
John Colvin 103725887f build: Resolve app data dir and shared mem prefix at runtime
We really can't define them at compile time anymore as we build multiple
exes that depend on libspark in the same dir (e.g., spark api server,
pubsub, ds-publisher, webapp, etc.). That means one libspark.so (or dll)
must serve all exes. We should compile a consistent libspark to mitigate
the risk of running an exe with the wrong version (of libspark). For
example, running pubsub with a libspark configured for spark api server,
leftover from an earlier build.
2024-09-18 14:02:38 +00:00
John Colvin 1ce7ddd252 Don't log "initializing spark config" if it has already been initialized 2024-09-18 14:02:37 +00:00
John Colvin 3e1000e8e7 vscode: Add debug cfg for spark api server 2024-09-18 14:02:37 +00:00
John Colvin 5561c54345 Use dependency injection in spark api server 2024-09-18 14:02:37 +00:00
John Colvin c7269176ca Add SparkLoggerAdapter for Msft ILogger 2024-09-18 14:02:37 +00:00
John Colvin ec34e8b2f2 Display exception stack trace w/ 1 call per line in ds webapp 2024-09-18 14:02:37 +00:00
John Colvin a54f9530b9 Remove unused ErrorView from ds webapp 2024-09-18 14:02:37 +00:00
John Colvin 53850044c0 Propagate ViewStream errors to webapp frontend 2024-09-18 14:02:37 +00:00
John Colvin 8e91091e3c Add ErrorChanged event to propagate DataStream exceptions 2024-09-18 14:02:37 +00:00
John Colvin 92ffade5da Set columns to empty array rather than null in ds webapp
If no data has been received. Since the 'columns' property was marked
'required', this eliminates a warning that was being logged to console.
2024-09-18 14:02:37 +00:00
John Colvin b636cf76f2 Improve alignment/spacing in ds webapp 2024-09-18 14:02:37 +00:00
John Colvin ac001b65c6 Configure datastream deployment with docker-compose
To deploy to aws, connect to our aws vpn then run:
tools/deploy-docker-compose.sh

The deploy script does the following:
* builds sparkd
* builds datastream apps (pubsub, md-publisher, and webapp)
* uploads the build to aws
* bounces all services (sparkd, pubsub, md-publisher, and webapp)

Note: the name 'md-publisher' refers to DataStreamPublisher w/ MarketData
configuration
2024-09-18 14:02:37 +00:00
John Colvin bc3869f087 Remove "BTS Cloud Streams" title from webapp
Space is precious when viewing on phone (tbh, it didn't look that good
anyways).
2024-09-18 14:02:37 +00:00
John Colvin 66583356ac fix: Ensure md-publisher waits for pubsub and sparkd
Bugs (fixed):
  * md-publisher silently fails if it tries to connect before those services are "ready".

The Docker compose "depends_on" property ensures sparkd and pubsub
containers are up, but doesn't prevent startup race bugs (e.g., if
md-publisher and pubsub start around the same time, and md-publisher
tries to connect before pubsub has started accepting connections). To
address these race conditions, we use a nifty tool called "dockerize"

References:
  * https://github.com/jwilder/dockerize
2024-09-18 14:02:37 +00:00
John Colvin ef11c6e418 Replace ErrorView component w/ robust QueryStatusView 2024-09-18 14:02:37 +00:00
John Colvin 361e4bdd48 Fix typos in query button theme 2024-09-18 14:02:37 +00:00
John Colvin 44ad5861fc fix: Don't assert on exception in BooleanExpression.evaluate
Bugs (fixed):
  * DataStream WebApp Server sometimes crashes when the user enters a
    bad query.
2024-09-18 14:02:37 +00:00
John Colvin 0ea6563ddb Change VITE_DATASTREAM_WEBSOCKET_URL to localhost 2024-09-18 14:02:37 +00:00
John Colvin ff7f8fce49 Assert that local ip address is successfully obtained 2024-09-18 14:02:37 +00:00
John Colvin cc28ba41d1 improvement: Resolve hostnames when comparing ip addrs
So we can to configure pubsub routes by hostname or ipv4 (ipv6 hasn't been
tested yet...so we should assume it doesn't work).
2024-09-18 14:02:37 +00:00
John Colvin 6fcec2c370 Assert TcpConnection endpoint matches expected 2024-09-18 14:02:37 +00:00
John Colvin 76393216c1 Fix typo in log msg (was missing interpolation '$') 2024-09-18 14:02:37 +00:00
John Colvin 3e792a41e0 Catch exceptions on AsyncTCPConnector_AsyncWrapper background thread
Since it spawns a new thread on each attempt, uncaught exceptions were previously undetected,
and caused silent failures down the pipe. This should make it easier to track such bugs down.
2024-09-18 14:02:37 +00:00
John Colvin 298273de91 fix: Format PubSubRoute as json in log msgs
It was previously using the default ToString, which simply returns the type name
2024-09-18 14:02:37 +00:00
John Colvin d256ec508b build: Upgrade packages (deps) in DataStreamTests 2024-09-18 14:02:37 +00:00
John Colvin 8293f1764e cleanup: Remove unused ViewStreamDatabase config 2024-09-18 14:02:37 +00:00
John Colvin 0a119b3f03 vscode: Add PubSubServer debug cfg to skip build 2024-09-18 14:02:37 +00:00
John Colvin e4940bba40 Configure apps as a distributed system via Docker compose 2024-09-18 14:02:37 +00:00
John Colvin 6b2a86f4f1 Remove reference to spark protobuf Config in ViewStream
We can't read spark protobuf Config until it has been initialized,
and since ViewStream doesn't have the configServer param handy it
isn't able to initialize config if necessary. In that case, it would simply
block until config was initialized by someone else. Such a risk doesn't
seem justified for this particular configuration dependency
(DataStreamConfig.UseUncopiedNewRowsInFire). For now, its hardcoded to false.
2024-09-18 14:02:37 +00:00
John Colvin 01b9d49df2 refactor: Run RemoteQueryManager as an IHostedService
This paradigm more accurately represents the RemoteQueryManager as a
Service that can be started/stopped.
2024-09-18 14:02:37 +00:00
John Colvin f3d7a9210d Remove inappropriate "Unable to dispose subscription" log msg 2024-09-18 14:02:37 +00:00
John Colvin 32e766f56c fix: Ensure spark config init and login are only performed once
As a static function that could be called from anywhere in the code
(directly or indirectly), 'Configuration.Initialize' was vulnerable to
race bugs. The "Configuration.get<T>()" method, whose calls are
ubiquitous in our code, would initialize config if it hadn't been done
so already. Without a reference to the configServer param, this param
would effectively be ignored/overridden with null.

It's important that login only be performed once, for obvious reasons
(our exes that connect to sparkd are generally designed to process data
for a single user). Furthermore, not every routine that requires a
successful login has a reference to the credentials needed to do it. To
address this, we now pass the ISparkdLoginService singleton to these
routines so they can wait until the singular login task has completed
before they begin.
2024-09-18 14:02:37 +00:00
John Colvin 58557311d4 Move misplaced log abt initializing query text to appropriate place 2024-09-18 14:02:37 +00:00
John Colvin 412a2576e0 Assert ViewStreamDatabase.instance is only created once
The instance must be initialized via ViewStreamDatabase.SetGlobalInstance
2024-09-18 14:02:37 +00:00
John Colvin 06de560169 cleanup: Remove unused code from ViewStreamDatabase 2024-09-18 14:02:37 +00:00
John Colvin 80b62a5a33 Include subscription id in ds websocket updates 2024-09-18 14:02:37 +00:00
John Colvin f05cff4ada fix: Define BoooleanConstant before StringConstant
Otherwise the former masks the latter and prevents it from matching
2024-09-18 14:02:37 +00:00
John Colvin b2d04363b6 Log event data in websocket open, close, error callbacks 2024-09-18 14:02:37 +00:00
John Colvin d9d2f70917 refactor: Bring back Material DataGrid
Fix the column resize bugs that made it previously unusable
2024-09-18 14:02:37 +00:00
John Colvin 3d07e8cf3d refactor: Improve react webapp state management
* Add queryTextResetTime as part of the CannedQuery state
  (the QueryControl compares the canned query click time with the time of the
  last user input, and applies the text from the most recent change)

* Replace 'isRunning' (bool) with a 'queryState' (string) to reflect the subscription status
  value received from the server. Less indirection this way.

* Replace inappropriate useMemo call w/ useEffect
2024-09-18 14:02:37 +00:00
John Colvin 68f75a6f44 cleanup: Get rid of magic const (subscriptionId) in webapp App.jsx 2024-09-18 14:02:37 +00:00
John Colvin ad0b6968ad build: Copy configuration profiles to publish dir 2024-09-18 14:02:37 +00:00
John Colvin fdaff5dcf5 cleanup: Remove unnecessary deps from csprojs 2024-09-18 14:02:37 +00:00
John Colvin ffa92ea4ae build: Change publish_data_stream.py to publish the sln
We were publishing individual projects as a workaround for the
dependency issue (bug) that caused some projects to incorrectly target
net8.0. The fact that publishing individual projects "just worked" was
probably dumb luck. Now that the underlying issue has been addressed, we
can resume publishing the sln as a whole.
2024-09-18 14:02:37 +00:00
John Colvin dd305b9c3f dev: Install docker in devcontainer
So we can start various services like sparkd, pubsub, ds publishers, ds
webapp, etc. from inside the devcontainer.
2024-09-18 14:02:37 +00:00
John Colvin 07b581e980 dev: Remove dotnet8 from devcontainer
We'll upgrade to dotnet8 eventually, but now isn't the time (too much
more important work to be done).
2024-09-18 14:02:37 +00:00
John Colvin 79fadf3dba dev: Run devcontainer on host network
So we don't need to worry about publishing the right ports (and don't
need to rebuild the container everytime the list of ports changes).
2024-09-18 14:02:37 +00:00
John Colvin c05d90fd26 fix: Downgrade Microsoft.Extensions.Hosting to 7.0.1
A handful of csprojs were referencing version 8.0.0. Since that version
targets net8.0, I have no idea why it didn't cause the build to fail.
Instead, this framework mismatch led to a mysterious runtime crash with
the following error, despite the dll in question being present in the
build dir:

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
The system cannot find the file specified.

It is worth noting that this crash would only happen for exes published
as part of the DataStreamSuite.sln with the "--self-contained" flag. For
example, the Bts.DataStreamSuite.Server exe would always fail if
published via:

dotnet publish --configuration Release --sc --framework net7.0 --runtime linux-x64 <DataStreamSuite.sln>
2024-09-18 14:02:37 +00:00
John Colvin 51f60188f5 Add HttpsRedirection middleware first in the webapp pipeline
Middleware handlers are invoked in the order in which they are added. Any middleware
that is added before HttpsRedirection may can prevent the request from being redirected.
As of now, only development-specific middleware is added ahead of HttpsRedircetion.
2024-09-18 14:02:37 +00:00
John Colvin cf93176991 build: Copy configuration profiles to build dir
So they are readily available to publish/deploy scripts.
2024-09-18 14:02:37 +00:00
John Colvin 6aa9307a3c Fix benign typo in Scanner/Parser msbuild targets
The output path referenced a non-existant msbuild metadata prop "RelativeOutputDir"
(the actual prop is called "RelativeDir"). Also, the OutputFile path is relative to the
project dir (the 'MSBuildProjectDir' prop), not the file being included.
2024-09-18 14:02:37 +00:00
John Colvin 3eb3cfbf9f fix: Catch exception when creating TcpClient 2024-09-18 14:02:37 +00:00
John Colvin 501671c9c5 fix: Catch WebSocketException in DataStreamSubscription 2024-09-18 14:02:37 +00:00
John Colvin 9d62fcde3d fix: Add null check to NonIncGroupByStream 2024-09-18 14:02:37 +00:00
John Colvin 50b4c8807e fix: Add null check to TableAccumulator2 2024-09-18 14:02:36 +00:00
John Colvin c6f6dc8bf4 fix: Add self-signed certificate to Dockerfile for ds webapp 2024-09-18 14:02:36 +00:00
John Colvin fb528d4683 fix: Make SystemSubscriptionMapPublisher threadsafe
The PubSubState.onTagMapChanged event may not be invoked on
the same thread as doWork.
2024-09-18 14:02:36 +00:00
John Colvin f1b2206577 fix: Add null check in TimeBasedFilter.cs 2024-09-18 14:02:36 +00:00
John Colvin 68d1865f36 Reduce task wait/timeout code in AsyncTCPConnector 2024-09-18 14:02:36 +00:00
John Colvin 3c8431837b Add a few canned queries to AwsProd.json for ds webapp 2024-09-18 14:02:36 +00:00
John Colvin e0d413b884 fix: Copy canned queries to clipboard on click
Instead of trying to update the text directly, which causes the front end
to overwrite the user's changes everytime the data updates from then on.
2024-09-18 14:02:36 +00:00
John Colvin ff8ebaa326 fix: Convert invalid doubles to nan in ds webapp serializer 2024-09-18 14:02:36 +00:00
John Colvin 370b84b6dd Increase datagrid maxheight in ds webapp to 1000px 2024-09-18 14:02:36 +00:00
John Colvin 715246c9c7 Improve error display in ds webapp 2024-09-18 14:02:36 +00:00
John Colvin a1f195721a fix: Dispose existing sub on subscribe req in ds webapp
Even if new sub has parse error. This fixes a bug where the previous
subscription would continue firing and updating the frontend, when it
should just display the error info to the user and cease updates.
2024-09-18 14:02:36 +00:00
John Colvin d7de423e35 fix: Get rid of "UseSpa" calls in webapp Production environment
This was leftover from a misguided attempt to fix a bug that turned out
to be due to an omitted environment var:
ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=Microsoft.AspNetCore.SpaProxy
2024-09-18 14:02:36 +00:00
John Colvin 244b3de513 Define webapp specific env vars in generic datastream app deploy script
For now, this makes things easier, as I don't need to write a special script just for the webapp
2024-09-18 14:02:36 +00:00
John Colvin 0683abbda6 Add config profile and Dockerfile args to deploy script 2024-09-18 14:02:36 +00:00
John Colvin 9d2886fe67 Copy DataStream WebApp 'dist' to 'wwwroot' in deploy script 2024-09-18 14:02:36 +00:00
John Colvin 2ac815949c Tweak DataGrid style in DataStream WebApp 2024-09-18 14:02:36 +00:00
John Colvin 046f451e76 Add AwsProd config for DataStream WebApp 2024-09-18 14:02:36 +00:00
John Colvin 36f191d49a fix: Add VITE_ prefix to imported env vars
For the DataStream WebApp client
2024-09-18 14:02:36 +00:00
John Colvin f55237029f Fix urls for DataStreamPublisher AwsProd.json 2024-09-18 14:02:36 +00:00
John Colvin 6fcf096924 Add benzinga news streams to AwsProd.json
This is a config profile for DataStreamPublisher, designed to be deployed
to aws (on public internet).
2024-09-18 14:02:36 +00:00
John Colvin 547383c8d9 fix build warnings: Make props nullable strings in SharedStreamConfig 2024-09-18 14:02:36 +00:00
Taha dc74b62304 Added benzinga streamd to MDPub's test config 2024-09-18 14:02:36 +00:00
Taha Afzal 8907681bb2 PubSubSingleTagState is not needed any more 2024-09-18 14:02:36 +00:00
Taha f16b921630 Icomplete SharedStreamsConfig was breaking build, fixing 2024-09-18 14:02:36 +00:00
Taha 614e9c69e1 Added new benzinga streams 2024-09-18 14:02:36 +00:00
John Colvin 5a59303dd4 whitespace: Format PubSubServer.json (indentation issues) 2024-09-18 14:02:36 +00:00
John Colvin d427538cd9 fix import from environment variable 2024-09-18 14:02:36 +00:00
John Colvin 46888af8fb Add a few tasks to run DataStream WebApp 2024-09-18 14:02:36 +00:00
John Colvin efaef11e7c fix add scripts to deploy data stream apps 2024-09-18 14:02:36 +00:00
John Colvin c095614c67 fix: Import websocket url from environment var 2024-09-18 14:02:36 +00:00
John Colvin f41114ee13 Add scripts to deploy data stream apps 2024-09-18 14:02:36 +00:00
John Colvin 39c33f082f Add SpaServer to Production environment
For Bts.DataStreamWebApp.Server
2024-09-18 14:02:36 +00:00
John Colvin a3c0bc977e Change DirectoryBrowser requestPath to "/browse"
So we can view a psuedo file explorer for the webapp by requesting the "/browse" path
(only activated in Development environment).
2024-09-18 14:02:36 +00:00
John Colvin 3a39b3c516 Publish Bts.DataStreamWebApp.Server along with PubSub & DataStream 2024-09-18 14:02:36 +00:00
John Colvin 9265746198 cleanup: Remove unused code in Bts.DataStreamWebApp.Client 2024-09-18 14:02:36 +00:00
John Colvin 0236e3a47a Capture OperationCanceledException (instead of TaskCanceledException)
The former is the base class for the latter, so this will widen the umbrella to catch a few corner cases
that would otherwise been handled by the generic "Exception" catch block. One corner case I know
of is when an op is canceled via "CancellationToken.ThrowIfCancellationRequested". In that case,
an OperationCanceledException is thrown (not a TaskCanceledException).

https://stackoverflow.com/questions/34359129/operationcanceledexception-vs-taskcanceledexception-when-task-is-canceled
2024-09-18 14:02:36 +00:00
John Colvin 71d52c2dc9 Hardcode webSocketUrl to aws server in DataStreamWebApp client 2024-09-18 14:02:36 +00:00
John Colvin ce0b4872ff Assert that System publishers 'doWork' is always called on same thread 2024-09-18 14:02:36 +00:00
John Colvin b686159cf3 fix: Make InternalPublisherQueue thread safe 2024-09-18 14:02:36 +00:00
John Colvin ee7c8c393e Improve error reporting in DataStreamWebSocketServer 2024-09-18 14:02:36 +00:00
John Colvin 7c4191289f data stream web app client check pt 2024-09-18 14:02:36 +00:00
John Colvin f18949a1e3 fix build: Fix Spark build after making config init async 2024-09-18 14:02:36 +00:00
John Colvin f3b9cb2d62 fix Change Configuration.initialize to be async 2024-09-18 14:02:36 +00:00
John Colvin faeb10cf9d refactor: Tweak SparkCoreServices to synchronize Configuration.init globally 2024-09-18 14:02:36 +00:00
John Colvin e5f1039671 refactor: Change Configuration.initialize to be async 2024-09-18 14:02:36 +00:00
John Colvin 39de6bdb2d vscode: Add 'isSparkApiEnabled' input to launch.json 2024-09-18 14:02:36 +00:00
John Colvin e93f970706 SparkApiService check pt 2024-09-18 14:02:36 +00:00
John Colvin 844677dae0 pubsub server checkpt 2024-09-18 14:02:36 +00:00
John Colvin 3541feef87 pubsub checkpt 2024-09-18 14:02:36 +00:00
John Colvin 776a589945 datastreamwebapp server checkpt 2024-09-18 14:02:36 +00:00
John Colvin 396f72d7c1 datastream webapp client check pt 2024-09-18 14:02:35 +00:00
John Colvin 62a9917a48 fix add pubsub services 2024-09-18 14:02:35 +00:00
John Colvin a3dd7c3815 Remove unused PubSubConfig members from MarketDataPublisher cfg json 2024-09-18 14:02:35 +00:00
John Colvin e669cf6b77 Remove unused PubSubConfig members from PubSubServer cfg json 2024-09-18 14:02:35 +00:00
John Colvin c5e3c4aa18 fix Remove unused PubSubConfig members 2024-09-18 14:02:35 +00:00
John Colvin be35ed120b Remove unused PubSubConfig members from DSQA config json 2024-09-18 14:02:35 +00:00
John Colvin 9846bf3936 Remove unused PubSubConfig members from WebApp config json 2024-09-18 14:02:35 +00:00
John Colvin cb5fcee2ce Remove unused PubSubConfig props 2024-09-18 14:02:35 +00:00
John Colvin 08319cfd38 Fix dsqa config json 2024-09-18 14:02:35 +00:00
John Colvin 777c276437 fix: Always call 'handle_internal_pubs' in PubSubMessageReactor main loop 2024-09-18 14:02:35 +00:00
John Colvin 5ab0e1f886 improvement: Accept CancellationToken, catch exceptions when running ds websocket server 2024-09-18 14:02:35 +00:00
John Colvin a90896f606 Fix mismatched types in PubSubServerTagStatsStream schema 2024-09-18 14:02:35 +00:00
John Colvin 3f6f5ab0e0 Add DataStreamPublisher service modules designed for Dependency Injection
* Change DataStreamPublisher json fields to match cs class property names verbatim
* Rename Publishers -> PublisherNodes in DataStreamPublisherConfig
2024-09-18 14:02:35 +00:00
John Colvin 24e5683ad2 refactor: Decouple ViewPublisher from IPubTableBroker impl 2024-09-18 14:02:35 +00:00
John Colvin 34999d0a5a Add PubSub service modules designed for Dependency Injection
* Get rid of JsonPropertyName attributes in PubSubConfig
  - The Dependency Injection framework (based around dotnet ApplicationBuilder)
    does not support this attribute, and maps property names verbatim to json fields.

* Change PubSubServer json fields to match cs class property names verbatim
2024-09-18 14:02:35 +00:00
John Colvin ace7ae2695 refactor: Decouple RemoteQueryManager from IManagedSubscriber, IPubTableBroker impl 2024-09-18 14:02:35 +00:00
John Colvin f9016907e6 refactor: Decouple ManagedSubscriber from ISubscriberCore impl 2024-09-18 14:02:35 +00:00
John Colvin 0913fe28d4 refactor: Only support 1 tag type in IPubSubServerTagHandler 2024-09-18 14:02:35 +00:00
John Colvin 400b4ff848 refactor: Decouple PubTableBroker from IPublisherCore impl
Reference interface rather than the PublisherCore impl.
2024-09-18 14:02:35 +00:00
John Colvin 5a36a5f4d4 improvement: Accept CancellationToken in JsonRpcRequestObservable 2024-09-18 14:02:35 +00:00
John Colvin 0f6539ed00 fix: Dispose market data sub in various md streams 2024-09-18 14:02:35 +00:00
John Colvin 475bf1effc cleanup: Remove unused pubsub tag handler code
* Removed 'IPubSubServerTagHandler.register'
  - All implementations of this function were empty
* Removed 'IPubSubServerTagHandler.supportedTagTypes'
  - This property wasn't referenced anywhere
* Remove IWorker inheritance from IPubSubServerTagHandler
  - No reason these interfaces have to be tied together
2024-09-18 14:02:35 +00:00
John Colvin ec1e657687 refactor: Rename CloudStreamManager.cs -> RemoteQueryManager.cs
This matches the file name
2024-09-18 14:02:35 +00:00
John Colvin 284c84dfe6 Change pub sub schema prefix 'bluto://' -> 'bts-cloud://'
In config json files (not actual code change)
2024-09-18 14:02:35 +00:00
John Colvin b78c61bf44 fix build: Fix prop names after refactoring PubSubRoute
* Change 'server_address' -> 'ServerAddress'
* Change 'tag_reg_exp' -> 'TagRegExp'
2024-09-18 14:02:35 +00:00
John Colvin 09a41775bb build: Add scripts to publish data stream apps 2024-09-18 14:02:35 +00:00
John Colvin b9ef3ddf91 Fix typo in log msg 2024-09-18 14:02:35 +00:00
John Colvin e516496fe8 Fix build scripts so they propagate the exit code back to the shell
I noticed this was broken because launch.json configurations would still start the debugger
even when the preLaunchTask (build) failed!
2024-09-18 14:02:35 +00:00
John Colvin a55705db75 vscode: Add DataStreamPublisher debug cfg to skip build 2024-09-18 14:02:35 +00:00
John Colvin e39ad91e1c build: Use separate cmd to build DataStreamSuite/QueryAnalyzer.sln
The DataStreamSuite.sln builds the new webapp now, which will
(eventually) replace DSQA. We'll keep it around for now, but with a
clean separation from the main build.
2024-09-18 14:02:35 +00:00
John Colvin 658472b2a8 feat: Add DataStream WebApp
Included in DataStreamSuite.sln, but not DataStreamQueryAnalyzer.sln
2024-09-18 14:02:35 +00:00
John Colvin 1ad94cfe49 Add spark service modules designed for Dependency Injection 2024-09-18 14:02:35 +00:00
John Colvin 22a5a9a4c1 build: Copy libspark to all dotnet dirs in single cmake target
This is cleaner than the previous impl, which used separate build
targets to copy libspark to "net7.0", and "net7.0-windows" (dirs).
2024-09-18 14:02:35 +00:00
John Colvin e5bbc26da5 fix: Parse ServerAddress as normal string
The "JsonValueOrArrayConverter<T>" doesn't work the way I thought it
would. When it is associated with a property via the JsonConverter
attribute, dotnet json parsing code throws an exception if "T" isn't
assignable to the property type.
2024-09-18 14:02:35 +00:00
John Colvin 6a628a3070 fix build (api server): Change namespace to bts.websocket_core 2024-09-18 14:02:35 +00:00
John Colvin ac120658eb Remove docker submodules again 2024-09-18 14:02:35 +00:00
John Colvin 85a36384ce Change externals url from ssh to https style
So we don't need ssh keys to clone it (the builtin credential manager
makes https authentication safe/easy)
2024-09-18 14:02:35 +00:00
John Colvin 563833bc67 cleanup: Fix benign typos in build scripts
Change BUILD_SPARK_PY var name to BUILD_PY (because these scripts to actually build 'spark')
2024-09-18 14:02:35 +00:00
John Colvin d77ac1600b fix build (warn): Only use Registry on windows 2024-09-18 14:02:35 +00:00
John Colvin 3b41a2065a cleanup: Fix numerous build warnings in DataStreamSuite
Nearly all warnings were due to nullability issues, since the concept of
nullable reference types did not exist when the DataStream code was
originally written.

* PubSubClientMessage
  - Normalize indentation/whitespace
  - Fix some typos
  - Address nullability issues to fix build warnings
  - Modernize code

* Compression related files
  - ZipEntry
  - ZipFile
  - ZipInputStream
  - TarHeader

* RemoteMessage
  - make 'message' nullable to resolve warnings elsewhere (in calling code)

* PubSubSingleTagStateEvent.cs
* PubSubMessageReactor
* PubSubState
* SystemHeartbeatPublisher
* SystemStatsPublisher
* SingleTagData
* ManagedTCPMessageHub
* PubsubDeserializationController
* PublisherCore
* InflaterHuffmanTree
* AsyncTCPConnection_APM
* ThreadSafeQueue
* ManagedSubscriber
* SubscriberCore
* PubSubServerManagedTCPConnection
* AsyncTCPConnection_APM
* SuperMapStream
* MapStream
* TradeBarsStream
2024-09-18 14:02:35 +00:00
John Colvin f993f01634 cleanup: Normalize indentation in TradeBarsStream 2024-09-18 14:02:35 +00:00
John Colvin e7067a708b cleanup: Disable nullability warnings
* BZip2InputStream
* TarInputStream
* Inflater
* InflaterDynHeader
* BZip2OutputStream
* DeflaterHuffman
* ParallelJoinTest
2024-09-18 14:02:35 +00:00
John Colvin 04ac2b9d3d cleanup: Modernize PubSubRoute code, json parsing 2024-09-18 14:02:35 +00:00
John Colvin 66c6b0bf8c cleanup: Remove unused DateTime grammar from exp parser 2024-09-18 14:02:34 +00:00
John Colvin 03dd4000fe Add JsonRpcRequestObservable, AsyncEnumerable 2024-09-18 14:02:34 +00:00
John Colvin e928295e71 Add json facilities for DataStream websocket api 2024-09-18 14:02:34 +00:00
John Colvin b94c5823e9 refactor: Add handy WebsocketExtensions
* IsSocketStateOpen
* IsClosedProperly
2024-09-18 14:02:34 +00:00
John Colvin 467e81b543 feat: Add JsonRpc types for websocket paradigm 2024-09-18 14:02:34 +00:00
John Colvin 8f7409b3e7 cleanup: Remove empty file (clearly added by accident) 2024-09-18 14:02:34 +00:00
John Colvin 0d19702e12 fix: Fix improper 'OfType' linq cast
Previously, animations were expressed through polymorphism (derived from the
base class CellAnimation), but the new impl uses composition. This 'OfType' call
was leftover from the polymorphism implementation, an attempt to linq cast
elements of base class (CellAnimation) to BackgroundAnimation.
2024-09-18 14:02:34 +00:00
John Colvin 466fa265fe editorconfig: Use standard c# capitalization rules
* Use 'PascalCase' for public members (instead of 'snake_case')
* Use 'camelCase' for private members (instead of '_snake_case')
2024-09-18 14:02:34 +00:00
John Colvin ebd1852221 refactor: Add WebsocketClient class
Basically an ISubject (I/O) wrapper for IWebsocketConnectionGateway
2024-09-18 14:02:34 +00:00
John Colvin f1130160b1 refactor: Change WebsocketServerConfig.port to uint32
It should always be a number between 1-65535
2024-09-18 14:02:34 +00:00
John Colvin 99fba0b3ce refactor: Rename WebsocketServerConfig proto pkg 'bts.websocket_core'
This matches the namespace used in spark_websocket csproj. Eventually,
I'd like to use conventional capitalization (TitleCase namespaces/types,
etc.), but let's shelf that until we have enough time/energy to do a
more comprehensive refactoring.
2024-09-18 14:02:34 +00:00
John Colvin 89afbbd00a refactor: Remove nullability constraint in GetValueOrDefault 2024-09-18 14:02:34 +00:00
John Colvin 9e4af550f8 refactor: Use events to avoid circular deps for ws sync/gateway 2024-09-18 14:02:34 +00:00
John Colvin ea67280252 refactor: Let caller specify nullability of T in json parse fn 2024-09-18 14:02:34 +00:00
Taha Afzal 8c06d84a8b Fixing problems where PSS's client socket's IP was different than what the client was sending in PubSubClientSubscription 2024-09-18 14:02:34 +00:00
Taha Afzal 941186a12a Fixing PubsubEchoTestStream 2024-09-18 14:02:34 +00:00
Taha Afzal 0984007c6e Added pss_echo() 2024-09-18 14:02:34 +00:00
Taha Afzal 2bb7a89777 Merging 2024-09-18 14:02:34 +00:00
Taha Afzal 15fc3cb785 src/DataStreamSuite/PubSub/ManagedTCP/AsyncTCPConnection_AsyncWrapper.cs 2024-09-18 14:02:34 +00:00
Taha 725396589e Adding TableMetaDataStream 2024-09-18 14:02:34 +00:00
Taha Afzal 6fc1ec4d67 Cleaning Config 1.0 (not completely done) 2024-09-18 14:02:34 +00:00
Taha 0496b299dd Added pubsub routes to the Title of DSQA 2024-09-18 14:02:34 +00:00
Taha b55c4103df Fixing the bug where messages were being sent by the pubsubserver out of order 2024-09-18 14:02:34 +00:00
Taha 6604eaaea7 some buf gixes + cleanup 2024-09-18 14:02:34 +00:00
Taha 29e5c72969 PubSuMessageReactor empties the message queue (instead oif one elem ata a time) in the main loop 2024-09-18 14:02:34 +00:00
Taha 21e07e1b2e PubSubServer's linux issues fixed 2024-09-18 14:02:34 +00:00
John Colvin 74afdde8de fix build: Add ".list" to SymbolLists config
For new exchanges, TAIFEX and CBOE
2024-09-17 13:01:05 +00:00
John Colvin 0a92ad2eb1 fix (build): Add break statement to new venue switch cases
Namely, TAIFEX and CBOE
2024-09-17 13:00:14 +00:00
John Colvin 56d207c3f1 fix: Preserve vs exp sec type (Option) when computing implied vol
Because the exp keys in the data map have sec type Option.
2024-09-16 13:46:53 -04:00
John Colvin 9172e752e3 ui: Highlight launcher buttons when selected
Namely, the expandable menu buttons in Analytics shell module
2024-09-16 13:46:53 -04:00
John Colvin adc9f2acfc Replace trivial refs to ThreadedBlackboard w/ IBus 2024-09-15 23:45:15 -04:00
John Colvin 41d17e67d2 fix: Move accounts subscription to dispatcher thread
We update a collection that is bound to the view in the callback (mutation
ops throw if performed on a different thread).
2024-09-15 23:45:15 -04:00
John Colvin 5cacff073b fix: Check 'HasTimestamp' before accessing prop in man fill row
Pending adds (i.e., unpersisted new rows) don't have timestamps.
In such cases, the 'Timestamp' getter throws an exception.
2024-09-15 23:45:15 -04:00
John Colvin c8da92c250 Cache/index options for faster lookups in SystemContractData 2024-09-15 23:45:15 -04:00
John Colvin c4e76076e3 fix: Include venue w/ symbol when publishing interp greeks 2024-09-15 23:45:14 -04:00
John Colvin 6a715b9a68 Fix typo in comment 2024-09-15 23:45:11 -04:00
John Colvin 1f28940c95 fix: SelectorList.RemoveAt doesn't need 'convert_back' delegate
So don't throw an exception if it is null.
2024-09-15 23:45:11 -04:00
John Colvin ebff40b88f fix: Don't assume venue is in spread def string
Pass it as an argument to the parse fn. This should be fine for now, but
obviously a singular venue param won't work for cross exchange spreads.
2024-09-15 23:45:11 -04:00
John Colvin a6d14a3ac3 improvement: Move system contracts sub off of dispatcher thread
Also add 200ms throttle. Contracts shouldn't change that often, so we don't need
lightening speed here. Furthermore, such changes may trigger expensive cpu ops.

Note: this change also replaces refs to ThreadedBlackboard w/ IBus (the
former is somewhat tethered to the dispatcher thread, particularly by
its timer_callback).
2024-09-15 23:45:11 -04:00
John Colvin af96bcb9e3 fix: Pass symbol/venue from vs usage cfg to AnalyticsService proto 2024-09-15 23:28:59 -04:00
John Colvin 619702cb04 cleanup: Remove unused code 2024-09-15 23:28:59 -04:00
John Colvin 5baec19aff refactor: Index vol and theos data by symbol/venue tuple
Rather than just symbol, to avoid conflicts when the same symbol exists
at multiple exchanges
2024-09-13 10:50:23 -04:00
John Colvin 39ef30c1e3 cleanup: Remove redundant type VolSurfaceSymbolStructure
There is an identical type (in terms of prop types and corresponding proto indices)
called VolSurfaceSymbolRelationship that is used in more places.
2024-09-13 10:50:23 -04:00
John Colvin c2f2d28914 Move nested vm classes into own files
VolSurfaceSettingsEditor has too much code (still). It is hard to
navigate.
2024-09-13 10:50:23 -04:00
John Colvin e06bc3bdf5 Simplify driver symbol structure in vs settings vm
The code was confusing and difficult to follow.
2024-09-13 10:50:23 -04:00
John Colvin e19c19c013 fix: Raise prop changed event when is_selected changes 2024-09-13 10:50:23 -04:00
John Colvin 8f324bc507 Add venue to vs calc fns 2024-09-13 10:50:23 -04:00
John Colvin 12107c42ce fix: Provide venue param w/ symbol when computing fut slide 2024-09-13 10:50:23 -04:00
John Colvin 91c6fb4e52 diag: Log added/removed exps when syncing vs input w/ system exps
This shouldn't happen often, but if it does, we should know about it.

PS: We recently fixed a bug caused by inequalities between
VolSurfaceExpirations in vs input, and in SystemContractData. User
inputs to the vs grid would be immediately reverted, as the exps
associated with the inputs were not found in the SystemContractData.
This bug would have been easier to track down with this logging in
place.
2024-09-13 10:50:23 -04:00
John Colvin 7044355547 Add venue to VolSurface(DisplayGrid)Expiration
So we can handle symbol/exp date conflicts for securities that differ
only by venue (exchange)
2024-09-13 10:50:23 -04:00
John Colvin 583ae65fb2 Clean up VolSurfaceExpiration
* Enable nullable lang feat
* Use file-scoped namespace
* Sort members
* Include sec type in Compare impl
2024-09-13 10:50:22 -04:00
John Colvin 552fec0edc Add null check in SelectorList ctr 2024-09-13 10:50:22 -04:00
John Colvin fcf6927fbf cleanup: Remove unused code 2024-09-13 10:50:22 -04:00
John Colvin 23f6d827d5 refactor: Replace ThreadedBlackboard w/ IBus
In SingleVolSurfaceCommittedOutputRetriever
2024-09-13 10:50:22 -04:00
John Colvin f083d0abab Clean up VolSurfaceTimeParameters
* Enable nullable lang feat
* Use file-scoped namespace
* Implement ICloneable
2024-09-13 10:50:22 -04:00
John Colvin a895e36922 cleanup: Remove unnecessary ternary op 2024-09-13 10:50:22 -04:00
John Colvin 59d7a72288 fix: Actually use (sec) type arg in to_security_expiration 2024-09-13 10:50:22 -04:00
John Colvin 7731f2f4d1 fix: Check security_type in vs exp Equals impl 2024-09-13 10:50:22 -04:00
John Colvin 41ae5897c0 fix: Maintain sec type when converting SecurityExpiration to vs exp
Avoids data loss
2024-09-13 10:50:22 -04:00
John Colvin c7949ccfba refactor: Get rid of sec type 'Option' default (magic const)
Better to be explict
2024-09-13 10:50:22 -04:00
John Colvin 567af79c7f Fix selection binding issues in vs settings editor
This specifically addresses issues in the driver symbol grids.
Unfortunately, we can't bind directly to ComboCheckBox.SelectedItems
because the view is contained in TabControl. When the selected tab
changes, the previously selected tab clears its ItemsSource (and
consequently the SelectedItems) as a side effect of being unloaded.
2024-09-13 10:50:22 -04:00
John Colvin 6bb4a7b25c refactor: Enable nullable (ref types) in ImmutableListExtensions 2024-09-13 10:50:22 -04:00
John Colvin bc7cef4c34 Fix typo in namespace bts.collection -> bts.collections 2024-09-13 10:50:22 -04:00
John Colvin ab9dc361d6 fix: Use ComboCheckBoxItem.IsSelectedProperty
Instead of Selector.IsSelectedProperty. Unlike ComboBoxItem, ComboCheckItem's
IsSelectedProperty isn't linked to Selector.IsSelectedProperty.
2024-09-13 10:50:21 -04:00
John Colvin 39da0a4dde Add currency column to mview 2024-09-13 10:50:21 -04:00
John Colvin 44e864d697 fix: Use SetCurrentValue instead of SetValue
So we propagate values to/from the binding data source,
rather than overwrite the data source itself.
2024-09-13 10:50:21 -04:00
John Colvin 0a02da3aba Add venue, sec type dropdown filters to exp params ui 2024-09-13 10:50:21 -04:00
John Colvin 836771a7f0 fix: Add null check in ComboCheckBox.SelectedItemsCollectionChanged 2024-09-13 10:50:21 -04:00
John Colvin f386badcfb fix: Disconnect old INotifyCollectionChanged source when dp changes 2024-09-13 10:50:21 -04:00
John Colvin 1d43a484db fix: Index opt/fut exps by venue in vs analytics 2024-09-13 10:50:21 -04:00
John Colvin 91042cb41e fix: Support multiple exchanges in exp params view/vm 2024-09-13 10:50:21 -04:00
John Colvin 10c0e4247d cleanup: Remove unused 'option_symbol' param from compute_atm_data 2024-09-13 10:50:21 -04:00
John Colvin 8e34264e6d fix: Filter by exch when getting atm data for sheets
This is necessary now that we support exchanges with overlapping securities
2024-09-13 10:50:21 -04:00
John Colvin 0a840d256b fix: Remove sec id prop from SecurityExpiration
This class isn't designed to represent a particular contract; it's
basically a key to get option theos.
2024-09-13 10:50:21 -04:00
John Colvin 8a69c51cac refactor: Add 'onDispatcher' param to 'ThreadedBlackboard.subscribe'
This will allow us to gradually move subscriptions off of the dispatcher
(render) thread. When the render thread is pegged, the ui is laggy and
unresponsive. The new param defaults to true, so it won't change
anything until we explicitly set it to false in 'subscribe' calls.
2024-09-13 10:50:21 -04:00
John Colvin 0262fd40bc fix: Remove redundant SparkTimer threads
This addresses some slowness on the front end. Prior to this commit,
each ThreadedBlackboard would start its own timer thread. Since multiple
ThreadedBlackboard run concurrently, this multiplied the frequency of
the SparkTimer callbacks by the number of active ThreadedBlackboards.

The fix is to start this thread in an IShellDaemon rather than the
ThreadedBlackboard. This avoids duplicate threads because the former is
guarenteed to be instantiated only once, via dependency injection.
2024-09-13 10:50:21 -04:00
John Colvin 859dfe3544 refactor: Simplify FakeMDDaemon code that delays post
Use Task.Delay/ContinueWith instead of subscribing to the SparkTimer tag.
2024-09-13 10:50:21 -04:00
John Colvin 9c624a2f79 refactor: Use IBus instead of ThreadedBlackboard
This should address some slowness/mouse lag in the front end (recently
reported by Brandon at Immutable Cap)
2024-09-13 10:50:20 -04:00
John Colvin dec1061b40 fix: Detect and log ccapi depth msg parse errors
This fixes a crash that would happen if a depth item's price or quantity
were an empty string (now we log an error and keep going).
2024-09-13 10:50:20 -04:00
John Colvin be4895faa6 fix: Actually store currency in shared mem
This field has always been in the Security proto, though it until now it
had been omitted from the shared memory representation (FixedSecurity).
2024-09-13 10:50:20 -04:00
Mohammad Arham 3c9755f0dd ADD: Added delay to databento file reader 2024-09-12 15:10:34 +00:00
Mohammad Arham 61ed847d7d Add: Replay speed added to mdreplayer 2024-09-11 06:50:37 +00:00
Mohammad Arham fc9094fea8 Added: CBOE working on databento 2024-09-11 06:17:26 +00:00
Mohammad Arham e36c0efc4b Added: GLBX working on databento 2024-09-11 06:16:42 +00:00
Mohammad Arham 4158a14cff Added: option to send timestamp in onbook IMDListener 2024-09-11 06:15:40 +00:00
Mohammad Arham 201a45cba0 taifex deo 2024-09-05 00:59:00 +00:00
Mohammad Arham ab31b9b253 Add: Multiple files working taifex 2024-09-03 15:15:55 +00:00
Adeel Khan 780ddc79a7 Add: Taifex I083 Message 2024-09-03 20:06:48 +05:00
Mohammad Arham d5a2adaed6 fix: removed errernous code 2024-09-03 13:09:54 +00:00
Mohammad Arham 008ab3f068 Merge branch 'development.new_exchanges' of bitbucket.org:bluetradesys/spark into development.new_exchanges 2024-09-02 16:31:14 -04:00
Mohammad Arham 7d926f588d FIX: typo, changed date to day 2024-09-02 16:31:10 -04:00
Mohammad Arham 707cd07876 Add: CBOE L1 books and contracts working 2024-08-28 16:22:51 +00:00
Mohammad Arham f7ecb9090c add: code to start working on cboe 2024-08-27 12:33:23 +00:00
Mohammad Arham a19e8a7315 change: changes to make taifex work 2024-08-27 07:45:59 -04:00
John Colvin cf189ecf81 refactor: Start cboe and taifex md 'start_databento'
Similar to how we start all ccapi implemented exchanges in "_start_cc"
(in MarketDataGateway)
2024-08-26 19:13:59 +00:00
John Colvin 4405b7adcb refactor: Rename cc_md_listeners -> venue_listeners
They are general purpose, not specific to ccapi.
2024-08-26 19:09:57 +00:00
John Colvin e51ee7b7b9 refactor: Wrap IDGenerator and IMarketDataListeners in shared_ptrs
Our various market data providers (ccapi, emumba, replay, onixs)
dereference pointers to common instances of these types concurrently on
different threads. Although we've correctly managed memory ownership
thus far, we really should be using smart pointers (this is why they
were made).
2024-08-26 19:03:29 +00:00
John Colvin dfaa74f426 build: Add databento dep via FetchContent
Now we actually build libdatabento in the devcontainer along with our
code (as we do with the vcpkg deps, though this is not part of vcpkg)
2024-08-26 17:13:51 +00:00
Mohammad Arham 1d2ce59009 add: added taifex entries 2024-08-22 23:13:05 +00:00
Adeel Khan 3602cc05bb added: TaifexDataHandler, temp 2024-08-23 02:06:47 +05:00
Adeel Khan ac88a81ac6 Security Extensions 2024-08-23 01:42:24 +05:00
Adeel Khan 01fa8e0c63 added: files for Taifex, Cboe 2024-08-23 00:57:40 +05:00
John Colvin 59547e0f37 fix build: Lock fmt version to 10.2.1 in vcpkg
This fixes the front-end (Windows) libspark build
2024-08-21 13:45:43 -04:00
John Colvin 3ce100a9cf build: Add databento to sparkd
* Install databento deps in docker
  - libzstd-dev
* Add databento cmake module to externals
2024-08-21 13:49:53 +00:00
John Colvin 6513fb0cd5 cleanup: Remove unused include 'date.h' from MDSource
This was an external header, and may interfere with a dependency in the
databento lib (which we are about to add).
2024-08-21 13:49:24 +00:00
Taha Afzal fd0fb1f760 Adding incremental book updates to IMarketDataListener 2024-08-12 22:49:27 -04:00
473 changed files with 6010 additions and 4019 deletions

No files matched your search

+4
View File
@@ -87,6 +87,10 @@ RUN dpkg -i /emumba/emumba-deribit-connector-3.3.1-Linux.LICENSE_DISABLED.deb \
# Pcap
RUN apt-get update && apt-get install -y libpcap0.8-dev
# Databento (deps)
RUN apt-get update && apt-get -y install libzstd-dev
# Docker in Docker
RUN apt-get update && apt-get install -y \
docker.io \
docker-compose \
+2 -1
View File
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.12)
project(spark_root)
project(spark)
set(CMAKE_CXX_STANDARD 20)
if(WIN32)
@@ -107,6 +107,7 @@ else()
add_subdirectory(src/lib_system)
add_subdirectory(src/lib_domain)
add_subdirectory(src/lib_python_md)
add_subdirectory(src/lib_logging)
add_subdirectory(src/app_sparkd)
add_subdirectory(src/data_files)
endif()
@@ -1,7 +1,7 @@
include(${CMAKE_SOURCE_DIR}/cmake/PackBasic.cmake)
include(GNUInstallDirs)
function(install_basic_config)
function(install_basic)
file(
GLOB_RECURSE ${PROJECT_NAME}_HEADERS
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
@@ -1,6 +1,33 @@
using BCG;
namespace bts {
//[DataStreamUserRespresentation("saver")]
// public class SaverStream : ViewStream {
// private readonly ViewStream _vs;
// private readonly string _file_name;
// public SaverStream(ViewStream vs, string file_name) {
// _vs = vs;
// _file_name = file_name;
// }
// protected override void myOnFirstSubscriber() {
// _vs.onChange += _handle_dp;
// }
// protected override void myOnLastSubscriber() {
// }
// private void _handle_dp(object dp_obj) {
// DataPacket dp = dp_obj as DataPacket;
// byte[] serialized_update = null;
// var _serializer = new UniversalStreamIOSerializer();
// serialized_update = _serializer.serialize(new bts.StreamIOMessage(new bts.StreamIOMessage.CreateMessage(dp.newRows)));
// StreamSerializationUtils.write_to_file(serialized_update, _file_name);
// myFireEvent(dp);
// }
// }
[DataStreamUserRespresentation("loader")]
public class LoaderStream : ViewStream {
@@ -31,7 +31,6 @@ namespace bts {
StreamIOMessage.CreateMessage cr_msg = new StreamIOMessage.CreateMessage(dp.newRows);
byte[] str_bytes = _serializer.serialize(new StreamIOMessage(cr_msg));
StreamSerializationUtils.write_to_file(str_bytes, _filename);
}
}
}
@@ -10,22 +10,17 @@ using System.Runtime.CompilerServices;
using bts.api;
using Bts.PubSub.Routing;
namespace bts
{
namespace bts {
[DataStreamUserRespresentation("pss_echo")]
public class PubsubEchoTestStream : ViewStream, IWorker
{
public class PayloadMessage
{
public class PubsubEchoTestStream : ViewStream, IWorker {
public class PayloadMessage {
public readonly string msg_id;
public readonly Int64 timestamp = 0;
public readonly byte[] payload = null;
public static byte[] create_data(int payload_size, byte payload_byte)
{
public static byte[] create_data(int payload_size, byte payload_byte) {
var rv = new byte[payload_size];
for (int i = 0; i < payload_size; i++)
{
for (int i = 0; i < payload_size; i++) {
rv[i] = payload_byte;
}
return rv;
@@ -41,16 +36,14 @@ namespace bts
// payload[i] = payload_byte;
// }
// }
public PayloadMessage(string guid_, Int64 timestamp_, byte[] payload_)
{
public PayloadMessage(string guid_, Int64 timestamp_, byte[] payload_) {
msg_id = guid_;
timestamp = timestamp_;
payload = payload_;
}
private PayloadMessage() { }
public byte[] serialize()
{
public byte[] serialize() {
var str = new MemoryStream();
BinaryWriter bw = new BinaryWriter(str);
bw.Write(msg_id);
@@ -62,8 +55,7 @@ namespace bts
return bytes;
}
public static PayloadMessage deserialize(byte[] ser_bytes)
{
public static PayloadMessage deserialize(byte[] ser_bytes) {
var str = new MemoryStream(ser_bytes);
BinaryReader br = new BinaryReader(str);
string guid = br.ReadString();
@@ -89,8 +81,7 @@ namespace bts
private readonly string _tag_name;
private readonly int _payload_sz;
private readonly IPubSubRouter _router;
private enum IOState
{
private enum IOState {
SEND = 0,
RECV = 1
};
@@ -119,8 +110,7 @@ namespace bts
public PubsubEchoTestStream(string server_url, int publish_period_msecs, int payload_size, string tag_name)
: this(server_url, TimeSpan.FromMilliseconds(publish_period_msecs), payload_size, tag_name, ViewStreamDatabase.instance) { }
protected override void myOnFirstSubscriber()
{
protected override void myOnFirstSubscriber() {
_pub_core = new PublisherCore(_router);
_sub_core = new SubscriberCore(_router);
_sub_core.subscribe(_tag_name);
@@ -128,14 +118,12 @@ namespace bts
}
protected override void myOnLastSubscriber()
{
protected override void myOnLastSubscriber() {
_vsd.removeWorker(this);
_sub_core.unsubscribe(_tag_name);
}
private void _fire_dp_after_send()
{
private void _fire_dp_after_send() {
// as soon as the data is published, its reflected in the stream state
Log.assert(_last_sent_msg != null);
BlueRow r = new BlueRow(_table.schema, _table.Count, _last_sent_msg.msg_id, _last_sent_msg.timestamp, DBNull.Value, DBNull.Value,
@@ -145,8 +133,7 @@ namespace bts
myFireEvent(dp_out);
}
private void _fire_dp_after_recv()
{
private void _fire_dp_after_recv() {
Log.assert(_last_recvd_msg != null);
// update the last publish row
int id = _table.Count - 1;
@@ -160,13 +147,11 @@ namespace bts
myFireEvent(dp_out);
}
private string _get_next_id()
{
private string _get_next_id() {
return _table.Count.ToString();
}
private void _publish_next_packet()
{
private void _publish_next_packet() {
var bytes = PayloadMessage.create_data(_payload_sz, _payload_byte);
_last_sent_msg = new PayloadMessage(_get_next_id(), epoch_now(), bytes);
var ser_bytes = _last_sent_msg.serialize();
@@ -175,25 +160,19 @@ namespace bts
_last_publish_time = DateTime.Now;
}
public void doWork()
{
Func<IEnumerable<PubSubServerMessage>, PayloadMessage> find_packet = (updates) =>
{
foreach (var u in updates)
{
public void doWork() {
Func<IEnumerable<PubSubServerMessage>, PayloadMessage> find_packet = (updates) => {
foreach (var u in updates) {
var recv_msg = PayloadMessage.deserialize(u.data);
if (recv_msg.msg_id == _last_sent_msg.msg_id)
{
if (recv_msg.msg_id == _last_sent_msg.msg_id) {
return recv_msg;
}
}
return null;
};
switch (_state)
{
switch (_state) {
case IOState.SEND:
if (DateTime.Now - _last_publish_time >= _publish_period)
{
if (DateTime.Now - _last_publish_time >= _publish_period) {
_publish_next_packet();
_last_publish_time = DateTime.Now;
_fire_dp_after_send();
@@ -205,8 +184,7 @@ namespace bts
var updates = _sub_core.get_updates(TimeSpan.Zero);
updates = updates.Where(u => u.tag == _tag_name);
var recv_msg = find_packet(updates);
if (recv_msg != null)
{
if (recv_msg != null) {
_last_recvd_msg = recv_msg;
_fire_dp_after_recv();
_state = IOState.SEND;
@@ -216,8 +194,7 @@ namespace bts
}
}
public static long epoch_now()
{
public static long epoch_now() {
return DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
}
@@ -16,6 +16,14 @@ public class DataStreamPublisherConfig {
public List<string>? CsvDirs { get; set; }
public string? MONGO_DB_URL { get; set; }
public string? MONGO_DB_NAME { get; set; }
public string? MONGO_DB_COLLECTION { get; set; }
public string? BENZINGA_NEWS_TTL { get; set; }
[Option(
"config",
MetaValue = "PATH",
@@ -419,7 +419,6 @@ namespace bts {
// var rcv_message = ExceptionAssert.Cast(res.AsyncState).To<AsyncReceiveMessage>();
// var buff_txt = AsyncTCPConnection_AsyncWrapper.to_hex(rcv_message.buffer, 0, rcv_message.buffer.Length);
// Log.Gen.info($"BeginReceive_callback_function _log_incoming_msg buff: {buff_txt}");
}
// this is the function passed to BeginReceive, we
@@ -1,5 +1,4 @@
namespace bts
{
namespace bts {
using BCG;
using BCG.Utilities.General;
using System;
@@ -12,19 +11,15 @@ namespace bts
// this ITCPConnection uses the TCPClient class instead of a raw socket (in the hope, that it would configure the socket correctly)
public class AsyncTCPConnection_AsyncWrapper : ITCPConnection, IWorker, IDisposable
{
public class ConnectionID
{
public class AsyncTCPConnection_AsyncWrapper : ITCPConnection, IWorker, IDisposable {
public class ConnectionID {
public readonly RemoteConnectionInfo self;
public readonly RemoteConnectionInfo peer;
public readonly Type conn_type;
public override string ToString()
{
public override string ToString() {
return $"{conn_type} self: {self} peer: {peer}";
}
public ConnectionID(RemoteConnectionInfo self_, RemoteConnectionInfo peer_, Type conn_type_)
{
public ConnectionID(RemoteConnectionInfo self_, RemoteConnectionInfo peer_, Type conn_type_) {
self = self_;
peer = peer_;
conn_type = conn_type_;
@@ -51,21 +46,17 @@ namespace bts
// return hex_builder.ToString().Trim();
// }
public AsyncTCPConnection_AsyncWrapper(TcpClient tcp_client)
{
public AsyncTCPConnection_AsyncWrapper(TcpClient tcp_client) {
_tcp_client = tcp_client;
_nw_stream = _tcp_client.GetStream();
_connection_id = new ConnectionID(TCPSocketUtils.get_self_address(_tcp_client.Client), TCPSocketUtils.get_peer_address(_tcp_client.Client), GetType());
Log.Gen.info($"AsyncTCPConnection_AsyncWrapper.cons connection: {_connection_id}");
}
private void _detect_connection_status_change()
{
Action testing_func = () =>
{
private void _detect_connection_status_change() {
Action testing_func = () => {
bool connected = _tcp_client.Connected;
while (true)
{
while (true) {
if (connected != _tcp_client.Connected)
Log.Gen.error($"Connection status changed this: {ToString()} {connected} -> {_tcp_client.Connected}");
connected = _tcp_client.Connected;
@@ -78,17 +69,14 @@ namespace bts
}
#region Sending
public void _send_fixed_size_msg(byte[] buffer)
{
// string buff_txt = to_hex(buffer, 0, buffer.Length);
// Log.Gen.info($"AsyncTCPConnection_AsyncWrapper._send_fixed_size_msg buffer: {buff_txt}");
public void _send_fixed_size_msg(byte[] buffer) {
//Log.Gen.info($"AsyncTCPConnection_AsyncWrapper._send_fixed_size_msg buffer: {to_hex(buffer, 0, buffer.Length)}");
int total_bytes_sent = 0;
int n_bytes = buffer.Length;
int n_transfers = 0;
while (_is_alive && total_bytes_sent < n_bytes)
{
while (_is_alive && total_bytes_sent < n_bytes) {
int remaining_bytes = n_bytes - total_bytes_sent;
_nw_stream.Write(buffer, total_bytes_sent, remaining_bytes);
total_bytes_sent += remaining_bytes;
@@ -97,10 +85,8 @@ namespace bts
Log.Gen.info($"AsyncTCPConnection_AsyncWrapper._send_fixed_size_msg sent {buffer.Length} bytes in {n_transfers} transfers");
}
private void _send_one_msg(byte[] msg)
{
try
{
private void _send_one_msg(byte[] msg) {
try {
// the total msg = [msg_sz, msg_type, data]
int sz = msg.Length + 4;
MemoryStream str = new MemoryStream();
@@ -111,20 +97,15 @@ namespace bts
str.Position = 0;
byte[] buff = str.ToArray();
_send_fixed_size_msg(buff);
}
catch (Exception ex)
{
} catch (Exception ex) {
_handle_error(new ErrorMessage(ex, $"_send_one_msg call_stacK: {ex.StackTrace}"));
}
}
private void _send_forever()
{
while (_is_alive)
{
private void _send_forever() {
while (_is_alive) {
byte[] data = _send_queue.dequeue();
if (data != null)
{
if (data != null) {
_send_one_msg(data);
}
}
@@ -137,47 +118,39 @@ namespace bts
}
#endregion
public void register(ITCPMessageHandler message_handler)
{
public void register(ITCPMessageHandler message_handler) {
_msg_handler = message_handler;
// starting thread pool threads to keep reading and sending
ThreadPool.QueueUserWorkItem(_ => _read_msgs_forever());
ThreadPool.QueueUserWorkItem(_ => _send_forever());
}
public RemoteConnectionInfo get_peer_address()
{
public RemoteConnectionInfo get_peer_address() {
return _connection_id.peer;
}
public RemoteConnectionInfo get_self_address()
{
public RemoteConnectionInfo get_self_address() {
return _connection_id.self;
}
public bool isDisposed { get { return !_is_alive; } }
public void doWork()
{
public void doWork() {
// send hb
}
#region Reading
// This makes the blocking IO call, the callstack is _read_msgs_forever -> _read_one_message -> _read_fixed_size_msg
private byte[] _read_fixed_size_msg(int n_bytes)
{
if (n_bytes <= 0)
{
private byte[] _read_fixed_size_msg(int n_bytes) {
if (n_bytes <= 0) {
throw new ArgumentException("Number of bytes to read must be greater than zero.", nameof(n_bytes));
}
byte[] buffer = new byte[n_bytes];
int total_bytes_read = 0;
int n_transfers = 0;
while (_is_alive && total_bytes_read < n_bytes)
{
while (_is_alive && total_bytes_read < n_bytes) {
int bytes_read = _nw_stream.Read(buffer, total_bytes_read, n_bytes - total_bytes_read);
if (bytes_read <= 0)
{
if (bytes_read <= 0) {
throw new IOException("Read 0 bytes, the connection was closed before all data could be read.");
}
n_transfers++;
@@ -188,44 +161,37 @@ namespace bts
return buffer;
}
private class OneRecvMessage
{
private class OneRecvMessage {
public int msg_type;
public byte[] data;
public OneRecvMessage(int msg_type_, byte[] data_)
{
public OneRecvMessage(int msg_type_, byte[] data_) {
msg_type = msg_type_;
data = data_;
}
public OneRecvMessage(byte[] msg)
{
public OneRecvMessage(byte[] msg) {
MemoryStream str = new MemoryStream(msg);
BinaryReader br = new BinaryReader(str);
int msg_type = br.ReadInt32();
if (msg_type == DATA_MSG_SIGNAL)
{
if (msg_type == DATA_MSG_SIGNAL) {
// TODO, polish it, too much memory bneing allocated
data = br.ReadBytes(msg.Length - 4);
}
}
public override string ToString()
{
public override string ToString() {
string rv = $"OneMessage msg_type: {msg_type} data_len: {data.Length}";
return rv;
}
}
private OneRecvMessage _read_one_message()
{
private OneRecvMessage _read_one_message() {
// read size first
byte[] sz_arr = _read_fixed_size_msg(4);
BinaryReader br = new BinaryReader(new MemoryStream(sz_arr));
br.BaseStream.Position = 0;
int msg_sz = br.ReadInt32();
Log.Gen.info($"AsyncTCPConnection_AsyncWrapper._read_one_message read msg_sz: {msg_sz}");
if (msg_sz < 0)
{
if (msg_sz < 0) {
throw new IOException("Read 0 bytes, the connection was closed before all data could be read.");
}
byte[] msg = _read_fixed_size_msg(msg_sz);
@@ -235,29 +201,19 @@ namespace bts
return rv;
}
private void _read_msgs_forever()
{
while (_is_alive)
{
try
{
private void _read_msgs_forever() {
while (_is_alive) {
try {
OneRecvMessage one_msg = _read_one_message();
if (one_msg.msg_type == DATA_MSG_SIGNAL)
{
if (one_msg.msg_type == DATA_MSG_SIGNAL) {
_msg_handler.onData(new RemoteMessage(one_msg.data, RemoteMessageType.Data, _connection_id.peer));
}
else if (one_msg.msg_type == HB_MSG_SIGNAL)
{
} else if (one_msg.msg_type == HB_MSG_SIGNAL) {
// keep a last hb time an dudpate it here atomically
_msg_handler.onData(new RemoteMessage(null, RemoteMessageType.Heartbeat, _connection_id.peer));
}
else
{
} else {
throw new ApplicationException($"Unknown message type: {one_msg.msg_type}");
}
}
catch (Exception ex)
{
} catch (Exception ex) {
_handle_error(new ErrorMessage(ex, $"_read_msgs_forever, call_stack: {ex.StackTrace}"));
}
}
@@ -267,19 +223,16 @@ namespace bts
public bool is_disposed => !_is_alive;
public class ErrorMessage
{
public class ErrorMessage {
public readonly SocketError? socket_error = null;
public readonly Exception exception = null;
public readonly bool is_exception = false;
public readonly string context = String.Empty;
public ErrorMessage(SocketError socket_error_, string context_)
{
public ErrorMessage(SocketError socket_error_, string context_) {
socket_error = socket_error_;
context = context_;
}
public ErrorMessage(Exception exception_, string context_)
{
public ErrorMessage(Exception exception_, string context_) {
is_exception = true;
exception = exception_;
context = context_;
@@ -287,30 +240,23 @@ namespace bts
public bool oom => exception != null && exception is OutOfMemoryException;
public override string ToString()
{
public override string ToString() {
if (is_exception)
return $"ErrorMessage exception: {exception} context: {context}";
return $"socket_error: {socket_error} context: {context}";
}
}
public void Dispose()
{
public void Dispose() {
// socket is closed and disposed here
lock (this)
{
if (_is_alive)
{
lock (this) {
if (_is_alive) {
//_master_worker.removeWorker(this);
_is_alive = false;
try
{
try {
bts.Log.Gen.info($"AsyncTCPConnection_APM.Dispose this: {this} closing tcp_client nin an orderly fashion now");
_tcp_client.Close();
}
catch (Exception ex)
{
} catch (Exception ex) {
String.Format("AsyncTCPConnection_APM.Dispose exception: {ex} thrown when closing socket");
if (ex is OutOfMemoryException)
throw ex;
@@ -320,10 +266,8 @@ namespace bts
}
}
private void _handle_error(ErrorMessage err_msg)
{
lock (this)
{
private void _handle_error(ErrorMessage err_msg) {
lock (this) {
Log.Gen.error($"AsyncTCPConnection_APM._handle_error this: {this} error_msg: {err_msg}");
if (err_msg.oom)
throw err_msg.exception;
@@ -331,9 +275,8 @@ namespace bts
}
}
public override string ToString()
{
public override string ToString() {
return _connection_id.ToString();
}
}
}
}
@@ -286,4 +286,4 @@ namespace BCG {
}
}
+13 -3
View File
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.14)
project(sparkd)
include(FetchContent)
include(${CMAKE_SOURCE_DIR}/cmake/safe_dep_glob.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/ProtobufGenerateCpp.cmake)
include(GNUInstallDirs)
@@ -57,6 +58,14 @@ target_include_directories(
)
add_dependencies(${PROJECT_NAME} rapidjson_project)
# databento
FetchContent_Declare(
databento
GIT_REPOSITORY https://github.com/databento/databento-cpp
GIT_TAG HEAD
)
FetchContent_MakeAvailable(databento)
# deribit-demo log level
if(NOT DEFINED DERIBIT_DEMO_LOG_LEVEL)
add_definitions(-DSPDLOG_ACTIVE_LEVEL=0)
@@ -130,6 +139,7 @@ target_link_libraries(
python_md
python_md_module
spark
databento::databento
${emumba-deribit-connector-library_LIBRARIES}
ssl
cryptopp
@@ -148,8 +158,8 @@ target_link_libraries(
-static-libstdc++
-pthread)
include(${CMAKE_SOURCE_DIR}/cmake/InstallBasicConfig.cmake)
install_basic_config()
include(${CMAKE_SOURCE_DIR}/cmake/InstallBasic.cmake)
install_basic()
install(
FILES
"${EXTERNALS_LIB}/libOnixS.IceImpactMulticastPriceFeedHandlerCpp.so.3.16.0.0"
@@ -1,22 +1,22 @@
#pragma once
#include "logging/logging.h"
#include "spark/api/public/ServiceContext.h"
#include "spark/api/services/AlgoDefinitionService.server.pb.h"
#include "spark/api/services/OrderService.client.pb.h"
#include "spark/api/services/OrderService.pb.h"
#include "spark/logging/logging.h"
#include "spark/persistence/IStore.h"
#include "spark/persistence/SqliteStore.h"
#include "spark/utils/PBUtils.h"
#include "spark/utils/TimeStamp.h"
#include "spark/utils/bts_assert.h"
#include "spark/utils/bts_no_copy.h"
#include <memory>
#include <boost/tokenizer.hpp>
#include <fmt/format.h>
#include <google/protobuf/util/time_util.h>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <utility>
@@ -69,4 +69,4 @@ class AlgoDefinitionServiceServer : public AlgoDefinitionServiceBase {
} // namespace algo
} // namespace orderman
} // namespace api
} // namespace bts
} // namespace bts
@@ -1,8 +1,8 @@
#include "AnalyticsServiceServer.h"
#include "logging/logging.h"
#include "spark/api/apicore.pb.h"
#include "spark/api/services/AnalyticsService.pb.h"
#include "spark/api/services/AnalyticsService.server.pb.h"
#include "spark/logging/logging.h"
#include "spark/persistence/IStore.h"
#include "spark/persistence/SqliteStore.h"
#include "spark/utils/PBUtils.h"
+4 -4
View File
@@ -1,9 +1,9 @@
#include "AdminReport.h"
#include "logging/logging.h"
#include "logging/protobufs/logging.pb.h"
#include "spark/api/public/ServiceContext.h"
#include "spark/config/config.h"
#include "spark/config/protos/logging.pb.h"
#include "spark/logging/logging.h"
#include "spark/quickbus/quickbus.h"
#include "spark/api/service_helpers/AdminServiceUtils.h"
@@ -17,9 +17,9 @@
namespace bts::cmds {
void md_report() {
auto cfg = config::get<config::Logging>();
auto cfg = config::get<logging::protobufs::Logging>();
cfg.mutable_console()->set_default_level("Fatal");
log::configure_logging(cfg);
logging::configure_logging(cfg);
std::map<api::CMEMics, std::string> mic_map;
mic_map[api::CMEMics::CME] = "XCME";
+1 -1
View File
@@ -1,5 +1,5 @@
#include "CMECert.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "spark/orderman/ilink3/IL3Dispatcher.h"
#include "spark/orderman/ilink3/IL3GW.h"
#include "spark/orderman/ilink3/IL3Reactor.h"
+1 -1
View File
@@ -1,8 +1,8 @@
#include "KeyCmd.h"
#include "logging/logging.h"
#include "spark/config/config.h"
#include "spark/config/protos/keycode.pb.h"
#include "spark/logging/logging.h"
#include "spark/os/os.h"
#include "spark/utils/AuthToken.h"
#include "spark/utils/FileUtils.h"
+1 -1
View File
@@ -1,5 +1,5 @@
#include "QuickTest.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include <thread>
+1 -1
View File
@@ -1,9 +1,9 @@
#include "Run.h"
#include "logging/logging.h"
#include "spark/api/public/ServiceContext.h"
#include "spark/config/config.h"
#include "spark/config/protos/ports.pb.h"
#include "spark/config/protos/quickbus_cfg.pb.h"
#include "spark/logging/logging.h"
#include "spark/md/MBOProcessor.h"
#include "spark/md/MBOServiceServer.h"
#include "spark/md/MDClient.h"
@@ -1,7 +1,7 @@
#include "TestPythonMdProviderCmd.h"
#include "logging/logging.h"
#include "python_md/md_sink_impl.h"
#include "python_md/py_md_executor.h"
#include "spark/logging/logging.h"
#include <pybind11/embed.h>
#include <pybind11/pybind11.h>
+3 -11
View File
@@ -1,30 +1,22 @@
#include "Web.h"
#include "md/cmds/Run.h"
#include "spark/api/public/ServiceContext.h"
#include "spark/api/services/MarketDataService.pb.h"
#include "spark/api/services/SyntheticSecurityService.pb.h"
#include "spark/config/config.h"
#include "spark/config/protos/market_data.pb.h"
#include "spark/config/protos/ports.pb.h"
#include "spark/config/protos/quickbus_cfg.pb.h"
#include "spark/md/MBOProcessor.h"
#include "spark/md/MDClient.h"
#include "spark/md/SyntheticSecurityService.h"
#include "spark/md/relay/QueryServer.h"
#include "spark/metrics/metrics.h"
#include "spark/metrics/system_metrics.h"
#include "spark/quickbus/quickbus.h"
#include "spark/quickbus/core/Quickbus.h"
#include "spark/tracing/PerfLog.h"
#include "spark/utils/Dispatcher.h"
#include "spark/utils/thread_manager.h"
#include "md/cmds/Cleanup.h"
#include "md/cmds/Run.h"
#include "sparkd/exchange_sim/ExchangeSim.h"
#include "sparkd/http/WebServer.h"
#include "sparkd/user/AdminServiceServer.h"
#include "sparkd/user/AuthServiceServer.h"
#include <optional>
#include <string>
#include <vector>
namespace bts::cmds {
@@ -1,5 +1,5 @@
#include "DeribitDemo.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "sparkd/cmds/crypto/DeribitDemoListener.h"
#include <csignal>
@@ -1,6 +1,6 @@
#include "DeribitDemoConfiguration.h"
#include "RapidJsonReader.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "rapidjson/istreamwrapper.h"
#include <emumba-deribit-connector/deribit_utils.h>
#include <fstream>
@@ -1,9 +1,9 @@
#ifdef SPARK_ENABLE_CCAPI
#include "LiveLadderDemoCmd.h"
#include "LiveLadderDemo.h"
#include "logging/logging.h"
#include "spark/api/md/MarketDataConfig.pb.h"
#include "spark/io/ProtoReader.h"
#include "spark/logging/logging.h"
#include "sparkd/cmds/common/Validators.h"
#include "sparkd/cmds/crypto/LiveLadderDemo.h"
#include <CLI11/CLI11.hpp>
@@ -1,7 +1,7 @@
#include "Cleanup.h"
#include "logging/logging.h"
#include "spark/config/config.h"
#include "spark/config/protos/market_data.pb.h"
#include "spark/logging/logging.h"
#include "spark/md/ShmSegmentName.h"
#include "spark/md/protos/co2.pb.h"
#include <boost/filesystem.hpp>
+1 -1
View File
@@ -1,8 +1,8 @@
#include "Run.h"
#include "Cleanup.h"
#include "domain/security_criteria.h"
#include "logging/logging.h"
#include "spark/config/protos/market_data.pb.h"
#include "spark/logging/logging.h"
#include "spark/md/SymbolLoader.h"
#include "spark/md/UserSymbol.h"
#include "spark/md/relay/RelayRecorder.h"
@@ -18,7 +18,9 @@ EnumOptionNames<api::Venue> VenueOption::names() {
NAME_PAIR(api::VENUE_BINANCE),
NAME_PAIR(api::VENUE_BINANCE_US),
NAME_PAIR(api::VENUE_COINBASE),
NAME_PAIR(api::VENUE_BINANCE_USDS_FUTURES)};
NAME_PAIR(api::VENUE_BINANCE_USDS_FUTURES),
NAME_PAIR(api::VENUE_CBOE),
NAME_PAIR(api::VENUE_TAIFEX)};
}
std::string VenueOption::name(api::Venue venue) {
@@ -45,6 +47,10 @@ std::string VenueOption::name(api::Venue venue) {
return "coinbase";
case api::VENUE_BINANCE_USDS_FUTURES:
return "binance_usds_futures";
case api::VENUE_CBOE:
return "cboe";
case api::VENUE_TAIFEX:
return "taifex";
default:
return std::to_string(static_cast<int32_t>(venue));
}
@@ -10,14 +10,14 @@
#include <iostream>
#include <string>
#include "logging/logging.h"
#include "spark/config/config.h"
#include "spark/config/protos/exchange_sim_cfg.pb.h"
#include "spark/config/protos/ports.pb.h"
#include "spark/config/protos/system_config.pb.h"
#include "spark/domain_model/Security.pb.h"
#include "spark/logging/logging.h"
#include "spark/md/PriceSize.h"
#include "spark/os/os.h"
#include "system/protobufs/system_config.pb.h"
#include "spark/domain_model/Security.pb.h"
#include "spark/md/IntPrice.h"
@@ -31,6 +31,9 @@
namespace bts {
namespace sim {
using bts::system::protobufs::SystemConfig;
auto cfg = "[DEFAULT]\n"
"ConnectionType=acceptor\n"
"SocketAcceptPort=$EXCHANGE_SIM_FIX_PORT\n"
@@ -144,7 +147,7 @@ int start_exchange_sim(bts::api::Venue venue, md::MBOWriter *mbo) {
auto venue_string = boost::to_lower_copy(api::Venue_Name(venue));
boost::replace_all(
str_settings, "$BTS_DATA_PATH",
config::get<config::SystemConfig>().data_path());
config::get<SystemConfig>().data_path());
boost::replace_all(str_settings, "$SIM_VENUE", venue_string);
std::string port_string;
switch (venue) {
@@ -2,10 +2,10 @@
#include "spark/md/SecurityDB.h"
#include "IDGenerator.h"
#include "logging/logging.h"
#include "spark/config/config.h"
#include "spark/config/protos/exchange_sim_cfg.pb.h"
#include "spark/domain_model/Security.h"
#include "spark/logging/logging.h"
#include "spark/md/MBOProcessor.h"
#include "spark/md/MDProducer.h"
#include "spark/md/Shm/FixedSecurity.h"
@@ -1,11 +1,11 @@
#include "EMExecutionGateway.h"
#include "logging/logging.h"
#include "spark/api/service_helpers/AdminServiceUtils.h"
#include "spark/api/services/AdminService.pb.h"
#include "spark/api/services/OrderService.pb.h"
#include "spark/domain_model/Security.pb.h"
#include "spark/domain_model/SecurityKey.h"
#include "spark/domain_model/common.h"
#include "spark/logging/logging.h"
#include "spark/md/SecurityOracle.h"
#include "spark/orderman/CancelOrderMsg.h"
#include "spark/orderman/CancelReplaceOrderMsg.h"
+1 -1
View File
@@ -1,10 +1,10 @@
#include "ApiGateway.h"
#include "logging/logging.h"
#include "spark/api/core/ApiClientInterop.h"
#include "spark/api/public/ApiUtils.h"
#include "spark/api/services/AdminService.client.pb.h"
#include "spark/api/services/AuthService.client.pb.h"
#include "spark/logging/logging.h"
#include "spark/utils/bts_assert.h"
#include <mutex>
#include <unordered_map>
@@ -1,5 +1,6 @@
#include "MultipartFormDecoder.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/iter_find.hpp>
+1 -1
View File
@@ -3,9 +3,9 @@
#include "WebServer.h"
#include "ApiGateway.h"
#include "MultipartFormDecoder.h"
#include "logging/logging.h"
#include "spark/api/apigateway.pb.h"
#include "spark/api/core/ApiClientInterop.h"
#include "spark/logging/logging.h"
#include "spark/os/os.h"
#include "spark/tracing/PerfLog.h"
#include "spark/utils/Dispatcher.h"
@@ -1,11 +1,11 @@
#include "MarketDataAuxiliaryServiceServer.h"
#include "VolumeAtPriceState.h"
#include "logging/logging.h"
#include "spark/api/public/ServiceContext.h"
#include "spark/api/services/MarketDataRelay.client.pb.h"
#include "spark/api/services/MarketDataRelay.pb.h"
#include "spark/config/config.h"
#include "spark/config/protos/toggles.pb.h"
#include "spark/logging/logging.h"
#include "spark/utils/Dispatcher.h"
#include "spark/utils/PBUtils.h"
#include "spark/utils/bts_chrono.h"
@@ -1,10 +1,10 @@
#include "MarketDataGateway.h"
#include "domain/security_id.h"
#include "logging/logging.h"
#include "spark/api/md/MarketDataConfig.pb.h"
#include "spark/api/md/MarketDataConfigUtils.h"
#include "spark/config/config.h"
#include "spark/domain/DomainSecurityUtils.h"
#include "spark/logging/logging.h"
#include "spark/md/GeneralMarketDataListener.h"
#include "spark/md/GeneralSecurityIndex.h"
#include "spark/md/IMarketDataListener.h"
@@ -3,9 +3,9 @@
#include "domain/book.h"
#include "domain/rfq.h"
#include "domain/security.h"
#include "domain/security_market_data_statistics.h"
#include "domain/security_state.h"
#include "domain/trade_record.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "spark/md/IMarketDataListener.h"
#include "sparkd/md/MarketDataError.h"
@@ -19,7 +19,7 @@ class MarketDataListener : public IMarketDataListener {
void on_security_statistics(
const domain::SecurityMarketDataStatistics &security_stats) override;
void on_book(const domain::Book &book) override;
void on_book(const domain::Book &book, std::optional<utils::TimeStamp>) override;
void on_trades(
const std::vector<const domain::TradeRecord *> &trades) override;
void on_rfqs(const std::vector<const domain::RFQ *> &rfqs) override;
@@ -39,7 +39,7 @@ inline void MarketDataListener::on_security_state(
inline void MarketDataListener::on_security_statistics(
const domain::SecurityMarketDataStatistics & /*security_stats*/) {}
inline void MarketDataListener::on_book(const domain::Book & /*book*/) {}
inline void MarketDataListener::on_book(const domain::Book & /*book*/, std::optional<utils::TimeStamp>) {}
inline void MarketDataListener::on_trades(
const std::vector<const domain::TradeRecord *> & /*trades*/) {}
@@ -1,13 +1,13 @@
#pragma once
#ifndef _WIN32
#include "spark/core/ValueWrapper.h"
#include "system/FMT_IMPL.h"
#include "system/value_wrapper.h"
namespace bts::md {
using MarketDataListenerID =
core::ValueWrapper<struct MarketDataListenedIDTag, std::uint32_t>;
utils::ValueWrapper<struct MarketDataListenedIDTag, std::uint32_t>;
} // namespace bts::md
@@ -7,13 +7,13 @@
#include "domain/security_id.h"
#include "domain/spot_security.h"
#include "domain/trade_record.h"
#include "logging/logging.h"
#include "python_md/md_sink.h"
#include "python_md/py_book.h"
#include "python_md/py_md_executor.h"
#include "python_md/py_security.h"
#include "python_md/py_security_list.h"
#include "python_md/py_trade.h"
#include "spark/logging/logging.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/os/os.h"
#include "spark/persistence/IDGenerator.h"
@@ -1,6 +1,6 @@
#include "ReplayMarketDataSubscription.h"
#include "logging/logging.h"
#include "spark/api/md/MarketDataReplayConfig.pb.h"
#include "spark/logging/logging.h"
#include "spark/md/GeneralMarketDataListener.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/md/MDProducer.h"
@@ -1,7 +1,7 @@
#pragma once
#include "spark/io/JsonMacros.h"
#include "sparkd/md/binance/BinanceFilterType.h"
#include "system/json/json_macros.h"
#include "system/json/json_reader.h"
#include <iostream>
@@ -1,6 +1,6 @@
#pragma once
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "sparkd/md/binance/BinanceFilterType.h"
#include "system/json/json_reader.h"
@@ -1,7 +1,7 @@
#pragma once
#include "spark/io/JsonMacros.h"
#include "sparkd/md/binance/BinanceFilterType.h"
#include "system/json/json_macros.h"
#include "system/json/json_reader.h"
#include <iostream>
@@ -2,7 +2,7 @@
#include "BinanceMiniTickerUpdate.h"
#include "domain/price.h"
#include "domain/quantity.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "domain/security_market_data_statistics.h"
#include "sparkd/md/ccapi/CCApiReader.h"
#include "system/json/json_dumper.h"
#include "system/json/json_reader.h"
@@ -1,6 +1,6 @@
#pragma once
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "domain/security_market_data_statistics.h"
#include "sparkd/md/binance/BinanceMiniTickerEventType.h"
#include "system/time_stamp.h"
@@ -1,7 +1,7 @@
#pragma once
#include "spark/io/JsonMacros.h"
#include "sparkd/md/binance/BinanceFilterType.h"
#include "system/json/json_macros.h"
#include "system/json/json_reader.h"
#include <nlohmann/json.hpp>
@@ -1,7 +1,7 @@
#include "BinancePriceStatistics.h"
#include "domain/price.h"
#include "domain/quantity.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "domain/security_market_data_statistics.h"
#include "sparkd/md/ccapi/CCApiReader.h"
#include "system/json/json_dumper.h"
#include "system/json/json_reader.h"
@@ -1,6 +1,6 @@
#include "BinancePriceStatisticsAdaptor.h"
#include "domain/security_id.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "domain/security_market_data_statistics.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/utils/bts_fatal.h"
#include "sparkd/md/binance/BinancePriceStatistics.h"
@@ -3,7 +3,7 @@
#include "domain/protobufs/venue.pb.h"
#include "domain/security.h"
#include "domain/security_criteria.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "spark/persistence/IDGenerator.h"
#include "spark/utils/bts_fatal.h"
#include "sparkd/md/binance/BinanceMessageType.h"
@@ -2,7 +2,7 @@
#include "domain/protobufs/venue.pb.h"
#include "domain/quantity.h"
#include "domain/security.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "system/json/json_reader.h"
#include <ccapi_cpp/ccapi_message.h>
@@ -1,13 +1,13 @@
#pragma once
#include "domain/protobufs/venue.h"
#include "spark/io/JsonMacros.h"
#include "sparkd/md/binance/BinanceFilterTuple.h"
#include "sparkd/md/binance/BinanceInstrumentStatus.h"
#include "sparkd/md/binance/BinanceOrderType.h"
#include "sparkd/md/binance/BinancePermission.h"
#include "sparkd/md/binance/BinanceQuoteAsset.h"
#include "system/FMT_IMPL.h"
#include "system/json/json_macros.h"
#include <nlohmann/json.hpp>
#include <ostream>
@@ -2,10 +2,10 @@
#include "domain/protobufs/venue.pb.h"
#include "domain/security.h"
#include "domain/security_criteria.h"
#include "logging/logging.h"
#include "spark/api/md/BinanceMarketDataConfig.pb.h"
#include "spark/io/ProtoPrinter.h"
#include "spark/io/QueryParams.h"
#include "spark/logging/logging.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/persistence/IDGenerator.h"
#include "sparkd/md/binance/BinanceMessageType.h"
@@ -1,7 +1,7 @@
#include "BinanceUsPriceStatistics.h"
#include "domain/price.h"
#include "domain/quantity.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "domain/security_market_data_statistics.h"
#include "sparkd/md/ccapi/CCApiReader.h"
#include "system/json/json_dumper.h"
#include "system/json/json_reader.h"
@@ -1,6 +1,6 @@
#include "BinanceUsPriceStatisticsAdaptor.h"
#include "domain/security_id.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "domain/security_market_data_statistics.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/utils/bts_fatal.h"
#include "sparkd/md/binance_us/BinanceUsPriceStatistics.h"
@@ -3,7 +3,7 @@
#include "domain/protobufs/venue.pb.h"
#include "domain/security.h"
#include "domain/security_criteria.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "spark/persistence/IDGenerator.h"
#include "sparkd/md/binance_us/BinanceUsMessageType.h"
#include "sparkd/md/binance_us/BinanceUsSpot.h"
@@ -2,10 +2,10 @@
#include "domain/protobufs/venue.pb.h"
#include "domain/security.h"
#include "domain/security_criteria.h"
#include "logging/logging.h"
#include "spark/api/md/BinanceUsMarketDataConfig.pb.h"
#include "spark/io/ProtoPrinter.h"
#include "spark/io/QueryParams.h"
#include "spark/logging/logging.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/persistence/IDGenerator.h"
#include "sparkd/md/binance/BinanceSpot.h"
@@ -2,7 +2,7 @@
#include "domain/price.h"
#include "domain/quantity.h"
#include "domain/security.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "system/json/json_dumper.h"
#include "system/json/json_reader.h"
@@ -1,7 +1,7 @@
#include "BinanceUsdsFuturesPriceStatistics.h"
#include "domain/price.h"
#include "domain/quantity.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "domain/security_market_data_statistics.h"
#include "sparkd/md/ccapi/CCApiReader.h"
#include "system/json/json_reader.h"
@@ -1,6 +1,6 @@
#pragma once
#include "spark/io/JsonMacros.h"
#include "system/json/json_macros.h"
#include "system/json/json_reader.h"
#include <nlohmann/json.hpp>
@@ -1,6 +1,6 @@
#include "BinanceUsdsFuturesPriceStatisticsAdaptor.h"
#include "domain/security_id.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "domain/security_market_data_statistics.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/utils/bts_fatal.h"
#include "sparkd/md/binance_usds_futures/BinanceUsdsFuturesPriceStatistics.h"
@@ -2,8 +2,8 @@
#include "domain/security.h"
#include "domain/security_criteria.h"
#include "domain/security_id.h"
#include "logging/logging.h"
#include "spark/api/md/BinanceUsdsFuturesMarketDataConfig.pb.h"
#include "spark/logging/logging.h"
#include "spark/persistence/IDGenerator.h"
#include "spark/utils/bts_fatal.h"
#include "sparkd/md/binance_usds_futures/BinanceUsdsFuture.h"
@@ -3,10 +3,10 @@
#include "domain/security.h"
#include "domain/security_criteria.h"
#include "domain/security_id.h"
#include "logging/logging.h"
#include "spark/api/md/BinanceUsdsFuturesMarketDataConfig.pb.h"
#include "spark/io/ProtoPrinter.h"
#include "spark/io/QueryParams.h"
#include "spark/logging/logging.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/persistence/IDGenerator.h"
#include "sparkd/md/binance_usds_futures/BinanceUsdsFuturesMessageType.h"
@@ -1,9 +1,9 @@
#pragma once
#include "spark/core/StringFinder.h"
#include "spark/core/StringJoiner.h"
#include "spark/utils/bts_assert.h"
#include "system/FMT_IMPL.h"
#include "system/string_finder.h"
#include "system/string_joiner.h"
#include <boost/algorithm/string/split.hpp>
#include <cstddef>
@@ -1,6 +1,6 @@
#pragma once
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include <ccapi_cpp/ccapi_event_handler.h>
@@ -1,9 +1,9 @@
#include "CCApiMarketDataProvider.h"
#include "domain/protobufs/venue.pb.h"
#include "logging/logging.h"
#include "spark/api/md/MarketDataConfig.pb.h"
#include "spark/config/config.h"
#include "spark/io/ProtoPrinter.h"
#include "spark/logging/logging.h"
#include "spark/md/GeneralMarketDataListener.h"
#include "spark/md/GeneralSecurityIndex.h"
#include "spark/md/MDProducer.h"
@@ -9,6 +9,7 @@
#include <ccapi_cpp/ccapi_macro.h>
#include <ccapi_cpp/ccapi_message.h>
#include <ccapi_cpp/ccapi_session.h>
#include <exception>
#include <vector>
namespace bts::md {
@@ -32,8 +33,20 @@ static bool parse(const ccapi::Message &msg, domain::Book &book) {
// ["ASK_PRICE", "ASK_SIZE"]
const auto &props = level.getNameValueMap();
for (const auto &[name, value] : props) {
bid_walker.parse_field(name, value) ||
ask_walker.parse_field(name, value);
if (value.empty()) {
LOG(md, Error,
"Received depth item with empty '{}' value. full_msg:\n{}",
name, msg.toStringPretty());
continue;
}
try {
bid_walker.parse_field(name, value) ||
ask_walker.parse_field(name, value);
} catch (const std::exception &ex) {
LOG(md, Fatal, "Error parsing depth update: {}\nmsg:\n{}",
std::string{ex.what()}, msg.toStringPretty());
bts_assert_msg(false, "Fatal error parsing depth update.");
}
}
}
@@ -1,6 +1,5 @@
#include "CCApiMessageLogger.h"
#include "spark/core/StringJoiner.h"
#include "system/time_stamp.h"
#include "system/string_joiner.h"
#include <fmt/format.h>
#include <range/v3/view.hpp>
@@ -1,5 +1,5 @@
#include "CCApiSession.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "sparkd/md/ccapi/CCApiCorrelationID.h"
#include "sparkd/md/ccapi/CCApiEventDemuxer.h"
#include "sparkd/md/ccapi/ICCApiMessageHandler.h"
@@ -1,8 +1,7 @@
#pragma once
#include "spark/core/NaN.h"
#include <cstdint>
#include <limits>
#include <nlohmann/json.hpp>
#include <vector>
@@ -24,8 +23,8 @@ namespace bts::md {
class CCApiTradeRecord {
public:
bool is_buyer_maker = false;
double last_price = core::NaN::value();
double last_size = core::NaN::value();
double last_price = std::numeric_limits<double>::quiet_NaN();
double last_size = std::numeric_limits<double>::quiet_NaN();
std::uint64_t trade_id = 0;
static std::vector<CCApiTradeRecord> parse(const ccapi::Message &source);
@@ -1,5 +1,5 @@
#include "CCDemoListener.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "sparkd/md/MarketDataError.h"
#include <functional>
@@ -25,7 +25,7 @@ void CCDemoListener::on_security_state(const domain::SecurityState &) {}
void CCDemoListener::on_security_statistics(
const domain::SecurityMarketDataStatistics &) {}
void CCDemoListener::on_book(const domain::Book &book) {
void CCDemoListener::on_book(const domain::Book &book, std::optional<utils::TimeStamp> ) {
auto bids = book[domain::Side::Buy];
auto asks = book[domain::Side::Sell];
size_t idx = 0;
@@ -11,7 +11,7 @@ class CCDemoListener : public IMarketDataListener {
void on_security_state(const domain::SecurityState &security_state) override;
void on_security_statistics(
const domain::SecurityMarketDataStatistics &security_stats) override;
void on_book(const domain::Book &book) override;
void on_book(const domain::Book &book, std::optional<utils::TimeStamp> ) override;
void on_trades(
const std::vector<domain::TradeRecord const *> &trades) override;
void on_rfqs(const std::vector<domain::RFQ const *> &rfqs) override;
@@ -1,7 +1,7 @@
#include "CoinbasePriceStatistics.h"
#include "domain/price.h"
#include "domain/quantity.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "domain/security_market_data_statistics.h"
#include "sparkd/md/ccapi/CCApiReader.h"
#include "system/json/json_dumper.h"
#include "system/json/json_reader.h"
@@ -1,6 +1,6 @@
#include "CoinbasePriceStatisticsAdaptor.h"
#include "domain/security_id.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "domain/security_market_data_statistics.h"
#include "spark/md/IMarketDataListener.h"
#include "sparkd/md/coinbase/CoinbasePriceStatistics.h"
@@ -3,7 +3,7 @@
#include "domain/protobufs/venue.pb.h"
#include "domain/security.h"
#include "domain/security_criteria.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "spark/persistence/IDGenerator.h"
#include "sparkd/md/ccapi/CCApiCorrelationID.h"
#include "sparkd/md/ccapi/CCApiMessageHandler.h"
@@ -2,7 +2,7 @@
#include "domain/protobufs/currency.pb.h"
#include "domain/quantity.h"
#include "domain/security.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "system/json/json_reader.h"
#include <ccapi_cpp/ccapi_message.h>
@@ -2,7 +2,7 @@
#include "domain/book.h"
#include "domain/book_level_comp.h"
#include "domain/security_id.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/utils/bts_assert.h"
@@ -1,7 +1,7 @@
#include "DeribitInstrumentStore.h"
#include "domain/protobufs/security_type.h"
#include "domain/security.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "spark/persistence/IDGenerator.h"
#include "spark/utils/bts_fatal.h"
#include "sparkd/md/deribit/DeribitCombo.h"
@@ -60,10 +60,10 @@
#include "domain/protobufs/venue.pb.h"
#include "domain/security.h"
#include "domain/security_criteria.h"
#include "logging/logging.h"
#include "spark/io/websocket/JsonRpcError.h"
#include "spark/io/websocket/JsonRpcHandler.h"
#include "spark/io/websocket/JsonRpcRequest.h"
#include "spark/logging/logging.h"
#include "sparkd/md/ccapi/CCApiCorrelationID.h"
#include "sparkd/md/ccapi/CCApiJsonRpcRequest.h"
#include "sparkd/md/ccapi/CCApiJsonRpcRouter.h"
@@ -2,12 +2,12 @@
#include "domain/protobufs/venue.pb.h"
#include "domain/security.h"
#include "domain/security_criteria.h"
#include "logging/logging.h"
#include "spark/api/md/DeribitMarketDataConfig.pb.h"
#include "spark/domain_model/Security.pb.h"
#include "spark/io/ProtoPrinter.h"
#include "spark/io/websocket/JsonRpcError.h"
#include "spark/io/websocket/JsonRpcRequest.h"
#include "spark/logging/logging.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/persistence/IDGenerator.h"
#include "sparkd/md/ccapi/CCApiCorrelationID.h"
@@ -1,7 +1,8 @@
#include "DeribitTickerAdaptor.h"
#include "domain/security_id.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "domain/security_market_data_statistics.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/utils/bts_assert.h"
#include "system/json/json_reader.h"
#include <nlohmann/json.hpp>
@@ -1,11 +1,12 @@
#include "EmumbaDeribitSubscription.h"
#include "spark/api/md/EmumbaDeribitMarketDataConfig.pb.h"
#include "spark/config/protos/system_config.pb.h"
#include "spark/utils/thread_manager.h"
#include "sparkd/md/emumba/EmumbaDeribitData.h"
#include "system/protobufs/system_config.pb.h"
namespace bts::md {
using bts::config::SystemConfig;
using bts::system::protobufs::SystemConfig;
using Path = boost::filesystem::path;
+2 -4
View File
@@ -1,11 +1,10 @@
#include "FTXFuture.h"
#include "domain/future_security.h"
#include "domain/protobufs/currency.pb.h"
#include "domain/protobufs/venue.pb.h"
#include "domain/security.h"
#include "spark/core/TableFormatter.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "system/json/json_reader.h"
#include "system/table_formatter.h"
#include <ccapi_cpp/ccapi_message.h>
#include <nlohmann/json.hpp>
@@ -18,7 +17,6 @@ namespace bts::md::ftx {
using bts::core::TableFormatter;
using bts::domain::FutureSecurity;
using bts::domain::Security;
using bts::domain::protobufs::Currency;
using bts::io::JsonReader;
using std::string;
using std::stringstream;
@@ -1,5 +1,5 @@
#include "FTXHistoricalPriceAdaptor.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "domain/security_market_data_statistics.h"
#include "spark/md/IMarketDataListener.h"
#include "sparkd/md/ftx/FTXHistoricalPriceRecord.h"
@@ -1,6 +1,6 @@
#include "FTXHistoricalPriceRecord.h"
#include "domain/price.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "domain/security_market_data_statistics.h"
#include "sparkd/md/ccapi/CCApiReader.h"
#include "system/json/json_reader.h"
+8 -7
View File
@@ -1,16 +1,17 @@
#include "FTXMarket.h"
#include "domain/protobufs/venue.pb.h"
#include "domain/security.h"
#include "spark/core/NaN.h"
#include "spark/core/TableFormatter.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "spark/utils/bts_fatal.h"
#include "sparkd/md/ftx/FTXSecurityType.h"
#include "system/json/json_reader.h"
#include "system/nan.h"
#include "system/table_formatter.h"
#include <ccapi_cpp/ccapi_element.h>
#include <ccapi_cpp/ccapi_macro.h>
#include <ccapi_cpp/ccapi_message.h>
#include <limits>
#include <nlohmann/json.hpp>
#include <regex>
@@ -133,11 +134,11 @@ void from_json(const nlohmann::json &j, FTXMarket &mkt) {
jr.read("minProvideSize", mkt.min_provide_size);
jr.read("enabled", mkt.enabled);
jr.read_or("ask", mkt.ask, NaN::value());
jr.read_or("bid", mkt.bid, NaN::value());
jr.read_or("last", mkt.last, NaN::value());
jr.read_or("ask", mkt.ask, std::numeric_limits<double>::quiet_NaN());
jr.read_or("bid", mkt.bid, std::numeric_limits<double>::quiet_NaN());
jr.read_or("last", mkt.last, std::numeric_limits<double>::quiet_NaN());
jr.read("postOnly", mkt.post_only);
jr.read_or("price", mkt.price, NaN::value());
jr.read_or("price", mkt.price, std::numeric_limits<double>::quiet_NaN());
jr.read("priceIncrement", mkt.price_increment);
jr.read("sizeIncrement", mkt.size_increment);
jr.read("restricted", mkt.restricted);
@@ -3,7 +3,7 @@
#include "domain/protobufs/venue.pb.h"
#include "domain/security.h"
#include "domain/security_criteria.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "spark/persistence/IDGenerator.h"
#include "sparkd/md/ccapi/CCApiCorrelationID.h"
#include "sparkd/md/ccapi/CCApiMessageHandler.h"
@@ -2,9 +2,9 @@
#include "domain/protobufs/venue.pb.h"
#include "domain/security.h"
#include "domain/security_criteria.h"
#include "logging/logging.h"
#include "spark/api/md/FTXMarketDataConfig.pb.h"
#include "spark/io/ProtoPrinter.h"
#include "spark/logging/logging.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/persistence/IDGenerator.h"
#include "sparkd/md/ccapi/CCApiCorrelationID.h"
@@ -1,8 +1,8 @@
#include "OnixsGlbxSubscription.h"
#include "logging/logging.h"
#include "spark/api/md/MarketDataConfig.pb.h"
#include "spark/api/md/MarketDataConfigUtils.h"
#include "spark/config/config.h"
#include "spark/logging/logging.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/md/MBOProcessor.h"
#include "spark/md/SymbolLoader.h"
@@ -49,7 +49,7 @@ static inline std::ostream &fmt_ladder(
LiveLadderPrinter::LiveLadderPrinter(std::ostream *out) : out_ptr_(out) {}
void LiveLadderPrinter::on_book(const domain::Book &book) {
void LiveLadderPrinter::on_book(const domain::Book &book, std::optional<utils::TimeStamp>) {
auto bids = book[domain::Side::Buy];
auto asks = book[domain::Side::Sell];
if (bids.is_populated() || asks.is_populated()) {
@@ -1,5 +1,6 @@
#pragma once
#include "spark/utils/bts_assert.h"
#include "sparkd/md/MarketDataError.h"
#include "sparkd/md/MarketDataListener.h"
@@ -12,7 +13,7 @@ class LiveLadderPrinter : public MarketDataListener {
public:
explicit LiveLadderPrinter(std::ostream *out = &std::cout);
void on_book(const domain::Book &book) override;
void on_book(const domain::Book &book, std::optional<utils::TimeStamp>) override;
void on_error(const MarketDataError &error) override;
private:
@@ -2,7 +2,7 @@
#include "domain/book.h"
#include "domain/book_level_comp.h"
#include "domain/security_id.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "spark/md/IMarketDataListener.h"
#include "sparkd/md/ccapi/CCApiCorrelationID.h"
#include "system/json/json_reader.h"
@@ -1,7 +1,7 @@
#include "OkxInstrumentStore.h"
#include "domain/protobufs/security_type.h"
#include "domain/security.h"
#include "spark/logging/logging.h"
#include "logging/logging.h"
#include "spark/persistence/IDGenerator.h"
#include "spark/utils/bts_fatal.h"
#include "sparkd/md/okx/OkxInstrument.h"
@@ -2,9 +2,9 @@
#include "domain/protobufs/venue.pb.h"
#include "domain/security.h"
#include "domain/security_criteria.h"
#include "logging/logging.h"
#include "spark/api/md/OkxMarketDataConfig.pb.h"
#include "spark/io/ProtoPrinter.h"
#include "spark/logging/logging.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/persistence/IDGenerator.h"
#include "sparkd/md/ccapi/CCApiSession.h"
@@ -1,7 +1,7 @@
#include "OkxTickerAdaptor.h"
#include "domain/price.h"
#include "domain/security_id.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "domain/security_market_data_statistics.h"
#include "spark/md/IMarketDataListener.h"
#include "sparkd/md/ccapi/CCApiCorrelationID.h"
#include "sparkd/md/okx/OkxTicker.h"
@@ -1,8 +1,8 @@
#include "EmMDListener.h"
#include "domain/protobufs/trading_status.pb.h"
#include "logging/logging.h"
#include "spark/api/services/ShellDiagnosticService.server.pb.h"
#include "spark/domain_model/Security.pb.h"
#include "spark/logging/logging.h"
#include "spark/md/GeneralSecurityIndex.h"
#include "spark/md/IntPrice.h"
#include "spark/md/MDProducer.h"
@@ -1,9 +1,8 @@
#include "EmumbaMain.h"
#include "EMTradingSession.h"
#include "EmMDListener.h"
#include "logging/logging.h"
#include "spark/config/config.h"
#include "spark/config/protos/system_config.pb.h"
#include "spark/logging/logging.h"
#include "spark/md/GeneralSecurityIndex.h"
#include "spark/md/MDProducer.h"
#include "spark/md/SecurityDB.h"
@@ -17,6 +16,7 @@
#include "spark/utils/proto_helper.h"
#include "spark/utils/thread_manager.h"
#include "sparkd/cmds/crypto/DeribitDemoConfiguration.h"
#include "system/protobufs/system_config.pb.h"
#include <boost/filesystem.hpp>
#include <emumba-deribit-connector/deribit_listener.h>
@@ -30,7 +30,7 @@ using namespace bts::orderman;
namespace bts::md {
using bts::config::SystemConfig;
using bts::system::protobufs::SystemConfig;
using Path = boost::filesystem::path;
struct EmumbaMain::PImpl {
@@ -1,9 +1,11 @@
#pragma once
#include "logging/logging.h"
#include "spark/domain_model/Security.pb.h"
#include "spark/logging/logging.h"
#include "spark/md/common.h"
#include "spark/orderman/RFQMsg.h"
#include "spark/os/os.h"
#include <boost/container/small_vector.hpp>
#include <emumba-deribit-connector/deribit_handler.h>
#include <emumba-deribit-connector/deribit_listener.h>
@@ -13,8 +13,8 @@
#include "spark/utils/proto_helper.h"
#include "spark/config/protos/market_data.pb.h"
#include "spark/config/protos/system_config.pb.h"
#include "spark/utils/thread_manager.h"
#include "system/protobufs/system_config.pb.h"
#include <boost/filesystem.hpp>
#include <memory>
@@ -43,7 +43,7 @@ namespace bts {
namespace md {
namespace ice {
using bts::config::SystemConfig;
using bts::system::protobufs::SystemConfig;
using Path = boost::filesystem::path;
ICEMain::ICEMain()
@@ -1,8 +1,8 @@
#include "MDP3Main.h"
#include "domain/protobufs/trading_status.pb.h"
#include "logging/logging.h"
#include "spark/config/config.h"
#include "spark/logging/logging.h"
#include "spark/md/MBOProcessor.h"
#include "spark/md/SecurityDB.h"
#include "spark/md/cme/MDP3Utils.h"
@@ -14,7 +14,6 @@
#include "spark/utils/proto_helper.h"
#include "spark/config/protos/market_data.pb.h"
#include "spark/config/protos/system_config.pb.h"
#include "spark/utils/thread_manager.h"
#include <boost/filesystem.hpp>
@@ -1,12 +1,11 @@
#include "MDRecorder.h"
#include "logging/logging.h"
#include "spark/api/md/MarketDataConfig.pb.h"
#include "spark/api/md/MarketDataConfigUtils.h"
#include "spark/api/services/MarketDataRelay.client.pb.h"
#include "spark/api/services/MarketDataRelay.pb.h"
#include "spark/config/config.h"
#include "spark/config/protos/system_config.pb.h"
#include "spark/domain_model/Security.pb.h"
#include "spark/logging/logging.h"
#include "spark/md/MDClient.h"
#include "spark/md/MDConsumer.h"
#include "spark/md/MDConsumerHandle.h"
@@ -18,6 +17,7 @@
#include "spark/utils/bts_assert.h"
#include "spark/utils/datetime.h"
#include "spark/utils/thread_manager.h"
#include "system/protobufs/system_config.pb.h"
#include "system/time_stamp.h"
#include <array>
@@ -30,7 +30,7 @@
namespace bts::md::recording {
using bts::config::SystemConfig;
using bts::system::protobufs::SystemConfig;
using Path = boost::filesystem::path;
std::string MDRecorder::file_start_seq = "marketdata";
@@ -5,12 +5,12 @@
#include "domain/security.h"
#include "domain/security_common.h"
#include "domain/security_id.h"
#include "domain/security_market_data_statistics.h"
#include "domain/side.h"
#include "domain/trade_record.h"
#include "logging/logging.h"
#include "spark/domain/DomainSecurityUtils.h"
#include "spark/domain/SecurityMarketDataStatistics.h"
#include "spark/domain_model/Security.pb.h"
#include "spark/logging/logging.h"
#include "spark/md/GeneralMarketDataListener.h"
#include "spark/md/IMarketDataListener.h"
#include "spark/md/MDProducer.h"
@@ -22,6 +22,7 @@
#include "sparkd/md/recording/MDRecorder.h"
#include "system/time_stamp.h"
#include <cstdint>
#include <fstream>
#include <string>
@@ -56,10 +57,14 @@ struct MDReplayer ::PImpl {
std::set<uint32_t> sec_keys = {};
uint64_t start_time = 0;
std::shared_ptr<IMarketDataListener> listener{nullptr};
PImpl(bts::api::Venue venue) : venue(venue) {}
double replay_speed;
PImpl(bts::api::Venue venue, double replay_speed)
: venue(venue), replay_speed(replay_speed) {}
};
MDReplayer::MDReplayer(bts::api::Venue venue) : me(new PImpl(venue)) {
MDReplayer::MDReplayer(bts::api::Venue venue, double replay_speed)
: me(new PImpl(venue, replay_speed)) {
LOG(md, Info, "MDReplayer::MDReplayer venue: {}", Venue_Name(venue));
}
@@ -98,6 +103,7 @@ void MDReplayer::_replay_file_once(const std::string &file_name) {
int i = 0;
uint64_t beg_ns = bts::core::TimeStamp::now_ns();
uint64_t last_msg_ts = 0;
double replay_speed = me->replay_speed > 0 ? me->replay_speed: 1;
while (!in.eof() && utils::pb::readbuf(in, &rec_msg)) {
if (i++ == 0) {
last_msg_ts = rec_msg.timestamp();
@@ -107,8 +113,9 @@ void MDReplayer::_replay_file_once(const std::string &file_name) {
uint64_t this_msg_ts = rec_msg.timestamp();
bts_assert(this_msg_ts >= last_msg_ts);
uint64_t ts_diff = this_msg_ts - last_msg_ts;
uint64_t adjusted_ts = ts_diff/replay_speed;
last_msg_ts = this_msg_ts;
std::this_thread::sleep_for(std::chrono::nanoseconds(ts_diff));
std::this_thread::sleep_for(std::chrono::nanoseconds(adjusted_ts));
_replay_message(rec_msg);
}
log_progress(i);
@@ -147,7 +154,7 @@ void MDReplayer::_replay_message(const bts::co2::RecordedMDMessage &m) {
break;
}
case (co2::RecordedMDMessage::MDRecordCase::kMisc): {
bts::domain::SecurityMarketDataStatistics stats(m.sec_key(), m.misc());
auto stats = domain::DomainSecurityUtils::convert(m.sec_key(), m.misc());
me->listener->on_security_statistics(stats);
break;
}
Loaded 100 of 473 files, more files were not shown because too many files have changed in this diff. Show more