Compare commits
303
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9bfd33320e | ||
|
|
f7a2693952 | ||
|
|
d573447d64 | ||
|
|
ccd7d29501 | ||
|
|
291699fb9b | ||
|
|
056e0f8aa7 | ||
|
|
45ed583d46 | ||
|
|
54a2131b20 | ||
|
|
a4bbb6c88b | ||
|
|
e6c2ceb931 | ||
|
|
c43ec4a56d | ||
|
|
b871cc4e09 | ||
|
|
6aec729b6a | ||
|
|
025625e0b9 | ||
|
|
5c5bc243d2 | ||
|
|
0d0af32b85 | ||
|
|
46c2d2e916 | ||
|
|
ff6d0f0e1b | ||
|
|
86ca092f18 | ||
|
|
ec3d642cee | ||
|
|
7489d70c95 | ||
|
|
81bb5404cb | ||
|
|
a0155beb83 | ||
|
|
c2f8e92b10 | ||
|
|
7ae0142dff | ||
|
|
780b74fc56 | ||
|
|
78bc14348d | ||
|
|
52bc0f1a17 | ||
|
|
c52c24c3f2 | ||
|
|
0d9277bf6a | ||
|
|
761797dc24 | ||
|
|
39a560c394 | ||
|
|
b4f01da8d8 | ||
|
|
f7ca1efdb8 | ||
|
|
1b4ed339d6 | ||
|
|
5af89e0124 | ||
|
|
1fddbf1cca | ||
|
|
1cd1a23c80 | ||
|
|
b987ec6a8a | ||
|
|
f509026815 | ||
|
|
557b658146 | ||
|
|
e3c4960622 | ||
|
|
350b4307dc | ||
|
|
762ca47a59 | ||
|
|
79b83ba494 | ||
|
|
51f5155a1a | ||
|
|
d0b3124813 | ||
|
|
29128dd014 | ||
|
|
9e8f5809c3 | ||
|
|
7e2001744c | ||
|
|
f5b83efade | ||
|
|
aedb9d2ae1 | ||
|
|
5ccd28d84d | ||
|
|
3320888fc8 | ||
|
|
456e9bf357 | ||
|
|
275a757eb7 | ||
|
|
d51d170891 | ||
|
|
87d138740f | ||
|
|
625f165a63 | ||
|
|
8421ed0ae9 | ||
|
|
2a03eb323d | ||
|
|
cac6a9cd53 | ||
|
|
a148b8fdcb | ||
|
|
d635e8a978 | ||
|
|
7aadd38934 | ||
|
|
b63b11982b | ||
|
|
88a4d2ed80 | ||
|
|
26bdef7ddd | ||
|
|
db0ffba8ed | ||
|
|
a274a214b4 | ||
|
|
bbcfa3c75a | ||
|
|
89229d65f1 | ||
|
|
0e75cde409 | ||
|
|
42fa6dfaff | ||
|
|
400143c84d | ||
|
|
e915945880 | ||
|
|
ca6673e98f | ||
|
|
479f3dccff | ||
|
|
9601ebab20 | ||
|
|
c272d8a8c2 | ||
|
|
b344ab3377 | ||
|
|
ae3080b031 | ||
|
|
f0464331cb | ||
|
|
0648b618bf | ||
|
|
59282b8c70 | ||
|
|
34a86009ce | ||
|
|
0ad9ae9001 | ||
|
|
a296e1e772 | ||
|
|
7f53d8b161 | ||
|
|
fbd8bbd4a8 | ||
|
|
3da52b350f | ||
|
|
243d6827d4 | ||
|
|
00221f9bd9 | ||
|
|
a6171ae405 | ||
|
|
be5d01a797 | ||
|
|
e5d9d324bf | ||
|
|
c34dee9d96 | ||
|
|
e5a98aab41 | ||
|
|
10cd35372b | ||
|
|
ad4515be39 | ||
|
|
ff4d87dd6b | ||
|
|
8ddde3f9da | ||
|
|
51093dc3a5 | ||
|
|
5d5db9ad9f | ||
|
|
fca808fe0d | ||
|
|
07d14f877b | ||
|
|
5ea6dccdd4 | ||
|
|
ac956a5c02 | ||
|
|
1fba09cf94 | ||
|
|
0baa6b875e | ||
|
|
cdacc2d4d4 | ||
|
|
1433541947 | ||
|
|
1070ca7ace | ||
|
|
56fa27dd7e | ||
|
|
d87b522bc6 | ||
|
|
166cb03782 | ||
|
|
40bad84c48 | ||
|
|
c3786d9d64 | ||
|
|
9080e3124b | ||
|
|
d9c536124a | ||
|
|
7de6b2907e | ||
|
|
75f017e9f8 | ||
|
|
7757ab3ea0 | ||
|
|
3186dd383c | ||
|
|
45f751c9c6 | ||
|
|
e4d3774980 | ||
|
|
eedb3ce05d | ||
|
|
6a7d38c0fd | ||
|
|
7f9967834d | ||
|
|
31ccbfcd19 | ||
|
|
c2abf90cc4 | ||
|
|
8dc4735248 | ||
|
|
d940d9f11d | ||
|
|
1e0c75c6c7 | ||
|
|
fbaa17bc40 | ||
|
|
38e3cd6197 | ||
|
|
3bb9961af4 | ||
|
|
da8088fd8d | ||
|
|
748a65f671 | ||
|
|
66d80136bd | ||
|
|
10386311d4 | ||
|
|
629a7f8130 | ||
|
|
81189bb2cc | ||
|
|
e5681a50f2 | ||
|
|
69fe4569e3 | ||
|
|
faedb0a49e | ||
|
|
c7caf66f9c | ||
|
|
14504f4a94 | ||
|
|
5b601a4016 | ||
|
|
e3207b921a | ||
|
|
d148255917 | ||
|
|
98db8e61a5 | ||
|
|
45aa75e8bb | ||
|
|
b2471d45b2 | ||
|
|
11e2df8c76 | ||
|
|
cba6852655 | ||
|
|
5eeaedde26 | ||
|
|
b63052dbaa | ||
|
|
29f5bc798e | ||
|
|
04603acbb9 | ||
|
|
bc6890055e | ||
|
|
ea94c09c78 | ||
|
|
00b1d3c51c | ||
|
|
e3c3bc78fc | ||
|
|
a11d390dcd | ||
|
|
7c74a961d4 | ||
|
|
5db21ad2ca | ||
|
|
b68c963b5e | ||
|
|
a43070f812 | ||
|
|
f703dabdfe | ||
|
|
237d3eea4b | ||
|
|
e009316bfb | ||
|
|
5528efd2d2 | ||
|
|
818bdec130 | ||
|
|
09f91735fe | ||
|
|
d9fc18547b | ||
|
|
d257cf2c77 | ||
|
|
079f46404f | ||
|
|
f6b5ab040c | ||
|
|
86ddf3078d | ||
|
|
bc4fe19bdb | ||
|
|
edcc73e934 | ||
|
|
5905ca3e92 | ||
|
|
bb259b128a | ||
|
|
bc7ac8523b | ||
|
|
0c4c2b7231 | ||
|
|
420351c093 | ||
|
|
f69e6b89c5 | ||
|
|
c3e22e4b23 | ||
|
|
1d443531fd | ||
|
|
54e5a68730 | ||
|
|
880c95d92b | ||
|
|
40956c5335 | ||
|
|
44aba08978 | ||
|
|
9ec1c8fdae | ||
|
|
3231ffb343 | ||
|
|
8d7f1738cf | ||
|
|
9101214e66 | ||
|
|
59774ccbb5 | ||
|
|
fcb6c9b8d9 | ||
|
|
c6b2e2f21e | ||
|
|
2eac97c1a9 | ||
|
|
b4b0e10f29 | ||
|
|
38d9db4a90 | ||
|
|
6a679ff78c | ||
|
|
aba3f21020 | ||
|
|
fede19fd11 | ||
|
|
0508858859 | ||
|
|
3fa8dbf112 | ||
|
|
77ae4703b3 | ||
|
|
e840b9617f | ||
|
|
19ee603413 | ||
|
|
a28bfa1175 | ||
|
|
4e4a48283d | ||
|
|
7a761d00ce | ||
|
|
968be6a99a | ||
|
|
03404eb3f1 | ||
|
|
ff1a970982 | ||
|
|
ed890b4d84 | ||
|
|
e87003cc41 | ||
|
|
bc06037843 | ||
|
|
c4c7cebfc5 | ||
|
|
f18bcd2995 | ||
|
|
a6a1b6ac53 | ||
|
|
8c3da4e43c | ||
|
|
06b955dceb | ||
|
|
e75d15146c | ||
|
|
cb07384c9f | ||
|
|
fc9e502539 | ||
|
|
fcbf3388c0 | ||
|
|
899bea940f | ||
|
|
14b7509607 | ||
|
|
25668e8df0 | ||
|
|
5345ba8ff8 | ||
|
|
515ed5aabd | ||
|
|
12e068a3d1 | ||
|
|
8268599893 | ||
|
|
9bf05973bd | ||
|
|
cea4d05bc4 | ||
|
|
0b7208784b | ||
|
|
059ccbdab6 | ||
|
|
75eaf8c3d4 | ||
|
|
1e8fcd794f | ||
|
|
726329c4bf | ||
|
|
2d01f3f0f4 | ||
|
|
2a595c0fd7 | ||
|
|
5f9866c9e8 | ||
|
|
6365378947 | ||
|
|
78f1cf88e0 | ||
|
|
4877436877 | ||
|
|
78d238fdfb | ||
|
|
1b43124756 | ||
|
|
a1feb3fddf | ||
|
|
024328bf8b | ||
|
|
d90fa1a1e8 | ||
|
|
3e817d4fb0 | ||
|
|
80d7e34bf1 | ||
|
|
8ab69c919b | ||
|
|
99531bcfa0 | ||
|
|
6bd516d4f2 | ||
|
|
1a1d771e1b | ||
|
|
050fcf7c6e | ||
|
|
aa6d453d5b | ||
|
|
112c78e50b | ||
|
|
41ec7fb668 | ||
|
|
b19bf2fd26 | ||
|
|
c5f7477521 | ||
|
|
14323e7964 | ||
|
|
aadeae3201 | ||
|
|
b72e8aed02 | ||
|
|
39db9b1bd7 | ||
|
|
0820cc3e9a | ||
|
|
b1ba9a1315 | ||
|
|
991a199d06 | ||
|
|
39ce4323a1 | ||
|
|
d9fcd290d9 | ||
|
|
9d045f65d2 | ||
|
|
05939b02c5 | ||
|
|
aa91638fe4 | ||
|
|
1c0cd176a1 | ||
|
|
1018ae387a | ||
|
|
065fc54f73 | ||
|
|
95fb13f58b | ||
|
|
4eb2931cb8 | ||
|
|
5326015a48 | ||
|
|
fcbe319470 | ||
|
|
5ad21c88b2 | ||
|
|
3a9c1d557b | ||
|
|
6fb5b83249 | ||
|
|
95830fafdf | ||
|
|
d68b03bb91 | ||
|
|
e7062ce01e | ||
|
|
932738f98e | ||
|
|
1426b00e83 | ||
|
|
e724409b58 | ||
|
|
9cf828e9a4 | ||
|
|
41408fb609 | ||
|
|
4c21e32838 | ||
|
|
385f3ea402 | ||
|
|
8d6d8cab18 | ||
|
|
01615f824a | ||
|
|
c6779ddc90 | ||
|
|
46eff65435 |
No files matched your search
Vendored
+9
-5
@@ -8,13 +8,15 @@
|
||||
"program": "${workspaceRoot}/build/ninja_debug/server/sparkd",
|
||||
"args": [
|
||||
"run",
|
||||
// "test",
|
||||
// "-a",
|
||||
// "[ilink3]"
|
||||
"test",
|
||||
"-a",
|
||||
"OutrightVanillaOrder"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}/build/ninja_debug/server/",
|
||||
"environment": [],
|
||||
"environment": [
|
||||
{ "name": "TZ", "value": "America/Chicago" }
|
||||
],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
@@ -31,7 +33,9 @@
|
||||
"request": "launch",
|
||||
"program": "/home/bts/spark/build/ninja_debug/server/sparkd",
|
||||
"args": [
|
||||
"run"
|
||||
"test",
|
||||
"-a",
|
||||
"[ilink3]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/ninja_debug/server/",
|
||||
|
||||
@@ -41,6 +41,7 @@ else ()
|
||||
-Wno-missing-braces -Wno-ignored-qualifiers \
|
||||
--std=c++17 -fdiagnostics-color")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -DNDEBUG -O3")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wno-undef")
|
||||
add_subdirectory(src/server/sparkd)
|
||||
add_subdirectory(src/lib)
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
using bts.api;
|
||||
using bts.api.core;
|
||||
using bts.api.orderman;
|
||||
using bts.utils;
|
||||
using mbts.spark.utilities;
|
||||
using bts.api;
|
||||
using bts.api.core;
|
||||
using bts.api.orderman;
|
||||
using bts.utils;
|
||||
using mbts.spark.utilities;
|
||||
using mbts.ui.utility;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
namespace mbts.spark {
|
||||
interface IAlgoProvider {
|
||||
AlgoTypeSetImmutable get_permitted_algos(SecurityImmutable security);
|
||||
AlgoTypeSetImmutable get_permitted_algos(SecurityCriteriaClause clause);
|
||||
IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_algos();
|
||||
IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_algos(SecurityImmutable security);
|
||||
IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_algos(SecurityCriteriaClause clause);
|
||||
}
|
||||
|
||||
// This interface is used to distinguish the attachable algo provider
|
||||
// from the standard one wrt MEF export/import.
|
||||
interface IAttachableAlgoProvider : IAlgoProvider { }
|
||||
|
||||
class AlgoProvider : IAlgoProvider {
|
||||
readonly IEnumerable<SecurityAlgoTypeSetImmutable> _security_algo_types;
|
||||
readonly IAlgoStudioModel _studio_model;
|
||||
readonly ISecurityAuxiliaryDataModel _security_auxiliary_model;
|
||||
readonly IObservable<TableUpdate<AlgoData, AlgoKey>> _studio_algos_source;
|
||||
readonly DynamicOrderHelper _dynamic_helper;
|
||||
readonly AlgoTypeSetImmutable _full_set;
|
||||
|
||||
public AlgoProvider(IEnumerable<SecurityAlgoTypeSetImmutable> algo_sets, IAlgoStudioModel studio_model, DynamicOrderHelper dynamic_helper, ISecurityAuxiliaryDataModel security_auxiliary_model) {
|
||||
_security_algo_types = algo_sets;
|
||||
_studio_model = studio_model;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
namespace mbts.spark {
|
||||
interface IAlgoProvider {
|
||||
AlgoTypeSetImmutable get_permitted_algos(SecurityImmutable security);
|
||||
AlgoTypeSetImmutable get_permitted_algos(SecurityCriteriaClause clause);
|
||||
IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_algos();
|
||||
IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_algos(SecurityImmutable security);
|
||||
IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_algos(SecurityCriteriaClause clause);
|
||||
}
|
||||
|
||||
// This interface is used to distinguish the attachable algo provider
|
||||
// from the standard one wrt MEF export/import.
|
||||
interface IAttachableAlgoProvider : IAlgoProvider { }
|
||||
|
||||
class AlgoProvider : IAlgoProvider {
|
||||
readonly IEnumerable<SecurityAlgoTypeSetImmutable> _security_algo_types;
|
||||
readonly IAlgoStudioModel _studio_model;
|
||||
readonly ISecurityAuxiliaryDataModel _security_auxiliary_model;
|
||||
readonly IObservable<TableUpdate<AlgoData, AlgoKey>> _studio_algos_source;
|
||||
readonly DynamicOrderHelper _dynamic_helper;
|
||||
readonly AlgoTypeSetImmutable _full_set;
|
||||
|
||||
public AlgoProvider(IEnumerable<SecurityAlgoTypeSetImmutable> algo_sets, IAlgoStudioModel studio_model, DynamicOrderHelper dynamic_helper, ISecurityAuxiliaryDataModel security_auxiliary_model) {
|
||||
_security_algo_types = algo_sets;
|
||||
_studio_model = studio_model;
|
||||
_dynamic_helper = dynamic_helper;
|
||||
_full_set = new AlgoTypeSetImmutable(
|
||||
ImmutableHashSet.CreateRange(
|
||||
@@ -51,42 +51,42 @@ namespace mbts.spark {
|
||||
_studio_algos_source = studio_model.definitions
|
||||
.StartWith(TableUpdate<AlgoData, AlgoKey>.mk_empty(AlgoData.key_fn))
|
||||
.Cache();
|
||||
}
|
||||
|
||||
public AlgoTypeSetImmutable get_permitted_algos(SecurityImmutable security) =>
|
||||
_security_algo_types.Where(p => p.security_criteria.includes(security))
|
||||
.Select(sec_algos => sec_algos.algo_type_set)
|
||||
.Aggregate(_full_set, (result, algos) => result.intersect_with(algos));
|
||||
|
||||
public AlgoTypeSetImmutable get_permitted_algos(SecurityCriteriaClause clause) =>
|
||||
_security_algo_types.Where(p => p.security_criteria.is_subset_of(clause))
|
||||
.Select(sec_algos => sec_algos.algo_type_set)
|
||||
.Aggregate(_full_set, (result, algos) => result.intersect_with(algos));
|
||||
|
||||
public IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_algos() =>
|
||||
_studio_algos_source
|
||||
.AppendTable(_security_algo_types
|
||||
.Select(s => s.algo_type_set)
|
||||
.Aggregate(AlgoTypeSetImmutable.empty, (a, b) => a.union_with(b))
|
||||
.define_algos(_dynamic_helper));
|
||||
|
||||
public IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_algos(SecurityCriteriaClause security_clause) {
|
||||
var system_algos = _security_algo_types.match_algos(
|
||||
security_clause,
|
||||
_dynamic_helper,
|
||||
def => _fit_to_type(def, security_clause, _security_algo_types));
|
||||
|
||||
return _studio_algos_source.Select(
|
||||
a => (algo: a, fitted_def: _fit_to_type(a.value, security_clause, _security_algo_types)),
|
||||
tup => tup.algo.key)
|
||||
.Select(tup => AlgoData.create(tup.fitted_def, tup.algo.name, tup.algo.key), a => a.key)
|
||||
.AppendTable(system_algos.Values);
|
||||
}
|
||||
|
||||
public IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_algos(SecurityImmutable security) {
|
||||
var clause = new SecurityCriteriaClause(
|
||||
exchanges: new[] { security.Exchange },
|
||||
security_types: new[] { security.security_type() });
|
||||
}
|
||||
|
||||
public AlgoTypeSetImmutable get_permitted_algos(SecurityImmutable security) =>
|
||||
_security_algo_types.Where(p => p.security_criteria.includes(security))
|
||||
.Select(sec_algos => sec_algos.algo_type_set)
|
||||
.Aggregate(_full_set, (result, algos) => result.intersect_with(algos));
|
||||
|
||||
public AlgoTypeSetImmutable get_permitted_algos(SecurityCriteriaClause clause) =>
|
||||
_security_algo_types.Where(p => p.security_criteria.is_subset_of(clause))
|
||||
.Select(sec_algos => sec_algos.algo_type_set)
|
||||
.Aggregate(_full_set, (result, algos) => result.intersect_with(algos));
|
||||
|
||||
public IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_algos() =>
|
||||
_studio_algos_source
|
||||
.AppendTable(_security_algo_types
|
||||
.Select(s => s.algo_type_set)
|
||||
.Aggregate(AlgoTypeSetImmutable.empty, (a, b) => a.union_with(b))
|
||||
.define_algos(_dynamic_helper));
|
||||
|
||||
public IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_algos(SecurityCriteriaClause security_clause) {
|
||||
var system_algos = _security_algo_types.match_algos(
|
||||
security_clause,
|
||||
_dynamic_helper,
|
||||
def => _fit_to_type(def, security_clause, _security_algo_types));
|
||||
|
||||
return _studio_algos_source.Select(
|
||||
a => (algo: a, fitted_def: _fit_to_type(a.value, security_clause, _security_algo_types)),
|
||||
tup => tup.algo.key)
|
||||
.Select(tup => AlgoData.create(tup.fitted_def, tup.algo.name, tup.algo.key), a => a.key)
|
||||
.AppendTable(system_algos.Values);
|
||||
}
|
||||
|
||||
public IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_algos(SecurityImmutable security) {
|
||||
var clause = new SecurityCriteriaClause(
|
||||
exchanges: new[] { security.Exchange },
|
||||
security_types: new[] { security.security_type() });
|
||||
// i.e., non-studio algos
|
||||
var system_algos = _security_algo_types.match_algos(
|
||||
clause,
|
||||
@@ -94,135 +94,141 @@ namespace mbts.spark {
|
||||
def => _fit_to_type(def, security, _security_algo_types),
|
||||
_security_auxiliary_model.get_display_quantity_divisor(security));
|
||||
|
||||
return _studio_algos_source.Select(
|
||||
a => (algo: a, fitted_def: _fit_to_type(a.value, security, _security_algo_types)),
|
||||
tup => tup.algo.key)
|
||||
// filter out algos that use an unsupported root, because this would have the effect of duplicating the default algo
|
||||
// (e.g., GlbxIceberg orders would be converted to Limit/Spreader orders for non-Glbx securities).
|
||||
.Filter(tup => tup.fitted_def.actual().CustomCase == tup.algo.value.actual().CustomCase, tup => tup.algo.key)
|
||||
.Select(tup => AlgoData.create(tup.fitted_def, tup.algo.name, tup.algo.key), AlgoData.key_fn)
|
||||
return _studio_algos_source.Select(
|
||||
a => (algo: a, fitted_def: _fit_to_type(a.value, security, _security_algo_types)),
|
||||
tup => tup.algo.key)
|
||||
// filter out algos that use an unsupported root, because this would have the effect of duplicating the default algo
|
||||
// (e.g., GlbxIceberg orders would be converted to Limit/Spreader orders for non-Glbx securities).
|
||||
.Filter(tup => tup.fitted_def.actual().CustomCase == tup.algo.value.actual().CustomCase, tup => tup.algo.key)
|
||||
.Select(tup => AlgoData.create(tup.fitted_def, tup.algo.name, tup.algo.key), AlgoData.key_fn)
|
||||
.AppendTable(system_algos.Values);
|
||||
}
|
||||
|
||||
protected virtual void assign_fallback_algo(CustomOrderDefinition mdef, SecurityCriteriaClause security_clause) {
|
||||
if (security_clause.security_types.empty_if_null().Contains(Security.ContractOneofCase.Synthetic.security_type())) {
|
||||
mdef.Spreader = new SpreaderOrderDefinition();
|
||||
} else {
|
||||
mdef.Limit = new LimitOrderDefinition();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void assign_fallback_algo(CustomOrderDefinition mdef, SecurityImmutable security) {
|
||||
if (security.ContractCase == Security.ContractOneofCase.Synthetic) {
|
||||
mdef.Spreader = new SpreaderOrderDefinition {
|
||||
Security = security.CloneToMutable()
|
||||
};
|
||||
} else {
|
||||
mdef.Limit = new LimitOrderDefinition();
|
||||
}
|
||||
}
|
||||
|
||||
CustomOrderDefinitionImmutable _fit_to_type(CustomOrderDefinitionImmutable defi, SecurityCriteriaClause security_clause, IEnumerable<SecurityAlgoTypeSetImmutable> algo_sets) {
|
||||
var mroot = defi.CloneToMutable();
|
||||
if (_fit_to_type(mroot, security_clause, algo_sets)) {
|
||||
defi = new CustomOrderDefinitionImmutable(mroot);
|
||||
}
|
||||
return defi;
|
||||
}
|
||||
|
||||
CustomOrderDefinitionImmutable _fit_to_type(CustomOrderDefinitionImmutable defi, SecurityImmutable security, IEnumerable<SecurityAlgoTypeSetImmutable> algo_sets) {
|
||||
var mroot = defi.CloneToMutable();
|
||||
if (_fit_to_type(mroot, security, algo_sets)) {
|
||||
defi = new CustomOrderDefinitionImmutable(mroot);
|
||||
}
|
||||
return defi;
|
||||
}
|
||||
|
||||
bool _fit_to_type(CustomOrderDefinition mdef, SecurityCriteriaClause security_clause, IEnumerable<SecurityAlgoTypeSetImmutable> algo_sets) {
|
||||
while (mdef.CustomCase == CustomOrderDefinition.CustomOneofCase.Composite)
|
||||
mdef = mdef.Composite.Definition;
|
||||
var sec_sets = algo_sets.Where(s => security_clause.is_subset_of(s.security_criteria));
|
||||
if (mdef.CustomCase == CustomOrderDefinition.CustomOneofCase.Dynamic) {
|
||||
if (!algo_sets.All(s => s.algo_type_set.dynamic_types.Contains(mdef.Dynamic.DynamicOrderType))) {
|
||||
assign_fallback_algo(mdef, security_clause);
|
||||
return true;
|
||||
}
|
||||
} else if (!sec_sets.All(s => s.algo_type_set.factory_types.Contains(mdef.CustomCase))) {
|
||||
assign_fallback_algo(mdef, security_clause);
|
||||
return true;
|
||||
}
|
||||
return OrderDataHelper.get_child_algo_data(mdef).Count(cad => _fit_to_type(cad.get_child(mdef), security_clause, algo_sets)) > 0;
|
||||
}
|
||||
|
||||
bool _fit_to_type(CustomOrderDefinition mdef, SecurityImmutable security, IEnumerable<SecurityAlgoTypeSetImmutable> algo_sets) {
|
||||
while (mdef.CustomCase == CustomOrderDefinition.CustomOneofCase.Composite)
|
||||
mdef = mdef.Composite.Definition;
|
||||
var sec_sets = algo_sets.Where(s => s.security_criteria.includes(security));
|
||||
if (mdef.CustomCase == CustomOrderDefinition.CustomOneofCase.Dynamic) {
|
||||
if (!sec_sets.All(s => s.algo_type_set.dynamic_types.Contains(mdef.Dynamic.DynamicOrderType))) {
|
||||
assign_fallback_algo(mdef, security);
|
||||
return true;
|
||||
}
|
||||
} else if (!sec_sets.All(s => s.algo_type_set.factory_types.Contains(mdef.CustomCase))) {
|
||||
assign_fallback_algo(mdef, security);
|
||||
return true;
|
||||
}
|
||||
return OrderDataHelper.get_child_algo_data(mdef).Count(cad => _fit_to_type(cad.get_child(mdef), security, algo_sets)) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
class AttachableAlgoProvider : AlgoProvider, IAttachableAlgoProvider {
|
||||
public AttachableAlgoProvider(IEnumerable<SecurityAlgoTypeSetImmutable> algo_sets, IAlgoStudioModel studio_model, DynamicOrderHelper dynamic_helper, ISecurityAuxiliaryDataModel security_auxiliary_model)
|
||||
: base(algo_sets, studio_model, dynamic_helper, security_auxiliary_model) { }
|
||||
|
||||
// arbitrarily assign LimitOrderDefinition (this is just a placeholder; the real child is the attach target algo).
|
||||
// Note: although 'None' might seem approrpriate, the server requires a valid definition (perhaps this will change in the future).
|
||||
protected override void assign_fallback_algo(CustomOrderDefinition mdef, SecurityCriteriaClause security_clause) =>
|
||||
mdef.Limit = new LimitOrderDefinition();
|
||||
|
||||
// arbitrarily assign LimitOrderDefinition (this is just a placeholder; the real child is the attach target algo).
|
||||
// Note: although 'None' might seem approrpriate, the server requires a valid definition (perhaps this will change in the future).
|
||||
protected override void assign_fallback_algo(CustomOrderDefinition mdef, SecurityImmutable security) =>
|
||||
mdef.Limit = new LimitOrderDefinition();
|
||||
}
|
||||
|
||||
static class AlgoProviderExtensions {
|
||||
// This stream filters out composite algos that are not subsets of the non-composite algo types in the table
|
||||
// (normally, such composites are 'auto-fit,' meaning the algo nodes that are not part of the set are replaced with ones that are).
|
||||
// For example, consider a composite algo the following structure: Offset -> GlbxIceberg.
|
||||
// If an update arrives with these noncomposite types: "Iceberg, Limit, Market," that composite algo is not a subset of the non-composite algo types,
|
||||
// because GlbxIceberg is not in the table, so it would only be added to the table if/when GlbxIceberg arrives.
|
||||
public static IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_complete_algos(this IAlgoProvider algo_provider) =>
|
||||
subscribe_complete_algos(algo_provider.subscribe_algos());
|
||||
|
||||
public static IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_complete_algos(IObservable<TableUpdate<AlgoData, AlgoKey>> source) =>
|
||||
Observable.Create<TableUpdate<AlgoData, AlgoKey>>(o => {
|
||||
var last_out = TableUpdate<AlgoData, AlgoKey>.mk_empty(AlgoData.key_fn);
|
||||
var incomplete_composites = ImmutableHashSet<AlgoData>.Empty;
|
||||
return source.Subscribe(table => {
|
||||
var bd = last_out.to_builder();
|
||||
foreach (var algo in incomplete_composites.Where(a => OrderDataHelper.enumerate_algo_structure(a.value).All(tup => _is_part_contained(tup, table.state)))) {
|
||||
incomplete_composites = incomplete_composites.Remove(algo);
|
||||
bd.add_or_update(algo);
|
||||
}
|
||||
foreach (var a in table.removed.Concat(table.changes.Old()))
|
||||
bd.remove(a.key);
|
||||
foreach (var a in table.added.Concat(table.changed)) {
|
||||
var structure = OrderDataHelper.enumerate_algo_structure(a.value);
|
||||
if (structure.All(t => _is_part_contained(t, table.state))) {
|
||||
bd.add_or_update(a);
|
||||
} else {
|
||||
incomplete_composites = incomplete_composites.Add(a);
|
||||
}
|
||||
}
|
||||
o.OnNext(last_out = bd.to_table());
|
||||
});
|
||||
});
|
||||
|
||||
static bool _is_part_contained((CustomOrderDefinition.CustomOneofCase type, string dyn, uint studio_id, uint spreader_sec) structure, IReadOnlyDictionary<AlgoKey, AlgoData> state) =>
|
||||
structure.type == CustomOrderDefinition.CustomOneofCase.Composite ||
|
||||
structure.type == CustomOrderDefinition.CustomOneofCase.Dynamic ?
|
||||
state.ContainsKey(AlgoKey.from_dynamic_type(structure.dyn)) :
|
||||
state.ContainsKey(AlgoKey.from_known_type(structure.type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void assign_fallback_algo(CustomOrderDefinition mdef, SecurityCriteriaClause security_clause) {
|
||||
if (security_clause.security_types.empty_if_null().Contains(Security.ContractOneofCase.Synthetic.security_type())) {
|
||||
mdef.Spreader = new SpreaderOrderDefinition();
|
||||
} else {
|
||||
mdef.Limit = new LimitOrderDefinition();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void assign_fallback_algo(CustomOrderDefinition mdef, SecurityImmutable security) {
|
||||
if (security.ContractCase == Security.ContractOneofCase.Synthetic) {
|
||||
mdef.Spreader = new SpreaderOrderDefinition {
|
||||
Security = security.CloneToMutable()
|
||||
};
|
||||
} else {
|
||||
mdef.Limit = new LimitOrderDefinition();
|
||||
}
|
||||
}
|
||||
|
||||
CustomOrderDefinitionImmutable _fit_to_type(CustomOrderDefinitionImmutable defi, SecurityCriteriaClause security_clause, IEnumerable<SecurityAlgoTypeSetImmutable> algo_sets) {
|
||||
var mroot = defi.CloneToMutable();
|
||||
if (_fit_to_type(mroot, security_clause, algo_sets)) {
|
||||
defi = new CustomOrderDefinitionImmutable(mroot);
|
||||
}
|
||||
return defi;
|
||||
}
|
||||
|
||||
CustomOrderDefinitionImmutable _fit_to_type(CustomOrderDefinitionImmutable defi, SecurityImmutable security, IEnumerable<SecurityAlgoTypeSetImmutable> algo_sets) {
|
||||
var mroot = defi.CloneToMutable();
|
||||
if (_fit_to_type(mroot, security, algo_sets)) {
|
||||
defi = new CustomOrderDefinitionImmutable(mroot);
|
||||
}
|
||||
return defi;
|
||||
}
|
||||
|
||||
bool _fit_to_type(CustomOrderDefinition mdef, SecurityCriteriaClause security_clause, IEnumerable<SecurityAlgoTypeSetImmutable> algo_sets) {
|
||||
while (mdef.CustomCase == CustomOrderDefinition.CustomOneofCase.Composite)
|
||||
mdef = mdef.Composite.Definition;
|
||||
var sec_sets = algo_sets.Where(s => security_clause.is_subset_of(s.security_criteria));
|
||||
if (mdef.CustomCase == CustomOrderDefinition.CustomOneofCase.Dynamic) {
|
||||
if (!algo_sets.All(s => s.algo_type_set.dynamic_types.Contains(mdef.Dynamic.DynamicOrderType))) {
|
||||
assign_fallback_algo(mdef, security_clause);
|
||||
return true;
|
||||
}
|
||||
} else if (!sec_sets.All(s => s.algo_type_set.factory_types.Contains(mdef.CustomCase))) {
|
||||
assign_fallback_algo(mdef, security_clause);
|
||||
return true;
|
||||
}
|
||||
return OrderDataHelper.get_child_algo_data(mdef).Count(cad => _fit_to_type(cad.get_child(mdef), security_clause, algo_sets)) > 0;
|
||||
}
|
||||
|
||||
bool _fit_to_type(CustomOrderDefinition mdef, SecurityImmutable security, IEnumerable<SecurityAlgoTypeSetImmutable> algo_sets) {
|
||||
while (mdef.CustomCase == CustomOrderDefinition.CustomOneofCase.Composite)
|
||||
mdef = mdef.Composite.Definition;
|
||||
var sec_sets = algo_sets.Where(s => s.security_criteria.includes(security));
|
||||
if (mdef.CustomCase == CustomOrderDefinition.CustomOneofCase.Dynamic) {
|
||||
if (!sec_sets.All(s => s.algo_type_set.dynamic_types.Contains(mdef.Dynamic.DynamicOrderType))) {
|
||||
assign_fallback_algo(mdef, security);
|
||||
return true;
|
||||
}
|
||||
} else if (!sec_sets.All(s => s.algo_type_set.factory_types.Contains(mdef.CustomCase))) {
|
||||
assign_fallback_algo(mdef, security);
|
||||
return true;
|
||||
}
|
||||
return OrderDataHelper.get_child_algo_data(mdef).Count(cad => _fit_to_type(cad.get_child(mdef), security, algo_sets)) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
class AttachableAlgoProvider : AlgoProvider, IAttachableAlgoProvider {
|
||||
public AttachableAlgoProvider(IEnumerable<SecurityAlgoTypeSetImmutable> algo_sets, IAlgoStudioModel studio_model, DynamicOrderHelper dynamic_helper, ISecurityAuxiliaryDataModel security_auxiliary_model)
|
||||
: base(algo_sets, studio_model, dynamic_helper, security_auxiliary_model) { }
|
||||
|
||||
// arbitrarily assign LimitOrderDefinition (this is just a placeholder; the real child is the attach target algo).
|
||||
// Note: although 'None' might seem approrpriate, the server requires a valid definition (perhaps this will change in the future).
|
||||
protected override void assign_fallback_algo(CustomOrderDefinition mdef, SecurityCriteriaClause security_clause) =>
|
||||
mdef.Limit = new LimitOrderDefinition();
|
||||
|
||||
// arbitrarily assign LimitOrderDefinition (this is just a placeholder; the real child is the attach target algo).
|
||||
// Note: although 'None' might seem approrpriate, the server requires a valid definition (perhaps this will change in the future).
|
||||
protected override void assign_fallback_algo(CustomOrderDefinition mdef, SecurityImmutable security) =>
|
||||
mdef.Limit = new LimitOrderDefinition();
|
||||
}
|
||||
|
||||
static class AlgoProviderExtensions {
|
||||
// This stream filters out composite algos that are not subsets of the non-composite algo types in the table
|
||||
// (normally, such composites are 'auto-fit,' meaning the algo nodes that are not part of the set are replaced with ones that are).
|
||||
// For example, consider a composite algo the following structure: Offset -> GlbxIceberg.
|
||||
// If an update arrives with these noncomposite types: "Iceberg, Limit, Market," that composite algo is not a subset of the non-composite algo types,
|
||||
// because GlbxIceberg is not in the table, so it would only be added to the table if/when GlbxIceberg arrives.
|
||||
public static IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_complete_algos(this IAlgoProvider algo_provider, bool allow_undefined_child = false) =>
|
||||
subscribe_complete_algos(algo_provider.subscribe_algos(), allow_undefined_child);
|
||||
|
||||
public static IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_complete_algos(IObservable<TableUpdate<AlgoData, AlgoKey>> source, bool allow_undefined_child = false) =>
|
||||
Observable.Create<TableUpdate<AlgoData, AlgoKey>>(o => {
|
||||
var last_out = TableUpdate<AlgoData, AlgoKey>.mk_empty(AlgoData.key_fn);
|
||||
var incomplete_composites = ImmutableHashSet<AlgoData>.Empty;
|
||||
return source.Subscribe(table => {
|
||||
var bd = last_out.to_builder();
|
||||
foreach (var algo in incomplete_composites.Where(a => _validate_algo_structure(a.value, table.state, allow_undefined_child))) {
|
||||
incomplete_composites = incomplete_composites.Remove(algo);
|
||||
bd.add_or_update(algo);
|
||||
}
|
||||
foreach (var a in table.removed.Concat(table.changes.Old()))
|
||||
bd.remove(a.key);
|
||||
foreach (var a in table.added.Concat(table.changed)) {
|
||||
if (_validate_algo_structure(a.value, table.state, allow_undefined_child)) {
|
||||
bd.add_or_update(a);
|
||||
} else {
|
||||
incomplete_composites = incomplete_composites.Add(a);
|
||||
}
|
||||
}
|
||||
o.OnNext(last_out = bd.to_table());
|
||||
});
|
||||
});
|
||||
|
||||
static bool _validate_algo_structure(CustomOrderDefinitionImmutable custom_def, IReadOnlyDictionary<AlgoKey, AlgoData> allowed_algo_parts, bool allow_undefined_child) =>
|
||||
OrderDataHelper.enumerate_algo_structure(custom_def)
|
||||
.Select((algo_node, index) =>
|
||||
// None is an acceptable algo type as long as it's not the root algo (i.e., index > 0)
|
||||
(index > 0 && allow_undefined_child && algo_node.type == CustomOrderDefinition.CustomOneofCase.None) || _is_part_contained(algo_node, allowed_algo_parts))
|
||||
.All();
|
||||
|
||||
static bool _is_part_contained((CustomOrderDefinition.CustomOneofCase type, string dyn, uint studio_id, uint spreader_sec) structure, IReadOnlyDictionary<AlgoKey, AlgoData> state) =>
|
||||
structure.type == CustomOrderDefinition.CustomOneofCase.Composite ||
|
||||
structure.type == CustomOrderDefinition.CustomOneofCase.Dynamic ?
|
||||
state.ContainsKey(AlgoKey.from_dynamic_type(structure.dyn)) :
|
||||
state.ContainsKey(AlgoKey.from_known_type(structure.type));
|
||||
}
|
||||
}
|
||||
@@ -162,7 +162,7 @@ namespace mbts.spark {
|
||||
strip_name_filter.load_state(filters.strip_name);
|
||||
mic_code_filter.load_state(filters.mic_code);
|
||||
}
|
||||
rows_view.set_sort_descriptions(s.sorting_criteria, columns);
|
||||
rows_view.set_sort_descriptions(s.sorting_criterion, columns);
|
||||
}
|
||||
}), DataGridFilterHelper.hook_filters(rows_view, _filters),
|
||||
settings_manager.subscribe_current().OnDispatcher().Subscribe(grid_settings_manager),
|
||||
|
||||
@@ -91,9 +91,9 @@ namespace bts.shell {
|
||||
}
|
||||
|
||||
|
||||
public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criteria, enable_background_color: true);
|
||||
public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criterion, enable_background_color: true);
|
||||
|
||||
public IReadOnlyList<SortingCriteria> sorting_criteria => _sorting_criteria ?? (_sorting_criteria = DefaultColumns.default_sorting_criteria.ToList());
|
||||
public IReadOnlyList<SortingCriteria> sorting_criterion => _sorting_criteria ?? (_sorting_criteria = DefaultColumns.default_sorting_criterion.ToList());
|
||||
|
||||
public static StartupData Default(SecurityCriteria security_criteria) =>
|
||||
new StartupData(security_criteria, new FilterStates(), null);
|
||||
@@ -131,7 +131,7 @@ namespace bts.shell {
|
||||
|
||||
|
||||
|
||||
public static IEnumerable<SortingCriteria> default_sorting_criteria {
|
||||
public static IEnumerable<SortingCriteria> default_sorting_criterion {
|
||||
get {
|
||||
yield return new SortingCriteria(security.id, true);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace bts.shell.time_and_sales {
|
||||
[ProtoMember(1)]
|
||||
public readonly SecurityCriteria security_criteria;
|
||||
[ProtoMember(2)]
|
||||
List<SortingCriteria> _sorting_criteria;
|
||||
List<SortingCriteria> _sorting_criterion;
|
||||
[ProtoMember(3)]
|
||||
public FilterStates filters;
|
||||
[ProtoMember(4)]
|
||||
@@ -28,19 +28,19 @@ namespace bts.shell.time_and_sales {
|
||||
public TimeAndSalesSettings(SecurityCriteria security_criteria) :
|
||||
this(security_criteria, new FilterStates(), null, null) { }
|
||||
|
||||
public TimeAndSalesSettings(SecurityCriteria security_criteria, FilterStates filters, GridSettings grid = default, List<SortingCriteria> sorting_criteria = null) {
|
||||
public TimeAndSalesSettings(SecurityCriteria security_criteria, FilterStates filters, GridSettings grid = default, List<SortingCriteria> sorting_criterion = null) {
|
||||
this.security_criteria = security_criteria;
|
||||
this.filters = filters;
|
||||
this.grid = grid;
|
||||
_sorting_criteria = sorting_criteria;
|
||||
_sorting_criterion = sorting_criterion;
|
||||
}
|
||||
|
||||
public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criteria);
|
||||
public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criterion);
|
||||
|
||||
public List<SortingCriteria> sorting_criteria => _sorting_criteria ?? (_sorting_criteria = DefaultColumns.default_sorting_criteria.ToList());
|
||||
public List<SortingCriteria> sorting_criterion => _sorting_criterion ?? (_sorting_criterion = DefaultColumns.default_sorting_criterion.ToList());
|
||||
|
||||
public static TimeAndSalesSettings Default(SecurityCriteria security_criteria) =>
|
||||
new TimeAndSalesSettings(security_criteria, new FilterStates(), null, DefaultColumns.default_sorting_criteria.ToList());
|
||||
new TimeAndSalesSettings(security_criteria, new FilterStates(), null, DefaultColumns.default_sorting_criterion.ToList());
|
||||
|
||||
public TimeAndSalesSettings with(SecurityCriteria security_criteria) =>
|
||||
new TimeAndSalesSettings(security_criteria, filters, grid);
|
||||
@@ -53,7 +53,7 @@ namespace bts.shell.time_and_sales {
|
||||
public static GridColumnSettings aggressor => new GridColumnSettings(Columns.Aggressor.col_id(), DefaultColumnHeaders.Aggressor, width: DefaultColumnWidths.Aggressor);
|
||||
public static GridColumnSettings security_key => new GridColumnSettings(Columns.SecurityKey.col_id(), DefaultColumnHeaders.SecurityKey, is_visible: false, width: DefaultColumnWidths.SecurityKey);
|
||||
|
||||
public static IEnumerable<SortingCriteria> default_sorting_criteria {
|
||||
public static IEnumerable<SortingCriteria> default_sorting_criterion {
|
||||
get {
|
||||
yield return new SortingCriteria(time.id, false);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace bts.shell.time_and_sales {
|
||||
})),
|
||||
_menu_display_vm.spark_cmd
|
||||
};
|
||||
_vm.load(_state.filters, _state.sorting_criteria, _state.grid);
|
||||
_vm.load(_state.filters, _state.sorting_criterion, _state.grid);
|
||||
_vm.request_show_ladder += show_ladder;
|
||||
var security_criteria_src = _bus.subscribe(update_securities_cmd.tag);
|
||||
var subs = new List<IDisposable> {
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace bts.shell {
|
||||
grid ?? this.grid,
|
||||
menu_display ?? this.menu_display);
|
||||
|
||||
public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criteria);
|
||||
public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criterion);
|
||||
|
||||
static class DefaultColumns {
|
||||
public static GridColumnSettings name => new GridColumnSettings(col_id(Columns.Name), DefaultColumnHeaders.Name, width: DefaultColumnWidths.Security);
|
||||
@@ -80,7 +80,7 @@ namespace bts.shell {
|
||||
public static GridColumnSettings security_key => new GridColumnSettings(col_id(Columns.SecurityKey), DefaultColumnHeaders.SecurityKey, is_visible: false, width: DefaultColumnWidths.SecurityKey);
|
||||
public static GridColumnSettings user => new GridColumnSettings(col_id(Columns.User), DefaultColumnHeaders.User, is_visible: false, width: DefaultColumnWidths.User);
|
||||
|
||||
public static IEnumerable<SortingCriteria> default_sorting_criteria {
|
||||
public static IEnumerable<SortingCriteria> default_sorting_criterion {
|
||||
get {
|
||||
yield return new SortingCriteria(name.id, true);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace mbts.spark {
|
||||
_revert_cmd_tooltip = backing(nameof(revert_cmd_tooltip), get_revert_tooltip);
|
||||
//
|
||||
_dispose = new CompositeDisposable(
|
||||
_model.subscribe_complete_algos().OnDispatcher().Subscribe(_definitions_update_buffer),
|
||||
_model.subscribe_complete_algos(allow_undefined_child: true).OnDispatcher().Subscribe(_definitions_update_buffer),
|
||||
_definitions_update_buffer.OnDispatcher()
|
||||
.SubscribeEach(u => {
|
||||
u.FilterIncremental(a => a.key.is_composite, out var added, out var changes, out var removed);
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace mbts.spark {
|
||||
TimeTextTuple.FromDateTime(DateTime.Today),
|
||||
TimeTextTuple.FromDateTime(DateTime.Today.AddDays(1)))
|
||||
},
|
||||
settings.sorting_criteria);
|
||||
settings.sorting_criterion);
|
||||
// resources/subscriptions
|
||||
_dispose = new CompositeDisposable(
|
||||
ObservableAutoWrapper.connect(col_tups, columns, ct => ct.col),
|
||||
@@ -209,8 +209,8 @@ namespace mbts.spark {
|
||||
public FillsFilterStates get_filters() =>
|
||||
_rows_manager.get_filters();
|
||||
|
||||
public IEnumerable<SortingCriteria> get_sorting_criteria() =>
|
||||
_rows_manager.get_sorting_criteria();
|
||||
public IEnumerable<SortingCriteria> get_sorting_criterion() =>
|
||||
_rows_manager.get_sorting_criterion();
|
||||
|
||||
public void on_sorting(object sender, DIYGridSortingEventArgs e) =>
|
||||
_rows_manager.on_sorting(e);
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace mbts.spark {
|
||||
public override UIElement Content => _view;
|
||||
public override IEnumerable<SparkCommand> Commands => _commands;
|
||||
|
||||
public override FillsSettings SaveState => _state = new FillsSettings(_state.orders, _vm.get_sorting_criteria().ToList(), _vm.get_filters(), _vm.get_grid_save_state()) {
|
||||
public override FillsSettings SaveState => _state = new FillsSettings(_state.orders, _vm.get_sorting_criterion().ToList(), _vm.get_filters(), _vm.get_grid_save_state()) {
|
||||
menu_display = _menu_display_vm.safe_create()
|
||||
};
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace bts.shell {
|
||||
readonly IBus _bus;
|
||||
readonly OrdersModel _orders_model;
|
||||
readonly UserSettingsHub _settings_hub;
|
||||
/// Fills 'sorting-criteria' settings were compromised a while back (mid-late 2018).
|
||||
/// Fills 'sorting-criterion' settings were compromised a while back (mid-late 2018).
|
||||
/// The issue was that, when a column was sorted, its 'sort member path' was assigned to the SortingCriteria.col_name,
|
||||
/// rather than the <see cref="Columns"/> enum/id string.
|
||||
/// This dictionary serves as a reverse-lookup so the sort member path can be converted to the enum/id string.
|
||||
@@ -58,7 +58,7 @@ namespace bts.shell {
|
||||
_bus.post(SparkTags.ShowWindow, await load(state));
|
||||
|
||||
IShellWindow _create(FillsSettings state) {
|
||||
GridSettingsHelper.normalize_sorting_criteria(state.sorting_criteria, _sort_member_to_id);
|
||||
GridSettingsHelper.normalize_sorting_criterion(state.sorting_criterion, _sort_member_to_id);
|
||||
var settings_manager = new WindowSettingsManager<GridSettings>(_settings_hub,
|
||||
state.grid,
|
||||
get: us => us.fills_grid,
|
||||
|
||||
@@ -34,9 +34,9 @@ namespace bts.shell.fills {
|
||||
this.grid = grid;
|
||||
}
|
||||
|
||||
public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criteria);
|
||||
public static GridSettings MiniGridSettings => GridSettings.Default.with(DefaultColumns.Mini.all, DefaultColumns.Mini.sorting_criteria);
|
||||
public IReadOnlyList<SortingCriteria> sorting_criteria => _sorting_criteria ?? (_sorting_criteria = DefaultColumns.default_sorting_criteria.ToList());
|
||||
public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criterion);
|
||||
public static GridSettings MiniGridSettings => GridSettings.Default.with(DefaultColumns.Mini.all, DefaultColumns.Mini.sorting_criterion);
|
||||
public IReadOnlyList<SortingCriteria> sorting_criterion => _sorting_criteria ?? (_sorting_criteria = DefaultColumns.default_sorting_criterion.ToList());
|
||||
public static FillsSettings Default() =>
|
||||
new FillsSettings(null, null, new FillsFilterStates(), null);
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace bts.shell.fills {
|
||||
public static GridColumnSettings fill_key => new GridColumnSettings(col_id(Columns.FillKey), DefaultColumnHeaders.FillKey, width: DefaultColumnWidths.FillKey);
|
||||
public static GridColumnSettings order_key => new GridColumnSettings(col_id(Columns.OrderKey), DefaultColumnHeaders.OrderKey, width: DefaultColumnWidths.OrderKey);
|
||||
public static GridColumnSettings security_key => new GridColumnSettings(col_id(Columns.SecurityKey), DefaultColumnHeaders.SecurityKey, is_visible: false, width: DefaultColumnWidths.SecurityKey);
|
||||
public static IEnumerable<SortingCriteria> default_sorting_criteria {
|
||||
public static IEnumerable<SortingCriteria> default_sorting_criterion {
|
||||
get {
|
||||
yield return new SortingCriteria(fill_time.id, false);
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace bts.shell.fills {
|
||||
};
|
||||
|
||||
public static IEnumerable<GridColumnSettings> all => DefaultColumns.all.Select(_convert);
|
||||
public static IEnumerable<SortingCriteria> sorting_criteria => default_sorting_criteria.Where(c => _try_get_data(c.col_name, out (bool is_visible, double? _) d) && d.is_visible);
|
||||
public static IEnumerable<SortingCriteria> sorting_criterion => default_sorting_criterion.Where(c => _try_get_data(c.col_name, out (bool is_visible, double? _) d) && d.is_visible);
|
||||
|
||||
static bool _try_get_data(string id_str, out (bool is_visible, double? width_override) data) {
|
||||
if (Enum.TryParse(id_str, out Columns k) && _mini_cols_data.TryGetValue(k, out data))
|
||||
|
||||
@@ -635,8 +635,8 @@ namespace mbts.spark {
|
||||
if (s.mini_ob.value == null)
|
||||
s.mini_ob = new LadderMiniOrderBookSettings(bts.shell.orderbook.OrderBookStartupData.default_mini_grid.general);
|
||||
#pragma warning disable CS0612 // Type or member is obsolete
|
||||
if (s.mini_ob.value.sorting_criteria.Count == 0)
|
||||
s.mini_ob = new LadderMiniOrderBookSettings(s.mini_ob.value.with(sorting_criteria: bts.shell.orderbook.OrderBookStartupData.default_mini_grid.general.sorting_criteria));
|
||||
if (s.mini_ob.value.sorting_criterion.Count == 0)
|
||||
s.mini_ob = new LadderMiniOrderBookSettings(s.mini_ob.value.with(sorting_criterion: bts.shell.orderbook.OrderBookStartupData.default_mini_grid.general.sorting_criterion));
|
||||
#pragma warning restore CS0612 // Type or member is obsolete
|
||||
s.row_height = LadderRender.measure_row_height(s);
|
||||
return s;
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace mbts.spark {
|
||||
string candidate = string.Empty;
|
||||
if (a.HasValue) {
|
||||
var algo_name = a.Value.name;
|
||||
var words = algo_name.Split(delim);
|
||||
var words = algo_name.Split(delim, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (words.Length == 1) {
|
||||
var single_word = words[0];
|
||||
if (single_word.Length > 1) {
|
||||
@@ -153,7 +153,7 @@ namespace mbts.spark {
|
||||
candidate = single_word;
|
||||
}
|
||||
} else {
|
||||
candidate = words.Take(2).Select(w => w.Substring(0, 1)).list_string(string.Empty);
|
||||
candidate = string.Join(string.Empty, words.Take(2).Select(w => w.Substring(0, 1)));
|
||||
}
|
||||
}
|
||||
return candidate.ToUpper();
|
||||
|
||||
@@ -401,7 +401,7 @@ namespace mbts.spark {
|
||||
clone = SparkUtils.clone_proto(_current);
|
||||
#pragma warning disable CS0612 // Type or member is obsolete
|
||||
clone.mini_ob = new LadderMiniOrderBookSettings(_current.mini_ob.value != null ?
|
||||
mini_ob.create().with(sorting_criteria: _current.mini_ob.value.sorting_criteria) :
|
||||
mini_ob.create().with(sorting_criterion: _current.mini_ob.value.sorting_criterion) :
|
||||
mini_ob.create());
|
||||
#pragma warning restore CS0612 // Type or member is obsolete
|
||||
}
|
||||
|
||||
@@ -8,16 +8,16 @@ namespace bts.shell.manual_fills {
|
||||
[ProtoContract]
|
||||
class ManualFillsSettings {
|
||||
[ProtoMember(1)]
|
||||
readonly SortingCriteria[] _sorting_criteria;
|
||||
readonly SortingCriteria[] _sorting_criterion;
|
||||
|
||||
public static ManualFillsSettings Default =>
|
||||
new ManualFillsSettings(new[] { new SortingCriteria(nameof(mbts.ui.spark.ManualFillsView.Columns.Security), true) });
|
||||
|
||||
public ManualFillsSettings() { }
|
||||
|
||||
public ManualFillsSettings(IEnumerable<SortingCriteria> sorting_criteria) =>
|
||||
_sorting_criteria = sorting_criteria.ToArray();
|
||||
public ManualFillsSettings(IEnumerable<SortingCriteria> sorting_criterion) =>
|
||||
_sorting_criterion = sorting_criterion.ToArray();
|
||||
|
||||
public IReadOnlyList<SortingCriteria> sorting_criteria => _sorting_criteria ?? Array.Empty<SortingCriteria>();
|
||||
public IReadOnlyList<SortingCriteria> sorting_criterion => _sorting_criterion ?? Array.Empty<SortingCriteria>();
|
||||
}
|
||||
}
|
||||
@@ -44,10 +44,10 @@ namespace bts.shell {
|
||||
var vm = ManualFillsVM.create(_bus, _orders_model);
|
||||
var view = new ManualFillsView { DataContext = vm };
|
||||
view.data_grid.Sorting += on_sorting;
|
||||
IReadOnlyList<SortingCriteria> last_sorting_criteria = Array.Empty<SortingCriteria>();
|
||||
IReadOnlyList<SortingCriteria> last_sorting_criterion = Array.Empty<SortingCriteria>();
|
||||
using (apply_sort()) {
|
||||
var col_sort_tuples =
|
||||
from sc in settings.sorting_criteria
|
||||
from sc in settings.sorting_criterion
|
||||
join col in view.data_grid.Columns on sc.col_name equals _col_id(col)
|
||||
select (col, sc);
|
||||
foreach (var (col, sc) in col_sort_tuples) {
|
||||
@@ -65,8 +65,8 @@ namespace bts.shell {
|
||||
new SparkCommandCommand("Delete Selected", Icons.Trash, vm.remove_selected_fills_cmd)
|
||||
};
|
||||
return (view, cmds, get_settings, Disposable.Create(
|
||||
vm.rows_view.subscribe_sorting_criteria(sm => view.data_grid.Columns.TryGetFirst(dc => dc.SortMemberPath == sm, out DataGridColumn match) ? _col_id(match) : null)
|
||||
.Subscribe(sc => last_sorting_criteria = sc),
|
||||
vm.rows_view.subscribe_sorting_criterion(sm => view.data_grid.Columns.TryGetFirst(dc => dc.SortMemberPath == sm, out DataGridColumn match) ? _col_id(match) : null)
|
||||
.Subscribe(sc => last_sorting_criterion = sc),
|
||||
vm));
|
||||
//
|
||||
void on_sorting(object sender, DataGridSortingEventArgs e) {
|
||||
@@ -102,7 +102,7 @@ namespace bts.shell {
|
||||
});
|
||||
|
||||
ManualFillsSettings get_settings() =>
|
||||
new ManualFillsSettings(last_sorting_criteria);
|
||||
new ManualFillsSettings(last_sorting_criterion);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
class OrderBookSortingData : IEquatable<OrderBookSortingData> {
|
||||
public readonly IReadOnlyList<SortingCriteria> sorting_criteria;
|
||||
public readonly IReadOnlyList<SortingCriteria> sorting_criterion;
|
||||
public readonly IComparer<OrderBookRowVM> comparer;
|
||||
public readonly string desc;
|
||||
|
||||
@@ -52,13 +52,13 @@ namespace mbts.spark {
|
||||
comp_builder.add(Comparer<OrderBookRowVM>.Create((l, r) => l.order_key.CompareTo(r.order_key)));
|
||||
}
|
||||
comparer = comp_builder.to_comparer();
|
||||
sorting_criteria = column_sorting_hierarchy.Select(col => new SortingCriteria(col.id, col.SortDirection.GetValueOrDefault() == ListSortDirection.Ascending)).ToArray();
|
||||
desc = string.Join(", ", sorting_criteria);
|
||||
sorting_criterion = column_sorting_hierarchy.Select(col => new SortingCriteria(col.id, col.SortDirection.GetValueOrDefault() == ListSortDirection.Ascending)).ToArray();
|
||||
desc = string.Join(", ", sorting_criterion);
|
||||
}
|
||||
|
||||
public bool Equals(OrderBookSortingData other) => other != null && EqualityComparer.safe_sequence_equals(sorting_criteria, other.sorting_criteria);
|
||||
public bool Equals(OrderBookSortingData other) => other != null && EqualityComparer.safe_sequence_equals(sorting_criterion, other.sorting_criterion);
|
||||
public override bool Equals(object obj) => base.Equals(obj);
|
||||
public override int GetHashCode() => EqualityComparer.aggregate_hash(sorting_criteria);
|
||||
public override int GetHashCode() => EqualityComparer.aggregate_hash(sorting_criterion);
|
||||
public override string ToString() => desc;
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ namespace mbts.spark {
|
||||
};
|
||||
|
||||
public (FilterStates filters, IReadOnlyList<SortingCriteria> sorting) create() =>
|
||||
(create_filter_states(), get_sorting_data().sorting_criteria);
|
||||
(create_filter_states(), get_sorting_data().sorting_criterion);
|
||||
|
||||
public void load_from((FilterStates filters, IReadOnlyList<SortingCriteria> sorting) state) {
|
||||
if (state.filters is FilterStates fs) {
|
||||
|
||||
@@ -606,7 +606,7 @@ namespace mbts.spark {
|
||||
_columns.filter_changed -= _on_filter_changed;
|
||||
grid_settings_manager.algo_tree_display_mode_changed -= _on_filter_changed;
|
||||
#pragma warning disable CS0612 // Type or member is obsolete
|
||||
_columns.load_from((state.filters, (state.orderbook_grid?.general ?? OrderBookStartupData.DefaultGrid.general).sorting_criteria));
|
||||
_columns.load_from((state.filters, (state.orderbook_grid?.general ?? OrderBookStartupData.DefaultGrid.general).sorting_criterion));
|
||||
#pragma warning restore CS0612 // Type or member is obsolete
|
||||
// resume column filter updates
|
||||
_columns.filter_changed += _on_filter_changed;
|
||||
@@ -739,7 +739,7 @@ namespace mbts.spark {
|
||||
static OrderBookFillsGridSettings _get_fills_settings(FillsVM fills_vm) =>
|
||||
fills_vm == null ? OrderBookStartupData.DefaultFillsGrid :
|
||||
new OrderBookFillsGridSettings {
|
||||
sorting_criteria = fills_vm.get_sorting_criteria().ToList(),
|
||||
sorting_criterion = fills_vm.get_sorting_criterion().ToList(),
|
||||
filters = fills_vm.get_filters(),
|
||||
general = fills_vm.grid_settings_manager.create()
|
||||
};
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace bts.shell.orderbook {
|
||||
[ProtoMember(2)]
|
||||
public FillsFilterStates filters { get; set; }
|
||||
[ProtoMember(3)]
|
||||
public List<SortingCriteria> sorting_criteria { get; set; }
|
||||
public List<SortingCriteria> sorting_criterion { get; set; }
|
||||
|
||||
public FillsSettings to_startup_data() =>
|
||||
new FillsSettings(null, sorting_criteria, filters, general);
|
||||
new FillsSettings(null, sorting_criterion, filters, general);
|
||||
}
|
||||
}
|
||||
@@ -82,9 +82,9 @@ namespace bts.shell.orderbook {
|
||||
algo_tree_display_mode = gs.algo_tree_display_mode;
|
||||
}
|
||||
|
||||
public OrderBookGridSettings create(IEnumerable<SortingCriteria> sorting_criteria) {
|
||||
public OrderBookGridSettings create(IEnumerable<SortingCriteria> sorting_criterion) {
|
||||
var gs = core_manager.create();
|
||||
gs.general = gs.general.with(sorting_criteria: sorting_criteria);
|
||||
gs.general = gs.general.with(sorting_criterion: sorting_criterion);
|
||||
gs.algo_tree_display_mode = _algo_tree_display_mode;
|
||||
return gs;
|
||||
}
|
||||
|
||||
@@ -133,15 +133,15 @@ namespace bts.shell.orderbook {
|
||||
get {
|
||||
var default_fills = FillsSettings.Default();
|
||||
var rv = new OrderBookFillsGridSettings {
|
||||
sorting_criteria = default_fills.sorting_criteria.ToList(),
|
||||
sorting_criterion = default_fills.sorting_criterion.ToList(),
|
||||
filters = default_fills.filters,
|
||||
general = FillsSettings.MiniGridSettings
|
||||
};
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
static GridSettings _default_general_grid => GridSettings.Default.with(DefaultColumns.standard, DefaultColumns.sorting_criteria);
|
||||
public static OrderBookGridSettings default_mini_grid => new OrderBookGridSettings(GridSettings.Default.with(DefaultColumns.mini, DefaultColumns.sorting_criteria)) {
|
||||
static GridSettings _default_general_grid => GridSettings.Default.with(DefaultColumns.standard, DefaultColumns.sorting_criterion);
|
||||
public static OrderBookGridSettings default_mini_grid => new OrderBookGridSettings(GridSettings.Default.with(DefaultColumns.mini, DefaultColumns.sorting_criterion)) {
|
||||
algo_tree_display_mode = AlgoTreeDisplayMode.RootAndLeafNodes
|
||||
};
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace bts.shell.orderbook {
|
||||
public static GridColumnSettings edit_price => new GridColumnSettings(Columns.EditablePrice.ToString(), DIYGrid.DefaultColumnHeaders.Price, width: DIYGrid.DefaultColumnWidths.MiniOrderBook.EditablePrice);
|
||||
public static GridColumnSettings commit => new GridColumnSettings(Columns.Commit.ToString(), width: DIYGrid.DefaultColumnWidths.MiniOrderBook.Commit);
|
||||
|
||||
public static IEnumerable<SortingCriteria> sorting_criteria {
|
||||
public static IEnumerable<SortingCriteria> sorting_criterion {
|
||||
get {
|
||||
yield return new SortingCriteria(time_created.id, false);
|
||||
}
|
||||
|
||||
@@ -64,9 +64,9 @@ namespace bts.shell {
|
||||
this.grid = grid;
|
||||
}
|
||||
|
||||
public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criteria);
|
||||
public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criterion);
|
||||
|
||||
public IReadOnlyList<SortingCriteria> sorting_criteria => _sort_criteria ?? (_sort_criteria = DefaultColumns.default_sorting_criteria.ToList());
|
||||
public IReadOnlyList<SortingCriteria> sorting_criterion => _sort_criteria ?? (_sort_criteria = DefaultColumns.default_sorting_criterion.ToList());
|
||||
public static PAndLStartupData Default() =>
|
||||
new PAndLStartupData(null, new FilterStates(), pnl_calc_type.midpoint);
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace bts.shell {
|
||||
public static GridColumnSettings pnl_price => new GridColumnSettings(col_id(Columns.PNLPrice), DefaultColumnHeaders.PnLPrice, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
public static GridColumnSettings has_day_trades => new GridColumnSettings(col_id(Columns.TradedToday), "Traded Today", width: 100, horizontal_alignment: System.Windows.HorizontalAlignment.Center);
|
||||
|
||||
public static IEnumerable<SortingCriteria> default_sorting_criteria {
|
||||
public static IEnumerable<SortingCriteria> default_sorting_criterion {
|
||||
get {
|
||||
yield return new SortingCriteria(account.id, true);
|
||||
yield return new SortingCriteria(exchange.id, true);
|
||||
|
||||
@@ -622,9 +622,7 @@ namespace bts.shell.pnl {
|
||||
|
||||
static class PNLDataExtensions {
|
||||
public static string pnl_symbol(this SecurityImmutable security) {
|
||||
if(security.HasIce)
|
||||
return PNLICEHelper.get_symbol(security);
|
||||
return security.Symbol;
|
||||
return bts.api.ExchangeSpecificUitlities.get_pnl_symbol(security);
|
||||
}
|
||||
|
||||
// while override_cpp could use double.NaN to indicate the lack of an override,
|
||||
@@ -636,7 +634,7 @@ namespace bts.shell.pnl {
|
||||
|
||||
public static (double default_cpp, double? override_cpp) pnl_cpp_tuple(this PNLUnitImmutable pnl_unit, SecurityImmutable security) {
|
||||
// TODO: actual impl
|
||||
double calced_pnl = PNLICEHelper.get_cpp(pnl_unit,security);
|
||||
double calced_pnl = bts.api.ExchangeSpecificUitlities.get_cpp(pnl_unit,security);
|
||||
return (calced_pnl, pnl_unit.HasCppOverride ? pnl_unit.CppOverride.Value : (double?)null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
using bts.api;
|
||||
using bts.api.orderman;
|
||||
using bts.api.position;
|
||||
using bts.utils;
|
||||
using mbts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
|
||||
namespace bts.shell.pnl {
|
||||
|
||||
static class PNLICEHelper{
|
||||
|
||||
public static bool is_spread(SecurityImmutable sec){
|
||||
return sec.HasSpread && sec.Ice.StripName.Contains("/");
|
||||
}
|
||||
|
||||
public static bool is_strip(SecurityImmutable sec){
|
||||
return sec.HasSpread && !is_spread(sec);
|
||||
}
|
||||
|
||||
public static bool is_ice_lots(SecurityImmutable sec){
|
||||
return sec.Ice.MarketDescription.Contains("ICE Lots");
|
||||
}
|
||||
|
||||
public static double get_future_cpp (SecurityImmutable sec){
|
||||
if(sec.Symbol == "HHD")
|
||||
return 1;
|
||||
if(is_ice_lots(sec))
|
||||
return 2500;
|
||||
else{
|
||||
var days_in_month = DateTime.DaysInMonth(Convert.ToInt32(sec.Future.ExpirationYear),
|
||||
Convert.ToInt32(sec.Future.ExpirationMonth));
|
||||
return days_in_month; // because the size is multiplied by 2500 already
|
||||
}
|
||||
}
|
||||
|
||||
public static double get_spread_cpp(SecurityImmutable sec){
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static double get_strip_cpp(PNLUnitImmutable pnl,
|
||||
SecurityImmutable sec){
|
||||
double rv = 0;
|
||||
foreach (var l in sec.Spread.Legs)
|
||||
if(l.Security.HasFuture)
|
||||
rv += get_cpp(pnl,l.Security);
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static string get_symbol (SecurityImmutable sec){
|
||||
var rv = String.Format("{0}{1}{2}",
|
||||
sec.Symbol,
|
||||
is_ice_lots(sec)? " ICE LOTS" : String.Empty,
|
||||
is_spread(sec)? " Spread" : String.Empty);
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static double get_cpp (PNLUnitImmutable pnl,
|
||||
SecurityImmutable sec){
|
||||
if (sec.HasGlbx)
|
||||
return pnl.CashValue;
|
||||
else if (sec.HasIce){
|
||||
if(sec.HasFuture)
|
||||
return get_future_cpp(sec);
|
||||
else if(is_spread(sec))
|
||||
return get_spread_cpp(sec);
|
||||
else if(is_strip(sec))
|
||||
return get_strip_cpp(pnl,sec);
|
||||
}
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -85,14 +85,14 @@ namespace bts.shell {
|
||||
Func<PNLSaveState> get_save_state = () => {
|
||||
var cols = cached_columns.ToArray(c => c.create());
|
||||
var filters = vm.get_filters_states();
|
||||
var sorting_criteria = vm.sorting_hierarchy.Select(tup => new SortingCriteria(tup.key.ToString(), tup.direction == ListSortDirection.Ascending)).ToArray();
|
||||
var sorting_criterion = vm.sorting_hierarchy.Select(tup => new SortingCriteria(tup.key.ToString(), tup.direction == ListSortDirection.Ascending)).ToArray();
|
||||
var calc_type = vm.calculation_type;
|
||||
var state = settings_manager.instance_settings;
|
||||
if (state == null) {
|
||||
// don't use defaults if the user manipulated the window state outside of the settings dialog (e.g., resized column(s) via drag, or changed sort/filter)
|
||||
var defaults = settings_manager.default_settings;
|
||||
if (calc_type == defaults.calculation_type &&
|
||||
defaults.sorting_criteria.SequenceEqual(sorting_criteria) &&
|
||||
defaults.sorting_criterion.SequenceEqual(sorting_criterion) &&
|
||||
defaults.grid.columns.SequenceEqual(cols) && defaults.filters.safe_equals(filters)) {
|
||||
// the user's current state still matches the defaults (i.e., no outside manipulation was performed); return null so this window will use the latest default settings when restored
|
||||
return new PNLSaveState { use_defaults = true, settings = null };
|
||||
@@ -101,7 +101,7 @@ namespace bts.shell {
|
||||
}
|
||||
// assign latest values, as they may have be modified outside of the settings dialog (in which case the settings manager would be out of date)
|
||||
state = state.with(
|
||||
sorting_criteria,
|
||||
sorting_criterion,
|
||||
vm.anchors,
|
||||
filters,
|
||||
state.grid.with(columns: cols, background: vm.grid_background_color.rgb_color()),
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace bts.shell.pnl {
|
||||
};
|
||||
|
||||
[ProtoMember(1)]
|
||||
SortingCriteria[] _sorting_criteria;
|
||||
SortingCriteria[] _sorting_criterion;
|
||||
[ProtoMember(5)]
|
||||
Columns[] _anchors;
|
||||
[ProtoMember(7)]
|
||||
@@ -106,7 +106,7 @@ namespace bts.shell.pnl {
|
||||
|
||||
public static PNLSettings Default =>
|
||||
new PNLSettings {
|
||||
_sorting_criteria = new[] {
|
||||
_sorting_criterion = new[] {
|
||||
new SortingCriteria(nameof(Columns.Account), true),
|
||||
new SortingCriteria(nameof(Columns.Security), true)
|
||||
},
|
||||
@@ -154,7 +154,7 @@ namespace bts.shell.pnl {
|
||||
public static GridSettings DefaultGridSettings =>
|
||||
GridSettings.Default.with(
|
||||
DefaultColumns.all,
|
||||
DefaultColumns.default_sorting_criteria,
|
||||
DefaultColumns.default_sorting_criterion,
|
||||
enable_background_color: true);
|
||||
|
||||
public static fills.FillsSettings DefaultAuxiliaryFills {
|
||||
@@ -289,8 +289,8 @@ namespace bts.shell.pnl {
|
||||
public PNLCellAppearance header_defaults => header_cell_appearance.to_appearance().merge(grid_defaults);
|
||||
public IReadOnlyList<PNLAnimationTriggerData> header_row_animations => _header_row_animations ?? (_header_row_animations = default_header_row_animations.ToArray());
|
||||
//
|
||||
public IReadOnlyList<SortingCriteria> sorting_criteria =>
|
||||
_sorting_criteria ?? (_sorting_criteria = DefaultColumns.default_sorting_criteria.ToArray());
|
||||
public IReadOnlyList<SortingCriteria> sorting_criterion =>
|
||||
_sorting_criterion ?? (_sorting_criterion = DefaultColumns.default_sorting_criterion.ToArray());
|
||||
|
||||
PNLCellAppearanceProto _grid_cell_appearance => _grid_cell_appearance_backing ?? (
|
||||
_grid_cell_appearance_backing = new PNLCellAppearanceProto {
|
||||
@@ -305,7 +305,7 @@ namespace bts.shell.pnl {
|
||||
});
|
||||
|
||||
public PNLSettings with(
|
||||
IEnumerable<SortingCriteria> sorting_criteria = null,
|
||||
IEnumerable<SortingCriteria> sorting_criterion = null,
|
||||
IEnumerable<Columns> anchors = null,
|
||||
FilterStates filters = null,
|
||||
GridSettings grid = null,
|
||||
@@ -323,7 +323,7 @@ namespace bts.shell.pnl {
|
||||
header_row_display = header_row_display ?? this.header_row_display,
|
||||
// row operators (anchors, sorting, filters)
|
||||
_anchors = (anchors ?? _anchors.empty_if_null()).ToArray(),
|
||||
_sorting_criteria = (sorting_criteria ?? _sorting_criteria.empty_if_null()).ToArray(),
|
||||
_sorting_criterion = (sorting_criterion ?? _sorting_criterion.empty_if_null()).ToArray(),
|
||||
filters = filters ?? this.filters,
|
||||
// cell appearance (group/header)
|
||||
_group_background_colors = _group_background_colors?.ToList(),
|
||||
@@ -349,7 +349,7 @@ namespace bts.shell.pnl {
|
||||
data_formatting.safe_equals(other.data_formatting) &&
|
||||
// row operators (anchors, sorting, filters)
|
||||
anchors.SequenceEqual(other.anchors) &&
|
||||
sorting_criteria.SequenceEqual(other.sorting_criteria) &&
|
||||
sorting_criterion.SequenceEqual(other.sorting_criterion) &&
|
||||
filters.safe_equals(other.filters) &&
|
||||
// cell appearance (group/header)
|
||||
group_background_colors.SequenceEqual(other.group_background_colors) &&
|
||||
@@ -431,7 +431,7 @@ namespace bts.shell.pnl {
|
||||
public static GridColumnSettings settlement_price => new GridColumnSettings(nameof(Columns.SettlementPrice), DefaultColumnHeaders.Settlement, false, width: DefaultColumnWidths.Settlement, horizontal_alignment: HorizontalAlignment.Right);
|
||||
public static GridColumnSettings pnl_price => new GridColumnSettings(nameof(Columns.PNLPrice), DefaultColumnHeaders.PnLPrice, width: DefaultColumnWidths.Price, horizontal_alignment: HorizontalAlignment.Right);
|
||||
|
||||
public static IEnumerable<SortingCriteria> default_sorting_criteria {
|
||||
public static IEnumerable<SortingCriteria> default_sorting_criterion {
|
||||
get {
|
||||
yield return new SortingCriteria(account.id, true);
|
||||
yield return new SortingCriteria(security.id, true);
|
||||
|
||||
@@ -118,15 +118,7 @@ namespace bts.shell.pnl {
|
||||
).FilterWithRaw(filter_src, PNLRowData.key_fn, null)
|
||||
.OnDispatcher()
|
||||
.Subscribe(_update),
|
||||
// Note: the symbol filter items don't really need to be an IObservable
|
||||
// (the symbol items used to be extracted from the IObservable pnl_source).
|
||||
// It is only an IObservable now due to legacy; the filter was designed to observe incremental updates.
|
||||
// This is can be easily changed if need be.
|
||||
Observable.Return(
|
||||
TableUpdate<string, string>.mk_empty(sym => sym).with_added(
|
||||
SecurityHelper.get_all_display_symbols()))
|
||||
.OnDispatcher()
|
||||
.Subscribe(symbol_filter_items_observer),
|
||||
_symbols_source(pnl_source).OnDispatcher().Subscribe(symbol_filter_items_observer),
|
||||
Disposable.Create(() => {
|
||||
foreach (var f in _all_filters)
|
||||
f.filter_changed -= _refresh_filter.execute;
|
||||
@@ -377,7 +369,7 @@ namespace bts.shell.pnl {
|
||||
}
|
||||
anchors.sync_with(settings.anchors);
|
||||
header_row_display = settings.header_row_display;
|
||||
sorting_hierarchy = DIYGridSortHelper.convert_sorting_criteria<ColumnKeys>(settings.sorting_criteria).ToList();
|
||||
sorting_hierarchy = DIYGridSortHelper.convert_sorting_criterion<ColumnKeys>(settings.sorting_criterion).ToList();
|
||||
// group background colors
|
||||
_group_background_converter = new AlternationConverter();
|
||||
_group_background_converter.Values.AddRange(settings.group_background_colors.Select(c => c.argb_color()));
|
||||
|
||||
@@ -337,8 +337,8 @@ namespace mbts.spark {
|
||||
public IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_algos(SecurityImmutable security, bool attachable_only = false) =>
|
||||
(attachable_only ? _attachable_algo_provider : _algo_provider).subscribe_algos(security);
|
||||
|
||||
public IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_complete_algos(bool attachable_only = false) =>
|
||||
(attachable_only ? _attachable_algo_provider : _algo_provider).subscribe_complete_algos();
|
||||
public IObservable<TableUpdate<AlgoData, AlgoKey>> subscribe_complete_algos(bool attachable_only = false, bool allow_undefined_child = false) =>
|
||||
(attachable_only ? _attachable_algo_provider : _algo_provider).subscribe_complete_algos(allow_undefined_child);
|
||||
#endregion
|
||||
|
||||
#region Input
|
||||
|
||||
@@ -44,17 +44,17 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
static class TradesSource {
|
||||
public static IEnumerable<Product> aggregate_security_criteria(IEnumerable<SecurityImmutable> securities, IEnumerable<SecurityCriteria> security_criteria) =>
|
||||
securities.Where(s => security_criteria.Any(sc => ContractPickerModel.security_in_criteria(sc, s)))
|
||||
public static IEnumerable<Product> aggregate_security_criteria(IEnumerable<SecurityImmutable> securities, IEnumerable<SecurityCriteria> security_criterion) =>
|
||||
securities.Where(s => security_criterion.Any(sc => ContractPickerModel.security_in_criteria(sc, s)))
|
||||
.Select(Product.from_security)
|
||||
.Distinct();
|
||||
|
||||
public static IObservable<IReadOnlyList<TradeInfo>> create(MDConsumer consumer, IObservable<IReadOnlyDictionary<uint, SecurityImmutable>> security_map, IObservable<IEnumerable<SecurityCriteria>> security_criteria, TimeSpan poll_interval) =>
|
||||
security_criteria.CombineLatest(security_map, (criterion, map) => (criterion, map))
|
||||
public static IObservable<IReadOnlyList<TradeInfo>> create(MDConsumer consumer, IObservable<IReadOnlyDictionary<uint, SecurityImmutable>> security_map, IObservable<IEnumerable<SecurityCriteria>> security_criterion, TimeSpan poll_interval) =>
|
||||
security_criterion.CombineLatest(security_map, (criterion, map) => (criterion, map))
|
||||
.Scan((channels: ImmutableDictionary<Product, ChannelConsumer>.Empty, active: new List<ChannelConsumer>(0)), (channel_data, data) => {
|
||||
var (criteria, map) = data;
|
||||
var (criterion, map) = data;
|
||||
var (channels, active) = channel_data;
|
||||
var products = aggregate_security_criteria(map.Values, criteria);
|
||||
var products = aggregate_security_criteria(map.Values, criterion);
|
||||
active = new List<ChannelConsumer>();
|
||||
foreach (var p in products) {
|
||||
if (!channels.TryGetValue(p, out var c)) {
|
||||
|
||||
@@ -68,8 +68,8 @@ namespace mbts.ui.controls {
|
||||
.to_comparer();
|
||||
}
|
||||
|
||||
public static IEnumerable<(TKey key, ListSortDirection direction)> convert_sorting_criteria<TKey>(IEnumerable<SortingCriteria> sorting_criteria) where TKey : struct {
|
||||
foreach (var sc in sorting_criteria) {
|
||||
public static IEnumerable<(TKey key, ListSortDirection direction)> convert_sorting_criterion<TKey>(IEnumerable<SortingCriteria> sorting_criterion) where TKey : struct {
|
||||
foreach (var sc in sorting_criterion) {
|
||||
if (Enum.TryParse(sc.col_name, false, out TKey key))
|
||||
yield return (key, sc.direction());
|
||||
}
|
||||
|
||||
@@ -76,9 +76,9 @@ namespace mbts.ui.settings {
|
||||
// columns
|
||||
[ProtoMember(6)]
|
||||
List<GridColumnSettings> _columns;
|
||||
// sorting criteria
|
||||
// sorting criterion
|
||||
[ProtoMember(7)]
|
||||
List<SortingCriteria> _sorting_criteria;
|
||||
List<SortingCriteria> _sorting_criterion;
|
||||
// background
|
||||
[ProtoMember(8)]
|
||||
[DefaultValue(_default_background)]
|
||||
@@ -103,7 +103,7 @@ namespace mbts.ui.settings {
|
||||
uint font_color = _default_font_color,
|
||||
ColorOpacityProto? selection_highlight = null,
|
||||
IEnumerable<GridColumnSettings> columns = null,
|
||||
IEnumerable<SortingCriteria> sorting_criteria = null,
|
||||
IEnumerable<SortingCriteria> sorting_criterion = null,
|
||||
uint background = _default_background,
|
||||
bool enable_background_color = _default_enable_background_color) {
|
||||
//
|
||||
@@ -113,7 +113,7 @@ namespace mbts.ui.settings {
|
||||
_font_weight = (ushort)font_weight.ToOpenTypeWeight();
|
||||
_selection_highlight = selection_highlight ?? new ColorOpacityProto(0, 1);
|
||||
_columns = new List<GridColumnSettings>(columns.empty_if_null());
|
||||
_sorting_criteria = new List<SortingCriteria>(sorting_criteria.empty_if_null());
|
||||
_sorting_criterion = new List<SortingCriteria>(sorting_criterion.empty_if_null());
|
||||
_background = background;
|
||||
_enable_background_color = enable_background_color;
|
||||
}
|
||||
@@ -127,15 +127,15 @@ namespace mbts.ui.settings {
|
||||
public uint background_color => _background;
|
||||
public bool enable_background_color => _enable_background_color;
|
||||
public IReadOnlyList<GridColumnSettings> columns => _columns ?? (_columns = new List<GridColumnSettings>(0));
|
||||
[Obsolete] // TODO: remove sorting_criteria from GridSettings entirely. This should be part of IShellWindow's StartupData, since it is an instance-specific setting, and prob not part of the shared defaults
|
||||
public IReadOnlyList<SortingCriteria> sorting_criteria => _sorting_criteria ?? (_sorting_criteria = new List<SortingCriteria>(0));
|
||||
[Obsolete] // TODO: remove sorting_criterion from GridSettings entirely. This should be part of IShellWindow's StartupData, since it is an instance-specific setting, and prob not part of the shared defaults
|
||||
public IReadOnlyList<SortingCriteria> sorting_criterion => _sorting_criterion ?? (_sorting_criterion = new List<SortingCriteria>(0));
|
||||
|
||||
public static GridSettings get_default() =>
|
||||
new GridSettings(_default_font_family, _default_font_size, FontWeights.Normal, _default_font_color, new ColorOpacityProto(Colors.MediumSlateBlue, 0.4));
|
||||
|
||||
public GridSettings with(
|
||||
IEnumerable<GridColumnSettings> columns = null,
|
||||
IEnumerable<SortingCriteria> sorting_criteria = null,
|
||||
IEnumerable<SortingCriteria> sorting_criterion = null,
|
||||
string font_family = null,
|
||||
double font_size = double.NaN,
|
||||
uint? background = null,
|
||||
@@ -147,7 +147,7 @@ namespace mbts.ui.settings {
|
||||
_font_color,
|
||||
_selection_highlight,
|
||||
columns ?? _columns,
|
||||
sorting_criteria ?? _sorting_criteria,
|
||||
sorting_criterion ?? _sorting_criterion,
|
||||
background ?? _background,
|
||||
enable_background_color ?? _enable_background_color);
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace mbts.ui.settings {
|
||||
_enable_background_color == other._enable_background_color &&
|
||||
EqualityComparer.safe_sequence_equals(columns, other.columns) &&
|
||||
#pragma warning disable CS0612 // Type or member is obsolete
|
||||
EqualityComparer.safe_sequence_equals(sorting_criteria, other.sorting_criteria);
|
||||
EqualityComparer.safe_sequence_equals(sorting_criterion, other.sorting_criterion);
|
||||
#pragma warning restore CS0612 // Type or member is obsolete
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
@@ -181,7 +181,7 @@ namespace mbts.ui.settings {
|
||||
_enable_background_color.GetHashCode(),
|
||||
EqualityComparer.safe_aggregate_hash(columns),
|
||||
#pragma warning disable CS0612 // Type or member is obsolete
|
||||
EqualityComparer.safe_aggregate_hash(sorting_criteria));
|
||||
EqualityComparer.safe_aggregate_hash(sorting_criterion));
|
||||
#pragma warning restore CS0612 // Type or member is obsolete
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,14 +54,14 @@ namespace mbts.ui.settings {
|
||||
public static string fmt_col_id<TColKey>(TColKey key) where TColKey : struct =>
|
||||
key.ToString();
|
||||
|
||||
public static void normalize_sorting_criteria<TColKey>(IEnumerable<SortingCriteria> sorting_criteria, IReadOnlyDictionary<string, TColKey> sort_member_to_id) where TColKey : struct =>
|
||||
normalize_sorting_criteria(sorting_criteria, new Func<string, TColKey?>[] {
|
||||
public static void normalize_sorting_criterion<TColKey>(IEnumerable<SortingCriteria> sorting_criterion, IReadOnlyDictionary<string, TColKey> sort_member_to_id) where TColKey : struct =>
|
||||
normalize_sorting_criterion(sorting_criterion, new Func<string, TColKey?>[] {
|
||||
parse_col_id<TColKey>,
|
||||
col_name => sort_member_to_id.TryGetValue(col_name, out var k) ? k : (TColKey?)null
|
||||
});
|
||||
|
||||
public static void normalize_sorting_criteria<TColKey>(IEnumerable<SortingCriteria> sorting_criteria, IEnumerable<Func<string, TColKey?>> conversion_dels) where TColKey : struct {
|
||||
foreach (var sc in sorting_criteria) {
|
||||
public static void normalize_sorting_criterion<TColKey>(IEnumerable<SortingCriteria> sorting_criterion, IEnumerable<Func<string, TColKey?>> conversion_dels) where TColKey : struct {
|
||||
foreach (var sc in sorting_criterion) {
|
||||
sc.col_name = conversion_dels
|
||||
.Select(del => del(sc.col_name))
|
||||
.FirstOrDefault(k => k.HasValue)?.ToString() ?? sc.col_name;
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace mbts.ui.controls {
|
||||
public Func<T, bool> filter { get; private set; }
|
||||
|
||||
public TFiltersState get_filters() => _filters.create();
|
||||
public IEnumerable<SortingCriteria> get_sorting_criteria() => _sorting.create();
|
||||
public IEnumerable<SortingCriteria> get_sorting_criterion() => _sorting.create();
|
||||
|
||||
public void on_sorting(DIYGridSortingEventArgs e) => _sorting.on_sorting(e);
|
||||
public void on_settings(TFiltersState filters, IEnumerable<SortingCriteria> sorting) {
|
||||
|
||||
@@ -54,13 +54,13 @@ namespace mbts.ui.controls {
|
||||
).to_comparer();
|
||||
}
|
||||
|
||||
public void load_from(IEnumerable<SortingCriteria> sorting_criteria) {
|
||||
public void load_from(IEnumerable<SortingCriteria> sorting_criterion) {
|
||||
var sort_member_to_id = _map
|
||||
.Where(kv => !string.IsNullOrEmpty(kv.Value.col.sort_member_path))
|
||||
.Distinct()
|
||||
.ToDictionary(kv => kv.Value.col.sort_member_path, kv => kv.Key);
|
||||
GridSettingsHelper.normalize_sorting_criteria(sorting_criteria, sort_member_to_id);
|
||||
_on_settings(sorting_criteria
|
||||
GridSettingsHelper.normalize_sorting_criterion(sorting_criterion, sort_member_to_id);
|
||||
_on_settings(sorting_criterion
|
||||
.Select(sc => (GridSettingsHelper.parse_col_id<TColKey>(sc.col_name), sc.is_ascending ? ListSortDirection.Ascending : ListSortDirection.Descending))
|
||||
.Where(t => t.Item1.HasValue)
|
||||
.Select(t => (t.Item1.Value, t.Item2)));
|
||||
|
||||
@@ -372,11 +372,11 @@ namespace mbts.ui {
|
||||
on sd.PropertyName equals col.path
|
||||
select new SortingCriteria(col.id, sd.Direction == ListSortDirection.Ascending);
|
||||
|
||||
public static IEnumerable<SortDescription> get_sort_descriptions(this IEnumerable<SortingCriteria> sorting_criteria, IEnumerable<DataGridColumn> columns) =>
|
||||
get_sort_descriptions(sorting_criteria, columns.Select(c => (controls.DataGridEx.GetCellKey(c)?.ToString(), c.SortMemberPath)));
|
||||
public static IEnumerable<SortDescription> get_sort_descriptions(this IEnumerable<SortingCriteria> sorting_criterion, IEnumerable<DataGridColumn> columns) =>
|
||||
get_sort_descriptions(sorting_criterion, columns.Select(c => (controls.DataGridEx.GetCellKey(c)?.ToString(), c.SortMemberPath)));
|
||||
|
||||
public static IEnumerable<SortDescription> get_sort_descriptions(this IEnumerable<SortingCriteria> sorting_criteria, IEnumerable<(string id, string path)> columns) =>
|
||||
from sc in sorting_criteria
|
||||
public static IEnumerable<SortDescription> get_sort_descriptions(this IEnumerable<SortingCriteria> sorting_criterion, IEnumerable<(string id, string path)> columns) =>
|
||||
from sc in sorting_criterion
|
||||
join col in columns
|
||||
on sc.col_name equals col.id
|
||||
select new SortDescription(col.path, sc.direction());
|
||||
@@ -384,9 +384,9 @@ namespace mbts.ui {
|
||||
/// <summary>
|
||||
/// Converts each <see cref="SortingCriteria"/> into a <see cref="SortDescription"/> and assigns the result to <paramref name="collection_view"/>.SortDescriptions.
|
||||
/// </summary>
|
||||
public static void set_sort_descriptions(this ICollectionView collection_view, IEnumerable<SortingCriteria> sorting_criteria, ObservableCollection<controls.DIYGrid.ColumnBase> columns) {
|
||||
public static void set_sort_descriptions(this ICollectionView collection_view, IEnumerable<SortingCriteria> sorting_criterion, ObservableCollection<controls.DIYGrid.ColumnBase> columns) {
|
||||
using (collection_view.DeferRefresh()) {
|
||||
collection_view.SortDescriptions.SetItems(sorting_criteria.empty_if_null()
|
||||
collection_view.SortDescriptions.SetItems(sorting_criterion.empty_if_null()
|
||||
.Select(sc => new SortDescription(
|
||||
columns.FirstOrDefault(c => string.Equals(c.id, sc.col_name, StringComparison.CurrentCultureIgnoreCase))?.sort_member_path,
|
||||
sc.is_ascending ? ListSortDirection.Ascending : ListSortDirection.Descending))
|
||||
@@ -394,18 +394,18 @@ namespace mbts.ui {
|
||||
}
|
||||
}
|
||||
|
||||
public static IObservable<IReadOnlyList<SortingCriteria>> subscribe_sorting_criteria(this ICollectionView collection_view, Func<string, string> sort_member_to_id) =>
|
||||
public static IObservable<IReadOnlyList<SortingCriteria>> subscribe_sorting_criterion(this ICollectionView collection_view, Func<string, string> sort_member_to_id) =>
|
||||
Observable.Create<IReadOnlyList<SortingCriteria>>(o => {
|
||||
INotifyCollectionChanged notification_src = collection_view.SortDescriptions;
|
||||
IList<SortDescription> sort_descriptions = collection_view.SortDescriptions;
|
||||
var sorting_criteria = sort_descriptions.Select(to_criteria).ToList();
|
||||
var sorting_criterion = sort_descriptions.Select(to_criteria).ToList();
|
||||
notification_src.CollectionChanged += on_sort_descriptions_changed;
|
||||
o.OnNext(sorting_criteria);
|
||||
o.OnNext(sorting_criterion);
|
||||
return Disposable.Create(dispose);
|
||||
// local methods
|
||||
void on_sort_descriptions_changed(object sender, NotifyCollectionChangedEventArgs e) {
|
||||
CollectionHelper.reflect_change(sorting_criteria, collection_view.SortDescriptions, to_criteria, null, e);
|
||||
o.OnNext(sorting_criteria);
|
||||
CollectionHelper.reflect_change(sorting_criterion, collection_view.SortDescriptions, to_criteria, null, e);
|
||||
o.OnNext(sorting_criterion);
|
||||
}
|
||||
SortingCriteria to_criteria(SortDescription sd) => new SortingCriteria(sort_member_to_id(sd.PropertyName), sd.Direction == ListSortDirection.Ascending);
|
||||
void dispose() => notification_src.CollectionChanged -= on_sort_descriptions_changed;
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
// restore sort state or supply default value
|
||||
pnl_view.set_sort_descriptions(startup_data.sorting_criteria, columns);
|
||||
pnl_view.set_sort_descriptions(startup_data.sorting_criterion, columns);
|
||||
|
||||
var col_settings_flags = new Dictionary<string, GridColumnSettingsFeatureFlags> {
|
||||
{ Columns.StartPNL.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor },
|
||||
|
||||
@@ -259,6 +259,7 @@ namespace mbts.co2 {
|
||||
}
|
||||
}
|
||||
|
||||
// If Size is wrong remember to update from
|
||||
[StructLayout(LayoutKind.Sequential, Size = 704)]
|
||||
internal struct ColdEntry {
|
||||
public int exchange_status;
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
using bts.api;
|
||||
using bts.api.orderman;
|
||||
using bts.api.position;
|
||||
using bts.utils;
|
||||
using mbts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
|
||||
namespace bts.api {
|
||||
|
||||
static class ExchangeSpecificUitlities{
|
||||
private static string _default_hub = "Henry";
|
||||
static class ICE{
|
||||
|
||||
#region Contract Type
|
||||
public static bool is_spread(SecurityImmutable sec){
|
||||
return sec.HasSpread && sec.Ice.StripName.Contains("/");
|
||||
}
|
||||
|
||||
public static bool is_strip(SecurityImmutable sec){
|
||||
return sec.HasSpread && !is_spread(sec);
|
||||
}
|
||||
|
||||
public static bool is_ice_lots(SecurityImmutable sec){
|
||||
return sec.Ice.MarketDescription.Contains("ICE Lots");
|
||||
}
|
||||
|
||||
public static bool is_tas(SecurityImmutable sec){
|
||||
return sec.Ice.MarketDescription.Contains("TAS");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CPP
|
||||
public static double get_future_cpp (SecurityImmutable sec){
|
||||
if(sec.Symbol == "HHD")
|
||||
// only futures in HHD are the dailies, everything
|
||||
// else is a strip or spread
|
||||
return 1;
|
||||
if(is_ice_lots(sec))
|
||||
return 2500;
|
||||
else{
|
||||
var days_in_month = DateTime.DaysInMonth(Convert.ToInt32(sec.Future.ExpirationYear),
|
||||
Convert.ToInt32(sec.Future.ExpirationMonth));
|
||||
return days_in_month; // because the size is multiplied by 2500 already
|
||||
}
|
||||
}
|
||||
|
||||
public static double get_spread_cpp(SecurityImmutable sec){
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static double get_strip_cpp(PNLUnitImmutable pnl,
|
||||
SecurityImmutable sec){
|
||||
// add up all the legs
|
||||
double rv = 0;
|
||||
foreach (var l in sec.Spread.Legs)
|
||||
if(l.Security.HasFuture)
|
||||
rv += get_cpp(pnl,l.Security);
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static double get_cpp (PNLUnitImmutable pnl,
|
||||
SecurityImmutable sec){
|
||||
if(sec.HasFuture)
|
||||
return get_future_cpp(sec);
|
||||
else if(is_spread(sec))
|
||||
return get_spread_cpp(sec);
|
||||
else if(is_strip(sec))
|
||||
return get_strip_cpp(pnl,sec);
|
||||
return Double.NaN;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Symbol
|
||||
public static string get_pnl_symbol (SecurityImmutable sec){
|
||||
// for pnl purposes, for a symbol, the division is :
|
||||
// Futures and Strips
|
||||
// ICE Lots
|
||||
// Spreads
|
||||
var rv = String.Format("{0}{1}{2}",
|
||||
sec.Symbol,
|
||||
is_ice_lots(sec)? " ICE LOTS" : String.Empty,
|
||||
is_spread(sec)? " Spread" : String.Empty);
|
||||
return rv;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Formatting
|
||||
public static string format_security (SecurityImmutable? security){
|
||||
if(security.HasValue && security.Value.HasIce){
|
||||
bool ice_lots = is_ice_lots(security.Value),
|
||||
tas = is_tas(security.Value);
|
||||
return String.Format("{0}{1}{2}{3}{4}",
|
||||
security?.Symbol,
|
||||
ice_lots? " ICE Lots" : String.Empty,
|
||||
tas ? " TAS" : String.Empty,
|
||||
String.Compare(security.Value.Ice.HubAlias, _default_hub,true)==0 ? String.Empty :
|
||||
" " + security.Value.Ice.HubAlias,
|
||||
" " + security?.Ice.StripName);
|
||||
}
|
||||
return String.Empty;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public static double get_cpp (PNLUnitImmutable pnl,
|
||||
SecurityImmutable sec){
|
||||
if(sec.HasIce)
|
||||
return ICE.get_cpp(pnl,sec);
|
||||
return pnl.CashValue;
|
||||
}
|
||||
|
||||
public static string get_pnl_symbol (SecurityImmutable sec){
|
||||
if(sec.HasIce)
|
||||
return ICE.get_pnl_symbol(sec);
|
||||
return sec.Symbol;
|
||||
}
|
||||
|
||||
public static string format_security(SecurityImmutable? security){
|
||||
if(security?.HasIce == true)
|
||||
return ICE.format_security(security);
|
||||
return security?.ToString();
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -11,8 +11,5 @@ namespace bts.api {
|
||||
default: return SecurityType.Unset;
|
||||
}
|
||||
}
|
||||
|
||||
public static string display_symbol(this SecurityImmutable security) =>
|
||||
SecurityHelper.get_display_symbol(security);
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace bts.api {
|
||||
switch (security?.ContractCase) {
|
||||
case ContractOneofCase.Future:
|
||||
if(security?.HasIce == true)
|
||||
return _format_ICE(security);
|
||||
return bts.api.ExchangeSpecificUitlities.format_security(security);
|
||||
return format_future(security?.Symbol, security?.security_desc(), security.Value.Future);
|
||||
case ContractOneofCase.Spread:
|
||||
if (security?.HasGlbx == true) {
|
||||
@@ -50,7 +50,7 @@ namespace bts.api {
|
||||
return security?.Glbx.SecurityDesc;
|
||||
}
|
||||
else if(security?.HasIce == true)
|
||||
return _format_ICE(security);
|
||||
return bts.api.ExchangeSpecificUitlities.format_security(security);
|
||||
return string.Join("", _format_future_legs(SecurityHelper.get_flat_future_legs(security?.Spread.Legs)));
|
||||
case ContractOneofCase.Synthetic: return security?.Synthetic.Name;
|
||||
default: return "Unknown-security";
|
||||
@@ -84,28 +84,5 @@ namespace bts.api {
|
||||
default: return $"{fl.quantity:+0;-0}{sym_exp_name}";
|
||||
}
|
||||
}
|
||||
|
||||
static string _format_ICE (SecurityImmutable? security){
|
||||
string symbol = security?.Symbol,
|
||||
strip = security?.Ice.StripName,
|
||||
md_desc = security?.Ice.MarketDescription,
|
||||
type_append = "";
|
||||
|
||||
if(md_desc.Contains("25k ICE Lots")){
|
||||
if(md_desc.Contains("TAS"))
|
||||
type_append = "TAS";
|
||||
}
|
||||
else if(md_desc.Contains("ICE Lots")){
|
||||
if(md_desc.Contains("TAS"))
|
||||
type_append = "ICE Lots TAS";
|
||||
else
|
||||
type_append = "ICE Lots";
|
||||
}
|
||||
else if(md_desc.Contains("TAS"))
|
||||
type_append = "TAS";
|
||||
type_append = string.IsNullOrEmpty(type_append) ?
|
||||
" " : $" {type_append} ";
|
||||
return $"{symbol}{type_append}{strip}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,10 @@
|
||||
using mbts.co2;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static bts.api.Security;
|
||||
|
||||
namespace bts.api {
|
||||
internal static class SecurityHelper {
|
||||
public static IEnumerable<string> get_all_display_symbols() =>
|
||||
get_all_display_symbols(UserSymbol.get_all().Select(usym => usym.symbol));
|
||||
|
||||
public static IEnumerable<string> get_all_display_symbols(IEnumerable<string> system_symbols) {
|
||||
// todo: actual impl
|
||||
return system_symbols;
|
||||
}
|
||||
|
||||
public static string get_display_symbol(SecurityImmutable security) {
|
||||
// todo: actual impl
|
||||
return security.Symbol;
|
||||
}
|
||||
|
||||
public static IEnumerable<FutureLeg> get_flat_future_legs(SecurityImmutable sec) {
|
||||
switch (sec.ContractCase) {
|
||||
case ContractOneofCase.Spread: return _get_flat_future_legs(sec.Spread.Legs, 1);
|
||||
@@ -97,26 +83,37 @@ namespace bts.api {
|
||||
}
|
||||
|
||||
public static int Compare(SecurityImmutable x, SecurityImmutable y) {
|
||||
if (x.ContractCase == ContractOneofCase.Future) {
|
||||
return y.ContractCase == ContractOneofCase.Future ? Compare(x.Symbol, x.Future, y.Symbol, y.Future) : -1;
|
||||
} else if (y.ContractCase == ContractOneofCase.Future) {
|
||||
return 1;
|
||||
int c = non_deterministic_impl();
|
||||
if (c == 0) {
|
||||
c = x.ToString().CompareTo(y.ToString());
|
||||
if (c == 0)
|
||||
c = x.Id.CompareTo(y.Id);
|
||||
}
|
||||
var xlegs = get_flat_future_legs(x).ToList();
|
||||
var ylegs = get_flat_future_legs(y).ToList();
|
||||
int max = Math.Min(xlegs.Count, ylegs.Count);
|
||||
for (int i = 0; i < max; i++) {
|
||||
int rv = Compare(xlegs[i].symbol, xlegs[i].future, ylegs[i].symbol, ylegs[i].future);
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
rv = xlegs[i].quantity.CompareTo(ylegs[i].quantity);
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
rv = xlegs[i].exchange.CompareTo(ylegs[i].exchange);
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
return c;
|
||||
// this has been observed to be non-determinisitc with certain ICE securities
|
||||
// (it is determenistic with other exchanges..as far as we know).
|
||||
int non_deterministic_impl() {
|
||||
if (x.ContractCase == ContractOneofCase.Future) {
|
||||
return y.ContractCase == ContractOneofCase.Future ? Compare(x.Symbol, x.Future, y.Symbol, y.Future) : -1;
|
||||
} else if (y.ContractCase == ContractOneofCase.Future) {
|
||||
return 1;
|
||||
}
|
||||
var xlegs = get_flat_future_legs(x).ToList();
|
||||
var ylegs = get_flat_future_legs(y).ToList();
|
||||
int max = Math.Min(xlegs.Count, ylegs.Count);
|
||||
for (int i = 0; i < max; i++) {
|
||||
int rv = Compare(xlegs[i].symbol, xlegs[i].future, ylegs[i].symbol, ylegs[i].future);
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
rv = xlegs[i].quantity.CompareTo(ylegs[i].quantity);
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
rv = xlegs[i].exchange.CompareTo(ylegs[i].exchange);
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
}
|
||||
return xlegs.Count.CompareTo(ylegs.Count);
|
||||
}
|
||||
return xlegs.Count.CompareTo(ylegs.Count);
|
||||
}
|
||||
|
||||
public static int Compare(string x_sym, FutureContract x, string y_sym, FutureContract y) {
|
||||
@@ -130,4 +127,4 @@ namespace bts.api {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,8 @@ namespace bts {
|
||||
Plugin,
|
||||
Sdk,
|
||||
Http,
|
||||
Spartan,
|
||||
iLink3
|
||||
// Please keep this list in sync with logging.h/logging.cpp
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,22 @@ using System.Reactive.Linq;
|
||||
|
||||
namespace System.Collections.Generic {
|
||||
public static class EnumerableExtensions {
|
||||
/// <summary>
|
||||
/// Determines whether all elements of a sequence are true.
|
||||
/// </summary>
|
||||
/// <param name="source">An <see cref="IEnumerable{bool}"/> that contains the elements to which to apply the predicate.</param>
|
||||
/// <returns>True if every element of the source sequence is true, or if the sequence is empty; otherwise false.</returns>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null</exception>
|
||||
public static bool All(this IEnumerable<bool> source) {
|
||||
if (source is null)
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
foreach (var v in source) {
|
||||
if (!v)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Similar to <see cref="Enumerable.All{TSource}(IEnumerable{TSource}, Func{TSource, bool})"/>, but returns false if the <paramref name="source"/> is empty.
|
||||
/// </summary>
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts.collections;
|
||||
using bts.resources;
|
||||
using bts.test;
|
||||
using bts.utils.proto;
|
||||
@@ -10,7 +11,6 @@ namespace bts.mcore {
|
||||
class SecurityTests {
|
||||
[Test]
|
||||
public void test_security_equal() {
|
||||
|
||||
SecurityImmutable a = new SecurityImmutable(new Security() { Id = 42 });
|
||||
SecurityImmutable b = new SecurityImmutable(new Security() { Id = 42 });
|
||||
SecurityImmutable c = new SecurityImmutable(new Security() { Id = 4 });
|
||||
@@ -29,20 +29,31 @@ namespace bts.mcore {
|
||||
|
||||
[Test]
|
||||
public void test_security_compare() {
|
||||
const string securities_resource = "KrandallOrderBookCrash.security_proto";
|
||||
// verify that the sample size doesn't shrink for some reason.
|
||||
// if it grows a bit that's fine; the generic comparison test
|
||||
// asserts against collections that are too large.
|
||||
const int min_sample_size = 91;
|
||||
foreach (var file_path in SecurityFiles.all())
|
||||
_test_security_compare(_read_securities(file_path));
|
||||
}
|
||||
|
||||
var securities = StreamHelper.ReadProtos<Security>(
|
||||
ResourceHelper.LoadResource(securities_resource))
|
||||
.Select(s => new SecurityImmutable(s))
|
||||
.ToList();
|
||||
Assert.IsTrue(securities.Count >= min_sample_size);
|
||||
void _test_security_compare(IEnumerable<SecurityImmutable> securities) {
|
||||
const int max_count = 2048;
|
||||
var sec_list = securities as IList<SecurityImmutable> ?? securities.ToList();
|
||||
if (sec_list.Count > max_count)
|
||||
sec_list = sec_list.WrapSubRange(0, max_count);
|
||||
ComparisonTests.transitive_comparison(sec_list, SecurityHelper.Comparer.InstanceImmutable);
|
||||
ComparisonTests.identity_comparison(sec_list, SecurityHelper.Comparer.InstanceImmutable);
|
||||
}
|
||||
|
||||
ComparisonTests.transitive_comparison(securities, SecurityHelper.Comparer.InstanceImmutable);
|
||||
ComparisonTests.identity_comparison(securities, SecurityHelper.Comparer.InstanceImmutable);
|
||||
IEnumerable<SecurityImmutable> _read_securities(string file_path) =>
|
||||
StreamHelper.ReadProtos<Security>(ResourceHelper.LoadResource(file_path)).Select(s => new SecurityImmutable(s));
|
||||
|
||||
static class SecurityFiles {
|
||||
public const string
|
||||
KrandallOrderBookCrash = "KrandallOrderBookCrash.security_proto",
|
||||
NonDeterministicICEFutures = "NonDeterministicICEFutures.security_proto";
|
||||
|
||||
public static IEnumerable<string> all() {
|
||||
yield return KrandallOrderBookCrash;
|
||||
yield return NonDeterministicICEFutures;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,14 @@ using System.Linq;
|
||||
|
||||
namespace bts.mcore {
|
||||
static class ComparisonTests {
|
||||
public static void transitive_comparison<T>(IEnumerable<T> items, IComparer<T> comparer) {
|
||||
// Verify that the sample size isn't too big.
|
||||
// This test compares each item to every other item
|
||||
// (technically twice; lhs/rhs is flipped the second time),
|
||||
// so performance is O(n^2).
|
||||
const int max_sample_size = 4092;
|
||||
/// <summary>
|
||||
/// Compares every permutation of pairs in the specified items.
|
||||
/// Be wary of use with large collections, as performance is O(n^2).
|
||||
/// </summary>
|
||||
public static void transitive_comparison<T>(IEnumerable<T> items, IComparer<T> comparer, int min_item_count = 2, int max_item_count = 5000) {
|
||||
var sorted_items = items.ToList();
|
||||
Assert.That(sorted_items.Count <= max_sample_size);
|
||||
Assert.That(sorted_items.Count >= min_item_count);
|
||||
Assert.That(sorted_items.Count <= max_item_count);
|
||||
sorted_items.Sort(comparer);
|
||||
for (int i = 0; i < sorted_items.Count - 1; i++) {
|
||||
for (int j = i + 1; j < sorted_items.Count; j++) {
|
||||
|
||||
@@ -16,5 +16,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\KrandallOrderBookCrash.security_proto" />
|
||||
<EmbeddedResource Include="Resources\NonDeterministicICEFutures.security_proto" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1 +1 @@
|
||||
set(sources files/cert_secure_logon.txt;files/futures.coconut.xz;files/onixs_ice/ConnectivityConfiguration.APITest.xml;files/onixs_ice/ConnectivityConfiguration.PerfTest.xml;files/onixs_ice/ConnectivityConfiguration.Production.xml;files/perf_trace/compiled.css;files/perf_trace/index.html;files/perf_trace/jquery-3.3.1.min.js;files/perf_trace/main.js;files/perf_trace/perf_log.sql;files/perf_trace/perf_trace_analysis.sql;files/perf_trace/plotly-latest.min.js)
|
||||
set(sources files/cert_secure_logon.txt;files/futures.coconut.xz;files/onixs_ice/ConnectivityConfiguration.APITest.xml;files/onixs_ice/ConnectivityConfiguration.APITest.xml.orig;files/onixs_ice/ConnectivityConfiguration.PerfTest.xml;files/onixs_ice/ConnectivityConfiguration.Production.xml;files/perf_trace/compiled.css;files/perf_trace/index.html;files/perf_trace/jquery-3.3.1.min.js;files/perf_trace/main.js;files/perf_trace/perf_log.sql;files/perf_trace/perf_trace_analysis.sql;files/perf_trace/plotly-latest.min.js;files/small_es.pcap.xz)
|
||||
@@ -1,12 +1,19 @@
|
||||
Session ID Access ID Secret Key Creation Date Expiration Date Environment
|
||||
|
||||
M4D lLtjH74y1Kh5XUJTLyH2 f1K_tROQp2lTIplVp34WxKa7xDUgfFnIteolfik061o 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC1 VEMlkDuLz74OVHSuacQB IuHyYT3b-9KUo3WsuXykt-fXsjzp7L-JOrdCSQZLNl0 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC5 77lzSUwPLlM9obaXh2mK z6aA9qfASDKfZkYTVKFqJd-78i0HZ2Q9ec3CKCYIqHg 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC7 RphzI3rn71oGUEiYnX9e y6OvvPPyoyj2S8YAnE1gFduXT8v29HIMjO5EngYxSNg 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC8 PYBIm2TI9gFPIxmHbuYl 6o-ZolGH2DdeQOlGtJ5Zqoh_kg7VdbxkmjeOHmigKwU 2019-09-03 2020-09-03 CERT
|
||||
|
||||
Session ID Access ID Secret Key Creation Date Expiration Date Environment
|
||||
|
||||
M4D lLtjH74y1Kh5XUJTLyH2 f1K_tROQp2lTIplVp34WxKa7xDUgfFnIteolfik061o 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC1 VEMlkDuLz74OVHSuacQB IuHyYT3b-9KUo3WsuXykt-fXsjzp7L-JOrdCSQZLNl0 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC5 77lzSUwPLlM9obaXh2mK z6aA9qfASDKfZkYTVKFqJd-78i0HZ2Q9ec3CKCYIqHg 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC7 RphzI3rn71oGUEiYnX9e y6OvvPPyoyj2S8YAnE1gFduXT8v29HIMjO5EngYxSNg 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC8 PYBIm2TI9gFPIxmHbuYl 6o-ZolGH2DdeQOlGtJ5Zqoh_kg7VdbxkmjeOHmigKwU 2019-09-03 2020-09-03 CERT
|
||||
|
||||
NGG RYcigz3bSLIIBBF2A2Hq qB1dm9VkTKeXcdQpFzla8B3_jwTgya_-Fk5iyEJvr2E 2020-06-15 2021-06-15 NEWRELEASE
|
||||
|
||||
NGF o4OTmmTLQ7Lv4g6bCm26 HbD3FneMyb9Fu-FkCDLscCczHqFcFE2PyWv978RXGyA 2019-12-20 2020-12-20 NEWRELEASE
|
||||
|
||||
UZE EeFdZ1FPepk6U4k3xBZA 2LjEtdLvBLLB1QuDJ4KiJW6M4dF6IHWd_UKmo7p3_Us 2020-06-24 2021-06-24 NEWRELEASE
|
||||
|
||||
VAE Y8iqatTewuoHX16gghw8 FNcCB3Ks1qleS56quYzH4V7zAu78YY2bCdLRi9tmU9E 2020-06-24 2021-06-24 NEWRELEASE
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MarketDataService.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/AlgoTypes.conf;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/keycode.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/position_cfg.conf;config/defaults/span.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spreader.proto;config/protos/subprocess.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/sod.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MBOProcessor.cpp;md/MBOServiceServer.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/Product.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityMapper.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ice/ICEUtils.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/service/MarketDataServiceServer.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/mbo_tests.cpp;md/test/md2_tests.cpp;md/test/md_test_utils.cpp;md/test/synthetic_book_merge_tests.cpp;md/vendor/OnixsUtils.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.Line truncated
|
||||
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MarketDataService.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/keycode.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/position_cfg.conf;config/defaults/span.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/AlgoTypes.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spartan.proto;config/protos/spreader.proto;config/protos/subprocess.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/sod.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MBOProcessor.cpp;md/MBOServiceServer.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/Product.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityMapper.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ice/ICEUtils.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/service/MarketDataServiceServer.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/mbo_tests.cpp;md/test/md2_tests.cpp;md/test/md_test_utils.cpp;md/test/synthetic_book_merge_tests.cpp;md/vendor/OnixsUtils.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/ExecutoLine truncated
|
||||
@@ -1 +1 @@
|
||||
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MarketDataService.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/keycode.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/position_cfg.conf;config/defaults/span.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/AlgoTypes.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spreader.proto;config/protos/subprocess.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/sod.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MBOProcessor.cpp;md/MBOServiceServer.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/Product.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityMapper.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ice/ICEUtils.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/service/MarketDataServiceServer.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/mbo_tests.cpp;md/test/md2_tests.cpp;md/test/md_test_utils.cpp;md/test/synthetic_book_merge_tests.cpp;md/vendor/OnixsUtils.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthSessioLine truncated
|
||||
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MarketDataService.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/keycode.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/position_cfg.conf;config/defaults/span.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/AlgoTypes.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spartan.proto;config/protos/spreader.proto;config/protos/subprocess.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/sod.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MBOProcessor.cpp;md/MBOServiceServer.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/Product.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityMapper.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ice/ICEUtils.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/service/MarketDataServiceServer.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/mbo_tests.cpp;md/test/md2_tests.cpp;md/test/md_test_utils.cpp;md/test/synthetic_book_merge_tests.cpp;md/vendor/OnixsUtils.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_testLine truncated
|
||||
@@ -130,9 +130,13 @@ else ()
|
||||
cryptopp
|
||||
pugixml
|
||||
lttng-ust
|
||||
Pcap++
|
||||
Packet++
|
||||
Common++
|
||||
ssh2
|
||||
-lrt
|
||||
-ldl
|
||||
-lpcap
|
||||
-static-libgcc
|
||||
-static-libstdc++
|
||||
-pthread)
|
||||
|
||||
@@ -580,7 +580,9 @@ bts::api::orderman::RoutingRecord AdminServiceUtils::get_routing_record(const bt
|
||||
rv.set_session(conn_ptr->name());
|
||||
rv.set_operator_id(cme_user_data->operator_id());
|
||||
rv.set_location(cme_user_data->location());
|
||||
|
||||
rv.set_smp_id(cme_user_data->smp_id());
|
||||
|
||||
if (cme_user_data->smp_instruction()== "O")
|
||||
rv.set_smp_instruction(api::orderman::SelfMatchPreventionInstruction::SELF_MATCH_PREVENTION_INSTRUCTION_CANCEL_RESTING);
|
||||
else if (cme_user_data->smp_instruction()== "N")
|
||||
|
||||
@@ -386,7 +386,9 @@ message NativeOrderState {
|
||||
RoutingRecord routing_record = 5;
|
||||
NativeOrderType native_type = 6;
|
||||
string last_transact_time = 7;
|
||||
uint64 last_transact_time_unix_ns = 9;
|
||||
double stop_px = 8;
|
||||
uint64 exchange_order_id_u64 = 10;
|
||||
}
|
||||
|
||||
// Custom order states
|
||||
@@ -455,7 +457,8 @@ enum TimeInForce {
|
||||
TIME_IN_FORCE_UNDEFINED = 0;
|
||||
TIME_IN_FORCE_DAY = 48;
|
||||
TIME_IN_FORCE_GTC = 49;
|
||||
TIME_IN_FORCE_IOC = 51;
|
||||
TIME_IN_FORCE_IOC = 51; // FAK
|
||||
TIME_IN_FORCE_DATE = 52;
|
||||
}
|
||||
|
||||
enum ManualOrderIndicator {
|
||||
|
||||
@@ -45,6 +45,12 @@ CMEOptions {
|
||||
}
|
||||
}
|
||||
|
||||
ICEPublisherOptions {
|
||||
value {
|
||||
network_interface: "eth1"
|
||||
}
|
||||
}
|
||||
|
||||
#to make this work in dev clone the operations repo
|
||||
#go here: c:\\code\\bts\\operations\\ice\\ICE_iMpactMulticastFeed_GettingStarted-1_1_36\\bin\\easyTunnel>
|
||||
#modify the easyTunnelProxy.properties file to replace
|
||||
|
||||
@@ -14,7 +14,7 @@ JetFIXSimConnection {
|
||||
end_time: "02:00:00"
|
||||
start_time: "02:05:00"
|
||||
raw_data: "1JE9X"
|
||||
use_cme_secure_logon: false
|
||||
use_cme_secure_logon: false
|
||||
seconds_to_pause : 1
|
||||
max_connection_attempts: 9999999
|
||||
}
|
||||
@@ -31,9 +31,9 @@ JetFIXSimConnection {
|
||||
end_time: "02:00:00"
|
||||
start_time: "02:05:00"
|
||||
raw_data: "1JE9X"
|
||||
use_cme_secure_logon: false
|
||||
use_cme_secure_logon: false
|
||||
seconds_to_pause : 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ JetFIX {
|
||||
socket_connect_host_ip: "63.247.113.154"
|
||||
socket_connect_port: 80
|
||||
sender_compid: "51251"
|
||||
target_compid: "ICE"
|
||||
target_compid: "ICE"
|
||||
start_time: "22:55:00"
|
||||
end_time: "22:05:00"
|
||||
sender_subid: "BTS"
|
||||
@@ -57,12 +57,12 @@ JetFIX {
|
||||
raw_data: "Starts123"
|
||||
max_order_msgs_per_window: 300
|
||||
auto_fix_seq_num: true
|
||||
|
||||
|
||||
seconds_to_replay: 6000
|
||||
}
|
||||
connection: @JetFIXSimConnection.sim
|
||||
#connection: @JetFIXSimConnection.sim_ice
|
||||
|
||||
|
||||
connection {
|
||||
name: "cme_mc5_99"
|
||||
platform: GLBX
|
||||
@@ -181,9 +181,9 @@ JetFIX {
|
||||
sender_subid: "BTS"
|
||||
raw_data: "S4PMA"
|
||||
auto_fix_seq_num: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JetFIX {
|
||||
rule: "CannedCertSession.name='gt_cert'"
|
||||
@@ -196,7 +196,7 @@ JetFIX {
|
||||
socket_connect_host_ip: "63.247.113.154"
|
||||
socket_connect_port: 80
|
||||
sender_compid: "51251"
|
||||
target_compid: "ICE"
|
||||
target_compid: "ICE"
|
||||
start_time: "22:55:00"
|
||||
end_time: "22:05:00"
|
||||
sender_subid: "BTS"
|
||||
@@ -204,7 +204,7 @@ JetFIX {
|
||||
raw_data: "Starts123"
|
||||
max_order_msgs_per_window: 300
|
||||
auto_fix_seq_num: true
|
||||
|
||||
|
||||
seconds_to_replay: 6000
|
||||
}
|
||||
connection: @JetFIXSimConnection.sim
|
||||
@@ -515,7 +515,7 @@ JetFIX {
|
||||
auto_fix_seq_num: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
JetFIX {
|
||||
@@ -2391,9 +2391,91 @@ JetFIX {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# NrCert gateways
|
||||
# 69.50.112.184,12,OESGW
|
||||
# 69.50.112.202,50,CME Eurodollar Options
|
||||
# 69.50.112.181,52,CME Globex FX Options II
|
||||
# 69.50.112.191,54,CME Equity Options
|
||||
# 69.50.112.174,56,NYMEX and COMEX Options
|
||||
# 69.50.112.172,58,CBOT Treasury Options
|
||||
# 69.50.112.195,60,CBOT Commodity and Equity Options
|
||||
# 69.50.112.177,64,CME E-mini S&P 500 Futures
|
||||
# 69.50.112.168,68,CME Equity Futures excluding E-mini S&P
|
||||
# 69.50.112.183,70,CME Commodity Futures
|
||||
# 69.50.112.189,72,CBOT Commodity Futures
|
||||
# 69.50.112.197,74,KRX Futures; BMD Futures and Options
|
||||
# 69.50.112.204,76,NYMEX and COMEX Metals and Alternative Market Futures
|
||||
# 69.50.112.167,78,NYMEX Non-Crude Energy Futures
|
||||
# 69.50.112.187,80,NYMEX Crude Energy Futures
|
||||
# 69.50.112.179,82,CME Eurodollar Futures
|
||||
# 69.50.112.198,84,CBOT Treasury Futures
|
||||
# 69.50.112.169,88,CME Globex FX Futures and Options
|
||||
# 69.50.112.199,99,AutoCert Segment
|
||||
|
||||
macro {
|
||||
name: "canned_004"
|
||||
expression: "[CannedCertSession.name, '004']"
|
||||
}
|
||||
|
||||
JetFIX {
|
||||
rule: "CannedCertSession.name in ['NGG', 'NGF', 'UZE', 'VAE']"
|
||||
value {
|
||||
# ES
|
||||
connection {
|
||||
name: "cme_canned_64"
|
||||
platform: GLBX
|
||||
socket_connect_host_ip: "69.50.112.177"
|
||||
socket_connect_port: 64530
|
||||
sender_compid: $canned_004
|
||||
target_compid: "CME"
|
||||
target_subid: "64"
|
||||
cme_market_segment_id: 64
|
||||
start_time: "00:30:00"
|
||||
end_time: "23:30:00"
|
||||
start_day: "sunday"
|
||||
end_day: "friday"
|
||||
sender_subid: "BTS"
|
||||
use_ilink3: true
|
||||
}
|
||||
# CL
|
||||
connection {
|
||||
name: "cme_canned_80"
|
||||
platform: GLBX
|
||||
socket_connect_host_ip: "69.50.112.187"
|
||||
socket_connect_port: 64530
|
||||
sender_compid: $canned_004
|
||||
target_compid: "CME"
|
||||
target_subid: "80"
|
||||
cme_market_segment_id: 80
|
||||
start_time: "00:30:00"
|
||||
end_time: "23:30:00"
|
||||
start_day: "sunday"
|
||||
end_day: "friday"
|
||||
sender_subid: "BTS"
|
||||
use_ilink3: true
|
||||
}
|
||||
connection {
|
||||
name: "cme_canned_99"
|
||||
platform: GLBX
|
||||
socket_connect_host_ip: "69.50.112.199"
|
||||
socket_connect_port: 64530
|
||||
sender_compid: $canned_004
|
||||
target_compid: "CME"
|
||||
target_subid: "99"
|
||||
cme_market_segment_id: 99
|
||||
start_time: "00:30:00"
|
||||
end_time: "23:30:00"
|
||||
start_day: "sunday"
|
||||
end_day: "friday"
|
||||
sender_subid: "BTS"
|
||||
use_ilink3: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#If no canned cert specified we fallback to just sim
|
||||
CannedCertSession { value { name: "" }}
|
||||
JetFIX {value {connection: @JetFIXSimConnection.sim}}
|
||||
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ message CMEOptions
|
||||
// Defines amount of time Feed Engine keeps cycling before going to sleep when no useful activity can be done
|
||||
optional uint32 spin_time = 4 [default = 1];
|
||||
optional uint32 channels_per_thread = 5 [default = 3];
|
||||
// rmem_max
|
||||
optional uint32 udp_socket_buffer_size = 11 [default = 268435456]; //256mb
|
||||
}
|
||||
message CMEChannel {
|
||||
@@ -110,9 +111,13 @@ message CMEOptions
|
||||
optional string feed_engine = 3 [default = "default"];
|
||||
|
||||
|
||||
// for re-orders
|
||||
optional uint32 max_gap_recovery_cache_size = 11 [default = 6];
|
||||
// for re-orders
|
||||
optional uint32 lost_packet_wait_timeout_ms = 12 [default = 10];
|
||||
|
||||
optional OnixSLogMode onixs_log_mode = 13 [default = Important];
|
||||
// If using both feeds prefer the B feed for snapshots
|
||||
optional bool prefer_backup_feeds = 15 [default = false];
|
||||
|
||||
optional bool use_tcp_replay = 20 [default = true];
|
||||
|
||||
@@ -9,9 +9,9 @@ message JetFIX {
|
||||
enum JetFIXPlatform {
|
||||
GLBX = 1;
|
||||
CBOE = 6;
|
||||
SIM = 2;
|
||||
ICE = 3;
|
||||
SIMICE = 4;
|
||||
SIM = 2;
|
||||
ICE = 3;
|
||||
SIMICE = 4;
|
||||
}
|
||||
optional JetFIXPlatform platform = 15 [default = GLBX];
|
||||
|
||||
@@ -87,6 +87,7 @@ message JetFIX {
|
||||
|
||||
optional uint32 max_connection_attempts = 346 [default=10];
|
||||
optional bool auto_fix_seq_num = 347 [default=false];
|
||||
optional bool use_ilink3 = 348 [default=false] ;
|
||||
}
|
||||
|
||||
repeated Connection connection = 10;
|
||||
@@ -116,4 +117,4 @@ message CMECannedSecureLogon {
|
||||
"MC8 AbEEtBn63WIAuItPDz1c n3ndjYb03Hx6wBO3me35HoONyDgO5TZKWk0tDSaX9KA 2018-04-05 2019-04-05 CERT \n"
|
||||
"T39 UWggBgHWAe07aqW3ps2I tbb3it0rUQSSTa0TC9QcRwkrHEMDLWhaJH4VQ0FqGB4 2018-04-05 2019-04-05 NEWRELEASE \n"
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
syntax='proto2';
|
||||
package bts.config;
|
||||
|
||||
message SpartanTASCfg {
|
||||
message TASSide {
|
||||
required uint32 quantity = 2;
|
||||
required int32 ticks_away = 3;
|
||||
}
|
||||
message TASTrigger {
|
||||
required string security = 1;
|
||||
required TASSide buy = 3;
|
||||
required TASSide sell = 4;
|
||||
}
|
||||
|
||||
required string user = 1;
|
||||
required string account = 2;
|
||||
|
||||
repeated TASTrigger tas_trigger = 3;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,4 +73,5 @@ message DynamicAlgos{
|
||||
optional bool enable_tas = 3 [default = false];
|
||||
optional bool enable_tascounter = 4 [default = false];
|
||||
optional bool enable_limit_cover = 5 [default = false];
|
||||
optional bool enable_onsignal = 6 [default = false];
|
||||
}
|
||||
@@ -32,6 +32,18 @@ std::string descriptor(api::Security const &sec) {
|
||||
return "No descriptor for non glbx / ice exchange";
|
||||
}
|
||||
|
||||
api::SecurityType security_type(api::Security const&sec) {
|
||||
if (sec.has_future())
|
||||
return api::SecurityType::SECURITYTYPE_FUTURE;
|
||||
else if (sec.has_option())
|
||||
return api::SecurityType::SECURITYTYPE_OPTION;
|
||||
else if (sec.has_spread())
|
||||
return api::SecurityType::SECURITYTYPE_SPREAD;
|
||||
else if (sec.has_synthetic())
|
||||
return api::SecurityType::SECURITYTYPE_SYNTHETIC;
|
||||
else
|
||||
return api::SecurityType::SECURITYTYPE_UNSET;
|
||||
}
|
||||
|
||||
boost::gregorian::date smallest_leg(
|
||||
::google::protobuf::RepeatedPtrField<::bts::api::ContractLeg> const &l) {
|
||||
|
||||
@@ -26,6 +26,7 @@ SecurityKey security_key(api::Security const &);
|
||||
std::string to_str(api::Security const &);
|
||||
std::pair<bool, api::Security> from_str(std::string const &);
|
||||
std::string descriptor(api::Security const &);
|
||||
api::SecurityType security_type(api::Security const&);
|
||||
|
||||
inline std::string const &side_name(api::Side side) {
|
||||
return api::Side_Name(side);
|
||||
@@ -41,6 +42,30 @@ inline api::Side other_side(api::Side side) {
|
||||
return side;
|
||||
}
|
||||
}
|
||||
template <class V> class TwoSided {
|
||||
public:
|
||||
TwoSided() : buy(), sell() {}
|
||||
|
||||
TwoSided(V const &buy, V const &sell) : buy(buy), sell(sell) {}
|
||||
|
||||
V const &get(api::Side side) const {
|
||||
if (side == api::SIDE_BUY)
|
||||
return buy;
|
||||
else
|
||||
return sell;
|
||||
}
|
||||
|
||||
void set(api::Side side, V const &v) {
|
||||
if (side == api::SIDE_BUY)
|
||||
buy = v;
|
||||
else
|
||||
sell = v;
|
||||
}
|
||||
|
||||
private:
|
||||
V buy;
|
||||
V sell;
|
||||
};
|
||||
|
||||
inline double market_epsilon() { return 1e-10; }
|
||||
|
||||
@@ -90,6 +115,25 @@ inline Price better_price(api::Side side, Price p1, Price p2) {
|
||||
return is_equal_or_better(side, p1, p2) ? p1 : p2;
|
||||
}
|
||||
|
||||
// Returns the worst possible price representable in the Price data type for the side in question
|
||||
inline Price worst_price(api::Side side) {
|
||||
switch (side) {
|
||||
case api::SIDE_BUY:
|
||||
return Price {std::numeric_limits<double>::min()};
|
||||
case api::SIDE_SELL:
|
||||
return Price {std::numeric_limits<double>::max()};
|
||||
default:
|
||||
bts_assert(false);
|
||||
break;
|
||||
}
|
||||
bts_assert(false);
|
||||
return Price(0);
|
||||
}
|
||||
|
||||
inline Price best_price(api::Side side) {
|
||||
return worst_price(other_side(side));
|
||||
}
|
||||
|
||||
inline Price decode_exchange_price(api::Security const &sec, Price in) {
|
||||
return Price(in.value() * sec.contract_spec().price_multiplier());
|
||||
}
|
||||
@@ -180,17 +224,15 @@ inline int price_diff_to_ticks(double price_1, double price_2,
|
||||
}
|
||||
// returns the difference (in ticks) bw and order and a market.
|
||||
// if the order has crossed the market, returns -ve ticks
|
||||
// (ie the buy order price > market_price or
|
||||
// (ie the buy order price > market_price or
|
||||
// sell_order_price < market_price)
|
||||
inline int order_diff_market(double order_price,
|
||||
double market_price,
|
||||
api::Side side,
|
||||
double tick_size){
|
||||
inline int order_diff_market(double order_price, double market_price,
|
||||
api::Side side, double tick_size) {
|
||||
switch (side) {
|
||||
case api::SIDE_BUY:
|
||||
return price_diff_to_ticks(order_price,market_price,tick_size);
|
||||
return price_diff_to_ticks(order_price, market_price, tick_size);
|
||||
case api::SIDE_SELL:
|
||||
return price_diff_to_ticks(market_price,order_price,tick_size);
|
||||
return price_diff_to_ticks(market_price, order_price, tick_size);
|
||||
default:
|
||||
bts_assert(false);
|
||||
break;
|
||||
@@ -212,31 +254,20 @@ inline bool gr_than(double p1, double p2, double tick_size) {
|
||||
return gr_than_eq(p1, p2, tick_size) &&
|
||||
!test_price_equality(p1, p2, tick_size);
|
||||
}
|
||||
inline bool test_price_equality(double price_1, double price_2) {
|
||||
return std::fabs(price_2 - price_1) < market_epsilon();
|
||||
}
|
||||
|
||||
// Works only if ICEExchangeData is part of the a spread security
|
||||
// inline bool is_ice_strip(const bts::api::ICEExchangeData& ice_data){
|
||||
// return ice_data.is_strip();
|
||||
// }
|
||||
// ice specialization /////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline bool is_ice_strip(const bts::api::ICEExchangeData& ice_data){
|
||||
// TODO, put this in the security
|
||||
inline bool is_ice_spread(const bts::api::ICEExchangeData& ice_data){
|
||||
const auto& strip = ice_data.strip_name();
|
||||
auto find = [&](const std::string& sub) -> bool {
|
||||
return strip.find(sub) != std::string::npos;
|
||||
};
|
||||
if(!find("/"))
|
||||
return find("-") ||
|
||||
find("Q1") || find("Q2") || find("Q3") || find("Q4") ||
|
||||
find("Cal");
|
||||
else
|
||||
return false;
|
||||
return strip.find("/") != std::string::npos;
|
||||
}
|
||||
|
||||
inline bool is_strip(const bts::api::Security& sec){
|
||||
if(sec.has_spread())
|
||||
if (sec.has_ice())
|
||||
return is_ice_strip(sec.ice());
|
||||
return false;
|
||||
return sec.has_ice() && sec.has_spread() && !is_ice_spread(sec.ice());
|
||||
}
|
||||
|
||||
inline bool is_spread_of_strips(const bts::api::Security& sec){
|
||||
|
||||
@@ -52,7 +52,7 @@ class FIXEncodingStream {
|
||||
auto msg_offset = _buffer.size();
|
||||
|
||||
_current_msg = FIXFragment(_buffer);
|
||||
_begin_string_bm = _current_msg.add<fix::BeginString>("FIX.4.2");
|
||||
_begin_string_bm = _current_msg.add<fix::BeginString>(std::string_view {"FIX.4.2"});
|
||||
_body_length_bm = _current_msg.add<fix::BodyLength>(0, 6);
|
||||
|
||||
char mt_encoding[4];
|
||||
|
||||
@@ -85,6 +85,7 @@ typedef StringField<307> UnderlyingSecurityDesc;
|
||||
typedef StringField<336> TradingSessionID;
|
||||
typedef StringField<35> MsgType;
|
||||
typedef StringField<37> OrderID;
|
||||
typedef BigIntField<37> OrderIDu64;
|
||||
typedef StringField<41> OrigClOrdID;
|
||||
typedef StringField<440> ClearingAccount;
|
||||
typedef StringField<48> SecurityID;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <memory>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <string_view>
|
||||
|
||||
#include "lib/jetfix/codec/ReaderCursor.h"
|
||||
#include "lib/utils/meta_programming.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
@@ -203,6 +205,13 @@ public:
|
||||
static std::pair<uint32_t,uint32_t> write (char*buffer,std::string const &str)
|
||||
{return write (buffer,str.data (),str.size ());}
|
||||
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
static uint32_t max_value_size (std::string_view const&str) {return str.size ();}
|
||||
static std::pair<uint32_t,uint32_t> write (char*buffer,std::string_view const &str)
|
||||
{return write (buffer,str.data (),str.size ());}
|
||||
#endif
|
||||
|
||||
static std::pair<uint32_t,uint32_t> write (char*buffer,const char*str,uint32_t sz)
|
||||
{
|
||||
memcpy (buffer,str,sz);
|
||||
|
||||
@@ -50,6 +50,12 @@ public:
|
||||
std::vector<jetfix::FIXEncodingStream> fix;
|
||||
|
||||
jetfix::FIXEncodingStream& first_stream() {bts_assert (fix.size()); return fix[0];}
|
||||
|
||||
void close_all() {
|
||||
for (auto &s : fix)
|
||||
s.close();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -23,9 +23,9 @@ SocketConnection::SocketConnection(bts::config::JetFIX::Connection const &cfg,
|
||||
: _fd(-1), _cfg(cfg), _log(cfg.log_fix_stream()), _in_log(), _out_log(),
|
||||
_perf_log(perf_log) {
|
||||
if (_log) {
|
||||
_in_log.open(std::string("/tmp/fix_raw_read_log_") + session_name(cfg),
|
||||
_in_log.open(std::string("/tmp/fix_raw_read_log_") + session_name(cfg).as_string,
|
||||
std::ios_base::app);
|
||||
_out_log.open(std::string("/tmp/fix_raw_write_log_") + session_name(cfg),
|
||||
_out_log.open(std::string("/tmp/fix_raw_write_log_") + session_name(cfg).as_string,
|
||||
std::ios_base::app);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +144,8 @@ CoreGateway::~CoreGateway() {
|
||||
me->timer_thread.join();
|
||||
}
|
||||
|
||||
config::JetFIX::Connection const &CoreGateway::cfg() {return me->cfg;}
|
||||
|
||||
void CoreGateway::send(OutFIXPtr const &fix, trace::CorID trace) {
|
||||
me->event_queue.push(EventData(&CoreGateway::sync_send, trace, fix));
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ public:
|
||||
trace::PerfLog &);
|
||||
|
||||
~CoreGateway();
|
||||
config::JetFIX::Connection const &cfg();
|
||||
|
||||
void start ();
|
||||
void stop ();
|
||||
void send (OutFIXPtr const &msgs, trace::CorID trace);
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
void stop () {_core.stop ();}
|
||||
void send (OutFIXPtr const &msgs,trace::CorID trace ) {_core.send (msgs,trace);}
|
||||
void dispatch_events () {_core.dispatch_events ();}
|
||||
|
||||
config::JetFIX::Connection const&cfg () {return _core.cfg();}
|
||||
|
||||
std::function<void()> &on_ready () {return _on_ready;}
|
||||
std::function<void()> &on_disconnect () {return _on_disconnect;}
|
||||
|
||||
@@ -786,9 +786,10 @@ OutFIXPtr make_logon(uint32_t seq_num, uint32_t last_seq_num_processed,
|
||||
if(session_cfg.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_ICE ||
|
||||
session_cfg.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_SIMICE)
|
||||
{
|
||||
buffer.add<ICEApplicationSystemName>("Katallage");
|
||||
buffer.add<ICEApplicationSystemVersion>("1.0");
|
||||
buffer.add<ICEApplicationSystemVendor>("Katallage");
|
||||
std::string sender_comp_id = session_cfg.sender_subid();
|
||||
buffer.add<ICEApplicationSystemName>(sender_comp_id);
|
||||
buffer.add<ICEApplicationSystemVersion>(std::string_view{"1.0"});
|
||||
buffer.add<ICEApplicationSystemVendor>(sender_comp_id);
|
||||
|
||||
buffer.add<UserName>(session_cfg.user_name());
|
||||
buffer.add<RawDataLength>(session_cfg.raw_data().size());
|
||||
@@ -796,19 +797,18 @@ OutFIXPtr make_logon(uint32_t seq_num, uint32_t last_seq_num_processed,
|
||||
buffer.add<EncryptMethod>(0);
|
||||
buffer.add<ICEStrategyPreference>(1);
|
||||
buffer.add<ICETimeStampPreference>(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.add<ApplicationSystemName>(application);
|
||||
buffer.add<ApplicationSystemVersion>("1.0");
|
||||
buffer.add<ApplicationSystemVendor>("BTS");
|
||||
} else {
|
||||
buffer.add<ApplicationSystemName>(std::string_view{application});
|
||||
buffer.add<ApplicationSystemVersion>(std::string_view{"1.0"});
|
||||
buffer.add<ApplicationSystemVendor>(std::string_view{"BTS"});
|
||||
|
||||
if (session_cfg.has_trading_session_id()) {
|
||||
buffer.add<fix::NoTradingSessions>(1);
|
||||
buffer.add<fix::TradingSessionID>(session_cfg.trading_session_id());
|
||||
}
|
||||
if (session_cfg.has_udf_support_indicator())
|
||||
buffer.add<fix::UDFSupportIndicator>(session_cfg.udf_support_indicator());
|
||||
buffer.add<fix::UDFSupportIndicator>(
|
||||
session_cfg.udf_support_indicator());
|
||||
|
||||
if (session_cfg.use_cme_secure_logon()) {
|
||||
bts_assert(session_cfg.sender_compid().size() >= 3);
|
||||
@@ -819,25 +819,24 @@ OutFIXPtr make_logon(uint32_t seq_num, uint32_t last_seq_num_processed,
|
||||
std::string last_seq_num_str(9, ' ');
|
||||
i32_toa(last_seq_num_processed, &last_seq_num_str[0], 9);
|
||||
auto ld = glbx::calculate_hmac(
|
||||
session_id, seq_num_str, session_cfg.sender_compid(),
|
||||
session_cfg.sender_subid(), time_str, session_cfg.target_subid(),
|
||||
std::to_string(session_cfg.seconds_between_hbs()),
|
||||
session_cfg.sender_locationid(), last_seq_num_str, application, "1.0",
|
||||
"BTS");
|
||||
#ifndef BTS_EDGE
|
||||
LOG(Jetfix, Info, "Canonical string for secure logon: {}", ld.canonical);
|
||||
#endif
|
||||
session_id, seq_num_str, session_cfg.sender_compid(),
|
||||
session_cfg.sender_subid(), time_str, session_cfg.target_subid(),
|
||||
std::to_string(session_cfg.seconds_between_hbs()),
|
||||
session_cfg.sender_locationid(), last_seq_num_str, application,
|
||||
"1.0", "BTS");
|
||||
#ifndef BTS_EDGE
|
||||
LOG(Jetfix, Info, "Canonical string for secure logon: {}",
|
||||
ld.canonical);
|
||||
#endif
|
||||
buffer.add<EncodedTextLen>(ld.access_key.size());
|
||||
buffer.add<EncodedText>(ld.access_key);
|
||||
buffer.add<EncryptedPasswordMethod>("CME-1-SHA-256");
|
||||
buffer.add<EncryptedPasswordMethod>(std::string_view{"CME-1-SHA-256"});
|
||||
buffer.add<EncryptedPasswordLen>(ld.signature.size());
|
||||
buffer.add<EncryptedPassword>(ld.signature);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
buffer.add<RawDataLength>(session_cfg.raw_data().size());
|
||||
buffer.add<RawData>(session_cfg.raw_data());
|
||||
if(session_cfg.user_name() != "")
|
||||
if (session_cfg.user_name() != "")
|
||||
buffer.add<UserName>(session_cfg.user_name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ void load_seq_nums(std::string const &path, uint32_t *last_seq_num,
|
||||
FIXFileStore::FIXFileStore(config::JetFIX::Connection const &cfg,
|
||||
std::string base_path)
|
||||
: me(new PImpl(cfg)) {
|
||||
auto sn = session_name(cfg);
|
||||
auto sn = session_name(cfg).as_string;
|
||||
me->active = sn.size() > 0;
|
||||
if (me->active) {
|
||||
|
||||
|
||||
@@ -75,49 +75,55 @@ bool in_session (datetime::PTime const &ref_date,
|
||||
return closest_earlier_end<closest_earlier_start;
|
||||
}
|
||||
|
||||
std::string session_name_from_ptime (datetime::PTime t,
|
||||
SessionName session_name_from_ptime (datetime::PTime t,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end)
|
||||
{
|
||||
std::string result (10,' ');
|
||||
SessionName result;
|
||||
result.as_string = std::string(10,' ');
|
||||
auto start_of_session = t;
|
||||
|
||||
if (time_of_day_start > time_of_day_end &&
|
||||
start_of_session.time_of_day () <= time_of_day_end)
|
||||
start_of_session -= boost::gregorian::date_duration (1);
|
||||
|
||||
sprintf (&result[0], "%04d-%02d-%02d",
|
||||
|
||||
using namespace boost::posix_time;
|
||||
ptime epoch(boost::gregorian::date(1970,1,1));
|
||||
ptime session_start_date(start_of_session.date());
|
||||
result.as_uint64_t = (session_start_date - epoch).total_milliseconds();
|
||||
|
||||
sprintf (&(result.as_string[0]), "%04d-%02d-%02d",
|
||||
(unsigned short) start_of_session.date ().year (),
|
||||
start_of_session.date ().month ().as_number (),
|
||||
start_of_session.date ().day ().as_number ());
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string session_name (datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday_start,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::gregorian::greg_weekday weekday_end,
|
||||
boost::posix_time::time_duration time_of_day_end)
|
||||
SessionName session_name (datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday_start,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::gregorian::greg_weekday weekday_end,
|
||||
boost::posix_time::time_duration time_of_day_end)
|
||||
{
|
||||
if (in_session (ref_date,weekday_start,time_of_day_start,weekday_end,time_of_day_end))
|
||||
return session_name_from_ptime (closest_before (ref_date,weekday_start,time_of_day_start),
|
||||
boost::posix_time::time_duration(0, 0, 0),
|
||||
boost::posix_time::time_duration(0, 0, 1));
|
||||
else
|
||||
return std::string ();
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string session_name (datetime::PTime const &ref_date,
|
||||
SessionName session_name (datetime::PTime const &ref_date,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end)
|
||||
{
|
||||
if (in_session (ref_date,time_of_day_start,time_of_day_end))
|
||||
return session_name_from_ptime (ref_date, time_of_day_start, time_of_day_end);
|
||||
else
|
||||
return "";
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string session_name (config::JetFIX::Connection const &session_cfg)
|
||||
SessionName session_name (config::JetFIX::Connection const &session_cfg)
|
||||
{
|
||||
auto now = datetime::local_now ();
|
||||
|
||||
@@ -134,7 +140,6 @@ std::string session_name (config::JetFIX::Connection const &session_cfg)
|
||||
parse_time (session_cfg.end_time ()));
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/config/protos/jetfix.pb.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/config/protos/jetfix.pb.h"
|
||||
|
||||
namespace boost {
|
||||
namespace gregorian {
|
||||
@@ -11,39 +11,45 @@ class greg_weekday;
|
||||
}
|
||||
namespace posix_time {
|
||||
class time_duration;
|
||||
}}
|
||||
|
||||
}
|
||||
} // namespace boost
|
||||
|
||||
namespace bts {
|
||||
namespace jetfix {
|
||||
|
||||
boost::gregorian::greg_weekday parse_weekday (std::string weekday_str);
|
||||
bool parse_time (std::string const &time_str,boost::posix_time::time_duration *out);
|
||||
boost::gregorian::greg_weekday parse_weekday(std::string weekday_str);
|
||||
bool parse_time(std::string const &time_str,
|
||||
boost::posix_time::time_duration *out);
|
||||
|
||||
datetime::PTime closest_before (datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday,
|
||||
boost::posix_time::time_duration time_of_day);
|
||||
datetime::PTime closest_before(datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday,
|
||||
boost::posix_time::time_duration time_of_day);
|
||||
|
||||
bool in_session (datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday_start,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::gregorian::greg_weekday weekday_end,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
bool in_session(datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday_start,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::gregorian::greg_weekday weekday_end,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
|
||||
bool in_session (datetime::PTime const &ref_date,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
bool in_session(datetime::PTime const &ref_date,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
|
||||
std::string session_name (datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday_start,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::gregorian::greg_weekday weekday_end,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
struct SessionName {
|
||||
std::string as_string;
|
||||
uint64_t as_uint64_t;
|
||||
bool empty() const {return as_string.empty();};
|
||||
};
|
||||
|
||||
std::string session_name (datetime::PTime const &ref_date,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
SessionName session_name(datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday_start,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::gregorian::greg_weekday weekday_end,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
SessionName session_name(datetime::PTime const &ref_date,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
SessionName session_name(config::JetFIX::Connection const &session_cfg);
|
||||
|
||||
std::string session_name (config::JetFIX::Connection const &session_cfg);
|
||||
|
||||
}}
|
||||
} // namespace jetfix
|
||||
} // namespace bts
|
||||
@@ -81,9 +81,9 @@ TEST_CASE ("JetFIX Field2Tests", "[jetfix]")
|
||||
std::string out (20, ' ');
|
||||
typedef StringField<123> Field;
|
||||
|
||||
REQUIRE(Field::max_value_size ("hello")==5);
|
||||
REQUIRE(Field::max_value_size (std::string_view{"hello"})==5);
|
||||
|
||||
auto result = Field::write (&out[0],"hello");
|
||||
auto result = Field::write (&out[0],std::string_view{"hello"});
|
||||
REQUIRE (result.first==5);
|
||||
REQUIRE (result.second=='h'+'e'+'l'+'l'+'o');
|
||||
REQUIRE (out.compare (0,5,"hello") == 0);
|
||||
@@ -112,7 +112,7 @@ TEST_CASE ("JetFIX FIXFragmentTests" , "[jetfix]")
|
||||
FIXFragment g (0);
|
||||
g.add<CharField<1>> ('a');
|
||||
g.add<FloatField<2>> (1.2,-1,6);
|
||||
g.add<StringField<3>> ("hello");
|
||||
g.add<StringField<3>> (std::string_view{"hello"});
|
||||
g.add<IntField<4>> (123,3);
|
||||
const char*t_s = "20150427-19:05:18.922";
|
||||
g.add<TimeField<5>> (datetime::parse_FIX_timestamp (t_s));
|
||||
@@ -141,14 +141,14 @@ TEST_CASE ("JetFIX FIXFragmentTests" , "[jetfix]")
|
||||
FIXFragment g;
|
||||
auto c_bm = g.add<CharField<1>> ('a');
|
||||
auto f_bm = g.add<FloatField<2>> (1.2,-1,6);
|
||||
auto s_bm = g.add<StringField<3>> ("hello");
|
||||
auto s_bm = g.add<StringField<3>> (std::string_view{"hello"});
|
||||
auto i_bm = g.add<IntField<4>> (123,3);
|
||||
auto t_bm = g.add<TimeField<5>> (datetime::parse_FIX_timestamp (t_s1));
|
||||
auto b_bm = g.add<BoolField<6>> (true);
|
||||
|
||||
g.overwrite (c_bm,'b');
|
||||
g.overwrite (f_bm,1.3,-1,6);
|
||||
g.overwrite (s_bm,"olleh");
|
||||
g.overwrite (s_bm,std::string_view {"olleh"});
|
||||
g.overwrite (i_bm,321,3);
|
||||
g.overwrite (t_bm,(datetime::parse_FIX_timestamp (t_s2)));
|
||||
g.overwrite (b_bm,false);
|
||||
@@ -172,11 +172,11 @@ TEST_CASE ("JetFIX FIXFragmentTests" , "[jetfix]")
|
||||
FIXFragment g1;;
|
||||
g1.add<CharField<1>> ('a');
|
||||
g1.add<FloatField<2>> (1.2,-1,6);
|
||||
g1.add<StringField<3>> ("hello");
|
||||
g1.add<StringField<3>> (std::string_view{"hello"});
|
||||
auto chk1 = g1.checksum ();
|
||||
|
||||
FIXFragment g2;
|
||||
g2.add<StringField<4>> ("goodbye");
|
||||
g2.add<StringField<4>> (std::string_view{"goodbye"});
|
||||
g2.add<IntField<5>> (321,3);
|
||||
auto chk2 = g2.checksum ();
|
||||
|
||||
|
||||
@@ -6,279 +6,270 @@
|
||||
#include "lib/jetfix/common/OutFIXPtr.h"
|
||||
#include "lib/jetfix/store/FIXFileStore.h"
|
||||
#include "lib/jetfix/store/session_name.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/utils/TempDir.h"
|
||||
#include "lib/utils/TimeStamp.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/logging/logging.h"
|
||||
|
||||
#include <boost/date_time.hpp>
|
||||
#include <boost/date_time/gregorian/gregorian.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/date_time.hpp>
|
||||
|
||||
namespace bts {
|
||||
namespace jetfix {
|
||||
|
||||
TEST_CASE ("JetFIX SessionNameTests", "[jetfix]")
|
||||
{
|
||||
SECTION("greg_weekday_works")
|
||||
{
|
||||
const char*days [] = {"sun","Monday","tuesday","Wedn","Thursday","Friday","sat"};
|
||||
TEST_CASE("JetFIX SessionNameTests", "[jetfix]") {
|
||||
SECTION("greg_weekday_works") {
|
||||
const char *days[] = {"sun", "Monday", "tuesday", "Wedn",
|
||||
"Thursday", "Friday", "sat"};
|
||||
|
||||
int i =0;
|
||||
int i = 0;
|
||||
for (auto d : days)
|
||||
REQUIRE (parse_weekday (d)==boost::gregorian::greg_weekday (i++));
|
||||
}
|
||||
|
||||
SECTION("closest_before_works")
|
||||
{
|
||||
auto same_day_before = closest_before (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(16, 59, 59));
|
||||
REQUIRE (datetime::FIX_date_time_string (same_day_before)=="20150717-16:59:59");
|
||||
|
||||
auto same_day_after = closest_before (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(17,0,1));
|
||||
REQUIRE (datetime::FIX_date_time_string (same_day_after)=="20150710-17:00:01");
|
||||
|
||||
auto another_day_same_week = closest_before (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Thursday,
|
||||
boost::posix_time::time_duration(16, 59, 59));
|
||||
REQUIRE (datetime::FIX_date_time_string (another_day_same_week)=="20150716-16:59:59");
|
||||
|
||||
auto another_day_previous_week = closest_before (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Saturday,
|
||||
boost::posix_time::time_duration(16, 59, 59));
|
||||
REQUIRE (datetime::FIX_date_time_string (another_day_previous_week)=="20150711-16:59:59");
|
||||
|
||||
REQUIRE(parse_weekday(d) == boost::gregorian::greg_weekday(i++));
|
||||
}
|
||||
|
||||
SECTION("in_session_works")
|
||||
{
|
||||
REQUIRE (in_session (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(17, 0, 1)));
|
||||
SECTION("closest_before_works") {
|
||||
auto same_day_before =
|
||||
closest_before(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(16, 59, 59));
|
||||
REQUIRE(datetime::FIX_date_time_string(same_day_before) ==
|
||||
"20150717-16:59:59");
|
||||
|
||||
REQUIRE (!in_session (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(16, 59, 59)));
|
||||
auto same_day_after = closest_before(
|
||||
datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Friday, boost::posix_time::time_duration(17, 0, 1));
|
||||
REQUIRE(datetime::FIX_date_time_string(same_day_after) ==
|
||||
"20150710-17:00:01");
|
||||
|
||||
REQUIRE (in_session (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
boost::posix_time::time_duration(17, 59, 59)));
|
||||
auto another_day_same_week =
|
||||
closest_before(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Thursday,
|
||||
boost::posix_time::time_duration(16, 59, 59));
|
||||
REQUIRE(datetime::FIX_date_time_string(another_day_same_week) ==
|
||||
"20150716-16:59:59");
|
||||
|
||||
REQUIRE (!in_session (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::posix_time::time_duration(0,0,0),
|
||||
boost::posix_time::time_duration(16, 0,0)));
|
||||
|
||||
REQUIRE (in_session (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)));
|
||||
|
||||
REQUIRE (!in_session (datetime::make_ptime (2015,7,17,17,47,0,0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)));
|
||||
auto another_day_previous_week =
|
||||
closest_before(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Saturday,
|
||||
boost::posix_time::time_duration(16, 59, 59));
|
||||
REQUIRE(datetime::FIX_date_time_string(another_day_previous_week) ==
|
||||
"20150711-16:59:59");
|
||||
}
|
||||
|
||||
SECTION("session_name_works")
|
||||
{
|
||||
REQUIRE (session_name (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(17, 0, 1)) ==
|
||||
"2015-07-12");
|
||||
SECTION("in_session_works") {
|
||||
REQUIRE(in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(17, 0, 1)));
|
||||
|
||||
REQUIRE (session_name (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(16, 59, 59)) == "");
|
||||
REQUIRE(!in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
REQUIRE (session_name (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
boost::posix_time::time_duration(17, 59, 59)) ==
|
||||
"2015-07-17");
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(16, 59, 59)));
|
||||
|
||||
REQUIRE (session_name (datetime::make_ptime (2015,7,17,18,0,0,0),
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
boost::posix_time::time_duration(17, 59, 59)) ==
|
||||
"");
|
||||
REQUIRE(in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
boost::posix_time::time_duration(17, 59, 59)));
|
||||
|
||||
REQUIRE (session_name (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)) ==
|
||||
"2015-07-16");
|
||||
REQUIRE(!in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::posix_time::time_duration(0, 0, 0),
|
||||
boost::posix_time::time_duration(16, 0, 0)));
|
||||
|
||||
REQUIRE (session_name (datetime::make_ptime (2015,7,17,17,51,0,0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)) ==
|
||||
"2015-07-17");
|
||||
|
||||
REQUIRE (session_name (datetime::make_ptime (2015,7,17,17,47,0,0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)) ==
|
||||
"");
|
||||
REQUIRE(in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)));
|
||||
|
||||
REQUIRE(!in_session(datetime::make_ptime(2015, 7, 17, 17, 47, 0, 0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)));
|
||||
}
|
||||
|
||||
SECTION("session_name_works") {
|
||||
REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(17, 0, 1)).as_string ==
|
||||
"2015-07-12");
|
||||
|
||||
REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(16, 59, 59)).as_string == "");
|
||||
|
||||
REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
boost::posix_time::time_duration(17, 59, 59)).as_string ==
|
||||
"2015-07-17");
|
||||
|
||||
REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 18, 0, 0, 0),
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
boost::posix_time::time_duration(17, 59, 59)).as_string == "");
|
||||
|
||||
REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)).as_string ==
|
||||
"2015-07-16");
|
||||
|
||||
REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 51, 0, 0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)).as_string ==
|
||||
"2015-07-17");
|
||||
|
||||
REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 47, 0, 0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)).as_string == "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE ("JetFIX FileStoreTests", "[jetfix]")
|
||||
{
|
||||
SECTION("empty_store_works")
|
||||
{
|
||||
TEST_CASE("JetFIX FileStoreTests", "[jetfix]") {
|
||||
SECTION("empty_store_works") {
|
||||
config::JetFIX::Connection c;
|
||||
c.set_name ("test");
|
||||
c.set_sender_compid ("CME");
|
||||
c.set_sender_subid ("G");
|
||||
c.set_target_compid ("1U7001N");
|
||||
c.set_target_subid ("BLUESTREAM");
|
||||
c.set_name("test");
|
||||
c.set_sender_compid("CME");
|
||||
c.set_sender_subid("G");
|
||||
c.set_target_compid("1U7001N");
|
||||
c.set_target_subid("BLUESTREAM");
|
||||
|
||||
c.set_start_time ("00:00:00");
|
||||
c.set_end_time ("23:59:59");
|
||||
c.set_start_time("00:00:00");
|
||||
c.set_end_time("23:59:59");
|
||||
|
||||
utils::TempDir td;
|
||||
|
||||
FIXFileStore fs (c,td.name ());
|
||||
REQUIRE (fs.session_active ());
|
||||
REQUIRE (fs.replay ().size ()==0);
|
||||
REQUIRE (fs.last_seq_num ()==0);
|
||||
REQUIRE (fs.last_seq_num_processed ()==0);
|
||||
|
||||
FIXFileStore fs(c, td.name());
|
||||
REQUIRE(fs.session_active());
|
||||
REQUIRE(fs.replay().size() == 0);
|
||||
REQUIRE(fs.last_seq_num() == 0);
|
||||
REQUIRE(fs.last_seq_num_processed() == 0);
|
||||
}
|
||||
|
||||
SECTION("in_msg_is_stored")
|
||||
{
|
||||
auto td = std::make_shared<utils::TempDir> ();
|
||||
SECTION("in_msg_is_stored") {
|
||||
auto td = std::make_shared<utils::TempDir>();
|
||||
config::JetFIX::Connection c;
|
||||
c.set_name ("test");
|
||||
c.set_sender_compid ("CME");
|
||||
c.set_sender_subid ("G");
|
||||
c.set_target_compid ("1U7001N");
|
||||
c.set_target_subid ("BLUESTREAM");
|
||||
c.set_name("test");
|
||||
c.set_sender_compid("CME");
|
||||
c.set_sender_subid("G");
|
||||
c.set_target_compid("1U7001N");
|
||||
c.set_target_subid("BLUESTREAM");
|
||||
|
||||
c.set_start_time ("00:00:00");
|
||||
c.set_end_time ("23:59:59");
|
||||
c.set_start_time("00:00:00");
|
||||
c.set_end_time("23:59:59");
|
||||
|
||||
FIXEncodingStream stream (c);
|
||||
auto &buf = stream.new_msg (MessageTypes::Logon);
|
||||
buf.add<fix::TargetLocationID> ("US,NC");
|
||||
buf.add<fix::EncryptMethod> (0);
|
||||
FIXEncodingStream stream(c);
|
||||
auto &buf = stream.new_msg(MessageTypes::Logon);
|
||||
buf.add<fix::TargetLocationID>(std::string_view{"US,NC"});
|
||||
buf.add<fix::EncryptMethod>(0);
|
||||
buf.add<fix::HeartBtInt>(30);
|
||||
buf.add<fix::ApplicationSystemName> ("O2");
|
||||
buf.add<fix::ApplicationSystemVersion> ("1.0");
|
||||
buf.add<fix::ApplicationSystemVendor> ("BTS");
|
||||
stream.close ();
|
||||
stream.stamp (2,3,datetime::FIX_timestamp (datetime::now ()));
|
||||
auto fix = stream.to_str ();
|
||||
|
||||
buf.add<fix::ApplicationSystemName>(std::string_view{"O2"});
|
||||
buf.add<fix::ApplicationSystemVersion>(std::string_view{"1.0"});
|
||||
buf.add<fix::ApplicationSystemVendor>(std::string_view{"BTS"});
|
||||
stream.close();
|
||||
stream.stamp(2, 3, datetime::FIX_timestamp(datetime::now()));
|
||||
auto fix = stream.to_str();
|
||||
|
||||
{
|
||||
FIXFileStore fs (c,td->name ());
|
||||
fs.store (InMsgBuffer (fix));
|
||||
fs.set_last_msg_processed (3);
|
||||
FIXFileStore fs(c, td->name());
|
||||
fs.store(InMsgBuffer(fix));
|
||||
fs.set_last_msg_processed(3);
|
||||
}
|
||||
|
||||
FIXFileStore fs (c,td->name ());
|
||||
auto replay = fs.replay ();
|
||||
REQUIRE (replay.size ()==1);
|
||||
REQUIRE (replay[0].type ()==MessageTypes::Logon);
|
||||
REQUIRE (replay[0].to_str ()==fix);
|
||||
REQUIRE (fs.last_seq_num ()==0);
|
||||
REQUIRE (fs.last_seq_num_processed ()==3);
|
||||
FIXFileStore fs(c, td->name());
|
||||
auto replay = fs.replay();
|
||||
REQUIRE(replay.size() == 1);
|
||||
REQUIRE(replay[0].type() == MessageTypes::Logon);
|
||||
REQUIRE(replay[0].to_str() == fix);
|
||||
REQUIRE(fs.last_seq_num() == 0);
|
||||
REQUIRE(fs.last_seq_num_processed() == 3);
|
||||
}
|
||||
|
||||
SECTION("out_msg_is_stored")
|
||||
{
|
||||
auto td = std::make_shared<utils::TempDir> ();
|
||||
SECTION("out_msg_is_stored") {
|
||||
auto td = std::make_shared<utils::TempDir>();
|
||||
config::JetFIX::Connection c;
|
||||
c.set_name ("test");
|
||||
c.set_sender_compid ("CME");
|
||||
c.set_sender_subid ("G");
|
||||
c.set_target_compid ("1U7001N");
|
||||
c.set_target_subid ("BLUESTREAM");
|
||||
c.set_name("test");
|
||||
c.set_sender_compid("CME");
|
||||
c.set_sender_subid("G");
|
||||
c.set_target_compid("1U7001N");
|
||||
c.set_target_subid("BLUESTREAM");
|
||||
|
||||
c.set_start_time ("00:00:00");
|
||||
c.set_end_time ("23:59:59");
|
||||
c.set_start_time("00:00:00");
|
||||
c.set_end_time("23:59:59");
|
||||
|
||||
auto msg_vec = std::make_shared<OutFIX>(c);
|
||||
auto &stream = msg_vec->fix.back ();
|
||||
auto &buf = stream.new_msg (MessageTypes::Logon);
|
||||
buf.add<fix::TargetLocationID> ("US,NC");
|
||||
buf.add<fix::EncryptMethod> (0);
|
||||
auto &stream = msg_vec->fix.back();
|
||||
auto &buf = stream.new_msg(MessageTypes::Logon);
|
||||
buf.add<fix::TargetLocationID>(std::string_view{"US,NC"});
|
||||
buf.add<fix::EncryptMethod>(0);
|
||||
buf.add<fix::HeartBtInt>(30);
|
||||
buf.add<fix::ApplicationSystemName> ("O2");
|
||||
buf.add<fix::ApplicationSystemVersion> ("1.0");
|
||||
buf.add<fix::ApplicationSystemVendor> ("BTS");
|
||||
stream.close ();
|
||||
stream.stamp (2,3,datetime::FIX_timestamp (datetime::now ()));
|
||||
|
||||
buf.add<fix::ApplicationSystemName>(std::string_view{"O2"});
|
||||
buf.add<fix::ApplicationSystemVersion>(std::string_view{"1.0"});
|
||||
buf.add<fix::ApplicationSystemVendor>(std::string_view{"BTS"});
|
||||
stream.close();
|
||||
stream.stamp(2, 3, datetime::FIX_timestamp(datetime::now()));
|
||||
|
||||
{
|
||||
FIXFileStore fs (c,td->name ());
|
||||
fs.store (msg_vec);
|
||||
FIXFileStore fs(c, td->name());
|
||||
fs.store(msg_vec);
|
||||
}
|
||||
|
||||
FIXFileStore fs (c,td->name ());
|
||||
auto replay = fs.replay ();
|
||||
REQUIRE (replay.size ()==0);
|
||||
REQUIRE (fs.last_seq_num ()==3);
|
||||
REQUIRE (fs.last_seq_num_processed ()==0);
|
||||
FIXFileStore fs(c, td->name());
|
||||
auto replay = fs.replay();
|
||||
REQUIRE(replay.size() == 0);
|
||||
REQUIRE(fs.last_seq_num() == 3);
|
||||
REQUIRE(fs.last_seq_num_processed() == 0);
|
||||
}
|
||||
|
||||
SECTION("test_performance")
|
||||
{
|
||||
auto td = std::make_shared<utils::TempDir> ();
|
||||
SECTION("test_performance") {
|
||||
auto td = std::make_shared<utils::TempDir>();
|
||||
config::JetFIX::Connection c;
|
||||
c.set_name ("test");
|
||||
c.set_sender_compid ("CME");
|
||||
c.set_sender_subid ("G");
|
||||
c.set_target_compid ("1U7001N");
|
||||
c.set_target_subid ("BLUESTREAM");
|
||||
c.set_name("test");
|
||||
c.set_sender_compid("CME");
|
||||
c.set_sender_subid("G");
|
||||
c.set_target_compid("1U7001N");
|
||||
c.set_target_subid("BLUESTREAM");
|
||||
|
||||
c.set_start_time ("00:00:00");
|
||||
c.set_end_time ("23:59:59");
|
||||
c.set_start_time("00:00:00");
|
||||
c.set_end_time("23:59:59");
|
||||
|
||||
auto start = utils::TimeStamp::now ();
|
||||
auto start = utils::TimeStamp::now();
|
||||
{
|
||||
FIXFileStore fs (c,td->name ());
|
||||
for (int i = 0; i < 10000;i++) {
|
||||
FIXFileStore fs(c, td->name());
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
auto msg_vec = std::make_shared<std::vector<FIXEncodingStream>>();
|
||||
msg_vec->emplace_back (c);
|
||||
auto &stream = msg_vec->back ();
|
||||
auto &buf = stream.new_msg (MessageTypes::Logon);
|
||||
buf.add<fix::TargetLocationID> ("US,NC");
|
||||
buf.add<fix::EncryptMethod> (0);
|
||||
msg_vec->emplace_back(c);
|
||||
auto &stream = msg_vec->back();
|
||||
auto &buf = stream.new_msg(MessageTypes::Logon);
|
||||
buf.add<fix::TargetLocationID>(std::string_view{"US,NC"});
|
||||
buf.add<fix::EncryptMethod>(0);
|
||||
buf.add<fix::HeartBtInt>(30);
|
||||
buf.add<fix::ApplicationSystemName> ("O2");
|
||||
buf.add<fix::ApplicationSystemVersion> ("1.0");
|
||||
buf.add<fix::ApplicationSystemVendor> ("BTS");
|
||||
stream.close ();
|
||||
stream.stamp (i,3,datetime::FIX_timestamp (datetime::now () - boost::gregorian::days (1)));
|
||||
fs.store (InMsgBuffer (stream.to_str ()));
|
||||
buf.add<fix::ApplicationSystemName>(std::string_view{"O2"});
|
||||
buf.add<fix::ApplicationSystemVersion>(std::string_view{"1.0"});
|
||||
buf.add<fix::ApplicationSystemVendor>(std::string_view{"BTS"});
|
||||
stream.close();
|
||||
stream.stamp(i, 3,
|
||||
datetime::FIX_timestamp(datetime::now() -
|
||||
boost::gregorian::days(1)));
|
||||
fs.store(InMsgBuffer(stream.to_str()));
|
||||
}
|
||||
}
|
||||
auto stop = utils::TimeStamp::now ();
|
||||
LOG(Testing,Info,"jetfix store gen: {} ms", (stop-start).milliseconds () );
|
||||
|
||||
start = utils::TimeStamp::now ();
|
||||
FIXFileStore fs (c,td->name ());
|
||||
stop = utils::TimeStamp::now ();
|
||||
LOG(Testing,Info,"jetfix store load: {} ms", (stop-start).milliseconds () );
|
||||
auto stop = utils::TimeStamp::now();
|
||||
LOG(Testing, Info, "jetfix store gen: {} ms",
|
||||
(stop - start).milliseconds());
|
||||
|
||||
start = utils::TimeStamp::now();
|
||||
FIXFileStore fs(c, td->name());
|
||||
stop = utils::TimeStamp::now();
|
||||
LOG(Testing, Info, "jetfix store load: {} ms",
|
||||
(stop - start).milliseconds());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace jetfix
|
||||
} // namespace bts
|
||||
+50
-61
@@ -2,85 +2,79 @@
|
||||
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/os/os.h"
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/utils/file_utils.h"
|
||||
#include "lib/utils/bts_assert.h"
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <fmt/ostream.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <syslog.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace bts {
|
||||
namespace log {
|
||||
|
||||
|
||||
struct InitSysLog {
|
||||
InitSysLog() {
|
||||
#ifndef WIN32
|
||||
openlog("spark",0,LOG_USER);
|
||||
openlog("spark", 0, LOG_USER);
|
||||
#endif
|
||||
|
||||
}
|
||||
} init;
|
||||
} init;
|
||||
|
||||
|
||||
auto formatter(LoggingConfig const&cfg) {
|
||||
return [cfg] (LogMsg const&m) {
|
||||
auto formatter(LoggingConfig const &cfg) {
|
||||
return [cfg](LogMsg const &m) {
|
||||
auto iso_date = datetime::iso_date_time_string(datetime::local_now());
|
||||
iso_date[sizeof("YYYY-MM-DD")-1] = ' ';
|
||||
iso_date[sizeof("YYYY-MM-DD") - 1] = ' ';
|
||||
#ifdef _WIN32
|
||||
return fmt::format("{}|{}|{:<8}|{:<5}|{:<3}|{:<4}|{:<35}|{}|{} ",
|
||||
iso_date,
|
||||
m.ts,
|
||||
m.subsystem_name,
|
||||
m.level_name,
|
||||
m.tid,
|
||||
//m.thread_name,
|
||||
os::process_id(),
|
||||
fmt::format("{}:{}",boost::filesystem::path(m.file).filename().string() , m.line),
|
||||
cfg.deployment_type,
|
||||
m.msg);
|
||||
return fmt::format(
|
||||
"{}|{}|{:<8}|{:<5}|{:<3}|{:<4}|{:<35}|{}|{} ", iso_date, m.ts,
|
||||
m.subsystem_name, m.level_name, m.tid,
|
||||
// m.thread_name,
|
||||
os::process_id(),
|
||||
fmt::format("{}:{}",
|
||||
boost::filesystem::path(m.file).filename().string(),
|
||||
m.line),
|
||||
cfg.deployment_type, m.msg);
|
||||
#else
|
||||
return fmt::format("{}|{}|{:<8}|{:<5}|{:<3}|{:<16}|{:<4}|{:<35}|{}|{} ",
|
||||
iso_date,
|
||||
m.ts,
|
||||
m.subsystem_name,
|
||||
m.level_name,
|
||||
m.tid,
|
||||
m.thread_name,
|
||||
os::process_id(),
|
||||
fmt::format("{}:{}",boost::filesystem::path(m.file).filename().string() , m.line),
|
||||
cfg.deployment_type,
|
||||
m.msg);
|
||||
return fmt::format(
|
||||
"{}|{}|{:<8}|{:<5}|{:<3}|{:<16}|{:<4}|{:<35}|{}|{} ", iso_date, m.ts,
|
||||
m.subsystem_name, m.level_name, m.tid, m.thread_name,
|
||||
os::process_id(),
|
||||
fmt::format("{}:{}",
|
||||
boost::filesystem::path(m.file).filename().string(),
|
||||
m.line),
|
||||
cfg.deployment_type, m.msg);
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
Sink console_sink(LoggingConfig const&cfg) {
|
||||
auto f = formatter(cfg);
|
||||
return [f] (LogMsg const &m) {std::cout << f(m) << std::endl;};
|
||||
Sink console_sink(LoggingConfig const &) {
|
||||
return [](LogMsg const &m) {
|
||||
std::cout << fmt::format("{:<8} | {}", m.subsystem_name, m.msg)
|
||||
<< std::endl;
|
||||
};
|
||||
}
|
||||
|
||||
Sink syslog_sink(LoggingConfig const&cfg) {
|
||||
Sink syslog_sink(LoggingConfig const &cfg) {
|
||||
#ifdef WIN32
|
||||
return null_sink();
|
||||
#else
|
||||
auto f = formatter(cfg);
|
||||
return [f] (LogMsg const &m) {syslog (LOG_INFO | LOG_USER,"%s",f(m).c_str ());};
|
||||
return [f](LogMsg const &m) {
|
||||
syslog(LOG_INFO | LOG_USER, "%s", f(m).c_str());
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
std::ifstream::pos_type filesize(std::string const&filename)
|
||||
{
|
||||
if(!boost::filesystem::exists(filename))
|
||||
std::ifstream::pos_type filesize(std::string const &filename) {
|
||||
if (!boost::filesystem::exists(filename))
|
||||
return 0;
|
||||
else {
|
||||
std::ifstream in(filename, std::ifstream::ate | std::ifstream::binary);
|
||||
@@ -88,24 +82,21 @@ std::ifstream::pos_type filesize(std::string const&filename)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Sink file_sink(LoggingConfig const&cfg) {
|
||||
Sink file_sink(LoggingConfig const &cfg) {
|
||||
static std::ofstream stream;
|
||||
static uint64_t bytes_written = 0;
|
||||
static uint64_t bytes_written = 0;
|
||||
const auto max_sz = 120 * 1024 * 1024;
|
||||
|
||||
auto f= formatter(cfg);
|
||||
|
||||
auto f = formatter(cfg);
|
||||
auto path = log_path();
|
||||
path /= "log";
|
||||
|
||||
|
||||
auto parent = path.parent_path();
|
||||
|
||||
|
||||
if (!boost::filesystem::is_directory(parent))
|
||||
if (!boost::filesystem::is_directory(parent))
|
||||
bts_assert(boost::filesystem::create_directories(parent));
|
||||
|
||||
if(boost::filesystem::exists(path)) {
|
||||
if (boost::filesystem::exists(path)) {
|
||||
auto sz = boost::filesystem::file_size(path);
|
||||
if (sz > max_sz) {
|
||||
auto backup = boost::filesystem::path(path.string() + ".old");
|
||||
@@ -113,10 +104,9 @@ Sink file_sink(LoggingConfig const&cfg) {
|
||||
}
|
||||
}
|
||||
|
||||
stream = std::ofstream(path.string(),std::ofstream::app);
|
||||
|
||||
return [=] (LogMsg const &m) {
|
||||
stream = std::ofstream(path.string(), std::ofstream::app);
|
||||
|
||||
return [=](LogMsg const &m) {
|
||||
auto msg = f(m);
|
||||
bytes_written += msg.size();
|
||||
if (bytes_written >= max_sz) {
|
||||
@@ -124,16 +114,15 @@ Sink file_sink(LoggingConfig const&cfg) {
|
||||
stream.close();
|
||||
auto backup = boost::filesystem::path(path.string() + ".old");
|
||||
boost::filesystem::rename(path, backup);
|
||||
stream = std::ofstream(path.string(),std::ofstream::app);
|
||||
stream = std::ofstream(path.string(), std::ofstream::app);
|
||||
}
|
||||
stream << f(m) << std::endl;
|
||||
};
|
||||
}
|
||||
|
||||
Sink null_sink() {
|
||||
return [](const LogMsg&) {};
|
||||
return [](const LogMsg &) {};
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
|
||||
} // namespace log
|
||||
} // namespace bts
|
||||
@@ -120,6 +120,8 @@ void configure_logging(bts::config::Logging const&cfg, bts::config::ThreadGroupC
|
||||
{log::Plugin,"Plugin"},
|
||||
{log::Sdk,"Sdk"},
|
||||
{log::Http,"Http"},
|
||||
{log::Spartan,"Spartan"},
|
||||
{log::iLink3,"ilink3"},
|
||||
};
|
||||
|
||||
real_cfg.sinks["console"] =
|
||||
|
||||
@@ -45,7 +45,9 @@ constexpr log::Subsystem Latency {Testing.ordinal+1 };
|
||||
constexpr log::Subsystem DataFlow {Latency.ordinal+1 };
|
||||
constexpr log::Subsystem Plugin {DataFlow.ordinal+1 };
|
||||
constexpr log::Subsystem Sdk {Plugin.ordinal+1 };
|
||||
constexpr log::Subsystem Http {Sdk.ordinal+1 };
|
||||
constexpr log::Subsystem Http {Sdk.ordinal+1 };
|
||||
constexpr log::Subsystem Spartan {Http.ordinal+1 };
|
||||
constexpr log::Subsystem iLink3 {Spartan.ordinal+1 };
|
||||
|
||||
struct LoggerHandle {
|
||||
LoggerHandle(LoggerHandle const&) = delete;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
#include "lib/utils/ValueWrapper.h"
|
||||
namespace bts {
|
||||
using ExchangeSecurityKey = utils::ValueWrapper<struct ExchangeSecurityKeyTag,uint64_t>;
|
||||
}
|
||||
@@ -60,10 +60,10 @@ class IntPrice {
|
||||
return delta.mantissa() < 0;
|
||||
}
|
||||
}
|
||||
bool operator <=(const IntPrice& other) {
|
||||
bool operator <=(const IntPrice& other) const {
|
||||
return *this == other || *this < other;
|
||||
}
|
||||
bool operator >=(const IntPrice& other) {
|
||||
bool operator >=(const IntPrice& other) const {
|
||||
return !(*this < other);
|
||||
}
|
||||
IntPrice operator - (const IntPrice& o) const {
|
||||
|
||||
+172
-166
@@ -1,71 +1,72 @@
|
||||
#ifndef _WIN32
|
||||
#include "MBOServiceServer.h"
|
||||
#include "MBOServiceServer.h"
|
||||
|
||||
#include "lib/api/services/OrderService.client.pb.h"
|
||||
#include "lib/utils/Dispatcher.h"
|
||||
#include "lib/utils/TimeStamp.h"
|
||||
#include "lib/domain_model/Security.h"
|
||||
#include "MDClient.h"
|
||||
#include "ExchangeOrderKey.h"
|
||||
#include "MBOProcessor.h"
|
||||
#include "MDClient.h"
|
||||
#include "lib/api/services/OrderService.client.pb.h"
|
||||
#include "lib/domain_model/Security.h"
|
||||
#include "lib/orderman/orderman_utils/orderman_common.h"
|
||||
#include "lib/utils/Dispatcher.h"
|
||||
#include "lib/utils/TimeStamp.h"
|
||||
|
||||
#include "lib/utils/LockBox.h"
|
||||
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <vector>
|
||||
|
||||
using namespace bts::api::orderman;
|
||||
|
||||
namespace bts {
|
||||
namespace md {
|
||||
namespace bts {
|
||||
namespace md {
|
||||
|
||||
//
|
||||
// Simple class to handle MD recovery and maintain an index of SecurityKey=>MDConsumerHandle
|
||||
// Simple class to handle MD recovery and maintain an index of
|
||||
// SecurityKey=>MDConsumerHandle
|
||||
|
||||
class HandleIndex {
|
||||
MDClient& _client;
|
||||
MDClient &_client;
|
||||
int _sub;
|
||||
std::optional<MDConsumer> _consumer;
|
||||
|
||||
public:
|
||||
utils::LockBox<std::unordered_map<SecurityKey,MDConsumerHandle>> index;
|
||||
public:
|
||||
utils::LockBox<std::unordered_map<SecurityKey, MDConsumerHandle>> index;
|
||||
|
||||
HandleIndex(md::MDClient& client):
|
||||
_client(client),
|
||||
_sub(0),
|
||||
_consumer(std::nullopt),
|
||||
index() {
|
||||
_sub = _client.on_consumer().subscribe([=](const MDConsumer& c) { on_consumer(c); });
|
||||
on_consumer(_client.current_consumer());
|
||||
}
|
||||
HandleIndex(md::MDClient &client)
|
||||
: _client(client), _sub(0), _consumer(std::nullopt), index() {
|
||||
_sub = _client.on_consumer().subscribe(
|
||||
[=](const MDConsumer &c) { on_consumer(c); });
|
||||
on_consumer(_client.current_consumer());
|
||||
}
|
||||
|
||||
~HandleIndex() { _client.on_consumer().unsubscribe(_sub); }
|
||||
|
||||
|
||||
private:
|
||||
void on_consumer(const MDConsumer& c) {
|
||||
private:
|
||||
void on_consumer(const MDConsumer &c) {
|
||||
MDConsumer temp(c);
|
||||
if (temp.all_heartbeats_ok()) {
|
||||
auto existing = _consumer ? _consumer->id() : 0;
|
||||
LOG(md,Info, "Updateing MBOService MDConsumer. Old {} new {}", existing, temp.id());
|
||||
LOG(md, Info, "Updateing MBOService MDConsumer. Old {} new {}",
|
||||
existing, temp.id());
|
||||
// clear the index
|
||||
index.lock([](auto& index) { index.clear(); });
|
||||
index.lock([](auto &index) { index.clear(); });
|
||||
// Swap to new consumer
|
||||
if (_consumer) {
|
||||
_consumer->swap(temp);
|
||||
} else {
|
||||
_consumer = temp;
|
||||
}
|
||||
else { _consumer = temp; }
|
||||
// Subscribe to on_security
|
||||
auto id = _consumer->id();
|
||||
_consumer->on_security([this,id](const SecurityPtr&, MDConsumerHandle handle) {
|
||||
if (_consumer->id() == id) {
|
||||
index.lock([handle](auto& index) {
|
||||
index[SecurityKey(handle.key())] = handle;
|
||||
});
|
||||
}
|
||||
});
|
||||
_consumer->on_security(
|
||||
[this, id](const SecurityPtr &, MDConsumerHandle handle) {
|
||||
if (_consumer->id() == id) {
|
||||
index.lock([handle](auto &index) {
|
||||
index[SecurityKey(handle.key())] = handle;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -73,21 +74,20 @@ private:
|
||||
class ActiveOrder {
|
||||
SecurityKey _security;
|
||||
SparkOrderKey _id;
|
||||
ExchangeOrderKey _ex_id;
|
||||
ExchangeOrderKey _ex_id;
|
||||
int32_t _position;
|
||||
|
||||
public:
|
||||
public:
|
||||
// empty constructor needed for unordered map operator[]
|
||||
// ActiveOrder(): _security(), _id(), _ex_id(), _position(-1) { bts_assert(false); }
|
||||
ActiveOrder(SecurityKey sec, SparkOrderKey s, ExchangeOrderKey ex): _security(sec), _id(s), _ex_id(ex), _position(-1) {}
|
||||
ActiveOrder(SecurityKey sec, SparkOrderKey s, const std::string& ex): _security(sec), _id(s), _ex_id(), _position(-1) {
|
||||
_ex_id = ExchangeOrderKey(std::stoul(ex));
|
||||
}
|
||||
// ActiveOrder(): _security(), _id(), _ex_id(), _position(-1) {
|
||||
// bts_assert(false); }
|
||||
ActiveOrder(SecurityKey sec, SparkOrderKey s, ExchangeOrderKey ex)
|
||||
: _security(sec), _id(s), _ex_id(ex), _position(-1) {}
|
||||
|
||||
SecurityKey security_id() const { return _security; }
|
||||
SparkOrderKey id() const { return _id; }
|
||||
ExchangeOrderKey exchange_id() const { return _ex_id; }
|
||||
int32_t& position() { return _position; };
|
||||
int32_t &position() { return _position; };
|
||||
int32_t position() const { return _position; };
|
||||
bool set_position(int32_t pos) {
|
||||
if (pos != _position) {
|
||||
@@ -108,23 +108,14 @@ public:
|
||||
// MBOService
|
||||
|
||||
struct MBOServiceImpl {
|
||||
MBOServiceImpl(
|
||||
api::ServiceContext& ctx,
|
||||
utils::Dispatcher& d,
|
||||
md::MDClient& c,
|
||||
MBOServiceBase::PiqPublisher&& pub
|
||||
):
|
||||
dispatcher(d),
|
||||
client(c),
|
||||
orders(ctx.locate<api::orderman::OrderService>()),
|
||||
handle_index(c),
|
||||
publish(pub),
|
||||
timer(d, 200, [&]() {timer_tick();}),
|
||||
orders_sub()
|
||||
{}
|
||||
MBOServiceImpl(api::ServiceContext &ctx, utils::Dispatcher &d,
|
||||
md::MDClient &c, MBOServiceBase::PiqPublisher &&pub)
|
||||
: dispatcher(d), client(c),
|
||||
orders(ctx.locate<api::orderman::OrderService>()), handle_index(c),
|
||||
publish(pub), timer(d, 200, [&]() { timer_tick(); }), orders_sub() {}
|
||||
|
||||
utils::Dispatcher& dispatcher;
|
||||
md::MDClient& client;
|
||||
utils::Dispatcher &dispatcher;
|
||||
md::MDClient &client;
|
||||
OrderService orders;
|
||||
|
||||
HandleIndex handle_index;
|
||||
@@ -138,23 +129,23 @@ struct MBOServiceImpl {
|
||||
void flush();
|
||||
};
|
||||
|
||||
|
||||
|
||||
///////////////////////
|
||||
|
||||
std::optional<uint32_t> search_orders(const ExchangeOrderKey oid, const std::vector<SnapshotOrder>& orders) {
|
||||
std::optional<uint32_t>
|
||||
search_orders(const ExchangeOrderKey oid,
|
||||
const std::vector<SnapshotOrder> &orders) {
|
||||
IntPrice price = {};
|
||||
size_t position = 0;
|
||||
for (size_t x = 0; x < orders.size(); ++x) {
|
||||
const auto& oo = orders[x];
|
||||
const auto &oo = orders[x];
|
||||
if (oo.id == oid) {
|
||||
if (oo.price == price) return { position };
|
||||
else return 0;
|
||||
}
|
||||
else if (price == oo.price) {
|
||||
if (oo.price == price)
|
||||
return {position};
|
||||
else
|
||||
return 0;
|
||||
} else if (price == oo.price) {
|
||||
position += oo.size;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
price = oo.price;
|
||||
position = oo.size;
|
||||
}
|
||||
@@ -162,11 +153,11 @@ std::optional<uint32_t> search_orders(const ExchangeOrderKey oid, const std::vec
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool update_position(const HandleIndex& handles, ActiveOrder& order) {
|
||||
const auto& index = handles.index;
|
||||
auto handle = index.lock([id=order.security_id()](const auto& index) {
|
||||
bool update_position(const HandleIndex &handles, ActiveOrder &order) {
|
||||
const auto &index = handles.index;
|
||||
auto handle = index.lock([id = order.security_id()](const auto &index) {
|
||||
auto iter = index.find(id);
|
||||
return iter != index.end() ? iter->second : MDConsumerHandle {};
|
||||
return iter != index.end() ? iter->second : MDConsumerHandle{};
|
||||
});
|
||||
|
||||
if (handle.is_initialized()) {
|
||||
@@ -185,9 +176,9 @@ bool update_position(const HandleIndex& handles, ActiveOrder& order) {
|
||||
}
|
||||
|
||||
void MBOServiceImpl::timer_tick() {
|
||||
//Dispatcher thread
|
||||
// Dispatcher thread
|
||||
std::vector<OrderPIQ> rows;
|
||||
for (auto& pair : active) {
|
||||
for (auto &pair : active) {
|
||||
if (update_position(handle_index, pair.second)) {
|
||||
rows.push_back(pair.second.to_piq());
|
||||
}
|
||||
@@ -197,29 +188,30 @@ void MBOServiceImpl::timer_tick() {
|
||||
}
|
||||
}
|
||||
|
||||
const NativeOrderState* native_order_state(const OrderRecord& record) {
|
||||
switch(record.state().custom_case()) {
|
||||
case OrderState::kMarket:
|
||||
return &record.state().market().native_state();
|
||||
case OrderState::kLimit:
|
||||
return &record.state().limit().native_state();
|
||||
case OrderState::kStop:
|
||||
return &record.state().stop().native_state();
|
||||
case OrderState::kStopLimit:
|
||||
return &record.state().stop_limit().native_state();
|
||||
case OrderState::kGlbxIceberg:
|
||||
return &record.state().glbx_iceberg().native_state();
|
||||
default:
|
||||
const NativeOrderState *native_order_state(const OrderRecord &record) {
|
||||
switch (record.state().custom_case()) {
|
||||
case OrderState::kMarket:
|
||||
return &record.state().market().native_state();
|
||||
case OrderState::kLimit:
|
||||
return &record.state().limit().native_state();
|
||||
case OrderState::kStop:
|
||||
return &record.state().stop().native_state();
|
||||
case OrderState::kStopLimit:
|
||||
return &record.state().stop_limit().native_state();
|
||||
case OrderState::kGlbxIceberg:
|
||||
return &record.state().glbx_iceberg().native_state();
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_active_exchange_order(const OrderRecord& record) {
|
||||
bool is_active_exchange_order(const OrderRecord &record) {
|
||||
return record.state().status() == ORDER_STATUS_WORKING &&
|
||||
native_order_state(record) != nullptr;
|
||||
}
|
||||
|
||||
void try_remove(MBOServiceImpl& me, std::set<uint32_t>& to_remove, const OrderRecord& record) {
|
||||
void try_remove(MBOServiceImpl &me, std::set<uint32_t> &to_remove,
|
||||
const OrderRecord &record) {
|
||||
auto key = SparkOrderKey(record.key());
|
||||
auto iter = me.active.find(key);
|
||||
if (iter != me.active.end()) {
|
||||
@@ -227,103 +219,113 @@ void try_remove(MBOServiceImpl& me, std::set<uint32_t>& to_remove, const OrderRe
|
||||
to_remove.insert(key.value());
|
||||
}
|
||||
}
|
||||
void try_add(MBOServiceImpl& me, std::vector<OrderPIQ>& to_add, const OrderRecord& record) {
|
||||
void try_add(MBOServiceImpl &me, std::vector<OrderPIQ> &to_add,
|
||||
const OrderRecord &record) {
|
||||
if (is_active_exchange_order(record)) {
|
||||
auto native = native_order_state(record);
|
||||
|
||||
auto ex_key = orderman::get_exchange_order_id(*native);
|
||||
auto u64_key =
|
||||
std::visit(overloaded{[](orderman::ExchangeOrderID const &str) {
|
||||
return std::stoul(str.value().data());
|
||||
},
|
||||
[](orderman::ExchangeOrderID64 oid) {
|
||||
return oid.value();
|
||||
}},
|
||||
ex_key);
|
||||
bts_assert(native);
|
||||
ActiveOrder order(
|
||||
SecurityKey(record.def().security_key()),
|
||||
SparkOrderKey(record.key()),
|
||||
native->exchange_order_id());
|
||||
ActiveOrder order(SecurityKey(record.def().security_key()),
|
||||
SparkOrderKey(record.key()), ExchangeOrderKey{u64_key});
|
||||
update_position(me.handle_index, order);
|
||||
to_add.push_back(order.to_piq());
|
||||
me.active.insert(std::make_pair(order.id(), order));
|
||||
}
|
||||
}
|
||||
|
||||
MBOServiceServer::MBOServiceServer(
|
||||
api::ServiceContext& ctx,
|
||||
utils::Dispatcher& d,
|
||||
md::MDClient& c
|
||||
) :
|
||||
MBOServiceBase(ctx),
|
||||
_me(new MBOServiceImpl(ctx,d,c,make_piq_publisher()))
|
||||
{
|
||||
// subscribe to mdclient ✔
|
||||
// make publishers ✔
|
||||
// subscribe to orders => stash active orders dict
|
||||
_me->orders_sub =
|
||||
_me->orders.subscribe_orders().subscribe([=](const auto& update) {
|
||||
// api thread
|
||||
const auto& added = update.added();
|
||||
const auto& changed = update.changed();
|
||||
const auto& removed = update.removed();
|
||||
_me->dispatcher.post([this,added,changed,removed]() {
|
||||
// dispatcher thread
|
||||
std::vector<OrderPIQ> to_add, to_change;
|
||||
std::set<uint32_t> to_remove;
|
||||
MBOServiceServer::MBOServiceServer(api::ServiceContext &ctx,
|
||||
utils::Dispatcher &d, md::MDClient &c)
|
||||
: MBOServiceBase(ctx),
|
||||
_me(new MBOServiceImpl(ctx, d, c, make_piq_publisher())) {
|
||||
// subscribe to mdclient ✔
|
||||
// make publishers ✔
|
||||
// subscribe to orders => stash active orders dict
|
||||
_me->orders_sub =
|
||||
_me->orders.subscribe_orders().subscribe([=](const auto &update) {
|
||||
// api thread
|
||||
const auto &added = update.added();
|
||||
const auto &changed = update.changed();
|
||||
const auto &removed = update.removed();
|
||||
_me->dispatcher.post([this, added, changed, removed]() {
|
||||
// dispatcher thread
|
||||
std::vector<OrderPIQ> to_add, to_change;
|
||||
std::set<uint32_t> to_remove;
|
||||
|
||||
// Remove
|
||||
for(const auto& r : removed) {
|
||||
// If it was active remove it and add to to_remove
|
||||
try_remove(*_me, to_remove, *r);
|
||||
}
|
||||
// Added
|
||||
for(const auto& add : added) {
|
||||
// If active add look up the position and add to the state
|
||||
try_add(*_me, to_add, *add);
|
||||
}
|
||||
// Changed
|
||||
for(const auto& ch : changed) {
|
||||
// new order is active and old is not look up piq and add to state
|
||||
bool is_active = is_active_exchange_order(*ch.current());
|
||||
bool was_active = is_active_exchange_order(*ch.previous());
|
||||
if (is_active && !was_active) {
|
||||
try_add(*_me, to_add, *ch.current());
|
||||
}
|
||||
else if (was_active && !is_active) {
|
||||
try_remove(*_me, to_remove, *ch.current());
|
||||
}
|
||||
// is_active && was_active => don't care
|
||||
// !is_active && !was_active => don't care
|
||||
}
|
||||
// Remove
|
||||
for (const auto &r : removed) {
|
||||
// If it was active remove it and add to to_remove
|
||||
try_remove(*_me, to_remove, *r);
|
||||
}
|
||||
// Added
|
||||
for (const auto &add : added) {
|
||||
// If active add look up the position and add to the state
|
||||
try_add(*_me, to_add, *add);
|
||||
}
|
||||
// Changed
|
||||
for (const auto &ch : changed) {
|
||||
// new order is active and old is not look up piq and add to
|
||||
// state
|
||||
bool is_active = is_active_exchange_order(*ch.current());
|
||||
bool was_active = is_active_exchange_order(*ch.previous());
|
||||
if (is_active && !was_active) {
|
||||
try_add(*_me, to_add, *ch.current());
|
||||
} else if (was_active && !is_active) {
|
||||
try_remove(*_me, to_remove, *ch.current());
|
||||
}
|
||||
// is_active && was_active => don't care
|
||||
// !is_active && !was_active => don't care
|
||||
}
|
||||
|
||||
_me->publish(&to_add, &to_change, &to_remove);
|
||||
if (!_me->timer.running()) _me->timer.start();
|
||||
});
|
||||
});
|
||||
}
|
||||
_me->publish(&to_add, &to_change, &to_remove);
|
||||
if (!_me->timer.running())
|
||||
_me->timer.start();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
MBOServiceServer::~MBOServiceServer() { }
|
||||
MBOServiceServer::~MBOServiceServer() {}
|
||||
|
||||
|
||||
void MBOServiceServer::get_orders_for_security(const MBOSecurityQuery& request, const api::Response<PositionData>& reply) {
|
||||
void MBOServiceServer::get_orders_for_security(
|
||||
const MBOSecurityQuery &request, const api::Response<PositionData> &reply) {
|
||||
PositionData response;
|
||||
response.set_security_id(request.security_id());
|
||||
auto handle = _me->handle_index.index.lock([id=request.security_id()](const auto& index) {
|
||||
auto iter = index.find(SecurityKey(id));
|
||||
return iter != index.end() ? iter->second : MDConsumerHandle {};
|
||||
});
|
||||
auto handle = _me->handle_index.index.lock(
|
||||
[id = request.security_id()](const auto &index) {
|
||||
auto iter = index.find(SecurityKey(id));
|
||||
return iter != index.end() ? iter->second : MDConsumerHandle{};
|
||||
});
|
||||
|
||||
std::unordered_map<ExchangeOrderKey, SparkOrderKey> reverse;
|
||||
for (const auto& pair : _me->active) {
|
||||
for (const auto &pair : _me->active) {
|
||||
reverse.insert(std::make_pair(pair.second.exchange_id(), pair.first));
|
||||
}
|
||||
|
||||
size_t count = 0;
|
||||
auto tick = handle.get_minimum_tick();
|
||||
if(handle.is_initialized()) {
|
||||
if (handle.is_initialized()) {
|
||||
auto mbo = handle.get_mbo();
|
||||
if (mbo) {
|
||||
for (const auto& o : mbo->bids) {
|
||||
for (const auto &o : mbo->bids) {
|
||||
double price = o.price.price();
|
||||
bool isnan = os::is_nan(request.price_level());
|
||||
if (isnan || securities::test_price_equality(request.price_level(), price, tick)) {
|
||||
if (isnan || securities::test_price_equality(request.price_level(),
|
||||
price, tick)) {
|
||||
++count;
|
||||
if (request.limit() && count > request.limit()) break;
|
||||
auto* entry = response.add_bid();
|
||||
if (request.limit() && count > request.limit())
|
||||
break;
|
||||
auto *entry = response.add_bid();
|
||||
entry->set_exchange_id(o.id.value());
|
||||
if (isnan) entry->set_price(price);
|
||||
if (isnan)
|
||||
entry->set_price(price);
|
||||
entry->set_size(o.size);
|
||||
auto iter = reverse.find(o.id);
|
||||
if (iter != reverse.end()) {
|
||||
@@ -331,15 +333,18 @@ void MBOServiceServer::get_orders_for_security(const MBOSecurityQuery& request,
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const auto& o : mbo->asks) {
|
||||
for (const auto &o : mbo->asks) {
|
||||
double price = o.price.price();
|
||||
bool isnan = os::is_nan(request.price_level());
|
||||
if (isnan || securities::test_price_equality(request.price_level(), price, tick)) {
|
||||
if (isnan || securities::test_price_equality(request.price_level(),
|
||||
price, tick)) {
|
||||
++count;
|
||||
if (request.limit() && count > request.limit()) break;
|
||||
auto* entry = response.add_ask();
|
||||
if (request.limit() && count > request.limit())
|
||||
break;
|
||||
auto *entry = response.add_ask();
|
||||
entry->set_exchange_id(o.id.value());
|
||||
if (isnan) entry->set_price(price);
|
||||
if (isnan)
|
||||
entry->set_price(price);
|
||||
entry->set_size(o.size);
|
||||
auto iter = reverse.find(o.id);
|
||||
if (iter != reverse.end()) {
|
||||
@@ -349,9 +354,10 @@ void MBOServiceServer::get_orders_for_security(const MBOSecurityQuery& request,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
reply(response);
|
||||
}
|
||||
|
||||
}} //namespace
|
||||
} // namespace md
|
||||
} // namespace bts
|
||||
#endif
|
||||
@@ -92,7 +92,7 @@ MDConsumer& MDClient::current_consumer() const {
|
||||
return _self->_consumer;
|
||||
}
|
||||
SecurityOracle MDClient::oracle() const {
|
||||
return SecurityOracle(*this);
|
||||
return SecurityOracle(_self->_cache);
|
||||
}
|
||||
std::set<UserSymbol> MDClient::symbols() const {
|
||||
return _self->_symbols;
|
||||
|
||||
@@ -897,7 +897,7 @@ public:
|
||||
scan_securities(resolve_legs);
|
||||
}
|
||||
|
||||
SecurityPtr get_security(SecurityKey key) const {
|
||||
const Security* get_security(SecurityKey key) const {
|
||||
return _cache.get_security(key);
|
||||
}
|
||||
|
||||
@@ -979,7 +979,7 @@ size_t MDConsumer::walk_security_list(SecurityCallback cb, const string& symbol,
|
||||
|
||||
size_t MDConsumer::scan_securities(bool resolve_legs) { return _pimpl->scan_securities(resolve_legs); }
|
||||
void MDConsumer::on_security(SecurityCallback cb, bool resolve_legs) { _pimpl->on_security(cb, resolve_legs); }
|
||||
const api::Security* MDConsumer::get_security(SecurityKey key) const { return _pimpl->get_security(key).get(); }
|
||||
const api::Security* MDConsumer::get_security(SecurityKey key) const { return _pimpl->get_security(key); }
|
||||
std::vector<api::Security const*> MDConsumer::get_securities() const {return _pimpl->get_securities();}
|
||||
|
||||
MDConsumerChannel MDConsumer::get_channel(const std::string& symbol, SecurityType type, Venue exchange) const {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "SecurityCache.h"
|
||||
#include "SecurityDB.h"
|
||||
#include "lib/utils/Dispatcher.h"
|
||||
#include "lib/utils/LockBox.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <google/btree/btree_map.h>
|
||||
#include <tbb/concurrent_queue.h>
|
||||
#include <mutex>
|
||||
|
||||
@@ -10,8 +12,8 @@ namespace bts {
|
||||
namespace md {
|
||||
|
||||
struct SecurityCacheImpl {
|
||||
std::mutex cache_mutex;
|
||||
std::unordered_map<SecurityKey, SecurityPtr> cache;
|
||||
utils::LockBox<btree::btree_map<SecurityKey, SecurityPtr>> cache;
|
||||
utils::LockBox<btree::btree_map<ExchangeSecurityKey, SecurityPtr>> ex_cache;
|
||||
tbb::concurrent_queue<SecurityPtr> update_queue;
|
||||
void enqueue_update_db(const SecurityPtr&);
|
||||
void flush();
|
||||
@@ -42,61 +44,83 @@ void SecurityCacheImpl::flush() {
|
||||
SecurityCache::SecurityCache() : _me(std::make_shared<SecurityCacheImpl>()) {}
|
||||
SecurityCache::~SecurityCache() {}
|
||||
|
||||
SecurityPtr SecurityCache::try_get_security(SecurityKey key) const {
|
||||
std::lock_guard<std::mutex> lock(_me->cache_mutex);
|
||||
auto iter = _me->cache.find(key);
|
||||
if (iter != _me->cache.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
return nullptr;
|
||||
const Security* SecurityCache::try_get_security(SecurityKey key) const {
|
||||
return _me->cache.lock([key](btree::btree_map<SecurityKey, SecurityPtr>& t) {
|
||||
auto iter = t.find(key);
|
||||
if (iter != t.end()) {
|
||||
return iter->second.get();
|
||||
}
|
||||
return (const api::Security*)nullptr;
|
||||
});
|
||||
}
|
||||
const Security* SecurityCache::try_get_security(ExchangeSecurityKey key) const {
|
||||
return _me->ex_cache.lock([key](btree::btree_map<ExchangeSecurityKey,SecurityPtr>& t) {
|
||||
auto iter = t.find(key);
|
||||
if (iter != t.end()) {
|
||||
return iter->second.get();
|
||||
}
|
||||
return (const api::Security*)nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
SecurityPtr SecurityCache::get_security(SecurityKey key) {
|
||||
std::unique_lock<std::mutex> lock(_me->cache_mutex);
|
||||
auto iter = _me->cache.find(key);
|
||||
if (iter != _me->cache.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
else {
|
||||
// unlock for db read
|
||||
lock.unlock();
|
||||
|
||||
const Security* SecurityCache::get_security(SecurityKey key) {
|
||||
const Security* result = try_get_security(key);
|
||||
if (result == nullptr) {
|
||||
// outside lock
|
||||
auto security = db::find_security(key);
|
||||
if (security) {
|
||||
LOG(md,Info, "Loaded security from database: {} {}", security->symbol(), security->id());
|
||||
return add_db_security(security);
|
||||
}
|
||||
return security;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<api::Security const*> SecurityCache::get_securities()
|
||||
{
|
||||
std::vector<api::Security const*> result;
|
||||
result.reserve(100000);
|
||||
|
||||
std::unique_lock<std::mutex> lock(_me->cache_mutex);
|
||||
for (auto const&p : _me->cache)
|
||||
result.push_back(p.second.get());
|
||||
return result;
|
||||
}
|
||||
|
||||
SecurityPtr SecurityCache::add_db_security(const SecurityPtr& security) {
|
||||
std::vector<api::Security const*> SecurityCache::get_securities() {
|
||||
std::vector<api::Security const*> result;
|
||||
result.reserve(100000);
|
||||
|
||||
_me->cache.lock([&result](auto& cache) {
|
||||
for (auto const&p : cache) {
|
||||
result.push_back(p.second.get());
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
const Security* SecurityCache::add_db_security(const SecurityPtr& security) {
|
||||
bts_assert(security);
|
||||
std::lock_guard<std::mutex> lock(_me->cache_mutex);
|
||||
SecurityKey key(security->id());
|
||||
auto result = _me->cache.insert(std::make_pair(SecurityKey(security->id()), security));
|
||||
// If result was inserted result.first->second is equal to security
|
||||
// If the value was already present it must be a recently inserted 'live' security and we should use it
|
||||
return result.first->second;
|
||||
if (security->has_glbx()) {
|
||||
_me->ex_cache.lock([&security](auto& cache) {
|
||||
ExchangeSecurityKey key(security->id());
|
||||
cache.insert(std::make_pair(key, security));
|
||||
});
|
||||
}
|
||||
return _me->cache.lock([&security](auto& cache) {
|
||||
SecurityKey key(security->id());
|
||||
auto result = cache.insert(std::make_pair(key, security));
|
||||
// If result was inserted result.first->second is equal to security
|
||||
// If the value was already present it must be a recently inserted 'live' security and we should use it
|
||||
return result.first->second.get();
|
||||
});
|
||||
}
|
||||
bool SecurityCache::add_live_security(const SecurityPtr& security) {
|
||||
bts_assert(security);
|
||||
std::lock_guard<std::mutex> lock(_me->cache_mutex);
|
||||
SecurityKey key(security->id());
|
||||
// Insert but don't overwrite existing
|
||||
auto result = _me->cache.insert(std::make_pair(SecurityKey(security->id()), security));
|
||||
_me->enqueue_update_db(security);
|
||||
return result.second;
|
||||
if (security->has_glbx()) {
|
||||
_me->ex_cache.lock([&security](auto& cache) {
|
||||
ExchangeSecurityKey key(security->id());
|
||||
cache.insert(std::make_pair(key, security));
|
||||
});
|
||||
}
|
||||
return _me->cache.lock([&](auto& cache) {
|
||||
SecurityKey key(security->id());
|
||||
// Insert but don't overwrite existing
|
||||
auto result = cache.insert(std::make_pair(SecurityKey(security->id()), security));
|
||||
_me->enqueue_update_db(security);
|
||||
return result.second;
|
||||
});
|
||||
}
|
||||
|
||||
void SecurityCache::flush_to_disk() { _me->flush(); }
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "lib/domain_model/Security.pb.h"
|
||||
#include "MDConsumerHandle.h"
|
||||
#include "lib/domain_model/SecurityKey.h"
|
||||
#include "lib/md/ExchangeSecurityKey.h"
|
||||
#include "SecurityPtr.h"
|
||||
#include <memory>
|
||||
|
||||
@@ -20,17 +21,18 @@ public:
|
||||
~SecurityCache();
|
||||
|
||||
//Load security from cache with fallback to database
|
||||
SecurityPtr get_security(SecurityKey key);
|
||||
const Security* get_security(SecurityKey key);
|
||||
|
||||
// Load all securities from cache, no fallback to database
|
||||
std::vector<api::Security const*> get_securities();
|
||||
|
||||
// Get the security if it's in the cache otherwise return nullptr. Does not query security database.
|
||||
SecurityPtr try_get_security(SecurityKey key) const;
|
||||
const Security* try_get_security(SecurityKey key) const;
|
||||
const Security* try_get_security(ExchangeSecurityKey key) const;
|
||||
|
||||
// returns true if the cache was updated
|
||||
bool add_live_security(const SecurityPtr& security);
|
||||
SecurityPtr add_db_security(const SecurityPtr& security);
|
||||
const Security* add_db_security(const SecurityPtr& security);
|
||||
|
||||
void flush_to_disk();
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/bts_core/utils/bts_no_copy.h"
|
||||
#include "Shm/FixedSecurity.h"
|
||||
#include "../bts_conn_exports.h"
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <atomic>
|
||||
|
||||
namespace bts {
|
||||
namespace md {
|
||||
|
||||
|
||||
class BTS_EXPORT SecurityConstructor {
|
||||
// An object "pool" optimized for the case where only one instance is ever used at a time
|
||||
template <class T>
|
||||
class SingleObjectPool<T> {
|
||||
public:
|
||||
using ptr_type = std::unique_ptr<T, std::function<void(T*)>>;
|
||||
ptr_type acquire() {
|
||||
T* pt = _inst ? _inst.release() : new T();
|
||||
return ptr_type(pt, [this](T* ptr) {
|
||||
return_inst(std::unique_ptr<T>(ptr));
|
||||
});
|
||||
}
|
||||
private:
|
||||
void return_inst(std::unique_ptr<T> t) {
|
||||
if (!_inst) {
|
||||
reset(t);
|
||||
_inst = std::move(t);
|
||||
}
|
||||
}
|
||||
unique_ptr<T> _inst;
|
||||
};
|
||||
|
||||
public:
|
||||
SecurityConstructor() : _future(), _option(), _spread() {}
|
||||
|
||||
SingleObjectPool<FixedFutureSecurity>& future() { return _future; }
|
||||
SingleObjectPool<FixedOptionSecurity>& option() { return _option; }
|
||||
SingleObjectPool<FixedSpreadSecurityL>& spread() { return _spread; }
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
void reset(T& t) {
|
||||
new (&t)T();
|
||||
}
|
||||
|
||||
SingleObjectPool<FixedFutureSecurity> _future;
|
||||
SingleObjectPool<FixedOptionSecurity> _option;
|
||||
SingleObjectPool<FixedSpreadSecurityL> _spread;
|
||||
};
|
||||
|
||||
|
||||
}}//namespace
|
||||
|
||||
@@ -75,7 +75,7 @@ void apply_compatibilit_mutations(Security& security) {
|
||||
}
|
||||
|
||||
size_t load_securities(
|
||||
const std::set<UserSymbol>& symbols,
|
||||
std::function<bool(const UserSymbol &symbo)> const&sym_filter,
|
||||
const std::function<void(const api::Security&)>& callback) {
|
||||
|
||||
size_t count = 0;
|
||||
@@ -92,7 +92,7 @@ size_t load_securities(
|
||||
api::Venue venue = (api::Venue)(int) select_stmt.getColumn("venue");
|
||||
auto type = (api::SecurityType)(int) select_stmt.getColumn("type");
|
||||
UserSymbol us(symbol, venue, type);
|
||||
if (symbols.find(us) != symbols.end()) {
|
||||
if (sym_filter(us)) {
|
||||
auto blob = select_stmt.getColumn("security_blob");
|
||||
if (security.ParseFromArray(blob, blob.getBytes())) {
|
||||
apply_compatibilit_mutations(security);
|
||||
@@ -109,6 +109,14 @@ size_t load_securities(
|
||||
return count;
|
||||
}
|
||||
|
||||
size_t load_securities(
|
||||
const std::set<UserSymbol>& symbols,
|
||||
const std::function<void(const api::Security&)>& callback) {
|
||||
return load_securities([&symbols] (UserSymbol const&symbol) {
|
||||
return symbols.find(symbol) != symbols.end();
|
||||
},callback);
|
||||
}
|
||||
|
||||
SecurityPtr find_security(SecurityKey key) {
|
||||
try {
|
||||
auto db = open_db();
|
||||
|
||||
@@ -28,6 +28,10 @@ size_t load_securities(
|
||||
const std::set<UserSymbol>& symbols,
|
||||
const std::function<void(const api::Security&)>& callback);
|
||||
|
||||
size_t load_securities(
|
||||
std::function<bool(const UserSymbol &symbo)> const&sym_filter,
|
||||
const std::function<void(const api::Security&)>& callback) ;
|
||||
|
||||
SecurityPtr find_security(SecurityKey);
|
||||
|
||||
Result insert_or_replace(const std::vector<SecurityPtr>&);
|
||||
|
||||
@@ -4,14 +4,18 @@
|
||||
namespace bts {
|
||||
namespace md {
|
||||
|
||||
SecurityOracle::SecurityOracle(const MDClient& client): _client(client) {}
|
||||
SecurityOracle::SecurityOracle(SecurityCache& cache): _cache(cache) {}
|
||||
SecurityOracle::~SecurityOracle() { }
|
||||
const api::Security* SecurityOracle::get_security(SecurityKey key) const {
|
||||
return _client.current_consumer().get_security(key);
|
||||
return _cache.get_security(key);
|
||||
}
|
||||
|
||||
const api::Security* SecurityOracle::get_security(ExchangeSecurityKey key) const {
|
||||
return _cache.try_get_security(key);
|
||||
}
|
||||
|
||||
std::vector<api::Security const*> SecurityOracle::get_securities() const {
|
||||
return _client.current_consumer().get_securities();
|
||||
return _cache.get_securities();
|
||||
}
|
||||
|
||||
}}//namespace
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/domain_model/SecurityKey.h"
|
||||
#include "lib/md/ExchangeSecurityKey.h"
|
||||
#include "lib/md/SecurityCache.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@@ -9,11 +11,12 @@ namespace api {class Security;}
|
||||
namespace md {
|
||||
class MDClient;
|
||||
class SecurityOracle {
|
||||
const MDClient& _client;
|
||||
SecurityCache& _cache;
|
||||
public:
|
||||
SecurityOracle(const MDClient&);
|
||||
SecurityOracle(SecurityCache&);
|
||||
~SecurityOracle();
|
||||
const api::Security* get_security(SecurityKey key) const;
|
||||
const api::Security* get_security(ExchangeSecurityKey key) const;
|
||||
std::vector<api::Security const*> get_securities() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <pugixml/pugixml.hpp>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
|
||||
|
||||
@@ -22,6 +23,27 @@ using namespace bts::api;
|
||||
namespace bts {
|
||||
namespace md {
|
||||
|
||||
std::ostream& operator<<(std::ostream&out, md::CMEConnection const&c)
|
||||
{
|
||||
out << "feed_type: " << c.feed_type
|
||||
<< " ip: " << c.ip
|
||||
<< " port: " << c.port
|
||||
<< " feed: " << c.feed;
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream&out, md::CMEChannel const &ch) {
|
||||
out << "id: " << ch.id << "\n";
|
||||
out << "symbols: \n";
|
||||
for (auto s : ch.symbols)
|
||||
out << "\t" << s.symbol() << ":" << api::SecurityType_Name(s.type()) << "\n" ;
|
||||
out << "Connections:\n";
|
||||
for (auto const &[st,c] : ch.connections)
|
||||
out << "\t" << st << " -> {" << c << "}\n";
|
||||
out << "\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
string data_path() {
|
||||
auto p = config::get<config::System>().data_path() + "cme_mdp3/";
|
||||
#ifdef _WIN32
|
||||
@@ -169,4 +191,4 @@ const vector<CMEChannel> parse_channels(const vector<UserSymbol>& symbols) {
|
||||
|
||||
|
||||
}} //namespace
|
||||
#endif
|
||||
#endif
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace bts {
|
||||
namespace md {
|
||||
|
||||
@@ -23,6 +22,9 @@ struct CMEChannel {
|
||||
std::map<std::string, CMEConnection> connections;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream&out, md::CMEConnection const&c);
|
||||
std::ostream& operator<<(std::ostream&out, md::CMEChannel const &ch);
|
||||
|
||||
void await_cme_config();
|
||||
const std::vector<CMEChannel> get_configured_cme_channels();
|
||||
const std::vector<CMEChannel> parse_channels(const std::vector<UserSymbol>& symbols);
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
|
||||
# Overview
|
||||
|
||||
The core abstraction that everything else is built on is the MDProducer+MDProducerHandle / MDConsumer+MDConsumerHandle.
|
||||
|
||||
A new market data source constructs an MDProducer and adds securities to it. When a security is added you get back an MDProducerHandle representing that security in shared memory. The memory is fully allocated and books can be written immidiately but the security will not be visible to the MDConsumer until the security key is stored on disk (SecurityIDRecorder). The MDProducerHandle assumes a **single writer** for most operations and *may break silently if this constraint is violated*.
|
||||
|
||||
The MDConsumer is the dual of the MDProducer. It provides an on_security() callback which is driven by the call to scan_securities(). No threads are created by MDConsumer/MDProducer instead they get cpu time from periodic calls to scan_securities (consumer), SecurityIDRecorder::do_work (producer). When a security is discovered by scan_securities the callback is called with the Security and the MDConsumerHandle. The MDConsumerHandle is thread safe and can be safely copied and read from concurrently.
|
||||
|
||||
## Single Writer Principle
|
||||
- https://mechanical-sympathy.blogspot.com/2011/09/single-writer-principle.html
|
||||
|
||||
# Core Classes
|
||||
|
||||
'*' = New in spark
|
||||
* MBOProcessor*
|
||||
* MBOServiceServer*
|
||||
* MDClient*
|
||||
* MDConsumer
|
||||
* MDConsumerHandle
|
||||
* MDProducer
|
||||
* MDProducerHandle
|
||||
* PlatformLoader
|
||||
* PriceSize/IntPrice
|
||||
* SecurityCache*
|
||||
* SecurityOracle*
|
||||
* SecurityDB*
|
||||
* SecurityIDRecorder
|
||||
* SecurityMapper*
|
||||
* SettlementRecorder
|
||||
* SyntheticSecurityService
|
||||
* FixedSecurity.h / MDStructure.h
|
||||
* SharedList.h
|
||||
|
||||
## MBOProcessor*
|
||||
|
||||
This class is an optional dependency of MDProducer. It takes the low level incremental updates to the MBO book and constructs the book on a different thread. This is optimized for the UI use case so it tries to get the mbo messages out of the critical path as soon as possible. This uses regular heap memory so is not compatible with out of process operation. It exposes a reader and writer interface.
|
||||
|
||||
Each update goes into a queue and gets processed by MBOProcessorImpl::process_incremental() on a single background thread. This thread drains the queue and constructs the books in place. Then it copies snapshots of the books and publishes them as immutable snapshots which are consumed by the MBOServiceServer/UI. If mbo load gets very high this function will stop publishing snapshots and only update books until the load reduces.
|
||||
|
||||
## MBOServiceServer*
|
||||
|
||||
Reads the snapshots from the MBOProcessor/MBOReader and serves them for the UI.
|
||||
|
||||
## MDClient*
|
||||
|
||||
New in spark.
|
||||
|
||||
This class handles constructing the MDConsumer, calling scan_securities on it and checking for bad heartbeats and re-constructing the MDConsumer if there was a failure. In edge those tasks were the responsibility of each consumer of the market data but it was mitigated because most things used streams rather than MDConsumer directly. MDConsumer is reference counted internally so when the consuming code gets an on_consumer() callback with a new MDConsumer it should keep a copy of the old MDConsumer until it has finished any asyncronous processes involving the MDConsumerHandles from that first consumer. Once an MDConsumer is destroyed the MDConsumerHandles it produced will cause an **Access Violation** on reading because the memory has been unmapped.
|
||||
|
||||
Spark has always used MD in process so, while based on existing functionality, this recovery process hasn't been well tested.
|
||||
|
||||
## MDConsumer
|
||||
|
||||
An MDConsumer maps the shared memory sections and produces MDConsumerHandles. These handles are only valid as long as the MDConsumer exists. It would make some sense to store the MDConsumer reference in the MDConsumerHandle to avoid this but MDConsumerHandle is designed to be *very* small for fast iteration. The MDConsumer also holds a reference to the ISyntheticSecurityService and makes synthetic securities 'look like' regular shared memory securities using polymorphism in the MDConsumerHandle.
|
||||
|
||||
Internally MDConsumer is a collection of MDConsumerInst which each handle a single symbol+type+exchange and the corresponding shared memory blocks.
|
||||
|
||||
* scan_securities - in spark this is always called by MDClient
|
||||
* get_handle - Low level way to get a handle. Does a linear walk though shared memory and can return a void handle (MDConsumerHandle::is_initialize() == false).
|
||||
* get_managed_handle - returns a 'managed handle' this is a shared_ptr to an MDConsumerhandle. The only difference is that this is tracked by the MDConsumer and may transition from uninitialized to initialized. Storing these in a vector and walking them is almost *50% slower* than doing the same thing with an unmanaged handle. If you use these it's probably best to store the uninitialized handles in a nursery and check them periodically. You can dereference a managed handle into a regular handle at any time.
|
||||
* get_channel - Gets a MDConsumerChannel representing common data for a symbol+type+exchange. This is mostly for the trade ticker / rfq and also exposes various counters which get published to dev-stats.
|
||||
|
||||
On Linux MDConsumer maps the shared memory as read-only pages. On Windows it cannot do this because std::atomic uses a different instruction which is considered a write by the CPU so we map it read/write.
|
||||
|
||||
If we have multiple platforms that can produce md for an exchange (i.e. onixs vs emumba) the MDConsumer consults the PlatformMap config key to determine which to read from. The md replayer impersonates the producer it was recorded from.
|
||||
|
||||
### MDConsumerChannel
|
||||
|
||||
read_trades() and read_rfqs() read from a ring buffer stored in the header section of the shared memory. They read directly into a google::protobuf::RepeatedPtrField to avoid extra copies in the QueryServer but can just as easily read into a std::vector. They expose a 'cursor' representing the position in the ring buffer and this cursor is sent all the way to the client so it can request updates.
|
||||
|
||||
## MDConsumerHandle
|
||||
|
||||
An MDConsumerHandle 4 states and would proably be impemented as an std::variant<> if done today. If not for the high performance requirements it could also be a virtual class but I didn't want to pay for a vtable. It is the size of 4 pointers plus the enum tag.
|
||||
|
||||
* VOID - an uninitialized handle
|
||||
* BBO - Legacy from Edge. This represents an option book where we only kept the top to save space. I think this has rotted by now and wont work but I kept it as an example of how to add polymorphism to the shared memory types.
|
||||
* DEPTH - Used for all exchange securities in Spark.
|
||||
* SYNTHETIC - A Synthetic handle. These are bigger so they get stored as a pointer.
|
||||
|
||||
Reading from a BBO/DEPTH handle is done with an optimistic copy. If you inrease the size of the book data this copy can fail more often and get significantly worse perf. The result of the read can be changed, unchanged or busy (timeout). In edge 'busy' happened 1-2 times per day across all reads and gets logged by QueryServer.
|
||||
|
||||
## MDProducer
|
||||
|
||||
Handle to writeable shared memory. Each market data producer "platform" (onixs_cme, onixs_ice, emumba, etc) constructs one.
|
||||
|
||||
## MDProducerHandle
|
||||
|
||||
All updates to a single security go through here. Assumes a single writer thread.
|
||||
|
||||
## PlatformLoader
|
||||
|
||||
In Edge this was the entry point to the run() for the market data producer process. It loaded the bts_md_*.so so each producer process only loaded the third party objects for a particular producer. In spark this is all in process so this is defunct. It looks like it still exists because it has some utility functions that probably belong in another file.
|
||||
|
||||
## PriceSize/IntPrice
|
||||
|
||||
Market data uses integer prices to avoid double problems.
|
||||
|
||||
## SecurityCache*
|
||||
|
||||
Created/Owned by MDClient this owns the Securities.
|
||||
|
||||
It has methods to get a security from the live collection or load them from the SecurityDB on disk if someone asks for one that hasn't been seen yet.
|
||||
* If a security is loaded from disk it 'freezes' it so when the live security arrives it will continue to serve the old security so we don't end up with 2 copies of a single security with different properties.
|
||||
* This class is also responsible for sending the live securities to the SecurityDB where we *always* overwrite stored securities with what comes from the exchange.
|
||||
* Survives beyond the MDConsumer in case of crash/recovery of out of process md.
|
||||
|
||||
## SecurityOracle*
|
||||
Interface on top of SecurityCache exposing the read get_ operations.
|
||||
|
||||
## SecurityDB*
|
||||
* Just a collection of methods for save/load of securities to sqlite.
|
||||
* Stored in binary format so we can use the protobuf versioning
|
||||
|
||||
## SecurityIDRecorder
|
||||
* Manages security to unique 32 bit id mapping across multiple processes
|
||||
* Provides a callback when ids are safely persisted.
|
||||
|
||||
## SecurityMapper*
|
||||
|
||||
* Happens *before* the security gets stored in shared memory.
|
||||
* Replaces the mapping.h from edge with a more organized mechanism.
|
||||
* Owned by the MDProducer each security is passed though SecurityMapper::apply() before it is first stored in shared memory
|
||||
* SecurityMapper is made up of multiple ISecurityMapper instances so each mapping can be in it's own class so it's easier to read each mapping. Currently all mappings are defined in SecurityMaper.cpp
|
||||
* The mappings each have an opportunity to mutate the FixedSecurity.
|
||||
|
||||
## SettlementRecorder
|
||||
|
||||
In Edge SettlementRecorder stored the settlements for a security so we could preserve yesterday/day before settlement. In Spark this broke and nobody seemed to care so it was never fixed.
|
||||
|
||||
## SyntheticSecurityService
|
||||
|
||||
Each synthetic security is a api::Security and a chunk of metadata. This service handles API requests to create/update synthetics and fires callbacks for MDConsumer which does the work of producing synethic books.
|
||||
|
||||
## MDStructure.h
|
||||
|
||||
### Hot vs Cold
|
||||
|
||||
## FixedSecurity.h
|
||||
* variable sized structure in shared mem
|
||||
* For FixedSpreadSecurity we stack allocate a lot of legs then memcpy() into shared memory only the correct number of legs
|
||||
* When accessing FixedSpreadSecurity it is cast back to a large number of legs. Iterate legs based on leg_count() not the static leg count.
|
||||
|
||||
## SharedList.h
|
||||
* Primitive list-like abstraction over shared memory
|
||||
* Allows variable sized entries so always accessed in O(N)
|
||||
* Data never moves so we point into it for O(1)
|
||||
|
||||
# Market Data Relay / Recorder
|
||||
* QueryServer
|
||||
- Stateless request/response
|
||||
- Uses multiple threads for throughput
|
||||
- Uses change timestamps per channel instead of per security
|
||||
- Will over-send books that change around the time of the request
|
||||
|
||||
* RelayClient
|
||||
- Runs in the shell (or outside)
|
||||
- Replicates books from the server (QueryServer) to local shared memory
|
||||
|
||||
* RelayRecorder
|
||||
- Records Protobufs from QueryServer to a file
|
||||
|
||||
# Diagnostic tools
|
||||
* sparkd md dump [symbol] [type] [exchange] [hot?]
|
||||
- **Primary diagnostic tool**
|
||||
- ShmDumper.cpp
|
||||
- Shows current contents of shared memory
|
||||
- append 'hot' to the end to see hot data i.e. books
|
||||
- If you get a "cannot open" check that the file exists in /run/shm/
|
||||
* dumpsecurities
|
||||
- Inspect security database
|
||||
* sparkd md tail
|
||||
- MDPeriodicDumper.cpp
|
||||
- for validating new market data
|
||||
- prints books at given sequence number interval
|
||||
* rectool
|
||||
- print recording to text / convert back to futures.coconut
|
||||
- This is most useful to checking if a particular symbol is in a replay file
|
||||
- Occasionally useful for testing very specific market data transitions
|
||||
|
||||
# Tuning / Dealing with Loss
|
||||
|
||||
## Packet loss
|
||||
#### If a small number 1-5 is lost it's upstream
|
||||
- Use tcpdump to capture
|
||||
- Check the tcpdump for gaps
|
||||
- Ask Pete to contact hosting provider
|
||||
#### If large gap probably overflow
|
||||
- make sure socket buffers sizes, rmem_max, spin_time, data_wait are all set
|
||||
- check affinity is set and working
|
||||
- check ethtool
|
||||
|
||||
|
||||
#### Show ethernet ring buffer sizes
|
||||
ethtool -g eth0
|
||||
#### change ethernet ring buffer rx size
|
||||
sudo ethtool -G [device] rx 4096
|
||||
#### interface statistics
|
||||
ethtool -S eth0
|
||||
- particularly look at:
|
||||
ethtool -S p1p1 | egrep "(bad)|(nodesc)"
|
||||
|
||||
### If increasing the ring buffer doesn't work you can tweak interrupt coalescing using:
|
||||
- /proc/sys/net/core/dev_weight
|
||||
- This is the maximum number of packets that can be dequeued in a single interrupt
|
||||
- https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Performance_Tuning_Guide/s-network-common-queue-issues.html
|
||||
|
||||
- **NOTE**: We've never used this and it's unlikely it will fix anything
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
|
||||
|
||||
********************
|
||||
classes
|
||||
********************
|
||||
|
||||
btscmd md => PlatformLoader
|
||||
|
||||
PlatformLoader:
|
||||
* Loads the platform specific dll
|
||||
* Calls ->start_marketdata() with a full vector<security_info>
|
||||
|
||||
SharedList<T> / SharedListWriter
|
||||
* Shared memory list object which spans across shared memory segments as necessary
|
||||
* O(N) walk
|
||||
* atomic add()
|
||||
* Single adder / multiple readers
|
||||
* no delete
|
||||
* Custom header
|
||||
|
||||
SecurityIDRecorder
|
||||
* add_security(security, lambda callback) -> int returns security id instantly
|
||||
* security_persisted callback when security id is safely persisted
|
||||
|
||||
SecurityIndex
|
||||
* Platform Implementation helper
|
||||
* Maps exhange_id to (ProducerHandle + Data)
|
||||
*
|
||||
|
||||
CacheEntry / CacheEntryDepth (CacheStructure.h)
|
||||
* CacheEntry(symbol, depth, # legs) -- size determined in constructor
|
||||
* Simple inheritance tree for optional depth
|
||||
* Has FixedSecurity
|
||||
* Fits in SharedList<T>
|
||||
* CRITICAL fields are at the front cache aligned. bbo/depth. Security goes at the end
|
||||
|
||||
* size, is_public(), is_persisted, is_resolved (spread)
|
||||
* statistics like bbo/trade counters
|
||||
* is_status_ok
|
||||
* bbo, depth, trade, status, open, close
|
||||
|
||||
FixedSecurity / FixsdSpreadSecurity
|
||||
* Normalized version of our protobuf security
|
||||
* Has methods to convert to pb Security
|
||||
* Size known at construction w/ # legs - spread legs of type security_key
|
||||
* Can use a union for option/future fields
|
||||
|
||||
MDProducer(symbol, type)
|
||||
* manages lifetime of SharedList instances
|
||||
* Hands out MDProducerHandle - entry for one security
|
||||
|
||||
MDProducerHandle
|
||||
* pointers to shared memory
|
||||
* update methods
|
||||
|
||||
MDConsumer
|
||||
* list of securities
|
||||
* find_security_id(symbol, type, etc)
|
||||
* get_cache_handle(security id#)
|
||||
* Hands out MDCacheHandle
|
||||
- if security is null add MDCacheHandle to a list to be updated
|
||||
next time securities are polled
|
||||
|
||||
MDCacheHandle
|
||||
* If security is not present add this is "null"
|
||||
* has pointers to relevant shared memory
|
||||
|
||||
|
||||
|
||||
********************
|
||||
* Cache Structure
|
||||
********************
|
||||
|
||||
2 Shared memory segment for each (SYMBOL, TYPE) - md_hot (bbo,depth,status), md_cold (others)
|
||||
|
||||
When a new security is discovered
|
||||
1. id is allocated to the security
|
||||
2. New CacheEntry is allocated in appropriate arena (is_public=false)
|
||||
3. md_cache entry count is incremented
|
||||
4. When id is persisted is_public=true, increment version on cache arena
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "lib/persistence/SqliteStore.h"
|
||||
#include "lib/utils/PBUtils.h"
|
||||
#include "lib/orderman/actors/SODPosition.h"
|
||||
#include "lib/utils/overloaded.h"
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <sys/time.h>
|
||||
@@ -39,6 +40,7 @@ struct FillStore::PImpl {
|
||||
|
||||
FillStore::FillStore(md::SecurityOracle o) : me(new PImpl(o)) {}
|
||||
|
||||
// returns the sod type of a non sod type fill
|
||||
auto sod_fill_kind (const api::orderman::Fill& fill){
|
||||
auto rv = Fill::FILL_KIND_SOD;
|
||||
switch (fill.fill_kind()){
|
||||
@@ -52,6 +54,7 @@ auto sod_fill_kind (const api::orderman::Fill& fill){
|
||||
rv = Fill::FILL_KIND_SOD_STRIP_LEG;
|
||||
break;
|
||||
default:
|
||||
LOG(persist, Error, "Stored fill kinds can not be SOD");
|
||||
rv = Fill::FILL_KIND_SOD;
|
||||
break;
|
||||
}
|
||||
@@ -60,24 +63,19 @@ auto sod_fill_kind (const api::orderman::Fill& fill){
|
||||
|
||||
auto leg_fill_kind (const api::Security& parent,
|
||||
const api::Security& child){
|
||||
if (parent.has_ice()){
|
||||
if(securities::is_strip(parent))
|
||||
return Fill::FILL_KIND_STRIP_LEG;
|
||||
else{
|
||||
// parent is a spread
|
||||
if(securities::is_spread_of_strips(parent)){
|
||||
// this has 3 levels strip spread -> strip -> outright
|
||||
// first level is an ordinary leg and second is a strip leg.
|
||||
// since we dont get the level passed we have to
|
||||
// use the following heurestics
|
||||
if(securities::is_strip(child))
|
||||
return Fill::FILL_KIND_LEG;
|
||||
else
|
||||
return Fill::FILL_KIND_STRIP_LEG;
|
||||
}
|
||||
else
|
||||
// regular spread
|
||||
if(securities::is_strip(parent))
|
||||
return Fill::FILL_KIND_STRIP_LEG;
|
||||
else{
|
||||
// parent is a spread
|
||||
if(securities::is_spread_of_strips(parent)){
|
||||
// this has 3 levels strip spread -> strip -> outright
|
||||
// first level is an ordinary leg and second is a strip leg.
|
||||
// since we dont get the level passed we have to
|
||||
// use the following heurestics
|
||||
if(securities::is_strip(child))
|
||||
return Fill::FILL_KIND_LEG;
|
||||
else
|
||||
return Fill::FILL_KIND_STRIP_LEG;
|
||||
}
|
||||
}
|
||||
return Fill::FILL_KIND_LEG;
|
||||
@@ -167,8 +165,21 @@ void FillStore::on_execution_report(
|
||||
fill.set_fill_status(api::orderman::Fill::FILL_STATUS_CORRECTED);
|
||||
fill.set_fill_key(fk);
|
||||
|
||||
auto exchange_ts = utils::pb::to_timestamp(
|
||||
datetime::parse_FIX_timestamp(to_str(er.transact_time)));
|
||||
auto exchange_ts =
|
||||
std::visit(overloaded {
|
||||
[](const orderman::ExchangeTimeStampStr& ts) {
|
||||
return utils::pb::to_timestamp(
|
||||
datetime::parse_FIX_timestamp(to_str(ts)));
|
||||
},
|
||||
[](ExchangeTimeStamp64 ts) {
|
||||
google::protobuf::Timestamp gts;
|
||||
auto seconds = ts.value() / 1E9;
|
||||
gts.set_seconds(seconds);
|
||||
gts.set_nanos(ts.value() - (seconds * 1E9));
|
||||
return gts;
|
||||
}
|
||||
}, er.transact_time);
|
||||
|
||||
*fill.mutable_timestamp() = exchange_ts;
|
||||
|
||||
auto it = me->known_orders.find(er.order_key);
|
||||
|
||||
@@ -222,7 +222,9 @@ void GLBXExecutionGateway::on_exe_report(
|
||||
msg.get<fix::ManualOrderIndicator>()
|
||||
? api::orderman::MANUAL_ORDER_INDICATOR_YES
|
||||
: api::orderman::MANUAL_ORDER_INDICATOR_YES;
|
||||
str_to(msg.get<fix::OrderID>(), &data->exchange_order_id);
|
||||
str_to(msg.get<fix::OrderID>(),
|
||||
& std::get<ExchangeOrderID>(
|
||||
data->exchange_order_id));
|
||||
|
||||
if (msg.has<fix::Price>())
|
||||
data->price = securities::decode_exchange_price(
|
||||
@@ -261,7 +263,9 @@ void GLBXExecutionGateway::on_exe_report(
|
||||
: Price(0);
|
||||
if (msg.has<fix::ExecID>())
|
||||
str_to(msg.get<fix::ExecID>(), &data->exchange_fill_id);
|
||||
str_to(msg.get<fix::TransactTimeStr>(), &data->transact_time);
|
||||
orderman::ExchangeTimeStampStr t;
|
||||
str_to(msg.get<fix::TransactTimeStr>(), &t);
|
||||
data->transact_time = t;
|
||||
|
||||
if (msg.has<fix::CustOrderHandlingInst>())
|
||||
data->cust_order_handling_inst = msg.get<fix::CustOrderHandlingInst>();
|
||||
@@ -280,12 +284,16 @@ void GLBXExecutionGateway::on_cancel_reject(
|
||||
decode_clorid(msg.get<fix::ClOrdID>(), &ok, &sk);
|
||||
|
||||
std::string reject_msg;
|
||||
CancelRejectReason reason = CancelRejectReason::Other;
|
||||
if (msg.has<fix::Text>())
|
||||
reject_msg = msg.get<fix::Text>();
|
||||
else if (msg.has<fix::CXlRejReason>())
|
||||
else if (msg.has<fix::CXlRejReason>()) {
|
||||
if (msg.get<fix::CXlRejReason>() == 2045)
|
||||
reason = CancelRejectReason::UnknownOrder;
|
||||
reject_msg = fmt::format("Order cancel was rejected with error code {}",
|
||||
msg.get<fix::CXlRejReason>());
|
||||
me->on_cancel_reject(ok, reject_msg);
|
||||
}
|
||||
me->on_cancel_reject({ok, reason,reject_msg});
|
||||
}
|
||||
|
||||
void GLBXExecutionGateway::on_connection_status_change(bool is_connected) {
|
||||
|
||||
Loaded 100 of 428 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user