Compare commits
310
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f61907eefb | ||
|
|
e01a37e4cf | ||
|
|
64fd23f0ed | ||
|
|
0220401011 | ||
|
|
af52c752f0 | ||
|
|
dc86ebd92e | ||
|
|
1ca23d7d8a | ||
|
|
bf564eb918 | ||
|
|
10637db1eb | ||
|
|
ea13bb31ec | ||
|
|
c20bd60ff7 | ||
|
|
305dc62389 | ||
|
|
f599c940b3 | ||
|
|
21477b90fe | ||
|
|
582a442ae8 | ||
|
|
b0bc03335d | ||
|
|
318db81ced | ||
|
|
454fa05692 | ||
|
|
ebba07b994 | ||
|
|
e53b7713a4 | ||
|
|
ad43b8535b | ||
|
|
ba07a6cc8a | ||
|
|
bb419cf048 | ||
|
|
7b74ff1525 | ||
|
|
2974a04281 | ||
|
|
0089bafeaa | ||
|
|
217d83e955 | ||
|
|
8ea18cb74a | ||
|
|
1b836b24a8 | ||
|
|
bad703a847 | ||
|
|
27dce596f5 | ||
|
|
bda097c754 | ||
|
|
09353b897b | ||
|
|
31009e38bb | ||
|
|
e1d66e9a0e | ||
|
|
616361eaf1 | ||
|
|
67b70d2d8c | ||
|
|
9f0a24f1ec | ||
|
|
85ad072837 | ||
|
|
6327bcc109 | ||
|
|
2e51aebc94 | ||
|
|
50ec2f14f7 | ||
|
|
2457fe4e35 | ||
|
|
59240ae45f | ||
|
|
04acb4f459 | ||
|
|
23a1f65c5f | ||
|
|
c0de84c4ec | ||
|
|
2ce99ddbd2 | ||
|
|
301df9ca36 | ||
|
|
3c58607fe1 | ||
|
|
561d8d66d5 | ||
|
|
14fc68f8e6 | ||
|
|
f19391dac5 | ||
|
|
64226d3698 | ||
|
|
65728df991 | ||
|
|
897c9808d0 | ||
|
|
022a489b18 | ||
|
|
49e3ec2f05 | ||
|
|
e8f98102d2 | ||
|
|
e6d845f970 | ||
|
|
e3b3663a78 | ||
|
|
afefaa36d1 | ||
|
|
e934e28b43 | ||
|
|
eb55be6066 | ||
|
|
27c410c485 | ||
|
|
cd8dc02487 | ||
|
|
e31a4f7265 | ||
|
|
2e83868209 | ||
|
|
0cce94129b | ||
|
|
8c643d74c6 | ||
|
|
394f495bd1 | ||
|
|
68d5a28fd4 | ||
|
|
4182b30d22 | ||
|
|
7f44233ae3 | ||
|
|
a4510ebbd9 | ||
|
|
69d9e36b4e | ||
|
|
c496a426ab | ||
|
|
1612ae7959 | ||
|
|
7c7aa727e2 | ||
|
|
45d6d0f673 | ||
|
|
80a5ec5265 | ||
|
|
09cc78914f | ||
|
|
546dbfbd54 | ||
|
|
a9e5fb8f46 | ||
|
|
7dd6efb477 | ||
|
|
0c150e1caa | ||
|
|
d2278e6b4a | ||
|
|
1b81ad7638 | ||
|
|
bd21cf56fe | ||
|
|
c37d4479b5 | ||
|
|
3f7e7d38ff | ||
|
|
591239b13e | ||
|
|
08494728f0 | ||
|
|
ef833c5705 | ||
|
|
44216afd51 | ||
|
|
cad407827d | ||
|
|
9714135b7d | ||
|
|
c82e598313 | ||
|
|
e7806d2fec | ||
|
|
090a9dfb17 | ||
|
|
27aa43f44d | ||
|
|
19e087aa69 | ||
|
|
167c8c23a0 | ||
|
|
d235f4be41 | ||
|
|
ec43dbd82d | ||
|
|
f07998d6a6 | ||
|
|
b3dc2cdcd4 | ||
|
|
0963aee137 | ||
|
|
c2f8e92b10 | ||
|
|
7ae0142dff | ||
|
|
c30bab899f | ||
|
|
46544f36f1 | ||
|
|
c7df3ac43c | ||
|
|
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 | ||
|
|
c3786d9d64 | ||
|
|
9080e3124b | ||
|
|
d9c536124a | ||
|
|
7de6b2907e | ||
|
|
75f017e9f8 | ||
|
|
7757ab3ea0 | ||
|
|
3186dd383c | ||
|
|
45f751c9c6 | ||
|
|
e4d3774980 | ||
|
|
eedb3ce05d | ||
|
|
6a7d38c0fd | ||
|
|
31ccbfcd19 | ||
|
|
c2abf90cc4 | ||
|
|
8dc4735248 | ||
|
|
d940d9f11d | ||
|
|
1e0c75c6c7 | ||
|
|
3bb9961af4 | ||
|
|
da8088fd8d | ||
|
|
748a65f671 | ||
|
|
66d80136bd | ||
|
|
81189bb2cc | ||
|
|
e5681a50f2 | ||
|
|
69fe4569e3 | ||
|
|
c7caf66f9c | ||
|
|
14504f4a94 | ||
|
|
5b601a4016 | ||
|
|
45aa75e8bb | ||
|
|
b2471d45b2 | ||
|
|
11e2df8c76 | ||
|
|
cba6852655 | ||
|
|
5eeaedde26 | ||
|
|
b63052dbaa | ||
|
|
29f5bc798e | ||
|
|
04603acbb9 | ||
|
|
bc6890055e | ||
|
|
ea94c09c78 | ||
|
|
e3c3bc78fc | ||
|
|
a11d390dcd | ||
|
|
7c74a961d4 | ||
|
|
5db21ad2ca | ||
|
|
f703dabdfe | ||
|
|
237d3eea4b | ||
|
|
818bdec130 | ||
|
|
d257cf2c77 | ||
|
|
079f46404f | ||
|
|
edcc73e934 | ||
|
|
bc7ac8523b | ||
|
|
0c4c2b7231 | ||
|
|
420351c093 | ||
|
|
f69e6b89c5 | ||
|
|
c3e22e4b23 | ||
|
|
880c95d92b | ||
|
|
3231ffb343 | ||
|
|
8d7f1738cf | ||
|
|
9101214e66 | ||
|
|
c6b2e2f21e | ||
|
|
2eac97c1a9 | ||
|
|
b4b0e10f29 | ||
|
|
38d9db4a90 | ||
|
|
6a679ff78c | ||
|
|
aba3f21020 | ||
|
|
fede19fd11 | ||
|
|
3fa8dbf112 | ||
|
|
77ae4703b3 | ||
|
|
a28bfa1175 | ||
|
|
4e4a48283d | ||
|
|
7a761d00ce | ||
|
|
968be6a99a | ||
|
|
03404eb3f1 | ||
|
|
ff1a970982 | ||
|
|
ed890b4d84 | ||
|
|
e87003cc41 | ||
|
|
bc06037843 | ||
|
|
c4c7cebfc5 | ||
|
|
f18bcd2995 | ||
|
|
a6a1b6ac53 | ||
|
|
8c3da4e43c | ||
|
|
06b955dceb | ||
|
|
e75d15146c | ||
|
|
cb07384c9f | ||
|
|
fc9e502539 | ||
|
|
fcbf3388c0 | ||
|
|
899bea940f | ||
|
|
14b7509607 | ||
|
|
25668e8df0 | ||
|
|
5345ba8ff8 | ||
|
|
9bf05973bd | ||
|
|
cea4d05bc4 | ||
|
|
0b7208784b | ||
|
|
059ccbdab6 | ||
|
|
75eaf8c3d4 | ||
|
|
1e8fcd794f | ||
|
|
726329c4bf | ||
|
|
2d01f3f0f4 | ||
|
|
2a595c0fd7 | ||
|
|
5f9866c9e8 | ||
|
|
78f1cf88e0 | ||
|
|
4877436877 | ||
|
|
1b43124756 | ||
|
|
a1feb3fddf | ||
|
|
024328bf8b | ||
|
|
80d7e34bf1 | ||
|
|
8ab69c919b | ||
|
|
99531bcfa0 | ||
|
|
6bd516d4f2 | ||
|
|
1a1d771e1b | ||
|
|
050fcf7c6e | ||
|
|
aadeae3201 | ||
|
|
b72e8aed02 | ||
|
|
0820cc3e9a | ||
|
|
b1ba9a1315 | ||
|
|
39ce4323a1 | ||
|
|
d9fcd290d9 | ||
|
|
05939b02c5 | ||
|
|
aa91638fe4 | ||
|
|
065fc54f73 | ||
|
|
95fb13f58b | ||
|
|
4eb2931cb8 | ||
|
|
5326015a48 | ||
|
|
fcbe319470 | ||
|
|
5ad21c88b2 | ||
|
|
3a9c1d557b | ||
|
|
9d1b03d1e2 | ||
|
|
9a677cf980 | ||
|
|
6fb5b83249 | ||
|
|
95830fafdf | ||
|
|
d68b03bb91 | ||
|
|
e7062ce01e | ||
|
|
932738f98e | ||
|
|
1426b00e83 | ||
|
|
e724409b58 | ||
|
|
9cf828e9a4 | ||
|
|
41408fb609 | ||
|
|
4c21e32838 | ||
|
|
385f3ea402 | ||
|
|
8d6d8cab18 | ||
|
|
01615f824a | ||
|
|
c6779ddc90 | ||
|
|
46eff65435 | ||
|
|
25445d58d0 | ||
|
|
0b313a8aa8 | ||
|
|
54f954fd4b | ||
|
|
980f38ba03 | ||
|
|
9eada2724b | ||
|
|
b5f53ee918 | ||
|
|
efc175f654 | ||
|
|
6074afd999 | ||
|
|
219dff4055 | ||
|
|
9a3b07b622 |
No files matched your search
+6
-2
@@ -4,8 +4,7 @@ cmake-build-debug/
|
||||
.idea/
|
||||
.dir-locals.el
|
||||
*.pyc
|
||||
.vscode/*
|
||||
!.vscode/*.json
|
||||
*.vscode/*
|
||||
.vs
|
||||
obj/
|
||||
*.csproj.user
|
||||
@@ -37,3 +36,8 @@ trace_data/
|
||||
*.rej
|
||||
/build
|
||||
.clangd/
|
||||
/.cache/
|
||||
.venv/**
|
||||
install/**
|
||||
.devcontainer/**
|
||||
/src/Spark.Admin.WebApp/src/bin/
|
||||
Vendored
-107
@@ -1,107 +0,0 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"/usr/include",
|
||||
"/usr/local/include",
|
||||
"${workspaceRoot}",
|
||||
"${workspaceFolder}/src",
|
||||
"${workspaceRoot}/externals/linux/include"
|
||||
],
|
||||
"defines": [],
|
||||
"intelliSenseMode": "clang-x64",
|
||||
"browse": {
|
||||
"path": [
|
||||
"/usr/include",
|
||||
"/usr/local/include",
|
||||
"${workspaceRoot}",
|
||||
"${workspaceFolder}/src",
|
||||
"${workspaceRoot}/externals/linux/include"
|
||||
],
|
||||
"limitSymbolsToIncludedHeaders": true,
|
||||
"databaseFilename": ""
|
||||
},
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17",
|
||||
"compileCommands": "${workspaceFolder}/build/ninja_debug/compile_commands.json"
|
||||
},
|
||||
{
|
||||
"name": "Windows",
|
||||
"intelliSenseMode": "clang-x64",
|
||||
"includePath": [
|
||||
"${workspaceRoot}/src",
|
||||
"${workspaceRoot}/build/src",
|
||||
"${workspaceRoot}/build/ninja_debug/src",
|
||||
"${workspaceRoot}/externals/windows/include",
|
||||
"${workspaceRoot}/externals/linux/include",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include/c++/6",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include/x86_64-linux-gnu/c++/6",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include/c++/6/backward",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/lib/gcc/x86_64-linux-gnu/6/include",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/local/include",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include/x86_64-linux-gnu",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include"
|
||||
],
|
||||
"defines": [
|
||||
"__linux__",
|
||||
"__x86_64__"
|
||||
],
|
||||
"browse": {
|
||||
"path": [
|
||||
"${workspaceRoot}/src",
|
||||
"${workspaceRoot}/build/src",
|
||||
"${workspaceRoot}/build/ninja_debug/src",
|
||||
"${workspaceRoot}/externals/windows/include",
|
||||
"${workspaceRoot}/externals/linux/include",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include/c++/6",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include/x86_64-linux-gnu/c++/6",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include/c++/6/backward",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/lib/gcc/x86_64-linux-gnu/6/include",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/local/include",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include/x86_64-linux-gnu",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include/*"
|
||||
],
|
||||
"limitSymbolsToIncludedHeaders": true,
|
||||
"databaseFilename": ""
|
||||
},
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17"
|
||||
},
|
||||
{
|
||||
"name": "WindowsQuick",
|
||||
"intelliSenseMode": "clang-x64",
|
||||
"includePath": [
|
||||
"${workspaceRoot}/src",
|
||||
"${workspaceRoot}/build/src",
|
||||
"${workspaceRoot}/build/ninja_debug/src",
|
||||
"${workspaceRoot}/externals/windows/include",
|
||||
"${workspaceRoot}/externals/linux/include",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include/c++/6",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include/x86_64-linux-gnu/c++/6",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include/c++/6/backward",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/lib/gcc/x86_64-linux-gnu/6/include",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/local/include",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include/x86_64-linux-gnu",
|
||||
"${workspaceRoot}/externals/windows/vscode/usr/include"
|
||||
],
|
||||
"defines": [
|
||||
"__linux__",
|
||||
"__x86_64__"
|
||||
],
|
||||
"browse": {
|
||||
"path": [
|
||||
"${workspaceRoot}/src"
|
||||
],
|
||||
"limitSymbolsToIncludedHeaders": true,
|
||||
"databaseFilename": "${workspaceRoot}/.vscode/browse.vc.db"
|
||||
},
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
Vendored
-395
@@ -1,395 +0,0 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Spark Local",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/build/ninja_debug/server/sparkd",
|
||||
"args": [
|
||||
"run",
|
||||
// "test",
|
||||
// "-a",
|
||||
// "[ilink3]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}/build/ninja_debug/server/",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SparkVM Launch",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "/home/bts/spark/build/ninja_debug/server/sparkd",
|
||||
"args": [
|
||||
"run"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/ninja_debug/server/",
|
||||
"environment": [],
|
||||
"externalConsole": true,
|
||||
"MIMode": "gdb",
|
||||
"preLaunchTask": "",
|
||||
"logging": {
|
||||
"engineLogging": false
|
||||
},
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "enable pretty-printer",
|
||||
"ignoreFailures": true
|
||||
},
|
||||
{
|
||||
"description": "Skip STL",
|
||||
"text": "skip -gfi /usr/include/c++/7/bits/*.h",
|
||||
"ignoreFailures": true
|
||||
},
|
||||
{
|
||||
"description": "LD LIBRARY",
|
||||
"text": "set env LD_LIBRARY_PATH=.",
|
||||
"ignoreFailures": false
|
||||
}
|
||||
],
|
||||
"pipeTransport": {
|
||||
"pipeCwd": "${workspaceRoot}",
|
||||
"pipeProgram": "c:\\program files\\git\\usr\\bin\\ssh.exe",
|
||||
"pipeArgs": [
|
||||
"bts@sparkvm"
|
||||
],
|
||||
"debuggerPath": "/usr/bin/gdb"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/home/bts/spark/": "${workspaceRoot}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "(gdb) Launch",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/build/ninja_debug/server/sparkd/sparkd",
|
||||
"args": [
|
||||
"run"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}/build/ninja_debug/src/server/sparkd",
|
||||
"environment": [],
|
||||
"externalConsole": true,
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Client Launch",
|
||||
"type": "clr",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/build/Debug/bin/net471/spark.exe",
|
||||
"args": [],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"stopAtEntry": false,
|
||||
"externalConsole": true,
|
||||
"requireExactSource": false
|
||||
},
|
||||
{
|
||||
"name": "SDK Launch",
|
||||
"type": "clr",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/build/Debug/bin/net471/spark_sdk.exe",
|
||||
"args": [
|
||||
"md",
|
||||
"GLBX",
|
||||
"Future",
|
||||
"CL",
|
||||
"CLZ9",
|
||||
"--user=bts",
|
||||
"--pass="
|
||||
],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"stopAtEntry": false,
|
||||
"externalConsole": true,
|
||||
"requireExactSource": false
|
||||
},
|
||||
{
|
||||
"name": "Excel Launch",
|
||||
"type": "clr",
|
||||
"request": "launch",
|
||||
"program": "C:/Program Files/Microsoft Office/Office14/EXCEL.EXE",
|
||||
"args": [
|
||||
"${workspaceRoot}/build/Debug/bin/net471/spark_excel-addin64-packed.xll"
|
||||
],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"stopAtEntry": false,
|
||||
"externalConsole": true,
|
||||
"requireExactSource": false
|
||||
},
|
||||
{
|
||||
"name": "Client Tests",
|
||||
"type": "clr",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/build/Debug/bin/net471/sparkcmd.exe",
|
||||
"args": [
|
||||
"test",
|
||||
"ApiUpdateTests"
|
||||
],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"stopAtEntry": false,
|
||||
"externalConsole": true,
|
||||
"requireExactSource": false
|
||||
},
|
||||
{
|
||||
"name": "Client Attach",
|
||||
"type": "clr",
|
||||
"request": "attach",
|
||||
"processId": "${command:pickProcess}"
|
||||
},
|
||||
{
|
||||
"name": "Spreader Tests",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "/home/bts/spark/build/ninja_debug/server/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"[spreader]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/ninja_debug/server/",
|
||||
"environment": [],
|
||||
"externalConsole": true,
|
||||
"MIMode": "gdb",
|
||||
"preLaunchTask": "",
|
||||
"logging": {
|
||||
"engineLogging": false
|
||||
},
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "enable pretty-printer",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"pipeTransport": {
|
||||
"pipeCwd": "${workspaceRoot}",
|
||||
"pipeProgram": "c:\\program files\\git\\usr\\bin\\ssh.exe",
|
||||
"pipeArgs": [
|
||||
"bts@sparkvm"
|
||||
],
|
||||
"debuggerPath": "/usr/bin/gdb"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/home/bts/spark/": "${workspaceRoot}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Admin Service Tests",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "/home/bts/spark/build/ninja_debug/src/server/sparkd/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"[admin_service]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/ninja_debug/src/server/sparkd/",
|
||||
"environment": [],
|
||||
"externalConsole": true,
|
||||
"MIMode": "gdb",
|
||||
"preLaunchTask": "",
|
||||
"logging": {
|
||||
"engineLogging": false
|
||||
},
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "enable pretty-printer",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"pipeTransport": {
|
||||
"pipeCwd": "${workspaceRoot}",
|
||||
"pipeProgram": "c:\\program files\\git\\usr\\bin\\ssh.exe",
|
||||
"pipeArgs": [
|
||||
"bts@sparkvm"
|
||||
],
|
||||
"debuggerPath": "/usr/bin/gdb"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/home/bts/spark/": "${workspaceRoot}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Limiter Tests",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "/home/bts/spark/build/ninja_debug/src/server/sparkd/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"[limiter]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/ninja_debug/src/server/sparkd/",
|
||||
"environment": [],
|
||||
"externalConsole": true,
|
||||
"MIMode": "gdb",
|
||||
"preLaunchTask": "",
|
||||
"logging": {
|
||||
"engineLogging": false
|
||||
},
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "enable pretty-printer",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"pipeTransport": {
|
||||
"pipeCwd": "${workspaceRoot}",
|
||||
"pipeProgram": "c:\\program files\\git\\usr\\bin\\ssh.exe",
|
||||
"pipeArgs": [
|
||||
"bts@sparkvm"
|
||||
],
|
||||
"debuggerPath": "/usr/bin/gdb"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/home/bts/spark/": "${workspaceRoot}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "MD Tests",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "/home/bts/spark/build/ninja_debug/server/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"[algo]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/ninja_debug/server/",
|
||||
"environment": [],
|
||||
"externalConsole": true,
|
||||
"MIMode": "gdb",
|
||||
"preLaunchTask": "",
|
||||
"logging": {
|
||||
"engineLogging": false
|
||||
},
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
},
|
||||
{
|
||||
"description": "Skip STL",
|
||||
"text": "skip -gfi /usr/include/c++/7/bits/*.h",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"pipeTransport": {
|
||||
"pipeCwd": "${workspaceRoot}",
|
||||
"pipeProgram": "c:\\program files\\git\\usr\\bin\\ssh.exe",
|
||||
"pipeArgs": [
|
||||
"bts@sparkvm"
|
||||
],
|
||||
"debuggerPath": "/usr/bin/gdb"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/home/bts/spark/": "${workspaceRoot}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "SparkVM attach",
|
||||
"type": "cppdbg",
|
||||
"request": "attach",
|
||||
"program": "/home/bts/spark/build/ninja_debug/src/server/sparkd/sparkd",
|
||||
"processId": "${command:pickRemoteProcess}",
|
||||
"MIMode": "gdb",
|
||||
"pipeTransport": {
|
||||
"pipeCwd": "${workspaceRoot}",
|
||||
"pipeProgram": "c:\\program files\\git\\usr\\bin\\ssh.exe",
|
||||
"pipeArgs": [
|
||||
"bts@sparkvm"
|
||||
],
|
||||
"debuggerPath": "/usr/bin/gdb"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/home/bts/spark/": "${workspaceRoot}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Python",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"stopOnEntry": false,
|
||||
"pythonPath": "${config:python.pythonPath}",
|
||||
"program": "${file}",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"env": {},
|
||||
"envFile": "${workspaceRoot}/.env",
|
||||
"args": [
|
||||
"DEBUG"
|
||||
],
|
||||
"debugOptions": [
|
||||
"WaitOnAbnormalExit",
|
||||
"WaitOnNormalExit",
|
||||
"RedirectOutput"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Remote Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": "${command:pickRemoteProcess}",
|
||||
"pipeTransport": {
|
||||
"pipeProgram": "c:\\program files\\git\\usr\\bin\\ssh.exe",
|
||||
"pipeArgs": [
|
||||
"bts@sparkvm"
|
||||
],
|
||||
"debuggerPath": "/home/bts/vsdbg/vsdbg",
|
||||
"pipeCwd": "${workspaceRoot}",
|
||||
"quoteArgs": true
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/home/bts/spark/": "${workspaceRoot}"
|
||||
},
|
||||
"justMyCode": true
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Remote Launch",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"program": "/usr/bin/dotnet",
|
||||
"args": [
|
||||
"sparkcmd.dll",
|
||||
"test",
|
||||
"test_join_create_and_takeout_market"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/ninja_debug/server",
|
||||
"pipeTransport": {
|
||||
"pipeProgram": "c:\\program files\\git\\usr\\bin\\ssh.exe",
|
||||
"pipeArgs": [
|
||||
"bts@sparkvm"
|
||||
],
|
||||
"debuggerPath": "/home/bts/vsdbg/vsdbg",
|
||||
"pipeCwd": "${workspaceRoot}",
|
||||
"quoteArgs": true
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/home/bts/spark/": "${workspaceRoot}"
|
||||
},
|
||||
"justMyCode": false
|
||||
},
|
||||
]
|
||||
}
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"utility": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"list": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"vector": "cpp",
|
||||
"xhash": "cpp",
|
||||
"xstring": "cpp",
|
||||
"system_error": "cpp",
|
||||
"array": "cpp",
|
||||
"string_view": "cpp"
|
||||
"xutility": "cpp",
|
||||
"*.ipp": "cpp"
|
||||
}
|
||||
}
|
||||
Vendored
-63
@@ -1,63 +0,0 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "client_build",
|
||||
"type": "shell",
|
||||
"command": ".\\tools\\buildspark.cmd",
|
||||
"problemMatcher":"$msCompile",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": false,
|
||||
"panel": "shared"
|
||||
},
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "server_build",
|
||||
"type": "shell",
|
||||
"command": ".\\tools\\buildsparkd.cmd",
|
||||
"problemMatcher": {
|
||||
"base": "$gcc",
|
||||
"owner": "cpp",
|
||||
"fileLocation": [
|
||||
"relative",
|
||||
"${workspaceFolder}"
|
||||
],
|
||||
"pattern": {
|
||||
"regexp": "(.?)(home)(.?)(bts)(.?)(spark)(.?)(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)",
|
||||
"file": 8,
|
||||
"line": 9,
|
||||
"column": 10,
|
||||
"severity": 11,
|
||||
"message": 12
|
||||
}
|
||||
},
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": false,
|
||||
"panel": "new"
|
||||
},
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "linux build (Debug)",
|
||||
"type": "shell",
|
||||
"command": "cd build/ninja_debug; time ninja",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
+9
-25
@@ -12,41 +12,22 @@ set (SPARK_PYTHON "${EXTERNALS_ROOT}/python")
|
||||
set (SPARK_BIN "${EXTERNALS_ROOT}/bin")
|
||||
set (SPARK_INCLUDE "${EXTERNALS_ROOT}/include")
|
||||
set (SPARK_LIB "${EXTERNALS_ROOT}/lib/${CMAKE_BUILD_TYPE}")
|
||||
set (BUILD_SDK OFF CACHE BOOL "Build the sdk")
|
||||
|
||||
include_directories (BEFORE SYSTEM ${SPARK_INCLUDE} ${EXTERNALS_ROOT}/include/zlib)
|
||||
link_directories (${SPARK_LIB})
|
||||
|
||||
if (WIN32)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
|
||||
/MP \
|
||||
/WX /wd4251 /wd4250 /wd4251 /wd4244 /wd4267 /wd4355 /wd4275 /wd4345 \
|
||||
/DCURL_STATICLIB \
|
||||
/D_WINSOCK_DEPRECATED_NO_WARNINGS \
|
||||
/D__TBB_NO_IMPLICIT_LINKAGE \
|
||||
/DBOOST_ALL_NO_LIB \
|
||||
/D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0600")
|
||||
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} /MT")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF /LTCG")
|
||||
|
||||
add_subdirectory(src/lib)
|
||||
else ()
|
||||
# so that sparkd looks for libspark.so in its directory
|
||||
set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
set (CMAKE_INSTALL_RPATH ".")
|
||||
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} \
|
||||
-fPIC -Wall -pedantic -Wextra -Werror \
|
||||
-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_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wno-undef")
|
||||
# so that sparkd looks for libspark.so in its directory
|
||||
add_subdirectory(src/server/sparkd)
|
||||
add_subdirectory(src/lib)
|
||||
add_subdirectory(src/web)
|
||||
# add_subdirectory(src/web)
|
||||
add_subdirectory(doc/user)
|
||||
add_subdirectory(src/sdk)
|
||||
if(BUILD_SDK)
|
||||
add_subdirectory(src/sdk)
|
||||
endif()
|
||||
add_subdirectory(src/data_files)
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/server
|
||||
@@ -62,4 +43,7 @@ else ()
|
||||
DEPENDS sparkd data_files_dir)
|
||||
|
||||
add_custom_target(server_layout ALL DEPENDS ${CMAKE_BINARY_DIR}/server)
|
||||
|
||||
install(FILES "${CMAKE_SOURCE_DIR}/externals/linux/lib/${CMAKE_BUILD_TYPE}/libACE-5.7.5.so" DESTINATION bin)
|
||||
install(FILES "${CMAKE_SOURCE_DIR}/externals/linux/lib/${CMAKE_BUILD_TYPE}/libOnixS.IceImpactMulticastPriceFeedHandlerCpp.so.3.16.0.0" DESTINATION bin)
|
||||
endif()
|
||||
@@ -0,0 +1,179 @@
|
||||
{
|
||||
"version": 3,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "spark",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
},
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"environment": {
|
||||
"SPARK_CMAKE_CXX_FLAGS": "/MP /WX /wd4250 /wd4251 /wd4244 /wd4267 /wd4355 /wd4275 /wd4345 /bigobj /EHsc /DCURL_STATICLIB /D_WINSOCK_DEPRECATED_NO_WARNINGS /D__TBB_NO_IMPLICIT_LINKAGE /DBOOST_ALL_NO_LIB /std:c++17 /D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0600",
|
||||
"DOTNET_TARGET_FRAMEWORK": "net471"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_CXX_FLAGS": "$env{SPARK_CMAKE_CXX_FLAGS}",
|
||||
"CMAKE_CXX_FLAGS_DEBUG": "$env{SPARK_CMAKE_CXX_FLAGS} /MTd",
|
||||
"CMAKE_CXX_FLAGS_RELEASE": "$env{SPARK_CMAKE_CXX_FLAGS} /MT",
|
||||
"CMAKE_CXX_STANDARD": "17",
|
||||
"CMAKE_SHARED_LINKER_FLAGS_DEBUG": "/DEBUG",
|
||||
"CMAKE_SHARED_LINKER_FLAGS_RELEASE": "/OPT:REF /OPT:ICF /LTCG",
|
||||
"DOTNET_BINARY_DIR": "${sourceDir}/build/$<CONFIG>/bin/$env{DOTNET_TARGET_FRAMEWORK}",
|
||||
"EXTERNALS_ROOT": "${sourceDir}/externals/windows",
|
||||
"SPARK_BIN": "${sourceDir}/externals/windows/bin",
|
||||
"SPARK_INCLUDE": "${sourceDir}/externals/windows/include",
|
||||
"SPARK_LIB": "${sourceDir}/externals/windows/lib/$<CONFIG>"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sparkd",
|
||||
"hidden": true,
|
||||
"description": "Sparkd common config",
|
||||
"binaryDir": "${sourceDir}/build/${presetName}",
|
||||
"generator": "Ninja",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Linux"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_WITH_INSTALL_RPATH": {
|
||||
"type": "BOOL",
|
||||
"value": true
|
||||
},
|
||||
"CMAKE_CXX_STANDARD": "17",
|
||||
"CMAKE_EXE_LINKER_FLAGS": "-Wno-undef",
|
||||
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install/${presetName}",
|
||||
"CMAKE_INSTALL_RPATH": ".",
|
||||
"EXTERNALS_ROOT": "${sourceDir}/externals/linux",
|
||||
"SPARK_BIN": "${sourceDir}/externals/linux/bin",
|
||||
"SPARK_INCLUDE": "${sourceDir}/externals/linux/include"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sparkd-debug-clang",
|
||||
"displayName": "Debug (clang)",
|
||||
"description": "Debug build compiled w/ clang",
|
||||
"inherits": "sparkd",
|
||||
"binaryDir": "${sourceDir}/build/clang/debug",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug",
|
||||
"CMAKE_C_COMPILER": "clang",
|
||||
"CMAKE_CXX_COMPILER": "clang++",
|
||||
"CMAKE_CXX_FLAGS_DEBUG": "-g -fPIC -Wall -pedantic -Wextra -Werror -Wno-missing-braces -Wno-ignored-qualifiers -Wno-deprecated-copy -Wno-unused-but-set-variable -Wno-c++17-extensions --std=c++17 -fdiagnostics-color -DDEBUG",
|
||||
"CMAKE_EXPORT_COMPILE_COMMANDS": {
|
||||
"type": "BOOL",
|
||||
"value": true
|
||||
},
|
||||
"SPARK_LIB": "${sourceDir}/externals/linux/lib/Debug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sparkd-release-clang",
|
||||
"displayName": "Release (clang)",
|
||||
"description": "Release build compiled w/ clang",
|
||||
"binaryDir": "${sourceDir}/build/clang/release",
|
||||
"inherits": "sparkd",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"CMAKE_C_COMPILER": "clang",
|
||||
"CMAKE_CXX_COMPILER": "clang++",
|
||||
"CMAKE_CXX_FLAGS_RELEASE": "-fPIC -Wall -pedantic -Wextra -Werror -Wno-missing-braces -Wno-ignored-qualifiers -Wno-deprecated-copy -Wno-c++17-extensions --std=c++17 -fdiagnostics-color -fno-omit-frame-pointer -DNDEBUG -O3",
|
||||
"SPARK_LIB": "${sourceDir}/externals/linux/lib/Release"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sparkd-debug-gcc",
|
||||
"displayName": "Debug (gcc)",
|
||||
"description": "Debug build compiled w/ gcc",
|
||||
"inherits": "sparkd",
|
||||
"binaryDir": "${sourceDir}/build/gcc/debug",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug",
|
||||
"CMAKE_C_COMPILER": "gcc",
|
||||
"CMAKE_CXX_COMPILER": "g++",
|
||||
"CMAKE_CXX_FLAGS_DEBUG": "-g -fPIC -Wall -pedantic -Wextra -Werror -Wno-missing-braces -Wno-ignored-qualifiers -Wno-deprecated-copy -Wno-catch-value --std=c++17 -fdiagnostics-color -DDEBUG",
|
||||
"CMAKE_EXPORT_COMPILE_COMMANDS": {
|
||||
"type": "BOOL",
|
||||
"value": true
|
||||
},
|
||||
"SPARK_LIB": "${sourceDir}/externals/linux/lib/Debug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sparkd-release-gcc",
|
||||
"displayName": "Release (gcc)",
|
||||
"description": "Release build compiled w/ gcc",
|
||||
"inherits": "sparkd",
|
||||
"binaryDir": "${sourceDir}/build/gcc/release",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"CMAKE_C_COMPILER": "/usr/local/bin/gcc",
|
||||
"CMAKE_CXX_COMPILER": "/usr/local/bin/g++",
|
||||
"CMAKE_CXX_FLAGS_RELEASE": "-fPIC -Wall -pedantic -Wextra -Werror -Wno-missing-braces -Wno-ignored-qualifiers -Wno-deprecated-copy -Wno-catch-value --std=c++17 -fdiagnostics-color -fno-omit-frame-pointer -DNDEBUG -O3",
|
||||
"SPARK_LIB": "${sourceDir}/externals/linux/lib/Release"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "spark",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
},
|
||||
"hidden": true
|
||||
},
|
||||
{
|
||||
"name": "spark-debug",
|
||||
"displayName": "Debug",
|
||||
"inherits": "spark",
|
||||
"configurePreset": "spark",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "spark-release",
|
||||
"displayName": "Release",
|
||||
"inherits": "spark",
|
||||
"configurePreset": "spark",
|
||||
"configuration": "Release"
|
||||
},
|
||||
{
|
||||
"name": "sparkd",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Linux"
|
||||
},
|
||||
"hidden": true
|
||||
},
|
||||
{
|
||||
"name": "sparkd-debug-clang",
|
||||
"configurePreset": "sparkd-debug-clang",
|
||||
"displayName": "Debug (clang)",
|
||||
"inherits": "sparkd"
|
||||
},
|
||||
{
|
||||
"name": "sparkd-debug-gcc",
|
||||
"configurePreset": "sparkd-debug-gcc",
|
||||
"displayName": "Debug (gcc)",
|
||||
"inherits": "sparkd"
|
||||
},
|
||||
{
|
||||
"name": "sparkd-release-clang",
|
||||
"configurePreset": "sparkd-release-clang",
|
||||
"displayName": "Release (clang)",
|
||||
"inherits": "sparkd"
|
||||
},
|
||||
{
|
||||
"name": "sparkd-release-gcc",
|
||||
"configurePreset": "sparkd-release-gcc",
|
||||
"displayName": "Release (gcc)",
|
||||
"inherits": "sparkd"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
set(sources /home/eric/spark/doc/user/build.sh;content/_index.md;content/bts_spark/Glossary/_index.md;content/bts_spark/Help/_index.md;content/bts_spark/Help/about_spark.png;content/bts_spark/Help/image39.png;content/bts_spark/Help/image58.png;content/bts_spark/Launcher/_index.md;content/bts_spark/Launcher/image38.png;content/bts_spark/Launcher/image68.png;content/bts_spark/Logging-In-to-the-System/_index.md;content/bts_spark/Logging-In-to-the-System/image3.png;content/bts_spark/Logging-In-to-the-System/image64.png;content/bts_spark/Market/_index.md;content/bts_spark/Market/change_securities.png;content/bts_spark/Market/image11.png;content/bts_spark/Market/image14.png;content/bts_spark/Market/image20.png;content/bts_spark/Market/image21.png;content/bts_spark/Market/image23.png;content/bts_spark/Market/image24.png;content/bts_spark/Market/image34.png;content/bts_spark/Market/image49.png;content/bts_spark/Market/image53.png;content/bts_spark/Market/image66.png;content/bts_spark/Market/image69.png;content/bts_spark/Market/market_view.png;content/bts_spark/Market/settings_icon.png;content/bts_spark/Market/time_and_sales.png;content/bts_spark/My-Windows/_index.md;content/bts_spark/My-Windows/image15.png;content/bts_spark/My-Windows/image16.png;content/bts_spark/My-Windows/image37.png;content/bts_spark/Settings/_index.md;content/bts_spark/Settings/image51.png;content/bts_spark/Settings/image9.png;content/bts_spark/Spreader/_index.md;content/bts_spark/Spreader/image10.png;content/bts_spark/Spreader/image13.png;content/bts_spark/Spreader/image18.png;content/bts_spark/Spreader/image19.png;content/bts_spark/Spreader/image28.png;content/bts_spark/Spreader/image29.png;content/bts_spark/Spreader/image31.png;content/bts_spark/Spreader/image35.png;content/bts_spark/Spreader/image40.png;content/bts_spark/Spreader/image43.png;content/bts_spark/Spreader/image54.png;content/bts_spark/Spreader/image55.png;content/bts_spark/Spreader/image56.png;content/bts_spark/Spreader/image6.png;content/bts_spark/Spreader/image7.png;content/bts_spark/Spreader/image70.png;content/bts_spark/Spreader/image72.png;content/bts_spark/Spreader/image8.png;content/bts_spark/Trading/OrderTypes/index.md;content/bts_spark/Trading/_index.md;content/bts_spark/Trading/algo_studio.png;content/bts_spark/Trading/collapse_all_icon.png;content/bts_spark/Trading/cover_algo_control.png;content/bts_spark/Trading/expand_all_icon.png;content/bts_spark/Trading/image1.png;content/bts_spark/Trading/image17.png;content/bts_spark/Trading/image2.png;content/bts_spark/Trading/image25.png;content/bts_spark/Trading/image27.png;content/bts_spark/Trading/image33.png;content/bts_spark/Trading/image42.png;content/bts_spark/Trading/image44.png;content/bts_spark/Trading/image47.png;content/bts_spark/Trading/image48.png;content/bts_spark/Trading/image5.png;content/bts_spark/Trading/image50.png;content/bts_spark/Trading/image52.png;content/bts_spark/Trading/image57.png;content/bts_spark/Trading/image59.png;content/bts_spark/Trading/image60.png;content/bts_spark/Trading/image61.png;content/bts_spark/Trading/image62.png;content/bts_spark/Trading/image73.png;content/bts_spark/Trading/image74.png;content/bts_spark/Trading/join_algo_control.png;content/bts_spark/Trading/ladder.png;content/bts_spark/Trading/ladder_badges.png;content/bts_spark/Trading/ladder_main_part.png;content/bts_spark/Trading/lean_algo_control.png;content/bts_spark/Trading/mini_orderbook.png;content/bts_spark/Trading/oco_algo_control.png;content/bts_spark/Trading/offset_algo_control.png;content/bts_spark/Trading/pnl_calculation.png;content/bts_spark/Trading/pnl_window.png;content/bts_spark/Trading/recreate_icon.png;content/bts_spark/Trading/settings_icon.png;content/bts_spark/Trading/spark_menu_order_book.png;content/bts_spark/Trading/top_algo_control.png;content/bts_spark/Trading/trigger_algo_control.png;content/bts_spark/_index.md;content/release_notes/_index.md;content/system_requirements/_index.md;static/book.js;static/favicon.ico;static/image.js;templates/index.html;templates/page.html;templates/section.html;templates/shortcodes/back_button.html)
|
||||
+1
-1
Submodule docker/linux updated: 6f0dd9324b...26de8f7b3b.
+1
-1
Submodule externals updated: 2ea5e355a6...e9120dabfe.
@@ -0,0 +1,17 @@
|
||||
astroid==2.7.3
|
||||
autopep8==1.5.7
|
||||
cffi==1.14.6
|
||||
colorama==0.4.4
|
||||
isort==5.9.3
|
||||
lazy-object-proxy==1.6.0
|
||||
mccabe==0.6.1
|
||||
platformdirs==2.3.0
|
||||
protobuf==3.19.1
|
||||
pybars3==0.9.7
|
||||
pycodestyle==2.7.0
|
||||
pycparser==2.20
|
||||
pylint==2.10.2
|
||||
PyMeta3==0.5.1
|
||||
toml==0.10.2
|
||||
wrapt==1.12.1
|
||||
yapf==0.31.0
|
||||
+168
-232
@@ -1,232 +1,168 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27130.2024
|
||||
MinimumVisualStudioVersion = 15.0.26124.0
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_api", "src\client\spark_api\spark_api.csproj", "{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspark", "build\src\lib\libspark.vcxproj", "{3335AAF0-489D-359D-8305-9B7A44E2C760}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spark", "src\client\spark\Spark.csproj", "{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sparkcmd", "src\client\sparkcmd\sparkcmd.csproj", "{387566C6-C6F6-412C-A30C-9855BBCB4816}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_core", "src\client\spark_core\spark_core.csproj", "{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", "build\ZERO_CHECK.vcxproj", "{2256015B-E7D5-3614-8F39-814CA68A4444}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_sdk", "src\client\spark_sdk\spark_sdk.csproj", "{6963C314-83C4-4667-B0D0-C2F7AE208C29}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760} = {3335AAF0-489D-359D-8305-9B7A44E2C760}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_test", "src\client\spark_test\spark_test.csproj", "{ECD78CC5-138F-4809-A764-2358C2AC2E82}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_excel", "src\client\spark_excel\spark_excel.csproj", "{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
MinSizeRel|Any CPU = MinSizeRel|Any CPU
|
||||
MinSizeRel|x64 = MinSizeRel|x64
|
||||
MinSizeRel|x86 = MinSizeRel|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
RelWithDebInfo|Any CPU = RelWithDebInfo|Any CPU
|
||||
RelWithDebInfo|x64 = RelWithDebInfo|x64
|
||||
RelWithDebInfo|x86 = RelWithDebInfo|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Debug|x64.Build.0 = Debug|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|Any CPU.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|x86.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|x86.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|x64.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|x64.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|x86.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.Debug|x64.Build.0 = Debug|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.MinSizeRel|Any CPU.ActiveCfg = MinSizeRel|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.Release|x64.ActiveCfg = Release|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.Release|x64.Build.0 = Release|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.Release|x86.ActiveCfg = Release|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
{3335AAF0-489D-359D-8305-9B7A44E2C760}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|x64.Build.0 = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|Any CPU.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|x86.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|x86.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Release|x64.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Release|x64.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Release|x86.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|x64.Build.0 = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|x86.ActiveCfg = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|x86.Build.0 = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|x64.Build.0 = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|x86.Build.0 = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Debug|x64.Build.0 = Debug|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|Any CPU.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|x86.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|x86.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Release|x64.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Release|x64.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Release|x86.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Debug|x64.Build.0 = Debug|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.MinSizeRel|Any CPU.ActiveCfg = MinSizeRel|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Release|x64.ActiveCfg = Release|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Release|x64.Build.0 = Release|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Release|x86.ActiveCfg = Release|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Debug|x64.Build.0 = Debug|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|Any CPU.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|x86.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|x86.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Release|x64.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Release|x64.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Release|x86.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.MinSizeRel|x64.Build.0 = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.MinSizeRel|x86.ActiveCfg = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.MinSizeRel|x86.Build.0 = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|x64.Build.0 = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|x86.Build.0 = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.Debug|x64.Build.0 = Debug|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.MinSizeRel|Any CPU.Build.0 = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.MinSizeRel|x86.ActiveCfg = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.MinSizeRel|x86.Build.0 = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.Release|x64.ActiveCfg = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.Release|x64.Build.0 = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.Release|x86.ActiveCfg = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {422D1620-0166-4C26-9A81-CA8A2EB1AB58}
|
||||
EndGlobalSection
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27130.2024
|
||||
MinimumVisualStudioVersion = 15.0.26124.0
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_api", "src\client\spark_api\spark_api.csproj", "{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spark", "src\client\spark\Spark.csproj", "{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sparkcmd", "src\client\sparkcmd\sparkcmd.csproj", "{387566C6-C6F6-412C-A30C-9855BBCB4816}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_core", "src\client\spark_core\spark_core.csproj", "{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_sdk", "src\client\spark_sdk\spark_sdk.csproj", "{6963C314-83C4-4667-B0D0-C2F7AE208C29}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_test", "src\client\spark_test\spark_test.csproj", "{ECD78CC5-138F-4809-A764-2358C2AC2E82}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
MinSizeRel|Any CPU = MinSizeRel|Any CPU
|
||||
MinSizeRel|x64 = MinSizeRel|x64
|
||||
MinSizeRel|x86 = MinSizeRel|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
RelWithDebInfo|Any CPU = RelWithDebInfo|Any CPU
|
||||
RelWithDebInfo|x64 = RelWithDebInfo|x64
|
||||
RelWithDebInfo|x86 = RelWithDebInfo|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Debug|x64.Build.0 = Debug|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|Any CPU.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|x86.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|x86.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|x64.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|x64.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|x86.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|x64.Build.0 = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|Any CPU.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|x86.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|x86.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Release|x64.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Release|x64.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Release|x86.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|x64.Build.0 = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|x86.ActiveCfg = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|x86.Build.0 = Debug|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|x64.Build.0 = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|x86.Build.0 = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Debug|x64.Build.0 = Debug|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|Any CPU.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|x86.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|x86.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Release|x64.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Release|x64.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Release|x86.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Debug|x64.Build.0 = Debug|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|Any CPU.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|x86.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|x86.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Release|x64.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Release|x64.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Release|x86.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.MinSizeRel|x64.Build.0 = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.MinSizeRel|x86.ActiveCfg = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.MinSizeRel|x86.Build.0 = Debug|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|x64.Build.0 = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|x86.Build.0 = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {422D1620-0166-4C26-9A81-CA8A2EB1AB58}
|
||||
EndGlobalSection
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,6 +1,7 @@
|
||||
using bts.api;
|
||||
using bts.co2;
|
||||
using bts.utils;
|
||||
using bts.utils.csv;
|
||||
using mbts;
|
||||
using mbts.spark;
|
||||
using mbts.ui.controls;
|
||||
@@ -49,6 +50,18 @@ namespace bts.shell.time_and_sales {
|
||||
public void raise_invalidated() =>
|
||||
invalidated?.Invoke();
|
||||
|
||||
public static System.Collections.Specialized.OrderedDictionary csv_ordered_properties =>
|
||||
CsvHelper.create_ordering_maintainer(
|
||||
typeof(TimeAndSalesRowVM),
|
||||
new string[] {
|
||||
nameof(security),
|
||||
nameof(time),
|
||||
nameof(price),
|
||||
nameof(size),
|
||||
nameof(aggressor_side),
|
||||
nameof(security_key),
|
||||
});
|
||||
|
||||
public bool Equals(TimeAndSalesRowVM other) =>
|
||||
other != null &&
|
||||
row_key == other.row_key;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using bts.shell.fills;
|
||||
using bts.spark;
|
||||
using bts.view;
|
||||
using bts.utils.csv;
|
||||
using mbts;
|
||||
using mbts.co2;
|
||||
using mbts.persist;
|
||||
@@ -124,6 +125,8 @@ namespace bts.shell.time_and_sales {
|
||||
show_in_context_menu = _can_pause_updates
|
||||
};
|
||||
_commands = new SparkCommand[] {
|
||||
// csv export
|
||||
new SparkCommandCommand("Export to csv", Icons.Export, FileDialogCommand.export_csv(() => _vm.rows.ToCsv(TimeAndSalesRowVM.csv_ordered_properties), "TaS")),
|
||||
// ladder
|
||||
SparkCommands.ShowLadderAutoLookup(SparkCommands.KeyGestures.ShowLadder)
|
||||
.complete(current_sec_key_src, sec_keys => sec_keys.Count > 0),
|
||||
|
||||
@@ -5,6 +5,7 @@ using bts.collections;
|
||||
using bts.shell.fills;
|
||||
using bts.spark;
|
||||
using bts.utils;
|
||||
using bts.utils.csv;
|
||||
using mbts.collections;
|
||||
using mbts.persist;
|
||||
using mbts.spark.filters;
|
||||
@@ -333,6 +334,27 @@ namespace mbts.spark {
|
||||
public override bool Equals(object obj) => Equals(obj as Row);
|
||||
public override int GetHashCode() => _fill.FillKey.GetHashCode() ^ _order.Key.GetHashCode();
|
||||
|
||||
public static System.Collections.Specialized.OrderedDictionary csv_ordered_properties =>
|
||||
CsvHelper.create_ordering_maintainer(typeof(Row),
|
||||
new string[] {
|
||||
nameof(security),
|
||||
nameof(order_type),
|
||||
nameof(root_algo_display_name),
|
||||
nameof(side),
|
||||
nameof(fill_time),
|
||||
nameof(user),
|
||||
nameof(account),
|
||||
nameof(exchange),
|
||||
nameof(time_in_force),
|
||||
nameof(size),
|
||||
nameof(price),
|
||||
nameof(fill_kind),
|
||||
nameof(fill_status),
|
||||
nameof(fill_key),
|
||||
nameof(order_key),
|
||||
nameof(security_key)
|
||||
});
|
||||
|
||||
public event Action invalidated;
|
||||
void IRowVM.raise_invalidated() => invalidated?.Invoke();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using bts.shell;
|
||||
using bts.shell.fills;
|
||||
using bts.spark;
|
||||
using bts.view;
|
||||
using bts.utils.csv;
|
||||
using mbts.persist;
|
||||
using mbts.ui;
|
||||
using mbts.ui.settings;
|
||||
@@ -61,6 +62,7 @@ namespace mbts.spark {
|
||||
_view = new FillsView { DataContext = _vm };
|
||||
|
||||
_commands = new List<SparkCommand> {
|
||||
new SparkCommandCommand("Export to csv", Icons.Export, FileDialogCommand.export_csv(() => _vm.rows.ToCsv(FillsVM.Row.csv_ordered_properties), "Fills")),
|
||||
// wrap the grid settings view factory in a dialogCommand here since the vm is destroyed/recreated when the security criteria changes
|
||||
SparkCommands.window_settings_command(new DialogCommand(() => {
|
||||
var vm = new ShellSettingsDialogVM<GridSettings, SimpleGridSettingsVM>(
|
||||
|
||||
@@ -334,7 +334,6 @@ namespace mbts.spark {
|
||||
// this class is 100% mutable (there are literally 0 readonly members),
|
||||
// so GetHashCode must return the same hash for every instance.
|
||||
static readonly int _type_hash = typeof(LadderSettings).GetHashCode();
|
||||
uint _ticks_per_row;
|
||||
|
||||
// Default proto constructor
|
||||
// Added this so that when clients upgrade to a version with new settings,
|
||||
@@ -604,12 +603,6 @@ namespace mbts.spark {
|
||||
[ProtoMember(61), DefaultValue(true)]
|
||||
public bool status_message_visible { get; set; }
|
||||
|
||||
[ProtoMember(62)]
|
||||
public uint ticks_per_row {
|
||||
get => Math.Max(_ticks_per_row, 1);
|
||||
set => _ticks_per_row = value;
|
||||
}
|
||||
|
||||
[ProtoMember(900)]
|
||||
public LadderOrderLimits ladder_order_limits { get; set; }
|
||||
|
||||
@@ -719,8 +712,7 @@ namespace mbts.spark {
|
||||
a.max_clip == b.max_clip &&
|
||||
a.price_display_format == b.price_display_format &&
|
||||
a.status_message_visible == b.status_message_visible &&
|
||||
a.ladder_order_limits.safe_equals(b.ladder_order_limits) &&
|
||||
a._ticks_per_row == b._ticks_per_row;
|
||||
a.ladder_order_limits.safe_equals(b.ladder_order_limits);
|
||||
|
||||
public bool Equals(LadderSettings other) =>
|
||||
profile_equals(this, other) &&
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
using bts.api;
|
||||
using bts.api.orderman;
|
||||
using bts.shell.orderbook;
|
||||
using bts.utils;
|
||||
using mbts.persist;
|
||||
using mbts.spark.utilities;
|
||||
using mbts.ui;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.spark;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -55,9 +52,9 @@ namespace mbts.spark {
|
||||
public event Action piq_changed;
|
||||
|
||||
LadderModel model => _owner.model;
|
||||
ImmutableDictionary<uint, OrderSecurity> _orders = ImmutableDictionary<uint, OrderSecurity>.Empty;
|
||||
Dictionary<uint, (OrderRecordImmutable order, uint? p, AlgoData? algo, AlgoDefinitionMetadata? meta)> _orders = new Dictionary<uint, (OrderRecordImmutable order, uint? p, AlgoData? algo, AlgoDefinitionMetadata? meta)>();
|
||||
|
||||
public LadderOrderVM(ImmutableDictionary<uint, OrderSecurity> orders, double real_price, LadderVM owner, IBus bus, IObservable<LadderSettings.BadgeStyle> bs) {
|
||||
public LadderOrderVM((OrderRecordImmutable, uint?, AlgoData?, AlgoDefinitionMetadata?) op, double real_price, LadderVM owner, IBus bus, IObservable<LadderSettings.BadgeStyle> bs) {
|
||||
_owner = owner;
|
||||
_bus = bus;
|
||||
_bs = bs;
|
||||
@@ -81,7 +78,8 @@ namespace mbts.spark {
|
||||
double get_font_size(LadderSettings s) => s.orders_column.font_size;
|
||||
Brush get_foreground(LadderSettings s) => s.orders_column.foreground.rgb_brush();
|
||||
double get_row_height(LadderSettings s) => s.row_height;
|
||||
_orders = orders;
|
||||
//
|
||||
add_order(op);
|
||||
|
||||
_dispose = Disposable.Create(
|
||||
_bs.Subscribe(badge => {
|
||||
@@ -146,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) {
|
||||
@@ -155,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();
|
||||
@@ -177,6 +175,41 @@ namespace mbts.spark {
|
||||
RaisePropertyChanged(nameof(text_lines));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Order performs an add the first time it's called via the constructor. When it's called, directly
|
||||
/// it really serves as an update/replace. Also note that since the min_piq is a separate piece of state representing
|
||||
/// the lowest piq of the orders the badge represents, we must reevaluate if that has changed on said update.
|
||||
/// </summary>
|
||||
public void add_order((OrderRecordImmutable order, uint? p, AlgoData? algo, AlgoDefinitionMetadata? meta) new_op) {
|
||||
_orders[new_op.order.Key] = new_op;
|
||||
// reevaluate min piq if this order's piq is less
|
||||
if (new_op.p.HasValue) {
|
||||
// if this lovm only represents 1 order and the piq is now different, regardless of what it is that's our piq
|
||||
if (_orders.Count == 1 && new_op.p.Value != min_piq) {
|
||||
min_piq = new_op.p.Value;
|
||||
} else if (new_op.p.Value < min_piq) {
|
||||
min_piq = new_op.p.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void remove_order(uint order_key) {
|
||||
_orders.Remove(order_key);
|
||||
// on a remove, potentially the order w/ the lowest piq has been removed, so
|
||||
// if the min() is now > than the current min_piq, update the min_piq
|
||||
var prospective_piq = _orders.Select(op => op.Value.p).Where(piq => piq.HasValue).Min();
|
||||
if (prospective_piq > min_piq) {
|
||||
min_piq = prospective_piq;
|
||||
}
|
||||
}
|
||||
|
||||
//public void update(OrderRecordImmutable neworder) {
|
||||
// Log.assert(neworder.Key == id, $"OrderVM.update was called with an order with a different Key({neworder.Key}) from original({id})");
|
||||
// using (detect_property_changes()) {
|
||||
// _init(neworder);
|
||||
// }
|
||||
//}
|
||||
|
||||
public uint security_key => _owner.security.Id;
|
||||
public double price { get => double.IsNaN(_phantom_price) ? _real_price : _phantom_price; }
|
||||
public uint? min_piq {
|
||||
@@ -228,13 +261,9 @@ namespace mbts.spark {
|
||||
public CustomOrderDefinition.CustomOneofCase algo_type { get => _algo_type.Value; private set => _algo_type.Value = value; }
|
||||
public string algo_studio_abbreviation { get => _algo_studio_abbreviation.Value; private set => _algo_studio_abbreviation.Value = value; }
|
||||
|
||||
public IReadOnlyList<uint> order_keys => _orders.Keys.ToReadOnlyList();
|
||||
public IEnumerable<OrderRecordImmutable> root_orders => _root_nodes();
|
||||
|
||||
public void sync_orders(ImmutableDictionary<uint, OrderSecurity> new_orders) {
|
||||
_orders = new_orders;
|
||||
min_piq = new_orders.Count == 0 ? null : new_orders.Values.Select(o => o.piq).Min();
|
||||
}
|
||||
|
||||
void _cancel_order() {
|
||||
foreach (var order in _root_nodes()) {
|
||||
model.order_gateway.cancel_order(order).ignore();
|
||||
@@ -267,16 +296,14 @@ namespace mbts.spark {
|
||||
// I checked with Eric and he guesses that what is happening is that the Popup is throwing away the grid, but the binding doesn't remove the columns from that grid
|
||||
//
|
||||
// I think returning a new OrderbookVM is okay at the moment since this Popup window will not be saving any state at this time
|
||||
var ticks = _owner.spec.full_ticks_from_zero(real_price);
|
||||
if (!ticks.HasValue) {
|
||||
// this is an unexpected code path, but not necessarily a reason to crash, so log a warning and return null
|
||||
return null;
|
||||
}
|
||||
var min_price = _owner.spec.tickup(0, ticks.Value);
|
||||
var max_price = _owner.spec.tickup(min_price, 1);
|
||||
var price_filter = new filters.DoubleMinMaxState();
|
||||
price_filter.minimum.value = real_price;
|
||||
price_filter.maximum.value = real_price;
|
||||
|
||||
var state = new bts.shell.orderbook.OrderBookStartupData(
|
||||
new bts.shell.orderbook.FilterStates {
|
||||
security_criteria = new SecurityCriteria(_owner.security),
|
||||
price = price_filter,
|
||||
statuses = new[] { OrderStatus.Working },
|
||||
order_types = AlgoID.exchange_algo_keys
|
||||
},
|
||||
@@ -284,8 +311,7 @@ namespace mbts.spark {
|
||||
use_defaults: false
|
||||
);
|
||||
var settings_man = new WindowSettingsManager<OrderBookGridSettings>.DisconnectedImpl(state.orderbook_grid);
|
||||
var obvm = new OrderBookVM(_owner.bus, null, _owner.model.order_gateway, settings_man, true,
|
||||
global_filter: o => o.order.order.ui_price() >= min_price - MathUtils.epsilon && o.order.order.ui_price() <= max_price - MathUtils.epsilon);
|
||||
var obvm = new OrderBookVM(_owner.bus, null, _owner.model.order_gateway, settings_man, true);
|
||||
_owner.settings.Subscribe(s => settings_man.instance_settings = settings_man.instance_settings.with(s.mini_ob.value));
|
||||
obvm.columns.Insert(0, new OrderBookVM.AttachDetachColumn(typeof(MiniOrderBookView)));
|
||||
obvm.columns.Insert(0, new OrderBookVM.CommitColumn());
|
||||
|
||||
@@ -40,7 +40,6 @@ namespace mbts.spark {
|
||||
readonly ObservableKeyedCollection<AccountTuple?, uint> _accounts = new ObservableKeyedCollection<AccountTuple?, uint>(AccountTuple.nullable_key_fn);
|
||||
readonly ObservableKeyedCollection<AlgoDefinitionVM, AlgoKey> _algo_definitions = new ObservableKeyedCollection<AlgoDefinitionVM, AlgoKey>(d => d.key);
|
||||
readonly OrdersModel _model;
|
||||
readonly SecurityImmutable _security;
|
||||
uint? _desired_account;
|
||||
AlgoID? _desired_algo;
|
||||
TimeInForce _default_time_in_force;
|
||||
@@ -49,7 +48,6 @@ namespace mbts.spark {
|
||||
double _order_entry_panel_width, _zoom_factor;
|
||||
bool _auto_clear, _show_warn_on_cross, _enforce_max_clip, _enforce_max_settlement_cross_ticks;
|
||||
int _max_settlement_cross_ticks;
|
||||
uint _ticks_per_row;
|
||||
LadderSettings _current;
|
||||
LadderColumnSettingsVM
|
||||
_orders = new OrdersColumnSettingsVM(),
|
||||
@@ -90,7 +88,7 @@ namespace mbts.spark {
|
||||
|
||||
public LadderSettingsVM(OrdersModel model, SecurityImmutable security) {
|
||||
_model = model;
|
||||
_security = security;
|
||||
is_synthetic = security.ContractCase == Security.ContractOneofCase.Synthetic;
|
||||
favorite_algos_vm = new FavoriteAlgosVM(_algo_definitions);
|
||||
size_presets = new ObservableEditableCollection<IMutableValueWrapperVM<uint>>(_create_size_preset_vm);
|
||||
size_presets.CollectionChanged += (s, e) => RaisePropertyChanged(nameof(size_presets_text));
|
||||
@@ -112,9 +110,6 @@ namespace mbts.spark {
|
||||
accounts_view = new ListCollectionView<AccountTuple?>(_accounts) {
|
||||
CustomSort = Comparer<AccountTuple>.Default.to_nullable().to_non_generic()
|
||||
};
|
||||
// cmds
|
||||
tick_up_ticks_per_row_cmd = new DelegateCommand(increment_ticks_per_row);
|
||||
tick_down_ticks_per_row_cmd = new DelegateCommand(decrement_ticks_per_row);
|
||||
// update
|
||||
_update = new DeferrableActionWrapper(() => result_changed?.Invoke());
|
||||
mini_ob.result_changed += _update.execute;
|
||||
@@ -160,26 +155,6 @@ namespace mbts.spark {
|
||||
}
|
||||
AccountTuple? account_factory(uint key, string name) => new AccountTuple(key, name);
|
||||
AlgoDefinitionVM algo_factory(AlgoData data) => AlgoDefinitionVM.create(_model, data);
|
||||
void increment_ticks_per_row() {
|
||||
var tpr = ticks_per_row;
|
||||
for (uint i = 1; i < 100; i++) {
|
||||
var new_tpr = TickUtils.fit_ticks_per_row_to_dollars(security.ContractSpec, ticks_per_row + i);
|
||||
if (new_tpr != tpr) {
|
||||
ticks_per_row = new_tpr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
void decrement_ticks_per_row() {
|
||||
var tpr = ticks_per_row;
|
||||
for (uint i = 1; i < tpr; i++) {
|
||||
var new_tpr = TickUtils.fit_ticks_per_row_to_dollars(security.ContractSpec, tpr - i);
|
||||
if (new_tpr != tpr) {
|
||||
ticks_per_row = new_tpr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event Action result_changed;
|
||||
@@ -202,16 +177,6 @@ namespace mbts.spark {
|
||||
get => _alternate_order_size.Value;
|
||||
set => _alternate_order_size.Value = value;
|
||||
}
|
||||
public uint ticks_per_row {
|
||||
get => _ticks_per_row;
|
||||
set => Set(ref _ticks_per_row, value, dependent_props: nameof(rounded_ticks_per_row));
|
||||
}
|
||||
public ICommand tick_up_ticks_per_row_cmd { get; }
|
||||
public ICommand tick_down_ticks_per_row_cmd { get; }
|
||||
// since settings profiles may be shared among ladders
|
||||
// of different securities/tick sizes, the ticks per row setting
|
||||
// may need to be rounded to a number that is a factor of $1.00
|
||||
public uint? rounded_ticks_per_row => TickUtils.fit_ticks_per_row_to_dollars(_security.ContractSpec, ticks_per_row);
|
||||
|
||||
public MarketSizeDisplayVM size_display { get; } = new MarketSizeDisplayVM();
|
||||
public SimpleGridSettingsVM mini_ob { get; } = new SimpleGridSettingsVM(OrderBookGridSettingsManager.hard_column_flags);
|
||||
@@ -244,7 +209,7 @@ namespace mbts.spark {
|
||||
public FavoriteAlgosVM favorite_algos_vm { get; }
|
||||
|
||||
public double row_height => _row_height.Value;
|
||||
public bool is_synthetic => _security.ContractCase == Security.ContractOneofCase.Synthetic;
|
||||
public bool is_synthetic { get; }
|
||||
|
||||
public IEnumerable<LadderColumnSettingsVM> column_items {
|
||||
get {
|
||||
@@ -361,7 +326,6 @@ namespace mbts.spark {
|
||||
_current = settings;
|
||||
badge_style = settings.badge_style;
|
||||
alternate_order_size = settings.alternate_order_size;
|
||||
ticks_per_row = settings.ticks_per_row;
|
||||
favorite_algos_vm.load_from(settings.favorite_algos);
|
||||
size_display.load_from(settings.size_display);
|
||||
size_presets.SetItems(settings.calculator_buttons.empty_if_null().Select(s => _create_size_preset_vm((uint)s)));
|
||||
@@ -443,7 +407,6 @@ namespace mbts.spark {
|
||||
}
|
||||
clone.badge_style = badge_style;
|
||||
clone.alternate_order_size = alternate_order_size;
|
||||
clone.ticks_per_row = ticks_per_row;
|
||||
clone.favorite_algos = favorite_algos_vm.create();
|
||||
clone.size_display = size_display.create();
|
||||
clone.calculator_buttons = size_presets.Select(vm => (int)vm.value).ToArray();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using bts.api;
|
||||
using bts.api.core;
|
||||
using bts.api.orderman;
|
||||
using bts.proto;
|
||||
using bts.shell;
|
||||
@@ -9,7 +8,7 @@ using mbts.co2;
|
||||
using mbts.spark.utilities;
|
||||
using mbts.ui;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.utility;
|
||||
using mbts.ui.spark;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -29,6 +28,7 @@ namespace mbts.spark {
|
||||
readonly IBus _bus;
|
||||
readonly LadderModel _model;
|
||||
readonly Property<double> _high, _low, _change, _open, _settlement, _left_panel_width, _zoom_factor;
|
||||
//readonly Property<double> _window_width, _window_height;
|
||||
readonly Property<uint> _orders_column_width, _bid_column_width, _price_column_width, _ask_column_width, _last_column_width, _volume_column_width, _piq_column_width;
|
||||
readonly Property<ulong> _volume;
|
||||
readonly Property<bool> _auto_clear;
|
||||
@@ -49,10 +49,8 @@ namespace mbts.spark {
|
||||
ulong _last_trade_time = 0;
|
||||
IEqualityComparer<double> _equality;
|
||||
Dictionary<double, LadderOrderVM> _slot_price_vs_orders;
|
||||
ImmutableSortedDictionary<double, LadderOrderVM> _order_price_index;
|
||||
IReadOnlyDictionary<uint, OrderSecurity> _cache = DictionaryHelper.empty<uint, OrderSecurity>();
|
||||
ImmutableDictionary<AlgoKey, LadderFavoriteAlgoItem> _favorite_algo_map = ImmutableDictionary<AlgoKey, LadderFavoriteAlgoItem>.Empty;
|
||||
ContractSpecificationImmutable? _spec;
|
||||
|
||||
public static LadderVM create(IBus bus, LadderModel model, LadderSettings init, IObservable<LadderSettings> settings) =>
|
||||
new LadderVM(bus, model, init, settings, new OrderPropertiesEditorVM(model.order_gateway, Observable.Return(model.security_md), settings.Select(s => new InlineOrderProperties(model.order_gateway, s))));
|
||||
@@ -67,7 +65,6 @@ namespace mbts.spark {
|
||||
_bus = bus;
|
||||
_model = model;
|
||||
current_settings = init;
|
||||
_order_price_index = ImmutableSortedDictionary.Create<double, LadderOrderVM>(spec.price_comparer());
|
||||
this.settings = settings;
|
||||
_equality = TickUtils.tick_equality_comparer(_model.security.ContractSpec);
|
||||
display_quantity_divisor = model.order_gateway.security_auxiliary_model.get_display_quantity_divisor(model.security);
|
||||
@@ -125,8 +122,6 @@ namespace mbts.spark {
|
||||
(_show_zoom = bool_prop(nameof(show_zoom), s => s.zoom_slider_visible)).set,
|
||||
(_show_status_message = bool_prop(nameof(show_status_message), s => s.status_message_visible)).set,
|
||||
s => {
|
||||
// invalidate spec in case 'ticks per row' changed
|
||||
_spec = null;
|
||||
if (
|
||||
Set(ref _show_account_position, s.account_position_visible, nameof(show_account_position)) |
|
||||
Set(ref _show_day_position, s.day_position_visible, nameof(show_day_position)) |
|
||||
@@ -164,40 +159,71 @@ namespace mbts.spark {
|
||||
settings_command = new DelegateCommand(() => request_settings_dialog?.Invoke());
|
||||
|
||||
orders = new ObservableCollection<LadderOrderVM>();
|
||||
var orders_source = settings.Select(s => s.ticks_per_row).DistinctUntilChanged()
|
||||
.SelectManyInSeries(tpr => {
|
||||
var spec = TickUtils.multiply_tick_size(security.ContractSpec, tpr);
|
||||
var price_comp = Comparer<double>.Create((a, b) =>
|
||||
CompareUtils.nullable_compare(spec.full_ticks_from_zero(a), spec.full_ticks_from_zero(b)));
|
||||
return _order_price_source(model.orders, price_comp, p => TickUtils.normalize_price(spec, p));
|
||||
});
|
||||
|
||||
_dispose = Disposable.Create(
|
||||
settings.OnDispatcher().Subscribe(settings_observer),
|
||||
get_order_properties_editor_hooks(),
|
||||
bus.subscribe(SparkTags.LogActivity).OnDispatcher().Subscribe(status_update),
|
||||
orders_source.OnDispatcher().Subscribe(tup => {
|
||||
// we need to hook this up to model.orders which is filtered for just the security
|
||||
model.orders.OnDispatcher().Subscribe(working => {
|
||||
// Here we manage N orders to 1 price slot in the ladder
|
||||
Dictionary<double, HashSet<uint>> orders_used_in_this_update = new Dictionary<double, HashSet<uint>>(_equality);
|
||||
_cache = tup.map;
|
||||
/// remove empty price slots (the vm will be disposed automatically when it is removed from <see cref="orders"/>)
|
||||
var removed_prices = _slot_price_vs_orders.Keys.Except(tup.price_index.Keys).ToList();
|
||||
foreach (var p in removed_prices)
|
||||
_slot_price_vs_orders.Remove(p);
|
||||
// add or update current price slots
|
||||
foreach (var kv in tup.price_index) {
|
||||
_slot_price_vs_orders.AddOrUpdate(kv.Key,
|
||||
order_vm => order_vm.sync_orders(kv.Value),
|
||||
() => new LadderOrderVM(kv.Value, kv.Key, this, _bus, settings.Select(s => s.badge_style).OnDispatcher()));
|
||||
_cache = working.state;
|
||||
|
||||
foreach (var os in _cache.Values) {
|
||||
var wo = os.order;
|
||||
var slot_price_target = wo.ui_price();
|
||||
var order_type = wo.order_type();
|
||||
var filled = wo.filled();
|
||||
|
||||
if (_slot_price_vs_orders.TryGetValue(slot_price_target, out LadderOrderVM slot_vm)) {
|
||||
slot_vm.add_order((wo, os.piq, os.algo, os.meta));
|
||||
} else {
|
||||
slot_vm = new LadderOrderVM((wo, os.piq, os.algo, os.meta), slot_price_target, this, _bus, settings.Select(s => s.badge_style).OnDispatcher());
|
||||
_slot_price_vs_orders[slot_price_target] = slot_vm;
|
||||
}
|
||||
|
||||
// keep track of slot prices vs orders; we use this below to remove orders from the LadderOrderVMs
|
||||
// that are not found in this callback run
|
||||
if (!orders_used_in_this_update.TryGetValue(slot_price_target, out HashSet<uint> orders_at_level)) {
|
||||
orders_at_level = new HashSet<uint>();
|
||||
}
|
||||
orders_at_level.Add(wo.Key);
|
||||
orders_used_in_this_update[slot_price_target] = orders_at_level;
|
||||
|
||||
}
|
||||
// sync the collection
|
||||
orders.sync_with(_slot_price_vs_orders.Values);
|
||||
// update badge colors, text, etc.
|
||||
foreach (var lovm in orders)
|
||||
|
||||
// remove any orders from the lovm that aren't in here
|
||||
foreach(var kvp in orders_used_in_this_update) {
|
||||
var slot_vm = _slot_price_vs_orders[kvp.Key];
|
||||
foreach(var existing_order_key in slot_vm.order_keys) {
|
||||
if (!kvp.Value.Contains(existing_order_key)) {
|
||||
slot_vm.remove_order(existing_order_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// update dirty brushes and text
|
||||
foreach (var lovm in _slot_price_vs_orders.Values) {
|
||||
lovm.update();
|
||||
}
|
||||
|
||||
// complete removal of slots that were not updated
|
||||
// orders_used_in_this_update.Keys are the price levels in the update
|
||||
foreach (var slot_price in _slot_price_vs_orders.Keys.ToList()) {
|
||||
if (!orders_used_in_this_update.Keys.Contains(slot_price)) {
|
||||
_slot_price_vs_orders.TryGetValue(slot_price, out LadderOrderVM removal_candidate);
|
||||
if (removal_candidate != null) {
|
||||
removal_candidate.Dispose();
|
||||
}
|
||||
_slot_price_vs_orders.Remove(slot_price);
|
||||
}
|
||||
}
|
||||
|
||||
orders.sync_with(_slot_price_vs_orders.Values);
|
||||
}),
|
||||
WorkLoop.Start($"Ladder '{security}'", _tick),
|
||||
ObservableAutoWrapper.dispose_on_removed(orders, true),
|
||||
Disposable.Create(() => _on_disposed_impl?.Invoke(true))
|
||||
);
|
||||
IDisposable get_order_properties_editor_hooks() {
|
||||
@@ -273,8 +299,6 @@ namespace mbts.spark {
|
||||
remove => _on_disposed_impl -= value;
|
||||
}
|
||||
public SecurityImmutable security => _model.security;
|
||||
public ContractSpecificationImmutable spec => _spec ?? (
|
||||
_spec = TickUtils.multiply_tick_size(security.ContractSpec, current_settings?.ticks_per_row ?? 1)).Value;
|
||||
public uint display_quantity_divisor { get; }
|
||||
public LadderSettings current_settings { get; private set; }
|
||||
public double high => _high.Value;
|
||||
@@ -385,11 +409,11 @@ namespace mbts.spark {
|
||||
double _max_left_panel_scroll_position =>
|
||||
Math.Max(0, _left_panel_extent_height - _left_panel_view_port_height);
|
||||
|
||||
internal OrderRecordImmutable get_root_at_price(OrderSecurity op) {
|
||||
internal OrderRecordImmutable get_root_at_price((OrderRecordImmutable order, uint? _, AlgoData? __, AlgoDefinitionMetadata? meta) op) {
|
||||
var order = op.order;
|
||||
double p = _normalize_price(order.ui_price());
|
||||
double p = order.ui_price();
|
||||
foreach (var o in lineage(order.ParentKey)) {
|
||||
if (_equality.Equals(p, _normalize_price(o.ui_price())))
|
||||
if (_equality.Equals(p, o.ui_price()))
|
||||
order = o;
|
||||
}
|
||||
return order;
|
||||
@@ -518,64 +542,6 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
|
||||
static IObservable<(ImmutableSortedDictionary<double, ImmutableDictionary<uint, OrderSecurity>> price_index, IReadOnlyDictionary<uint, OrderSecurity> map)> _order_price_source(
|
||||
IObservable<TableUpdate<OrderSecurity, uint>> source,
|
||||
IComparer<double> price_comp,
|
||||
Func<double, double> normalize_price) {
|
||||
//
|
||||
return Observable.Create<(ImmutableSortedDictionary<double, ImmutableDictionary<uint, OrderSecurity>>, IReadOnlyDictionary<uint, OrderSecurity>)>(o => {
|
||||
var state = ImmutableSortedDictionary.Create<double, ImmutableDictionary<uint, OrderSecurity>>(price_comp);
|
||||
var sub = source.Subscribe(table => {
|
||||
var bd = state.ToBuilder();
|
||||
// removes
|
||||
var removes = table.removed.Concat(table.changes.Where(price_changed).Old());
|
||||
foreach (var old_order in removes) {
|
||||
var price = get_price(old_order);
|
||||
if (bd.TryGetValue(price, out var index)) {
|
||||
var new_index = index.Remove(old_order.order.Key);
|
||||
if (new_index.Count == 0) {
|
||||
bd.Remove(price);
|
||||
} else {
|
||||
bd[price] = new_index;
|
||||
}
|
||||
}
|
||||
}
|
||||
// changes
|
||||
var changes = table.changes.Where(ch => !price_changed(ch)).New();
|
||||
foreach (var changed_order in changes) {
|
||||
var price = get_price(changed_order);
|
||||
bd[price] = bd[price].SetItem(changed_order.order.Key, changed_order);
|
||||
}
|
||||
// adds
|
||||
var adds = table.added.Concat(table.changes.Where(price_changed).New());
|
||||
foreach (var new_order in adds) {
|
||||
var price = get_price(new_order);
|
||||
if (bd.TryGetValue(price, out var index)) {
|
||||
bd[price] = index.Add(new_order.order.Key, new_order);
|
||||
} else {
|
||||
bd[price] = ImmutableDictionary.CreateRange(
|
||||
new[] { new KeyValuePair<uint, OrderSecurity>(new_order.order.Key, new_order) });
|
||||
}
|
||||
}
|
||||
o.OnNext((state = bd.ToImmutable(), table.state));
|
||||
});
|
||||
return sub;
|
||||
});
|
||||
|
||||
bool price_changed(Change<OrderSecurity> ch) =>
|
||||
price_comp.Compare(ch.New.order.ui_price(), ch.Old.order.ui_price()) != 0;
|
||||
|
||||
double get_price(OrderSecurity order) {
|
||||
var p = order.order.ui_price();
|
||||
if (!(normalize_price is null))
|
||||
p = normalize_price(p);
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
double _normalize_price(double price) =>
|
||||
TickUtils.normalize_price(spec, price);
|
||||
|
||||
bool _validate_price(Side side, double price, out string msg) {
|
||||
msg = null;
|
||||
if (!price.is_real()) {
|
||||
|
||||
@@ -296,18 +296,6 @@ namespace mbts.spark {
|
||||
|
||||
Column[] columns { get; set; } = new Column[0];
|
||||
IEnumerable<Column> _visible_columns => columns.Where(c => c.settings.show);
|
||||
ContractSpecificationImmutable? _spec_backing;
|
||||
ContractSpecificationImmutable _spec {
|
||||
get {
|
||||
if (_spec_backing.HasValue) {
|
||||
return _spec_backing.Value;
|
||||
} else if (_vm != null) {
|
||||
_spec_backing = TickUtils.multiply_tick_size(security.ContractSpec, _settings?.ticks_per_row ?? 1);
|
||||
return _spec_backing.Value;
|
||||
}
|
||||
return SecurityDataHelper.Defaults.ContractSpecificationImmutable;
|
||||
}
|
||||
}
|
||||
|
||||
public void drag_out_of_bounds() =>
|
||||
_tactile_adorner?.drag_out_of_bounds();
|
||||
@@ -315,7 +303,7 @@ namespace mbts.spark {
|
||||
public void scroll_to_price(double price) {
|
||||
if (_scrollViewer == null || _price_list.is_null_or_empty())
|
||||
return;
|
||||
if (_spec.tickdiff(_price_list[0], price) is int target_row) {
|
||||
if (security.ContractSpec.tickdiff(_price_list[0], price) is int target_row) {
|
||||
int visible_row_count = (int)(_scrollViewer.ActualHeight / _settings.row_height);
|
||||
int curr_row = visible_row_count + (int)(_scrollViewer.VerticalOffset / _settings.row_height);
|
||||
if ((target_row > curr_row && target_row < _row_count) || (target_row < (curr_row - visible_row_count) && target_row >= 0))
|
||||
@@ -545,10 +533,10 @@ namespace mbts.spark {
|
||||
_price_list == null ? double.NaN : _price_list[row];
|
||||
|
||||
uint? _bid_size_from_row(int row) =>
|
||||
_size_from_row(row, _price_list, _bids, _spec);
|
||||
_size_from_row(row, _price_list, _bids, _vm.security.ContractSpec);
|
||||
|
||||
uint? _ask_size_from_row(int row) =>
|
||||
_size_from_row(row, _price_list, _asks, _spec);
|
||||
_size_from_row(row, _price_list, _asks, _vm.security.ContractSpec);
|
||||
|
||||
uint _volume_from_row(int row) {
|
||||
const int max_tries = 3;
|
||||
@@ -646,7 +634,7 @@ namespace mbts.spark {
|
||||
_vm.md.settlement_price,
|
||||
_settings.net_change == LadderSettings.NetChangeTerms.Ticks,
|
||||
column.settings,
|
||||
_spec);
|
||||
security.ContractSpec);
|
||||
} else {
|
||||
LadderRender.render_prices(
|
||||
column.visual_tup.visual,
|
||||
@@ -655,7 +643,7 @@ namespace mbts.spark {
|
||||
_settings.row_height,
|
||||
_price_list,
|
||||
column.settings,
|
||||
_spec,
|
||||
security.ContractSpec,
|
||||
_settings.price_display_format);
|
||||
}
|
||||
break;
|
||||
@@ -673,7 +661,7 @@ namespace mbts.spark {
|
||||
}
|
||||
void render_market_col(NativePriceSize[] depth) {
|
||||
var mid = LadderRender.index_of(_price_list, _last_origin_price, _price_comparer);
|
||||
LadderRender.render_sizes(column.visual_tup.visual, column.visual_tup.glyph_context, mid, _price_list, depth, _settings.row_height, _spec, column.settings, _fmt_mkt_depth_item);
|
||||
LadderRender.render_sizes(column.visual_tup.visual, column.visual_tup.glyph_context, mid, _price_list, depth, _settings.row_height, security.ContractSpec, column.settings, _fmt_mkt_depth_item);
|
||||
}
|
||||
}
|
||||
_apply_column_visual_offset();
|
||||
@@ -708,12 +696,7 @@ namespace mbts.spark {
|
||||
} else {
|
||||
_vm.OnDisposed += _on_vm_disposed;
|
||||
_prices_updated = 0;
|
||||
// invalidate the contract spec here, as well as in the 'settings update' callback.
|
||||
// While it is assumed that the settings IObservable will always fire at least once (on subscribe),
|
||||
// this serves as a redundancy/fail-safe; it ensures that the vm's security's
|
||||
// contract spec will be used, even if the settings sequence is empty.
|
||||
_invalidate_spec();
|
||||
_price_comparer = Comparer<double>.Create((x, y) => _spec.tick_equals(_normalize_price(x), _normalize_price(y)) ? 0 : y.CompareTo(x));
|
||||
_price_comparer = Comparer<double>.Create((x, y) => security.ContractSpec.tick_equals(x, y) ? 0 : y.CompareTo(x));
|
||||
_price_dirty = true;
|
||||
_piq_dirty = true;
|
||||
// **use local vm to protect against re-assignment,
|
||||
@@ -933,14 +916,14 @@ namespace mbts.spark {
|
||||
if (!_settings.piq_column.show)
|
||||
return;
|
||||
int origin_index = LadderRender.index_of(_price_list, _mkt_break_lines.origin, _price_comparer);
|
||||
LadderRender.render_piqs(_piq_vis_tup.visual, _last_vis_tup.glyph_context, origin_index, _price_list, _vm.price_vs_piq, _settings.row_height, _spec, _settings.piq_column, _fmt_mkt_quantity);
|
||||
LadderRender.render_piqs(_piq_vis_tup.visual, _last_vis_tup.glyph_context, origin_index, _price_list, _vm.price_vs_piq, _settings.row_height, security.ContractSpec, _settings.piq_column, _fmt_mkt_quantity);
|
||||
}
|
||||
|
||||
void _refresh_sizes() {
|
||||
Log.assert_d(_price_list != null);
|
||||
int origin_index = LadderRender.index_of(_price_list, _mkt_break_lines.origin, _price_comparer);
|
||||
LadderRender.render_sizes(_bid_vis_tup.visual, _bid_vis_tup.glyph_context, origin_index, _price_list, _bids, _settings.row_height, _spec, _settings.bid_column, _fmt_mkt_depth_item);
|
||||
LadderRender.render_sizes(_ask_vis_tup.visual, _ask_vis_tup.glyph_context, origin_index, _price_list, _asks, _settings.row_height, _spec, _settings.ask_column, _fmt_mkt_depth_item);
|
||||
LadderRender.render_sizes(_bid_vis_tup.visual, _bid_vis_tup.glyph_context, origin_index, _price_list, _bids, _settings.row_height, security.ContractSpec, _settings.bid_column, _fmt_mkt_depth_item);
|
||||
LadderRender.render_sizes(_ask_vis_tup.visual, _ask_vis_tup.glyph_context, origin_index, _price_list, _asks, _settings.row_height, security.ContractSpec, _settings.ask_column, _fmt_mkt_depth_item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -968,7 +951,7 @@ namespace mbts.spark {
|
||||
_price_list,
|
||||
vapls,
|
||||
_settings.row_height,
|
||||
_spec,
|
||||
security.ContractSpec,
|
||||
_settings.volume_column,
|
||||
last_index,
|
||||
_get_last_arrow_string(),
|
||||
@@ -1005,8 +988,8 @@ namespace mbts.spark {
|
||||
void _refresh_prices() {
|
||||
var prev_price_list = _price_list;
|
||||
_price_list = (!(_settings.net_change == LadderSettings.NetChangeTerms.None)) ?
|
||||
LadderRender.render_prices(_price_vis_tup.visual, _price_vis_tup.glyph_context, _mkt_break_lines.origin, _vm.md.settlement_price, _settings.net_change == LadderSettings.NetChangeTerms.Ticks, _row_count, _settings.row_height, _settings.price_column, _spec) :
|
||||
LadderRender.render_prices(_price_vis_tup.visual, _price_vis_tup.glyph_context, _mkt_break_lines.origin, _row_count, _settings.row_height, _settings.price_column, _spec, _settings.price_display_format);
|
||||
LadderRender.render_prices(_price_vis_tup.visual, _price_vis_tup.glyph_context, _mkt_break_lines.origin, _vm.md.settlement_price, _settings.net_change == LadderSettings.NetChangeTerms.Ticks, _row_count, _settings.row_height, _settings.price_column, security.ContractSpec) :
|
||||
LadderRender.render_prices(_price_vis_tup.visual, _price_vis_tup.glyph_context, _mkt_break_lines.origin, _row_count, _settings.row_height, _settings.price_column, security.ContractSpec, _settings.price_display_format);
|
||||
_ordershost.update_settings(_price_list, _price_comparer, _settings.row_height, _settings.orders_column);
|
||||
if (prev_price_list != null) {
|
||||
// maintain previous visible price range if possible
|
||||
@@ -1034,8 +1017,8 @@ namespace mbts.spark {
|
||||
SparkUtils.lazy_warn(!double.IsNaN(_mkt_break_lines.origin) && _mkt_break_lines.origin >= low && _mkt_break_lines.origin <= high,
|
||||
() => fmt_log_msg($"market break ({_mkt_break_lines.origin}) is unacceptable for the market range ({low} - {high})"));
|
||||
int prev_row_count = _row_count;
|
||||
int n_ticks_to_low = _spec.tickdiff(_mkt_break_lines.origin, low) ?? 0;
|
||||
int n_ticks_to_high = _spec.tickdiff(high, _mkt_break_lines.origin) ?? 0;
|
||||
int n_ticks_to_low = security.ContractSpec.tickdiff(_mkt_break_lines.origin, low) ?? 0;
|
||||
int n_ticks_to_high = security.ContractSpec.tickdiff(high, _mkt_break_lines.origin) ?? 0;
|
||||
int desired_row_count = Math.Max(n_ticks_to_low, n_ticks_to_high) * 2 + 1;
|
||||
_row_count = Math.Min(_max_row_count, desired_row_count);
|
||||
if (_row_count != prev_row_count) {
|
||||
@@ -1051,7 +1034,7 @@ namespace mbts.spark {
|
||||
_last_price_range_calc_time = now;
|
||||
//
|
||||
string fmt_log_msg(string msg) =>
|
||||
$"Ladder {security} (id:{security.Id}, low/high tick:{_spec.LowTick}/{_spec.HighTick}): {msg}.";
|
||||
$"Ladder {security} (id:{security.Id}, low/high tick:{security.ContractSpec.LowTick}/{security.ContractSpec.HighTick}): {msg}.";
|
||||
}
|
||||
return prices_changed;
|
||||
}
|
||||
@@ -1097,46 +1080,31 @@ namespace mbts.spark {
|
||||
prices != null && prices.Length > 0 ? prices[0].price : double.NaN;
|
||||
|
||||
double _get_bid_market_break() {
|
||||
var raw_bid_break = _get_bid_market_break_raw();
|
||||
return _normalize_price(raw_bid_break);
|
||||
}
|
||||
|
||||
double _normalize_price(double price) =>
|
||||
TickUtils.normalize_price(_spec, price);
|
||||
|
||||
double _get_bid_market_break_raw() {
|
||||
double best_bid = _get_top_price(_bids);
|
||||
double best_ask = _get_top_price(_asks);
|
||||
return double.IsNaN(best_bid) ?
|
||||
double.IsNaN(best_ask) ? _vm.settlement : _spec.tickdown(best_ask) :
|
||||
double.IsNaN(best_ask) ? _vm.settlement : security.ContractSpec.tickdown(best_ask) :
|
||||
best_bid;
|
||||
}
|
||||
|
||||
double _get_ask_market_break() {
|
||||
var raw_ask_break = _get_ask_market_break_raw();
|
||||
return _normalize_price(raw_ask_break);
|
||||
}
|
||||
double _get_ask_market_break_raw() {
|
||||
double best_bid = _get_top_price(_bids);
|
||||
double best_ask = _get_top_price(_asks);
|
||||
return double.IsNaN(best_ask) ?
|
||||
double.IsNaN(best_bid) ? _vm.settlement : best_bid :
|
||||
_spec.tickdown(best_ask);
|
||||
security.ContractSpec.tickdown(best_ask);
|
||||
}
|
||||
|
||||
double _get_mid_market_break() {
|
||||
double best_bid = _get_top_price(_bids);
|
||||
double best_ask = _get_top_price(_asks);
|
||||
return double.IsNaN(best_bid) ?
|
||||
double.IsNaN(best_ask) ? _vm.settlement : _spec.tickdown(best_ask) :
|
||||
double.IsNaN(best_ask) ? best_bid : TickUtils.mid_tick(_spec, best_bid, best_ask);
|
||||
double.IsNaN(best_ask) ? _vm.settlement : security.ContractSpec.tickdown(best_ask) :
|
||||
double.IsNaN(best_ask) ? best_bid : TickUtils.mid_tick(security.ContractSpec, best_bid, best_ask);
|
||||
}
|
||||
|
||||
double _get_session_low() => _normalize_price(_get_session_low_raw());
|
||||
double _get_session_high() => _normalize_price(_get_session_high_raw());
|
||||
|
||||
double _get_session_low_raw() => _vm.md.session_low;
|
||||
double _get_session_high_raw() => _vm.md.session_high;
|
||||
double _get_session_low() => _vm.md.session_low;
|
||||
double _get_session_high() => _vm.md.session_high;
|
||||
|
||||
void _render_mkt_break(DrawingVisual vis, double price, uint color) =>
|
||||
LadderRender.render_mkt_break(vis, _row_for_price(price), _settings.row_height, color);
|
||||
@@ -1145,9 +1113,6 @@ namespace mbts.spark {
|
||||
LadderRender.render_single_grid_line(vis, row, _settings.row_height, color, _price_column.x_left, _settings.price_column.width);
|
||||
#endregion
|
||||
|
||||
void _invalidate_spec() =>
|
||||
_spec_backing = null;
|
||||
|
||||
void _settings_updated(LadderSettings s) {
|
||||
bool init;
|
||||
double prev_row_height;
|
||||
@@ -1161,7 +1126,6 @@ namespace mbts.spark {
|
||||
/// The viewmodel will always have the most up-to-date settings, so ignore <see cref="s"/> and just get it from <see cref="_vm"/>.
|
||||
/// This is a workaround for the global settings-defaults issue: when defaults are updated, some properties are inadvertantly overwritten, such as column-widths, etc.
|
||||
_settings = _vm.get_save_state();
|
||||
_invalidate_spec();
|
||||
_bid_vis_tup.glyph_context = glyph_context(s.bid_column);
|
||||
_ask_vis_tup.glyph_context = glyph_context(s.ask_column);
|
||||
_price_vis_tup.glyph_context = glyph_context(s.price_column);
|
||||
@@ -1354,7 +1318,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
int _get_session_range_size() =>
|
||||
_owner._spec.tickdiff(_session_high, _session_low) ?? 0;
|
||||
_owner.security.spec_or_default().tickdiff(_session_high, _session_low) ?? 0;
|
||||
|
||||
LadderSettings _settings => _owner._settings;
|
||||
|
||||
|
||||
@@ -130,8 +130,6 @@ namespace mbts.spark {
|
||||
if (e.ChangedButton == MouseButton.Middle) {
|
||||
// create the new popup window in here
|
||||
var obvm = order.create_orderbook_vm();
|
||||
if (obvm is null)
|
||||
return;
|
||||
await Task.Delay(100); // Wait for obvm to load rows collection before showing UI to avoid a flash
|
||||
var view = new MiniOrderBookView(obvm);
|
||||
var popup = new System.Windows.Controls.Primitives.Popup {
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace mbts.spark {
|
||||
public static GlyphRun[] format_prices(double[] prices, double reference_price, bool format_in_tick_terms, double row_height, LadderColumnSettings settings, GlyphContext glyph_context, ContractSpecificationImmutable spec) {
|
||||
var result = new GlyphRun[prices.Length];
|
||||
Parallel.For(0, prices.Length, i =>
|
||||
result[i] = format_text(spec.format(prices[i] - reference_price, format_in_tick_terms), i, row_height, settings, glyph_context));
|
||||
result[i] = format_text(spec.format(prices[i], reference_price, format_in_tick_terms), i, row_height, settings, glyph_context));
|
||||
return result;
|
||||
}
|
||||
public static GlyphRun[] format_prices(double[] prices, double row_height, LadderColumnSettings settings, GlyphContext glyph_context, ContractSpecificationImmutable spec, LadderSettings.PriceDisplayFormat price_display_format) {
|
||||
@@ -181,28 +181,15 @@ namespace mbts.spark {
|
||||
var foreground = settings.foreground.rgb_brush();
|
||||
int curr_index = origin_index;
|
||||
double curr_price = prices[curr_index];
|
||||
NativePriceSize curr_size = NativePriceSize.NO_MARKET;
|
||||
var row_tick_groups = rungs
|
||||
.TakeWhile(nps => !nps.is_nan)
|
||||
.AggregateConsecutiveGroups(() => NativePriceSize.NO_MARKET,
|
||||
(aggr, rung) => rung.with(
|
||||
direct_size: aggr.direct_size + rung.direct_size,
|
||||
implied_size: aggr.implied_size + rung.implied_size),
|
||||
rung => {
|
||||
//spec.round_to_tick(rung.price);
|
||||
var ticks = spec.full_ticks_from_zero(rung.price);
|
||||
return ticks.HasValue ? spec.tickup(0, ticks.Value) : rung.price;
|
||||
});
|
||||
foreach (var rung in row_tick_groups) {
|
||||
//double price = spec.round_to_tick(rung.price);
|
||||
var ticks = spec.full_ticks_from_zero(rung.price);
|
||||
var price = ticks.HasValue ? spec.tickup(0, ticks.Value) : rung.price;
|
||||
for (int i = 0; i < rungs.Length; i++) {
|
||||
if (rungs[i].is_nan) break;
|
||||
double price = rungs[i].price;
|
||||
// prices are in descending order, so get diff from curr_price - price
|
||||
int tick_diff = spec.tickdiff_unchecked(curr_price, price);
|
||||
curr_index += tick_diff;
|
||||
curr_price = price;
|
||||
if (curr_index >= 0 && curr_index < prices.Length) {
|
||||
var gr = format_text(fmt(rung), curr_index, row_height, settings, glyph_context);
|
||||
var gr = format_text(fmt(rungs[i]), curr_index, row_height, settings, glyph_context);
|
||||
dc.DrawGlyphRun(foreground, gr);
|
||||
} else break;
|
||||
}
|
||||
|
||||
@@ -656,7 +656,7 @@
|
||||
ItemsSource="{Binding format_options}"
|
||||
SelectedItem="{Binding selected_format}"
|
||||
/>
|
||||
<StackPanel Grid.Row="1" Grid.ColumnSpan="2" Orientation="Horizontal" VerticalAlignment="Top">
|
||||
<StackPanel Grid.Row="1" Grid.ColumnSpan="2" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="{StaticResource MarginIndentChild}"
|
||||
Text="when implied is > 0"
|
||||
@@ -670,7 +670,6 @@
|
||||
IsEnabled="{Binding can_choose_alternate_implied_format}"
|
||||
ItemsSource="{Binding alternate_implied_format_options}"
|
||||
SelectedItem="{Binding selected_alternate_implied_format}"
|
||||
VerticalAlignment="Top"
|
||||
/>
|
||||
</StackPanel>
|
||||
<Border Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="12,4,0,0" Background="Transparent" BorderBrush="DimGray" BorderThickness="1" ToolTip="Sample Output">
|
||||
@@ -729,38 +728,7 @@
|
||||
Visibility="{Binding is_synthetic, Converter={StaticResource NetChangeGroupBoxIsVisibleVisibilityConverter}}"
|
||||
Padding="4"
|
||||
>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalPush2}}"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="{Binding Source={StaticResource VerticalPush1}}"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock>Ticks Per Row</TextBlock>
|
||||
<Grid Grid.Column="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<c:TickUpDownUInt
|
||||
Maximum="100"
|
||||
TickUpCommand="{Binding DataContext.tick_up_ticks_per_row_cmd, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}"
|
||||
TickDownCommand="{Binding DataContext.tick_down_ticks_per_row_cmd, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}"
|
||||
Value="{Binding DataContext.ticks_per_row, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}"
|
||||
/>
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
Margin="2,0,0,0"
|
||||
Text="{Binding DataContext.rounded_ticks_per_row, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}, StringFormat='({0})'}"
|
||||
ToolTip="The ticks per row parameter may need to be adjusted to fit evenly into dollars."
|
||||
/>
|
||||
</Grid>
|
||||
<c:RadioButtonsControl Grid.Row="2" Grid.ColumnSpan="3" ItemsSource="{Binding price_format_options}" ItemTemplate="{StaticResource EnumDescriptionTemplate}" SelectedItem="{Binding price_format}"/>
|
||||
</Grid>
|
||||
<c:RadioButtonsControl ItemsSource="{Binding price_format_options}" ItemTemplate="{StaticResource EnumDescriptionTemplate}" SelectedItem="{Binding price_format}"/>
|
||||
</GroupBox>
|
||||
<GroupBox
|
||||
Grid.Row="1"
|
||||
|
||||
@@ -4,6 +4,7 @@ using bts.api.orderman;
|
||||
using bts.collections;
|
||||
using bts.spark;
|
||||
using bts.utils;
|
||||
using bts.utils.csv;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using System;
|
||||
@@ -11,6 +12,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reactive.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Linq;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Columns = mbts.spark.OrderBookGridView.ColumnKeys;
|
||||
@@ -60,6 +62,35 @@ namespace mbts.spark {
|
||||
public event Action<(OrderSecurityRootPair oldval, OrderSecurityRootPair newval)> updated;
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public static System.Collections.Specialized.OrderedDictionary csv_ordered_properties =>
|
||||
CsvHelper.create_ordering_maintainer(
|
||||
typeof(OrderBookRowVM),
|
||||
new string[] {
|
||||
nameof(security_text),
|
||||
nameof(symbol),
|
||||
nameof(time_created),
|
||||
nameof(last_change),
|
||||
nameof(user),
|
||||
nameof(account),
|
||||
nameof(exchange),
|
||||
nameof(time_in_force),
|
||||
nameof(order_type),
|
||||
nameof(root_algo_display_name),
|
||||
nameof(order_sub_type),
|
||||
nameof(side),
|
||||
nameof(quantity),
|
||||
nameof(filled_quantity),
|
||||
nameof(price),
|
||||
nameof(avg_price),
|
||||
nameof(last_price),
|
||||
nameof(piq),
|
||||
nameof(status),
|
||||
// last message (could contains commas, so skipping)
|
||||
nameof(security_key),
|
||||
nameof(order_key),
|
||||
nameof(parent_order_key),
|
||||
});
|
||||
|
||||
// Core
|
||||
public OrderSecurityRootPair order_tuple { get; private set; }
|
||||
public OrderRecordImmutable order => order_tuple.order.order;
|
||||
|
||||
@@ -52,7 +52,6 @@ namespace mbts.spark {
|
||||
readonly CommonValueMonitor<SecurityImmutable?> _selected_security_mon = new CommonValueMonitor<SecurityImmutable?>();
|
||||
readonly RightPanelModel _right_panel = new RightPanelModel();
|
||||
readonly CustomStateSynchronizer _custom_state_sync;
|
||||
readonly Func<OrderSecurityRootPair, bool> _global_filter;
|
||||
OrderBookFillsGridSettings _cached_fills_settings = OrderBookStartupData.DefaultFillsGrid;
|
||||
double
|
||||
_raw_right_panel_width = OrderBookStartupData.Default.right_panel_width,
|
||||
@@ -72,8 +71,8 @@ namespace mbts.spark {
|
||||
FilterData _cached_filter_data;
|
||||
|
||||
public OrderBookVM(
|
||||
IBus bus, INotificationService notification_service, OrdersModel model, IWindowSettingsManager<OrderBookGridSettings> settings_manager, bool rows_are_initially_expanded = false, Func<OrderSecurityRootPair, bool> global_filter = null)
|
||||
: this(bus, notification_service, model, OrdersModel.piq_enabled ? model.on_order_tuples_with_root_and_piq : model.on_order_tuples_with_root, settings_manager, rows_are_initially_expanded, global_filter) { }
|
||||
IBus bus, INotificationService notification_service, OrdersModel model, IWindowSettingsManager<OrderBookGridSettings> settings_manager, bool rows_are_initially_expanded = false)
|
||||
: this(bus, notification_service, model, OrdersModel.piq_enabled ? model.on_order_tuples_with_root_and_piq : model.on_order_tuples_with_root, settings_manager, rows_are_initially_expanded) { }
|
||||
|
||||
public OrderBookVM(
|
||||
IBus bus,
|
||||
@@ -81,12 +80,10 @@ namespace mbts.spark {
|
||||
OrdersModel model,
|
||||
IObservable<TableUpdate<OrderSecurityRootPair, uint>> orders_source,
|
||||
IWindowSettingsManager<OrderBookGridSettings> settings_manager,
|
||||
bool rows_are_initially_expanded = false,
|
||||
Func<OrderSecurityRootPair, bool> global_filter = null) {
|
||||
bool rows_are_initially_expanded = false) {
|
||||
|
||||
_bus = bus;
|
||||
_model = model;
|
||||
_global_filter = global_filter;
|
||||
_selected_params_mon = new OrderParamsAggregator(model.dynamic_helper, _selection_change_throttle, k => _cached_orders.TryGetValue(k, out var o) ? o.order : (OrderSecurityAlgo?)null);
|
||||
ladder_vm = new LadderVMContainer(bus, model);
|
||||
order_mod_vm = new OrderParamsVM(this, AlgoEditingPermissions.AllowEditValues);
|
||||
@@ -614,7 +611,7 @@ namespace mbts.spark {
|
||||
// resume column filter updates
|
||||
_columns.filter_changed += _on_filter_changed;
|
||||
grid_settings_manager.algo_tree_display_mode_changed += _on_filter_changed;
|
||||
var new_filter = new FilterData(grid_settings_manager.algo_tree_display_mode, _columns.create_filter_states(), _global_filter);
|
||||
var new_filter = new FilterData(grid_settings_manager.algo_tree_display_mode, _columns.create_filter_states());
|
||||
var new_sort = _columns.get_sorting_data();
|
||||
if (!new_filter.Equals(_cached_filter_data)) {
|
||||
_cached_filter_data = new_filter;
|
||||
@@ -689,7 +686,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
void _on_filter_changed() {
|
||||
var fd = new FilterData(grid_settings_manager.algo_tree_display_mode, _columns.create_filter_states(), _global_filter);
|
||||
var fd = new FilterData(grid_settings_manager.algo_tree_display_mode, _columns.create_filter_states());
|
||||
if (!fd.Equals(_cached_filter_data)) {
|
||||
_cached_filter_data = fd;
|
||||
_row_collection.filter = fd.build_predicate();
|
||||
@@ -973,25 +970,13 @@ namespace mbts.spark {
|
||||
struct FilterData : IEquatable<FilterData> {
|
||||
public readonly AlgoTreeDisplayMode algo_tree_display_mode;
|
||||
public readonly FilterStates column_filters;
|
||||
public readonly Func<OrderSecurityRootPair, bool> global_filter;
|
||||
|
||||
public FilterData(AlgoTreeDisplayMode algo_tree_display_mode, FilterStates column_filters, Func<OrderSecurityRootPair, bool> global_filter) {
|
||||
public FilterData(AlgoTreeDisplayMode algo_tree_display_mode, FilterStates column_filters) {
|
||||
this.algo_tree_display_mode = algo_tree_display_mode;
|
||||
this.column_filters = column_filters;
|
||||
this.global_filter = global_filter;
|
||||
}
|
||||
|
||||
public Func<OrderSecurityRootPair, bool> build_predicate() {
|
||||
if (global_filter == null)
|
||||
return _build_predicate_core();
|
||||
var core_pred = _build_predicate_core();
|
||||
if (core_pred == null)
|
||||
return global_filter;
|
||||
var glbf = global_filter;
|
||||
return new Func<OrderSecurityRootPair, bool>(o => glbf(o) && core_pred(o));
|
||||
}
|
||||
|
||||
Func<OrderSecurityRootPair, bool> _build_predicate_core() {
|
||||
var pred = column_filters.build_predicate();
|
||||
if (algo_tree_display_mode == AlgoTreeDisplayMode.RootAndLeafNodes) {
|
||||
if (pred == null) {
|
||||
|
||||
@@ -6,6 +6,7 @@ using bts.shell.fills;
|
||||
using bts.shell.orderbook;
|
||||
using bts.spark;
|
||||
using bts.view;
|
||||
using bts.utils.csv;
|
||||
using mbts.persist;
|
||||
using mbts.spark.utilities;
|
||||
using mbts.ui;
|
||||
@@ -231,6 +232,7 @@ namespace mbts.spark {
|
||||
toggle_collapse_all_command,
|
||||
toggle_expand_all_command,
|
||||
show_grid_settings_command,
|
||||
new SparkCommandCommand("Export to csv", Icons.Export, FileDialogCommand.export_csv(() => _vm.rows.ToCsv(OrderBookRowVM.csv_ordered_properties), "OrderBook")),
|
||||
// hidden cmds (i.e., keyboard shortcuts at window level)
|
||||
hidden_cmd(new SparkCommandCommand(OrderBookView.CommandDescriptions.ModifyOrders, null, _vm.modify_selected_orders_cmd, OrderBookView.KeyboardShortcuts.ModifyOrders)),
|
||||
hidden_cmd(new SparkCommandCommand(OrderBookView.CommandDescriptions.RevertOrders, null, _vm.revert_selected_orders_cmd, OrderBookView.KeyboardShortcuts.RevertOrders)),
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
<Platforms>x64</Platforms>
|
||||
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<LanguageTargets>$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets</LanguageTargets>
|
||||
<LanguageTargets Condition="'$(VisualStudioVersion)'=='16.0'">$(MSBuildToolsPath)\Microsoft.CSharp.targets</LanguageTargets>
|
||||
<LanguageTargets Condition="'$(VisualStudioVersion)'=='17.0'">
|
||||
C:/Program Files/Microsoft Visual Studio/2022/Community/Msbuild/Current/Bin/amd64/Microsoft.CSharp.targets
|
||||
</LanguageTargets>
|
||||
<ApplicationIcon>logo.ico</ApplicationIcon>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<StartupObject>mbts.ui.shell.App</StartupObject>
|
||||
@@ -34,7 +35,7 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.6.1" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.24.3" />
|
||||
<PackageReference Include="IronPython" Version="2.7.7" />
|
||||
<PackageReference Include="NAudio" Version="1.8.4" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
|
||||
|
||||
File renamed without changes.
+17
-35
@@ -1,11 +1,10 @@
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.utils;
|
||||
using mbts.spark;
|
||||
using mbts.user.settings;
|
||||
using mbts.user.settings;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using bts;
|
||||
using static bts.utils.MathUtils;
|
||||
using bts.api;
|
||||
using bts.utils;
|
||||
|
||||
namespace mbts {
|
||||
static class TickExtensions {
|
||||
@@ -19,9 +18,6 @@ namespace mbts {
|
||||
public static bool is_valid(this RegionalTickFactors regional_tick) =>
|
||||
regional_tick.low_tick.is_valid() && regional_tick.high_tick.is_valid();
|
||||
|
||||
public static bool is_integer(this TickFactors tick) =>
|
||||
tick.tick_unit == tick.tick_base;
|
||||
|
||||
public static double tick_unit_frac(this TickFactors tick) =>
|
||||
tick.tick_unit / tick.tick_base;
|
||||
|
||||
@@ -92,33 +88,25 @@ namespace mbts {
|
||||
return _round_tick(tuf, val);
|
||||
}
|
||||
|
||||
public static double tickup(this RegionalTickFactors regional_tick, double input) =>
|
||||
regional_tick.tickup(input, 1);
|
||||
|
||||
public static double tickup(this RegionalTickFactors regional_tick, double input, uint count) =>
|
||||
regional_tick.tickup(input, count, TickUtils.precision_const);
|
||||
|
||||
public static double tickup(this RegionalTickFactors regional_tick, double input, uint count, double precision, bool bling = true) {
|
||||
if (!precision.is_real_positive())
|
||||
throw new ArgumentException(nameof(precision), "Must be a real positive number.");
|
||||
public static double tickup(this RegionalTickFactors regional_tick, double input) { return regional_tick.tickup(input, 1); }
|
||||
public static double tickup(this RegionalTickFactors regional_tick, double input, uint count) {
|
||||
if (DoubleHelper.IsNaNOrInfinity(input) || count == 0) return input;
|
||||
double val, tuf;
|
||||
if (input < regional_tick.low_tick_inclusive_end) {
|
||||
tuf = regional_tick.low_tick.tick_unit_frac();
|
||||
double ieeer = Math.IEEERemainder(input, tuf);
|
||||
input -= ieeer;
|
||||
if (ieeer < -precision) count--;
|
||||
if (ieeer < -_precision_const) count--;
|
||||
val = input + tuf * count;
|
||||
if (val > regional_tick.low_tick_inclusive_end) {
|
||||
count -= (uint)MathUtils.round_up((regional_tick.low_tick_inclusive_end - input) / tuf, precision);
|
||||
count -= (uint)Math.Ceiling((regional_tick.low_tick_inclusive_end - input) / tuf);
|
||||
tuf = regional_tick.high_tick.tick_unit_frac();
|
||||
val = regional_tick.low_tick_inclusive_end + tuf * count;
|
||||
}
|
||||
} else {
|
||||
tuf = regional_tick.high_tick.tick_unit_frac();
|
||||
double ieeer = Math.IEEERemainder(input, tuf);
|
||||
input -= ieeer;
|
||||
if (ieeer < -precision) count--;
|
||||
if (Math.Abs(ieeer) <= _precision_const) input -= ieeer;
|
||||
val = input + tuf * count;
|
||||
}
|
||||
return _round_tick(tuf, val);
|
||||
@@ -188,6 +176,8 @@ namespace mbts {
|
||||
static int _count_ticks(double tick_unit_frac, double value) =>
|
||||
(int)Math.Round(value / tick_unit_frac);
|
||||
|
||||
private const double _precision_const = 0.000000001;
|
||||
|
||||
public static double tickdown(this TickFactors tick, double input) { return tick.tickdown(input, 1); }
|
||||
public static double tickdown(this TickFactors tick, double input, uint count) {
|
||||
if (DoubleHelper.IsNaNOrInfinity(input)) return input;
|
||||
@@ -198,33 +188,25 @@ namespace mbts {
|
||||
return _round_tick(tuf, val);
|
||||
}
|
||||
|
||||
public static double tickdown(this RegionalTickFactors regional_tick, double input) =>
|
||||
regional_tick.tickdown(input, 1);
|
||||
|
||||
public static double tickdown(this RegionalTickFactors regional_tick, double input, uint count) =>
|
||||
tickdown(regional_tick, input, count, TickUtils.precision_const);
|
||||
|
||||
public static double tickdown(this RegionalTickFactors regional_tick, double input, uint count, double precision) {
|
||||
if (!precision.is_real_positive())
|
||||
throw new ArgumentException(nameof(precision), "Must be a real positive number.");
|
||||
public static double tickdown(this RegionalTickFactors regional_tick, double input) { return regional_tick.tickdown(input, 1); }
|
||||
public static double tickdown(this RegionalTickFactors regional_tick, double input, uint count) {
|
||||
if (DoubleHelper.IsNaNOrInfinity(input) || count == 0) return input;
|
||||
double val, tuf;
|
||||
if (input > regional_tick.low_tick_inclusive_end) {
|
||||
tuf = regional_tick.high_tick.tick_unit_frac();
|
||||
double ieeer = Math.IEEERemainder(input, tuf);
|
||||
input -= ieeer;
|
||||
if (ieeer > precision) count--;
|
||||
if (ieeer > _precision_const) count--;
|
||||
val = input - count * tuf;
|
||||
if (val < regional_tick.low_tick_inclusive_end) {
|
||||
count -= (uint)MathUtils.round_up((input - regional_tick.low_tick_inclusive_end) / tuf, precision);
|
||||
count -= (uint)Math.Ceiling((input - regional_tick.low_tick_inclusive_end) / tuf);
|
||||
tuf = regional_tick.low_tick.tick_unit_frac();
|
||||
val = regional_tick.low_tick_inclusive_end - tuf * count;
|
||||
}
|
||||
} else {
|
||||
tuf = regional_tick.low_tick.tick_unit_frac();
|
||||
double ieeer = Math.IEEERemainder(input, tuf);
|
||||
input -= ieeer;
|
||||
if (ieeer > precision) count--;
|
||||
if (Math.Abs(ieeer) <= _precision_const) input -= ieeer;
|
||||
val = input - tuf * count;
|
||||
}
|
||||
return _round_tick(tuf, val);
|
||||
@@ -355,4 +337,4 @@ namespace mbts {
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,14 +112,6 @@ namespace mbts.ui.shell {
|
||||
protected bool Set<T>(ref T backing, T value, [CallerMemberName]string name = "") =>
|
||||
Set(ref backing, value, EqualityComparer<T>.Default, name);
|
||||
|
||||
protected bool Set<T>(ref T backing, T value, [CallerMemberName] string name = "", params string[] dependent_props) {
|
||||
if (Set(ref backing, value, EqualityComparer<T>.Default, name)) {
|
||||
RaisePropertyChanged(dependent_props);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool Set<T>(ref T backing, T value, IEqualityComparer<T> comparer, [CallerMemberName]string name = "") {
|
||||
if (!comparer.Equals(backing, value)) {
|
||||
backing = value;
|
||||
|
||||
File renamed without changes.
+2
@@ -1,7 +1,9 @@
|
||||
using bts.api;
|
||||
using System.ComponentModel.Composition;
|
||||
|
||||
namespace mbts.user.settings
|
||||
{
|
||||
[InheritedExport]
|
||||
internal interface ISecurityBasedSettingsFactory
|
||||
{
|
||||
SecurityBasedSettings get(Venue exchange, SecurityType type, string symbol);
|
||||
+6
-1
@@ -1,4 +1,6 @@
|
||||
using bts.utils;
|
||||
using mbts.spark.utilities;
|
||||
using mbts.ui;
|
||||
using ProtoBuf;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
@@ -22,8 +24,11 @@ namespace mbts.user.settings {
|
||||
_low_tick_inclusive_end = low_tick_inclusive_end;
|
||||
}
|
||||
|
||||
[DisplayInfo("Low")]
|
||||
public TickFactors low_tick => _low_tick;
|
||||
[DisplayInfo("High")]
|
||||
public TickFactors high_tick => _high_tick;
|
||||
[DisplayInfo("Inclusive Low Range End Pt")]
|
||||
public double low_tick_inclusive_end => _low_tick_inclusive_end;
|
||||
|
||||
public bool Equals(RegionalTickFactors other) =>
|
||||
@@ -55,4 +60,4 @@ namespace mbts.user.settings {
|
||||
|
||||
public static bool operator !=(RegionalTickFactors x, RegionalTickFactors y) => !(x == y);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -1,7 +1,9 @@
|
||||
using ProtoBuf;
|
||||
using mbts.ui;
|
||||
using ProtoBuf;
|
||||
|
||||
namespace mbts.user.settings
|
||||
{
|
||||
[DisplayInfo("Tick Settings")]
|
||||
[ProtoContract]
|
||||
class SecurityTickSettings : SecurityBasedSettings
|
||||
{
|
||||
@@ -10,8 +12,10 @@ namespace mbts.user.settings
|
||||
theo_tick = new TickFactors();
|
||||
}
|
||||
|
||||
[DisplayInfo("Price", style = DisplayInfo.DisplayStyle.GroupBox)]
|
||||
[ProtoMember(1)]
|
||||
public RegionalTickFactors price_tick { get; set; }
|
||||
[DisplayInfo("Theo")]
|
||||
[ProtoMember(2)]
|
||||
public TickFactors theo_tick { get; set; }
|
||||
}
|
||||
+5
-2
@@ -1,4 +1,5 @@
|
||||
using ProtoBuf;
|
||||
using mbts.ui;
|
||||
using ProtoBuf;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
@@ -18,7 +19,9 @@ namespace mbts.user.settings {
|
||||
_tick_unit = tick_unit;
|
||||
}
|
||||
|
||||
[DisplayInfo("Base")]
|
||||
public double tick_base => _tick_base;
|
||||
[DisplayInfo("Unit")]
|
||||
public double tick_unit => _tick_unit;
|
||||
|
||||
public bool Equals(TickFactors other) =>
|
||||
@@ -45,4 +48,4 @@ namespace mbts.user.settings {
|
||||
|
||||
public static bool operator !=(TickFactors x, TickFactors y) => !(x == y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,25 +93,6 @@ namespace mbts.ui.controls {
|
||||
|
||||
public uint Increment { get { return (uint)GetValue(IncrementProperty); } set { SetValue(IncrementProperty, value); } }
|
||||
|
||||
#region TickUpCommand
|
||||
public static readonly DependencyProperty TickUpCommandProperty =
|
||||
TickUpDown.TickUpCommandProperty.AddOwner(typeof(TickUpDownUInt));
|
||||
|
||||
public ICommand TickUpCommand {
|
||||
get => GetValue(TickUpCommandProperty) as ICommand;
|
||||
set => SetValue(TickUpCommandProperty, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TickDownCommand
|
||||
public static readonly DependencyProperty TickDownCommandProperty =
|
||||
TickUpDown.TickDownCommandProperty.AddOwner(typeof(TickUpDownUInt));
|
||||
|
||||
public ICommand TickDownCommand {
|
||||
get => GetValue(TickDownCommandProperty) as ICommand;
|
||||
set => SetValue(TickDownCommandProperty, value);
|
||||
}
|
||||
#endregion
|
||||
// explicit props
|
||||
public bool EnableArrowKeyTick { get => _enable_arrow_key_tick.value; set => _enable_arrow_key_tick.value = value; }
|
||||
public ModifierKeys ArrowKeyTickModifiers { get => _arrow_key_tick_modifiers.value; set => _arrow_key_tick_modifiers.value = value; }
|
||||
@@ -139,19 +120,13 @@ namespace mbts.ui.controls {
|
||||
}
|
||||
|
||||
void _tick_up() {
|
||||
if (TickUpCommand is ICommand cmd) {
|
||||
cmd.ExecuteIfCan(null);
|
||||
} else if (TickUpDownHelper.tick_up(Value, Increment, out uint result)) {
|
||||
if (TickUpDownHelper.tick_up(Value, Increment, out uint result))
|
||||
SetCurrentValue(ValueProperty, result);
|
||||
}
|
||||
}
|
||||
|
||||
void _tick_down() {
|
||||
if (TickDownCommand is ICommand cmd) {
|
||||
cmd.ExecuteIfCan(null);
|
||||
} else if (TickUpDownHelper.tick_down(Value, Increment, out uint result)) {
|
||||
if (TickUpDownHelper.tick_down(Value, Increment, out uint result))
|
||||
SetCurrentValue(ValueProperty, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,25 @@ namespace mbts.ui {
|
||||
}
|
||||
}, can_execute == null ? null : new Func<object, bool>(_ => can_execute()));
|
||||
|
||||
public static IDialogCommand export_csv(
|
||||
Func<string> get_file_content,
|
||||
string source_window_name) =>
|
||||
new AnonymousFileDialogCommand<object>(_ =>
|
||||
_create_save_file_dialog(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
|
||||
$"BTS_Spark_{source_window_name}_{DateTime.Now.ToString("yyyyMMdd_HHmm")}.csv",
|
||||
new[] { ("CSV (comma delimited)", new string[] { "csv" }) }
|
||||
),
|
||||
(_, file) => {
|
||||
try {
|
||||
File.WriteAllText(file, get_file_content.Invoke());
|
||||
} catch (Exception ex) {
|
||||
BTSMessageBox.Show($"Error exporting data to csv: {ex}.", "CSV Export Error", BTSMessageBoxButtons.OK, System.Windows.MessageBoxImage.Error, true, false, true);
|
||||
}
|
||||
},
|
||||
// we are always able to perform an export, even when no rows (it will just be a header)
|
||||
(_) => true);
|
||||
|
||||
static TDialog _create_file_dialog<TDialog>(string initial_dir = null, IReadOnlyList<(string name, string[] extensions)> filter_items = null) where TDialog : FileDialog, new() {
|
||||
var rv = new TDialog();
|
||||
if (!string.IsNullOrEmpty(initial_dir))
|
||||
|
||||
@@ -0,0 +1,388 @@
|
||||
using bts.api;
|
||||
using bts.utils;
|
||||
using mbts.co2;
|
||||
using mbts.user.settings;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace mbts.spark {
|
||||
static class TickUtils {
|
||||
internal static ContractSpecificationImmutable spec_or_default(this ContractSpecificationImmutable? spec) =>
|
||||
spec.HasValue ? spec.Value : SecurityDataHelper.Defaults.ContractSpecificationImmutable;
|
||||
|
||||
internal static ContractSpecificationImmutable spec_or_default(this SecurityImmutable security) =>
|
||||
security.HasContractSpec ? security.ContractSpec : SecurityDataHelper.Defaults.ContractSpecificationImmutable;
|
||||
|
||||
internal static ContractSpecificationImmutable spec_or_default(this SecurityImmutable? security) =>
|
||||
security.HasValue && security.Value.HasContractSpec ? security.Value.ContractSpec : SecurityDataHelper.Defaults.ContractSpecificationImmutable;
|
||||
|
||||
public static ContractSpecificationImmutable spec_or_default(this SecurityMD? security_md) =>
|
||||
(security_md?.security).spec_or_default();
|
||||
|
||||
public static double ticksize(this ContractSpecificationImmutable spec, double price) =>
|
||||
Math.Abs(price) > spec.PriceBreak ? spec.HighTick : spec.LowTick;
|
||||
|
||||
public static string format(this ContractSpecificationImmutable spec, double price, double with_regard_to_price, bool in_tick_terms) {
|
||||
double net_change = price - with_regard_to_price;
|
||||
return (in_tick_terms) ?
|
||||
TickStore.get(spec).format_without_decimal_part((net_change) / spec.ticksize(net_change)) :
|
||||
TickStore.get(spec).format(net_change);
|
||||
}
|
||||
|
||||
public static string format(this ContractSpecificationImmutable spec, double price) =>
|
||||
TickStore.get(spec).format(price);
|
||||
|
||||
public static string format(this ContractSpecificationImmutable? spec, double price) =>
|
||||
spec.spec_or_default().format(price);
|
||||
|
||||
public static string format(this ContractSpecificationImmutable spec, double price, double display_multiplier, bool show_commas, string nan_text) =>
|
||||
TickStore.get(spec).format(price, display_multiplier, show_commas, nan_text);
|
||||
|
||||
public static string format(this ContractSpecificationImmutable? spec, double price, double display_multiplier, bool show_commas, string nan_text) =>
|
||||
spec.spec_or_default().format(price, display_multiplier, show_commas, nan_text);
|
||||
|
||||
public static double parse(this ContractSpecificationImmutable spec, string text, double display_multiplier, string nan_text) =>
|
||||
TickStore.get(spec).parse(text, display_multiplier, nan_text);
|
||||
|
||||
public static double parse(this ContractSpecificationImmutable? spec, string text, double display_multiplier, string nan_text) =>
|
||||
spec.spec_or_default().parse(text, display_multiplier, nan_text);
|
||||
|
||||
public static bool is_integer_tick(ContractSpecificationImmutable spec) =>
|
||||
spec.MainFraction == 0 &&
|
||||
spec.PriceDisplayFormat == 0 &&
|
||||
spec.LowTick > 0 &&
|
||||
MathUtils.is_int(spec.LowTick) &&
|
||||
spec.HighTick > 0 &&
|
||||
MathUtils.is_int(spec.HighTick);
|
||||
|
||||
public static ContractSpecification create_integer_tick_spec(int low_tick) =>
|
||||
create_integer_tick_spec(low_tick, low_tick);
|
||||
|
||||
public static ContractSpecification create_integer_tick_spec(int low_tick, int high_tick) {
|
||||
var rv = SecurityDataHelper.Defaults.ContractSpecification;
|
||||
rv.MainFraction = 0;
|
||||
rv.SubFraction = 0;
|
||||
rv.PriceDisplayFormat = 0;
|
||||
rv.PriceBreak = 0;
|
||||
rv.LowTick = low_tick;
|
||||
rv.HighTick = high_tick;
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static double low_tick(NativePriceSize[] bids, NativePriceSize[] asks) {
|
||||
double low = bids[bids.Length - 1].price;
|
||||
if (double.IsNaN(low))
|
||||
low = bids.LastOrDefault(nps => nps.price, p => !double.IsNaN(p), double.NaN);
|
||||
if (double.IsNaN(low))
|
||||
low = asks[0].price;
|
||||
return low;
|
||||
}
|
||||
|
||||
public static double high_tick(NativePriceSize[] bids, NativePriceSize[] asks) {
|
||||
double high = asks[asks.Length - 1].price;
|
||||
if (double.IsNaN(high))
|
||||
high = asks.LastOrDefault(nps => nps.price, p => !double.IsNaN(p), double.NaN);
|
||||
if (double.IsNaN(high))
|
||||
high = bids[0].price;
|
||||
return high;
|
||||
}
|
||||
|
||||
public static int? tickdiff(this ContractSpecificationImmutable spec, double x, double y) {
|
||||
if (get_regional_ticks(spec).try_get_tickdiff(x, y, out int n_low, out int n_high))
|
||||
return n_low + n_high;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int tickdiff_unchecked(this ContractSpecificationImmutable spec, double x, double y) {
|
||||
(int n_low, int n_high) = get_regional_ticks(spec).tickdiff_unchecked(x, y);
|
||||
return n_low + n_high;
|
||||
}
|
||||
|
||||
public static double mid_tick(ContractSpecificationImmutable spec, double bid, double ask) {
|
||||
double raw_mid;
|
||||
if (double.IsNaN(bid)) {
|
||||
if (double.IsNaN(ask)) return double.NaN;
|
||||
raw_mid = ask;
|
||||
} else if (double.IsNaN(ask)) {
|
||||
raw_mid = bid;
|
||||
} else {
|
||||
raw_mid = (bid + ask) / 2.0;
|
||||
}
|
||||
double tick_size = spec.ticksize(raw_mid);
|
||||
return raw_mid < 0 ?
|
||||
raw_mid + (raw_mid % tick_size) :
|
||||
raw_mid - (raw_mid % tick_size);
|
||||
}
|
||||
|
||||
public static TickFactors deduce_ticks(IEnumerable<ContractSpecification> contract_specs) {
|
||||
var ticks = new HashSet<TickFactors>(contract_specs.Select(TickStore.get).SelectMany(rtf => new[] { rtf.low_tick, rtf.high_tick }));
|
||||
switch (ticks.Count) {
|
||||
case 0: return TickStore.default_rtf.low_tick;
|
||||
case 1: return ticks.First();
|
||||
default:
|
||||
double tick_base_lcm = MathUtils.LCM(ticks.Select(t => (int)t.tick_base));
|
||||
double tick_unit_gcd = MathUtils.GCD(ticks.Select(t => t.tick_unit * (tick_base_lcm / t.tick_base)));
|
||||
return new TickFactors(tick_base_lcm, tick_unit_gcd);
|
||||
}
|
||||
}
|
||||
|
||||
public static RegionalTickFactors get_tick_factors(ContractSpecificationImmutable spec) =>
|
||||
TickStore.get(spec);
|
||||
|
||||
public static double tickup(this ContractSpecificationImmutable spec, double value) =>
|
||||
TickStore.get(spec).tickup(value);
|
||||
|
||||
public static double tickup(this ContractSpecificationImmutable spec, double value, int count) {
|
||||
if (count == 0) return value;
|
||||
if (count < 0) return TickStore.get(spec).tickdown(value, (uint)(-count));
|
||||
else return TickStore.get(spec).tickup(value, (uint)count);
|
||||
}
|
||||
|
||||
public static double tickdown(this ContractSpecificationImmutable spec, double value) =>
|
||||
TickStore.get(spec).tickdown(value);
|
||||
|
||||
public static double tickdown(this ContractSpecificationImmutable spec, double value, int count) {
|
||||
if (count == 0) return value;
|
||||
if (count < 0) return TickStore.get(spec).tickup(value, (uint)(-count));
|
||||
else return TickStore.get(spec).tickdown(value, (uint)count);
|
||||
}
|
||||
|
||||
public static bool tick_equals(this ContractSpecificationImmutable contract, double x, double y) =>
|
||||
MathUtils.RoundFractionalUnits(x, contract.LowTick) == MathUtils.RoundFractionalUnits(y, contract.LowTick);
|
||||
|
||||
public static IEqualityComparer<double> tick_equality_comparer(this ContractSpecificationImmutable contract) =>
|
||||
EqualityComparer.Create((double a, double b) => tick_equals(contract, a, b), x => MathUtils.RoundFractionalUnits(x, contract.LowTick));
|
||||
|
||||
public static int compare_tick_fallback_to_double(this ContractSpecificationImmutable contract, double x, double y) =>
|
||||
tick_equals(contract, x, y) ? 0 : x.CompareTo(y);
|
||||
|
||||
public static double round_to_tick(this ContractSpecificationImmutable spec, double value) {
|
||||
double intpart = (long)value;
|
||||
double floatpart = value % 1;
|
||||
double tick = spec.ticksize(value);
|
||||
floatpart = ((int)(floatpart / tick)) * tick;
|
||||
return intpart + floatpart;
|
||||
}
|
||||
|
||||
public static decimal round_to_tick(this ContractSpecificationImmutable spec, decimal value) {
|
||||
decimal intpart = (long)value;
|
||||
decimal floatpart = value % 1;
|
||||
decimal tick = (decimal)spec.ticksize((double)value);
|
||||
floatpart = ((int)(floatpart / tick)) * tick;
|
||||
return intpart + floatpart;
|
||||
}
|
||||
|
||||
public static RegionalTickFactors get_regional_ticks(ContractSpecificationImmutable? spec) =>
|
||||
spec.HasValue ? TickStore.get(spec.Value) : TickStore.default_rtf;
|
||||
|
||||
public static RegionalTickFactors get_regional_ticks(SecurityImmutable security) =>
|
||||
get_regional_ticks(security.spec_or_default());
|
||||
|
||||
static TickFactors _inflate_to_base(TickFactors tick_factors, double new_base) =>
|
||||
new TickFactors(new_base, tick_factors.tick_unit * new_base / tick_factors.tick_base);
|
||||
|
||||
public static class CompareUtils {
|
||||
public static IComparer<double> base_comparer =>
|
||||
Comparer<double>.Create(_compare_base);
|
||||
|
||||
public static IComparer<double> unit_comparer =>
|
||||
Comparer<double>.Create(_compare_unit);
|
||||
|
||||
public static IComparer<TickFactors> base_unit_comparer =>
|
||||
Comparer<TickFactors>.Create(bts.utils.CompareUtils.safe_comparison<TickFactors>(compare_base_unit));
|
||||
|
||||
public static int compare_base_unit(TickFactors a, TickFactors b) {
|
||||
int comp = _compare_base(a.tick_base, b.tick_base);
|
||||
return comp == 0 ? a.tick_unit.CompareTo(b.tick_unit) : comp;
|
||||
}
|
||||
|
||||
static int _compare_base(double a, double b) {
|
||||
double reduced_a = MathUtils.factor_out(a, 10);
|
||||
double reduced_b = MathUtils.factor_out(b, 10);
|
||||
int comp = reduced_a.CompareTo(reduced_b);
|
||||
return comp == 0 ? a.CompareTo(b) : comp;
|
||||
}
|
||||
|
||||
static int _compare_unit(double a, double b) =>
|
||||
_compare_unit(a, b, 0, 0);
|
||||
|
||||
static int _compare_unit(double a, double b, int a_mult10, int b_mult10) {
|
||||
// fractional-coins are a special case, as they may not be an integer to begin with
|
||||
if (!MathUtils.is_int(a))
|
||||
return _compare_unit(a * 10, b, ++a_mult10, b_mult10);
|
||||
if (!MathUtils.is_int(b))
|
||||
return _compare_unit(a, b * 10, a_mult10, ++b_mult10);
|
||||
double reduced_a = a_mult10 > 0 ? a : MathUtils.factor_out(a, 10, 5);
|
||||
double reduced_b = b_mult10 > 0 ? b : MathUtils.factor_out(b, 10, 5);
|
||||
int comp = reduced_a.CompareTo(reduced_b);
|
||||
return comp == 0 ? (a * Math.Pow(10, -a_mult10)).CompareTo(b * Math.Pow(10, -b_mult10)) : comp;
|
||||
}
|
||||
}
|
||||
|
||||
static class TickStore {
|
||||
public static readonly RegionalTickFactors default_rtf = new RegionalTickFactors(new TickFactors(1000, 1), new TickFactors(1000, 1), double.MaxValue);
|
||||
static readonly ConcurrentDictionary<SpecKey, RegionalTickFactors> _exchange_ticks = new ConcurrentDictionary<SpecKey, RegionalTickFactors>();
|
||||
static readonly bool _som_ticks_fix_enabled = config.Configuration.get<bts.config.toggles.SOMTicksFix>().enabled;
|
||||
|
||||
public static RegionalTickFactors get(ContractSpecification spec) =>
|
||||
_exchange_ticks.GetOrAdd(new SpecKey(spec), _create_rtf);
|
||||
|
||||
public static RegionalTickFactors get(ContractSpecificationImmutable spec) =>
|
||||
_exchange_ticks.GetOrAdd(new SpecKey(spec), _create_rtf);
|
||||
|
||||
public static RegionalTickFactors get(SecurityImmutable security) =>
|
||||
security.HasContractSpec ? get(security.ContractSpec) : default_rtf;
|
||||
|
||||
public static RegionalTickFactors get(SecurityImmutable? security) =>
|
||||
security.HasValue ? get(security.Value) : default_rtf;
|
||||
|
||||
static RegionalTickFactors _create_rtf(SpecKey key) {
|
||||
double tick_base = key.denominator;
|
||||
if (tick_base == 0) {
|
||||
// indicates tick is a decimal
|
||||
tick_base = 100;
|
||||
}
|
||||
return _create_rtf(key.low_tick, key.high_tick, key.price_break, tick_base, key.display_digits);
|
||||
}
|
||||
|
||||
static RegionalTickFactors _create_rtf(double low_tick, double high_tick, double price_break, double reduced_target_base, uint display_digits_override) {
|
||||
var low_tf = _try_create_tf(low_tick, reduced_target_base, display_digits_override);
|
||||
var high_tf = _try_create_tf(high_tick, reduced_target_base, display_digits_override);
|
||||
if (low_tf == null) {
|
||||
low_tf = high_tf ?? (high_tf = default_rtf.low_tick);
|
||||
} else if (high_tf == null)
|
||||
high_tf = low_tf;
|
||||
else {
|
||||
// if low/high tick-bases do not match, inflate the smaller base so they do
|
||||
// Note: this assumes the tick-bases are related by factors of 10 (i.e. they have all the same prime factors except for a different number of pairs of 5 and 2, e.g. 64 and 640)
|
||||
if (low_tf.tick_base > high_tf.tick_base) {
|
||||
high_tf = _inflate_to_base(high_tf, low_tf.tick_base);
|
||||
} else if (low_tf.tick_base < high_tf.tick_base) {
|
||||
low_tf = _inflate_to_base(low_tf, high_tf.tick_base);
|
||||
}
|
||||
}
|
||||
return new RegionalTickFactors(low_tf, high_tf, price_break);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates TickFactors with a base equal to "<paramref name="tick_base"/> * 10^n," where 'n' is a natural number (including 0).
|
||||
/// <para>Note: If <paramref name="display_digits_override"/> is non-zero, 'n' will be "<paramref name="display_digits_override"/> - Math.Ceiling(Log10(<paramref name="tick_base"/>))"</para>
|
||||
/// </summary>
|
||||
/// <param name="tick_size">The raw tick-size.</param>
|
||||
/// <param name="tick_base">The raw tick-base.</param>
|
||||
/// <returns>Well-defined TickFactors</returns>
|
||||
static TickFactors _try_create_tf(double tick_size, double tick_base, uint display_digits_override) {
|
||||
var tf = _try_create_tf(tick_size, tick_base);
|
||||
if (tf != null && display_digits_override > 0) {
|
||||
int display_digit_diff = (int)display_digits_override - tf.display_digits();
|
||||
if (_som_ticks_fix_enabled) {
|
||||
// we can always add display_digits (i.e. dislpay_digit_diff > 0), of course the ticks can be expressed precisely with extra 0s.
|
||||
// but if we are going to remove display_digits (i.e display_digit_diff < 0), we must make sure the tick_unit is large enough to be expressed precisely with that many fewer digits
|
||||
// - "-display_digit_diff <= Math.Ceiling(Math.Log10(tf.tick_unit))" will tell us if the digits can be removed without compromising precision
|
||||
// - unfortunately, we cannot rely on the exchange's ContractSpec for this, there is 1 known case where the data they give us is incorrect
|
||||
// SOM spreads ContractSpec (from the exchange):
|
||||
// LowTick: 0.0025 (aka 1/400, or 2/800)
|
||||
// MainFraction: 8
|
||||
// SubFraction: 0
|
||||
// PriceDisplayFormat: 1
|
||||
// - as you can see, this cannot possibly be formatted with 1 display digit, it ticks in increments of 1/400
|
||||
// - in practice, to maintain the '8' base, we format this in increments of 2/800 (e.g. 1-000, 1-002, 1-004, and so on up to 1-778, 2-000)
|
||||
if (display_digit_diff > 0 || (display_digit_diff < 0 && -display_digit_diff <= Math.Ceiling(Math.Log10(tf.tick_unit))))
|
||||
tf = _inflate_to_base(tf, tf.tick_base * Math.Pow(10, display_digit_diff));
|
||||
} else if (display_digit_diff != 0) {
|
||||
tf = _inflate_to_base(tf, tf.tick_base * Math.Pow(10, display_digit_diff));
|
||||
}
|
||||
}
|
||||
return tf;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates TickFactors with a base equal to "reduced_target_base * 10^n," where 'n' is a natural number (including 0).
|
||||
/// </summary>
|
||||
/// <param name="tick_size">The raw tick-size.</param>
|
||||
/// <param name="reduced_target_base">The smallest acceptable tick-base.</param>
|
||||
/// <returns>Well-defined TickFactors</returns>
|
||||
static TickFactors _try_create_tf(double tick_size, double reduced_target_base) {
|
||||
if (!_check_tick_size(tick_size))
|
||||
return null;
|
||||
double raw_base = 1 / tick_size;
|
||||
double raw_base_log10 = Math.Log10(raw_base);
|
||||
double reduced_target_base_log10 = Math.Log10(reduced_target_base);
|
||||
double log10_diff = raw_base_log10 - reduced_target_base_log10;
|
||||
if (MathUtils.is_int(log10_diff))
|
||||
return raw_base > reduced_target_base ? new TickFactors(raw_base, 1) : new TickFactors(reduced_target_base, Math.Pow(10, -log10_diff));
|
||||
int count = 0;
|
||||
double factored_base = log10_diff > 0 ? reduced_target_base * Math.Pow(10, Math.Ceiling(log10_diff)) : reduced_target_base;
|
||||
do {
|
||||
// Note that the modulus operator is not used here due to rounding errors.
|
||||
// Such a rounding errror was the cause of the bug https://bluetradesys.atlassian.net/browse/SP-283.
|
||||
if (MathUtils.is_int(factored_base / raw_base))
|
||||
return new TickFactors(factored_base, factored_base / raw_base);
|
||||
factored_base *= 10;
|
||||
} while (++count < 10);
|
||||
return null;
|
||||
}
|
||||
|
||||
static TickFactors _create_tf(double tick_size) {
|
||||
if (!_check_tick_size(tick_size))
|
||||
return default_rtf.low_tick;
|
||||
double matched_unit = double.MinValue;
|
||||
TickFactors matched_tf = null;
|
||||
foreach (var kv in _exchange_ticks) {
|
||||
if (kv.Key.high_tick == tick_size) {
|
||||
return kv.Value.high_tick;
|
||||
} else if (kv.Key.low_tick == tick_size) {
|
||||
return kv.Value.low_tick;
|
||||
} else if (is_better_match(kv.Key.high_tick)) {
|
||||
matched_unit = kv.Key.high_tick;
|
||||
matched_tf = kv.Value.high_tick;
|
||||
} else if (is_better_match(kv.Key.low_tick)) {
|
||||
matched_unit = kv.Key.low_tick;
|
||||
matched_tf = kv.Value.low_tick;
|
||||
}
|
||||
}
|
||||
return matched_tf ?? new TickFactors(1.0 / tick_size, 1);
|
||||
|
||||
bool is_better_match(double known_unit) =>
|
||||
known_unit < tick_size && known_unit > matched_unit && tick_size % known_unit == 0;
|
||||
}
|
||||
|
||||
static bool _check_tick_size(double tick_size) =>
|
||||
tick_size > 0 && (tick_size <= 0.5 || MathUtils.is_int(tick_size));
|
||||
|
||||
struct SpecKey : IEquatable<SpecKey> {
|
||||
public readonly uint denominator, display_digits;
|
||||
public readonly double low_tick, high_tick, price_break;
|
||||
|
||||
public SpecKey(ContractSpecification spec)
|
||||
: this(spec.MainFraction, spec.PriceDisplayFormat, spec.LowTick, spec.HighTick, spec.PriceBreak) { }
|
||||
|
||||
public SpecKey(ContractSpecificationImmutable spec)
|
||||
: this(spec.MainFraction, spec.PriceDisplayFormat, spec.LowTick, spec.HighTick, spec.PriceBreak) { }
|
||||
|
||||
public SpecKey(uint denominator, uint display_digits, double low_tick, double high_tick, double price_break) {
|
||||
this.denominator = denominator;
|
||||
this.display_digits = display_digits;
|
||||
this.low_tick = low_tick;
|
||||
this.high_tick = high_tick;
|
||||
this.price_break = price_break;
|
||||
}
|
||||
|
||||
public bool Equals(SpecKey other) =>
|
||||
denominator == other.denominator &&
|
||||
display_digits == other.display_digits &&
|
||||
low_tick == other.low_tick &&
|
||||
high_tick == other.high_tick &&
|
||||
price_break == other.price_break;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
obj is SpecKey sk && Equals(sk);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
EqualityComparer.aggregate_hash((int)denominator, (int)display_digits, low_tick.GetHashCode(), high_tick.GetHashCode(), price_break.GetHashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -112,9 +112,5 @@ namespace mbts.co2 {
|
||||
return !a.Equals(b);
|
||||
}
|
||||
}
|
||||
|
||||
static class NativePriceSizeExtensions {
|
||||
public static NativePriceSize with(this NativePriceSize nps, uint? direct_size = null, uint? implied_size = null) =>
|
||||
new NativePriceSize(nps.int_price, direct_size ?? nps.direct_size, implied_size ?? nps.implied_size);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.6.1" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.24.3" />
|
||||
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
|
||||
<PackageReference Include="System.Reactive" Version="3.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace bts {
|
||||
Plugin,
|
||||
Sdk,
|
||||
Http,
|
||||
iLink3
|
||||
// Please keep this list in sync with logging.h/logging.cpp
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,6 @@ namespace bts.utils {
|
||||
public static bool epsilon_equals(double x, double y) =>
|
||||
Math.Abs(x - y) < epsilon;
|
||||
|
||||
public static bool marginal_equals(double x, double y, double margin = epsilon) =>
|
||||
Math.Abs(x - y) < margin;
|
||||
|
||||
public static double GCD(IEnumerable<double> nums) {
|
||||
var no_zeros = nums.Where(n => n != 0);
|
||||
if (!no_zeros.Any()) return 0;
|
||||
@@ -105,44 +102,6 @@ namespace bts.utils {
|
||||
public static int RoundFractionalUnits(double value, double fractional_unit) =>
|
||||
(int)Math.Round(value / fractional_unit);
|
||||
|
||||
public static double round_down_abs(double value, double margin = epsilon) {
|
||||
if (value < 0) {
|
||||
return round_up(value, margin);
|
||||
} else if (value > 0) {
|
||||
return round_down(value, margin);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static double round_down(double value, double margin = epsilon) {
|
||||
if (double.IsNaN(value) || double.IsInfinity(value))
|
||||
return value;
|
||||
var result = Math.Floor(value);
|
||||
if (marginal_equals(value - result, 1, margin)) {
|
||||
result = Math.Ceiling(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double round_up_abs(double value, double margin = epsilon) {
|
||||
if (value < 0) {
|
||||
return round_down(value, margin);
|
||||
} else if (value > 0) {
|
||||
return round_up(value, margin);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static double round_up(double value, double margin = epsilon) {
|
||||
if (double.IsNaN(value) || double.IsInfinity(value))
|
||||
return value;
|
||||
var result = Math.Ceiling(value);
|
||||
if (marginal_equals(result - value, 1, margin)) {
|
||||
result = Math.Floor(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool is_int(double d) =>
|
||||
epsilon_equals(d, Math.Round(d));
|
||||
|
||||
|
||||
@@ -83,49 +83,6 @@ namespace System.Collections.Generic {
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static IEnumerable<TAccumulate> AggregateConsecutiveGroups<T, TGroupKey, TAccumulate>(
|
||||
this IEnumerable<T> source,
|
||||
Func<TAccumulate> seed_factory,
|
||||
Func<TAccumulate, T, TAccumulate> aggregate,
|
||||
Func<T, TGroupKey> group_key) =>
|
||||
AggregateConsecutiveGroups(source, seed_factory, aggregate, group_key, EqualityComparer<TGroupKey>.Default);
|
||||
|
||||
public static IEnumerable<TAccumulate> AggregateConsecutiveGroups<T, TGroupKey, TAccumulate>(
|
||||
this IEnumerable<T> source,
|
||||
Func<TAccumulate> seed_factory,
|
||||
Func<TAccumulate, T, TAccumulate> aggregate,
|
||||
Func<T, TGroupKey> group_key,
|
||||
IEqualityComparer<TGroupKey> group_key_comparer) {
|
||||
//
|
||||
if (source is null)
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
if (seed_factory is null)
|
||||
throw new ArgumentNullException(nameof(seed_factory));
|
||||
if (aggregate is null)
|
||||
throw new ArgumentNullException(nameof(aggregate));
|
||||
if (group_key is null)
|
||||
throw new ArgumentNullException(nameof(group_key));
|
||||
if (group_key_comparer is null)
|
||||
throw new ArgumentNullException(nameof(group_key_comparer));
|
||||
using (var en = source.GetEnumerator()) {
|
||||
if (en.MoveNext()) {
|
||||
var curr_group = group_key(en.Current);
|
||||
var agg = aggregate(seed_factory(), en.Current);
|
||||
while (en.MoveNext()) {
|
||||
var group = group_key(en.Current);
|
||||
if (group_key_comparer.Equals(group, curr_group))
|
||||
agg = aggregate(agg, en.Current);
|
||||
else {
|
||||
yield return agg;
|
||||
curr_group = group;
|
||||
agg = aggregate(seed_factory(), en.Current);
|
||||
}
|
||||
}
|
||||
yield return agg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CountAtLeast<T>(this IEnumerable<T> source, int count) {
|
||||
if (count < 0)
|
||||
throw new ArgumentException(ExceptionBuilder.Format.LessThan(0), nameof(count));
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
using bts.api;
|
||||
using bts.utils;
|
||||
using mbts;
|
||||
using mbts.user.settings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace bts.data.ticks {
|
||||
class TickFactorsFactory {
|
||||
static readonly RegionalTickFactors _default_rtf = new RegionalTickFactors(new TickFactors(1000, 1), new TickFactors(1000, 1), double.MaxValue);
|
||||
readonly Dictionary<SpecKey, RegionalTickFactors> _exchange_ticks = new Dictionary<SpecKey, RegionalTickFactors>();
|
||||
|
||||
public RegionalTickFactors default_rtf => _default_rtf;
|
||||
|
||||
public RegionalTickFactors get(ContractSpecification spec) =>
|
||||
_exchange_ticks.GetOrAdd(new SpecKey(spec), _create_rtf);
|
||||
|
||||
public RegionalTickFactors get(ContractSpecificationImmutable spec) =>
|
||||
_exchange_ticks.GetOrAdd(new SpecKey(spec), _create_rtf);
|
||||
|
||||
public RegionalTickFactors get(SecurityImmutable security) =>
|
||||
security.HasContractSpec ? get(security.ContractSpec) : _default_rtf;
|
||||
|
||||
public RegionalTickFactors get(SecurityImmutable? security) =>
|
||||
security.HasValue ? get(security.Value) : _default_rtf;
|
||||
|
||||
static RegionalTickFactors _create_rtf(SpecKey key) {
|
||||
double tick_base = key.denominator;
|
||||
if (tick_base == 0) {
|
||||
// indicates tick is a decimal
|
||||
tick_base = 100;
|
||||
}
|
||||
return _create_rtf(key.low_tick, key.high_tick, key.price_break, tick_base, key.display_digits);
|
||||
}
|
||||
|
||||
static RegionalTickFactors _create_rtf(double low_tick, double high_tick, double price_break, double reduced_target_base, uint display_digits_override) {
|
||||
var low_tf = _try_create_tf(low_tick, reduced_target_base, display_digits_override);
|
||||
var high_tf = _try_create_tf(high_tick, reduced_target_base, display_digits_override);
|
||||
if (low_tf == null) {
|
||||
low_tf = high_tf ?? (high_tf = _default_rtf.low_tick);
|
||||
} else if (high_tf == null)
|
||||
high_tf = low_tf;
|
||||
else {
|
||||
// if low/high tick-bases do not match, inflate the smaller base so they do
|
||||
// Note: this assumes the tick-bases are related by factors of 10 (i.e. they have all the same prime factors except for a different number of pairs of 5 and 2, e.g. 64 and 640)
|
||||
if (low_tf.tick_base > high_tf.tick_base) {
|
||||
high_tf = _inflate_to_base(high_tf, low_tf.tick_base);
|
||||
} else if (low_tf.tick_base < high_tf.tick_base) {
|
||||
low_tf = _inflate_to_base(low_tf, high_tf.tick_base);
|
||||
}
|
||||
}
|
||||
// if price break is not a multiple of both low/high tick, set it to nan
|
||||
// (much simpler than trying to interpret data that is incorrect)
|
||||
if (!price_break.is_real() || !MathUtils.is_int(price_break / low_tick) || !MathUtils.is_int(price_break / high_tick)) {
|
||||
price_break = double.NaN;
|
||||
high_tf = low_tf;
|
||||
}
|
||||
return new RegionalTickFactors(low_tf, high_tf, price_break);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates TickFactors with a base equal to "<paramref name="tick_base"/> * 10^n," where 'n' is a natural number (including 0).
|
||||
/// <para>Note: If <paramref name="display_digits_override"/> is non-zero, 'n' will be "<paramref name="display_digits_override"/> - Math.Ceiling(Log10(<paramref name="tick_base"/>))"</para>
|
||||
/// </summary>
|
||||
/// <param name="tick_size">The raw tick-size.</param>
|
||||
/// <param name="tick_base">The raw tick-base.</param>
|
||||
/// <returns>Well-defined TickFactors</returns>
|
||||
static TickFactors _try_create_tf(double tick_size, double tick_base, uint display_digits_override) {
|
||||
var tf = _try_create_tf(tick_size, tick_base);
|
||||
if (tf != null && display_digits_override > 0) {
|
||||
int display_digit_diff = (int)display_digits_override - tf.display_digits();
|
||||
if (display_digit_diff != 0) {
|
||||
tf = _inflate_to_base(tf, tf.tick_base * Math.Pow(10, display_digit_diff));
|
||||
}
|
||||
}
|
||||
return tf;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates TickFactors with a base equal to "reduced_target_base * 10^n," where 'n' is a natural number (including 0).
|
||||
/// </summary>
|
||||
/// <param name="tick_size">The raw tick-size.</param>
|
||||
/// <param name="reduced_target_base">The smallest acceptable tick-base.</param>
|
||||
/// <returns>Well-defined TickFactors</returns>
|
||||
static TickFactors _try_create_tf(double tick_size, double reduced_target_base) {
|
||||
if (!_check_tick_size(tick_size))
|
||||
return null;
|
||||
double raw_base = 1 / tick_size;
|
||||
double raw_base_log10 = Math.Log10(raw_base);
|
||||
double reduced_target_base_log10 = Math.Log10(reduced_target_base);
|
||||
double log10_diff = raw_base_log10 - reduced_target_base_log10;
|
||||
if (MathUtils.is_int(log10_diff))
|
||||
return raw_base > reduced_target_base ? new TickFactors(raw_base, 1) : new TickFactors(reduced_target_base, Math.Pow(10, -log10_diff));
|
||||
int count = 0;
|
||||
double factored_base = log10_diff > 0 ? reduced_target_base * Math.Pow(10, Math.Ceiling(log10_diff)) : reduced_target_base;
|
||||
do {
|
||||
// Note that the modulus operator is not used here due to rounding errors.
|
||||
// Such a rounding errror was the cause of the bug https://bluetradesys.atlassian.net/browse/SP-283.
|
||||
if (MathUtils.is_int(factored_base / raw_base))
|
||||
return new TickFactors(factored_base, factored_base / raw_base);
|
||||
factored_base *= 10;
|
||||
} while (++count < 10);
|
||||
return null;
|
||||
}
|
||||
|
||||
static TickFactors _inflate_to_base(TickFactors tick_factors, double new_base) =>
|
||||
new TickFactors(new_base, tick_factors.tick_unit * new_base / tick_factors.tick_base);
|
||||
|
||||
static bool _check_tick_size(double tick_size) =>
|
||||
tick_size > 0 && (tick_size <= 0.5 || MathUtils.is_int(tick_size));
|
||||
|
||||
struct SpecKey : IEquatable<SpecKey> {
|
||||
public readonly uint denominator, display_digits;
|
||||
public readonly double low_tick, high_tick, price_break;
|
||||
|
||||
public SpecKey(ContractSpecification spec)
|
||||
: this(spec.MainFraction, spec.PriceDisplayFormat, spec.LowTick, spec.HighTick, spec.PriceBreak) { }
|
||||
|
||||
public SpecKey(ContractSpecificationImmutable spec)
|
||||
: this(spec.MainFraction, spec.PriceDisplayFormat, spec.LowTick, spec.HighTick, spec.PriceBreak) { }
|
||||
|
||||
public SpecKey(uint denominator, uint display_digits, double low_tick, double high_tick, double price_break) {
|
||||
this.denominator = denominator;
|
||||
this.display_digits = display_digits;
|
||||
this.low_tick = low_tick;
|
||||
this.high_tick = high_tick;
|
||||
this.price_break = price_break;
|
||||
}
|
||||
|
||||
public bool Equals(SpecKey other) =>
|
||||
denominator == other.denominator &&
|
||||
display_digits == other.display_digits &&
|
||||
low_tick == other.low_tick &&
|
||||
high_tick == other.high_tick &&
|
||||
price_break == other.price_break;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
obj is SpecKey sk && Equals(sk);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
EqualityComparer.aggregate_hash((int)denominator, (int)display_digits, low_tick.GetHashCode(), high_tick.GetHashCode(), price_break.GetHashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,325 +0,0 @@
|
||||
using bts.api;
|
||||
using bts.data.ticks;
|
||||
using bts.utils;
|
||||
using mbts.co2;
|
||||
using mbts.user.settings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace mbts.spark {
|
||||
static class TickUtils {
|
||||
//const double _precision_const = 0.000000001;
|
||||
const double _precision_const = 0.00000001;
|
||||
|
||||
public static double precision_const => _precision_const;
|
||||
|
||||
[ThreadStatic]
|
||||
static TickFactorsFactory _exchange_ticks_backing;
|
||||
|
||||
static TickFactorsFactory _exchange_ticks =>
|
||||
_exchange_ticks_backing ?? (_exchange_ticks_backing = new TickFactorsFactory());
|
||||
|
||||
internal static ContractSpecificationImmutable spec_or_default(this ContractSpecificationImmutable? spec) =>
|
||||
spec.HasValue ? spec.Value : SecurityDataHelper.Defaults.ContractSpecificationImmutable;
|
||||
|
||||
internal static ContractSpecificationImmutable spec_or_default(this SecurityImmutable security) =>
|
||||
security.HasContractSpec ? security.ContractSpec : SecurityDataHelper.Defaults.ContractSpecificationImmutable;
|
||||
|
||||
internal static ContractSpecificationImmutable spec_or_default(this SecurityImmutable? security) =>
|
||||
security.HasValue && security.Value.HasContractSpec ? security.Value.ContractSpec : SecurityDataHelper.Defaults.ContractSpecificationImmutable;
|
||||
|
||||
public static ContractSpecificationImmutable spec_or_default(this SecurityMD? security_md) =>
|
||||
(security_md?.security).spec_or_default();
|
||||
|
||||
public static IComparer<double> price_comparer(this ContractSpecificationImmutable spec) =>
|
||||
MathUtils.epsilon_comparer.wrap<double, double>(p => spec.round_to_tick(p));
|
||||
|
||||
public static double ticksize(this ContractSpecificationImmutable spec, double price) {
|
||||
if (!spec.LowTick.is_real_positive()) {
|
||||
return spec.HighTick;
|
||||
} else if (!spec.HighTick.is_real_positive()) {
|
||||
return spec.LowTick;
|
||||
} else if (!price.is_real() || !spec.PriceBreak.is_real()) {
|
||||
return spec.LowTick;
|
||||
} else {
|
||||
return price > spec.PriceBreak ? spec.HighTick : spec.LowTick;
|
||||
}
|
||||
}
|
||||
|
||||
public static string format(this ContractSpecificationImmutable spec, double price, bool in_tick_terms) =>
|
||||
in_tick_terms ?
|
||||
_get(spec).format_without_decimal_part(price / spec.ticksize(price)) :
|
||||
_get(spec).format(price);
|
||||
|
||||
public static string format(this ContractSpecificationImmutable spec, double price) =>
|
||||
_get(spec).format(price);
|
||||
|
||||
public static string format(this ContractSpecificationImmutable? spec, double price) =>
|
||||
spec.spec_or_default().format(price);
|
||||
|
||||
public static string format(this ContractSpecificationImmutable spec, double price, double display_multiplier, bool show_commas, string nan_text) =>
|
||||
_get(spec).format(price, display_multiplier, show_commas, nan_text);
|
||||
|
||||
public static string format(this ContractSpecificationImmutable? spec, double price, double display_multiplier, bool show_commas, string nan_text) =>
|
||||
spec.spec_or_default().format(price, display_multiplier, show_commas, nan_text);
|
||||
|
||||
public static double parse(this ContractSpecificationImmutable spec, string text, double display_multiplier, string nan_text) =>
|
||||
_get(spec).parse(text, display_multiplier, nan_text);
|
||||
|
||||
public static double parse(this ContractSpecificationImmutable? spec, string text, double display_multiplier, string nan_text) =>
|
||||
spec.spec_or_default().parse(text, display_multiplier, nan_text);
|
||||
|
||||
public static bool is_integer_tick(ContractSpecificationImmutable spec) =>
|
||||
spec.MainFraction == 0 &&
|
||||
spec.PriceDisplayFormat == 0 &&
|
||||
spec.LowTick > 0 &&
|
||||
MathUtils.is_int(spec.LowTick) &&
|
||||
spec.HighTick > 0 &&
|
||||
MathUtils.is_int(spec.HighTick);
|
||||
|
||||
public static ContractSpecification create_integer_tick_spec(int low_tick) =>
|
||||
create_integer_tick_spec(low_tick, low_tick);
|
||||
|
||||
public static ContractSpecification create_integer_tick_spec(int low_tick, int high_tick) {
|
||||
var rv = SecurityDataHelper.Defaults.ContractSpecification;
|
||||
rv.MainFraction = 0;
|
||||
rv.SubFraction = 0;
|
||||
rv.PriceDisplayFormat = 0;
|
||||
rv.PriceBreak = 0;
|
||||
rv.LowTick = low_tick;
|
||||
rv.HighTick = high_tick;
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static double low_tick(NativePriceSize[] bids, NativePriceSize[] asks) {
|
||||
double low = bids[bids.Length - 1].price;
|
||||
if (double.IsNaN(low))
|
||||
low = bids.LastOrDefault(nps => nps.price, p => !double.IsNaN(p), double.NaN);
|
||||
if (double.IsNaN(low))
|
||||
low = asks[0].price;
|
||||
return low;
|
||||
}
|
||||
|
||||
public static double high_tick(NativePriceSize[] bids, NativePriceSize[] asks) {
|
||||
double high = asks[asks.Length - 1].price;
|
||||
if (double.IsNaN(high))
|
||||
high = asks.LastOrDefault(nps => nps.price, p => !double.IsNaN(p), double.NaN);
|
||||
if (double.IsNaN(high))
|
||||
high = bids[0].price;
|
||||
return high;
|
||||
}
|
||||
|
||||
public static int? tickdiff(this ContractSpecificationImmutable spec, double x, double y) {
|
||||
if (get_regional_ticks(spec).try_get_tickdiff(x, y, out int n_low, out int n_high))
|
||||
return n_low + n_high;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int tickdiff_unchecked(this ContractSpecificationImmutable spec, double x, double y) {
|
||||
(int n_low, int n_high) = get_regional_ticks(spec).tickdiff_unchecked(x, y);
|
||||
return n_low + n_high;
|
||||
}
|
||||
|
||||
public static double mid_tick(ContractSpecificationImmutable spec, double bid, double ask) {
|
||||
double raw_mid;
|
||||
if (double.IsNaN(bid)) {
|
||||
if (double.IsNaN(ask)) return double.NaN;
|
||||
raw_mid = ask;
|
||||
} else if (double.IsNaN(ask)) {
|
||||
raw_mid = bid;
|
||||
} else {
|
||||
raw_mid = (bid + ask) / 2.0;
|
||||
}
|
||||
double tick_size = spec.ticksize(raw_mid);
|
||||
return raw_mid < 0 ?
|
||||
raw_mid + (raw_mid % tick_size) :
|
||||
raw_mid - (raw_mid % tick_size);
|
||||
}
|
||||
|
||||
public static TickFactors deduce_ticks(IEnumerable<ContractSpecification> contract_specs) {
|
||||
var ticks = new HashSet<TickFactors>(contract_specs.Select(_get).SelectMany(rtf => new[] { rtf.low_tick, rtf.high_tick }));
|
||||
switch (ticks.Count) {
|
||||
case 0: return _exchange_ticks.default_rtf.low_tick;
|
||||
case 1: return ticks.First();
|
||||
default:
|
||||
double tick_base_lcm = MathUtils.LCM(ticks.Select(t => (int)t.tick_base));
|
||||
double tick_unit_gcd = MathUtils.GCD(ticks.Select(t => t.tick_unit * (tick_base_lcm / t.tick_base)));
|
||||
return new TickFactors(tick_base_lcm, tick_unit_gcd);
|
||||
}
|
||||
}
|
||||
|
||||
public static RegionalTickFactors get_tick_factors(ContractSpecificationImmutable spec) =>
|
||||
_get(spec);
|
||||
|
||||
public static double tickup(this ContractSpecificationImmutable spec, double value) =>
|
||||
_get(spec).tickup(value);
|
||||
|
||||
public static double tickup(this ContractSpecificationImmutable spec, double value, int count) {
|
||||
if (count == 0) return value;
|
||||
if (count < 0) return _get(spec).tickdown(value, (uint)(-count));
|
||||
else return _get(spec).tickup(value, (uint)count);
|
||||
}
|
||||
|
||||
public static double tickdown(this ContractSpecificationImmutable spec, double value) =>
|
||||
_get(spec).tickdown(value);
|
||||
|
||||
public static double tickdown(this ContractSpecificationImmutable spec, double value, int count) {
|
||||
if (count == 0) return value;
|
||||
if (count < 0) return _get(spec).tickup(value, (uint)(-count));
|
||||
else return _get(spec).tickdown(value, (uint)count);
|
||||
}
|
||||
|
||||
public static bool tick_equals(this ContractSpecificationImmutable contract, double x, double y) =>
|
||||
MathUtils.RoundFractionalUnits(x, contract.LowTick) == MathUtils.RoundFractionalUnits(y, contract.LowTick);
|
||||
|
||||
public static IEqualityComparer<double> tick_equality_comparer(this ContractSpecificationImmutable contract) =>
|
||||
EqualityComparer.Create((double a, double b) => tick_equals(contract, a, b), x => MathUtils.RoundFractionalUnits(x, contract.LowTick));
|
||||
|
||||
public static int compare_tick_fallback_to_double(this ContractSpecificationImmutable contract, double x, double y) =>
|
||||
tick_equals(contract, x, y) ? 0 : x.CompareTo(y);
|
||||
|
||||
public static double round_to_tick(this ContractSpecificationImmutable spec, double value) {
|
||||
double intpart = (long)value;
|
||||
double floatpart = value % 1;
|
||||
double tick = spec.ticksize(value);
|
||||
floatpart = ((int)Math.Round(floatpart / tick)) * tick;
|
||||
return intpart + floatpart;
|
||||
}
|
||||
|
||||
public static decimal round_to_tick(this ContractSpecificationImmutable spec, decimal value) {
|
||||
decimal intpart = (long)value;
|
||||
decimal floatpart = value % 1;
|
||||
decimal tick = (decimal)spec.ticksize((double)value);
|
||||
floatpart = ((int)(floatpart / tick)) * tick;
|
||||
return intpart + floatpart;
|
||||
}
|
||||
|
||||
public static int? full_ticks_from_zero(this ContractSpecificationImmutable spec, double value) =>
|
||||
full_ticks_from(spec, 0, value);
|
||||
|
||||
public static int? full_ticks_from(this ContractSpecificationImmutable spec, double origin, double value) {
|
||||
if (!value.is_real() || !origin.is_real())
|
||||
return null;
|
||||
if (value < origin) {
|
||||
if (spec.LowTick.is_real_positive()) {
|
||||
if (spec.HighTick.is_real_positive() && spec.PriceBreak < origin && spec.PriceBreak > value) {
|
||||
var ticks_to_break = MathUtils.round_up((spec.PriceBreak - origin) / spec.HighTick, precision_const);
|
||||
var low_ticks_remainder = MathUtils.round_up((value - spec.PriceBreak) / spec.LowTick, precision_const);
|
||||
return (int)(ticks_to_break + low_ticks_remainder);
|
||||
} else {
|
||||
return (int)MathUtils.round_up((value - origin) / spec.LowTick, precision_const);
|
||||
}
|
||||
} else if (spec.HighTick.is_real_positive()) {
|
||||
return (int)MathUtils.round_up((value - origin) / spec.HighTick, precision_const);
|
||||
}
|
||||
} else {
|
||||
if (spec.HighTick.is_real_positive()) {
|
||||
if (spec.LowTick.is_real_positive() && spec.PriceBreak > origin && spec.PriceBreak < value) {
|
||||
var ticks_to_break = MathUtils.round_down((spec.PriceBreak - origin) / spec.LowTick, precision_const);
|
||||
var high_ticks_remainder = MathUtils.round_down((value - spec.PriceBreak) / spec.HighTick, precision_const);
|
||||
return (int)(ticks_to_break + high_ticks_remainder);
|
||||
} else {
|
||||
return (int)MathUtils.round_down(value / spec.HighTick, precision_const);
|
||||
}
|
||||
} else if (spec.LowTick.is_real_positive()) {
|
||||
return (int)MathUtils.round_down(value / spec.LowTick, precision_const);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static RegionalTickFactors get_regional_ticks(ContractSpecificationImmutable? spec) =>
|
||||
spec.HasValue ? _get(spec.Value) : _exchange_ticks.default_rtf;
|
||||
|
||||
public static RegionalTickFactors get_regional_ticks(SecurityImmutable security) =>
|
||||
get_regional_ticks(security.spec_or_default());
|
||||
|
||||
public static ContractSpecificationImmutable multiply_tick_size(ContractSpecificationImmutable spec, uint factor) {
|
||||
factor = fit_ticks_per_row_to_dollars(spec, factor);
|
||||
return spec.with(low_tick: spec.LowTick * factor, high_tick: spec.HighTick * factor);
|
||||
}
|
||||
|
||||
public static double normalize_price(ContractSpecificationImmutable spec, double price) {
|
||||
var ticks = spec.full_ticks_from_zero(price);
|
||||
return ticks.HasValue ? spec.tickup(0, ticks.Value) : price;
|
||||
}
|
||||
|
||||
public static uint fit_ticks_per_row_to_dollars(ContractSpecificationImmutable spec, uint ticks_per_row) =>
|
||||
_fit_ticks_per_row_to_dollars(spec, ticks_per_row) ?? 1;
|
||||
|
||||
static uint? _fit_ticks_per_row_to_dollars(ContractSpecificationImmutable spec, uint ticks_per_row) {
|
||||
if (ticks_per_row == 0)
|
||||
return null;
|
||||
// it is assumed that low tick will be the same as high tick;
|
||||
// however, best to double check - return null if this isn't the case (let the caller decide what to do).
|
||||
var tf = get_tick_factors(spec);
|
||||
if (!tf.low_tick.Equals(tf.high_tick) || !tf.is_valid() || tf.low_tick.is_integer())
|
||||
return null;
|
||||
var ticks_per_dollar = (uint)(tf.low_tick.tick_base / tf.low_tick.tick_unit);
|
||||
// if ticks_per_row is greater than ticks_per_dollar, round to a multiple of ticks_per_dollar
|
||||
if (ticks_per_row > ticks_per_dollar) {
|
||||
return (uint)Math.Floor((double)(ticks_per_row / ticks_per_dollar));
|
||||
} else if (ticks_per_row == ticks_per_dollar) {
|
||||
return ticks_per_row;
|
||||
} else {
|
||||
uint max_decrease_adj = ticks_per_row;
|
||||
uint max_increase_adj = ticks_per_dollar - ticks_per_row - 1;
|
||||
for (uint adj = 0; adj < Math.Max(max_decrease_adj, max_increase_adj); adj++) {
|
||||
if (adj < max_decrease_adj) {
|
||||
var result = ticks_per_row - adj;
|
||||
if (ticks_per_dollar % result == 0)
|
||||
return result;
|
||||
}
|
||||
if (adj < max_increase_adj) {
|
||||
var result = ticks_per_row + adj;
|
||||
if (ticks_per_dollar % result == 0)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static RegionalTickFactors _get(ContractSpecification spec) => _exchange_ticks.get(spec);
|
||||
static RegionalTickFactors _get(ContractSpecificationImmutable spec) => _exchange_ticks.get(spec);
|
||||
|
||||
public static class CompareUtils {
|
||||
public static IComparer<double> base_comparer =>
|
||||
Comparer<double>.Create(_compare_base);
|
||||
|
||||
public static IComparer<double> unit_comparer =>
|
||||
Comparer<double>.Create(_compare_unit);
|
||||
|
||||
public static IComparer<TickFactors> base_unit_comparer =>
|
||||
Comparer<TickFactors>.Create(bts.utils.CompareUtils.safe_comparison<TickFactors>(compare_base_unit));
|
||||
|
||||
public static int compare_base_unit(TickFactors a, TickFactors b) {
|
||||
int comp = _compare_base(a.tick_base, b.tick_base);
|
||||
return comp == 0 ? a.tick_unit.CompareTo(b.tick_unit) : comp;
|
||||
}
|
||||
|
||||
static int _compare_base(double a, double b) {
|
||||
double reduced_a = MathUtils.factor_out(a, 10);
|
||||
double reduced_b = MathUtils.factor_out(b, 10);
|
||||
int comp = reduced_a.CompareTo(reduced_b);
|
||||
return comp == 0 ? a.CompareTo(b) : comp;
|
||||
}
|
||||
|
||||
static int _compare_unit(double a, double b) =>
|
||||
_compare_unit(a, b, 0, 0);
|
||||
|
||||
static int _compare_unit(double a, double b, int a_mult10, int b_mult10) {
|
||||
// fractional-coins are a special case, as they may not be an integer to begin with
|
||||
if (!MathUtils.is_int(a))
|
||||
return _compare_unit(a * 10, b, ++a_mult10, b_mult10);
|
||||
if (!MathUtils.is_int(b))
|
||||
return _compare_unit(a, b * 10, a_mult10, ++b_mult10);
|
||||
double reduced_a = a_mult10 > 0 ? a : MathUtils.factor_out(a, 10, 5);
|
||||
double reduced_b = b_mult10 > 0 ? b : MathUtils.factor_out(b, 10, 5);
|
||||
int comp = reduced_a.CompareTo(reduced_b);
|
||||
return comp == 0 ? (a * Math.Pow(10, -a_mult10)).CompareTo(b * Math.Pow(10, -b_mult10)) : comp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,6 @@ namespace bts.utils {
|
||||
public static int safe_compare<T>(this T a, T b) where T : IComparable<T> =>
|
||||
a == null ? (b == null ? 0 : -1) : (b == null ? 1 : a.CompareTo(b));
|
||||
|
||||
public static int nullable_compare<T>(T? a, T? b) where T : struct, IComparable<T> =>
|
||||
a.HasValue ?
|
||||
(b.HasValue ? a.Value.CompareTo(b.Value) : 1) :
|
||||
(b.HasValue ? -1 : 0);
|
||||
|
||||
#region Equality
|
||||
public static bool NullCheckEquals<T>(T x, T y) =>
|
||||
NullCheckEquals(x, y, (_x, _y) => _x.Equals(_y));
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
}
|
||||
|
||||
public static bool update_value_type<T>(ref T field, T newval) where T : struct, IEquatable<T> {
|
||||
bool rv = !field.Equals(newval);
|
||||
bool rv = field.Equals(newval);
|
||||
field = newval;
|
||||
return rv;
|
||||
}
|
||||
@@ -106,4 +106,4 @@
|
||||
v => v is TResult r ? r : throw new InvalidCastException($"Failed to cast element in source collection from type {typeof(T)} to {typeof(TResult)}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace bts.utils.csv {
|
||||
public static class CsvHelper {
|
||||
|
||||
public static string ToCsv<T>(this IEnumerable<T> items, OrderedDictionary properties = null) where T : class {
|
||||
var output = "";
|
||||
var delimiter = ",";
|
||||
if (properties == null) {
|
||||
properties = new OrderedDictionary();
|
||||
foreach (var pi in typeof(T).GetProperties()) {
|
||||
properties.Add(pi.Name, pi);
|
||||
}
|
||||
}
|
||||
|
||||
using (var sw = new StringWriter()) {
|
||||
var dict_values = properties.Values.OfType<PropertyInfo>();
|
||||
var header = dict_values.Select(n => n.Name).Aggregate((first, second) => first + delimiter + second);
|
||||
sw.WriteLine(header);
|
||||
foreach (var i in items) {
|
||||
var row = dict_values.Select(x => x.GetValue(i, null))
|
||||
.Select(x => x == null ? "null" : x.ToString())
|
||||
.Aggregate((first, second) => first + delimiter + second);
|
||||
sw.WriteLine(row);
|
||||
}
|
||||
output = sw.ToString();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public static OrderedDictionary create_ordering_maintainer(Type t, string[] property_names_in_order) {
|
||||
OrderedDictionary od = new OrderedDictionary();
|
||||
var props = t.GetProperties();
|
||||
foreach (var n in property_names_in_order) {
|
||||
var query = props.Where(pi => pi.Name == n);
|
||||
if (query.Any()) {
|
||||
var property_info = query.First();
|
||||
if (!od.Contains(property_info)) {
|
||||
od.Add(n, property_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
return od;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reflection;
|
||||
|
||||
using System.IO;
|
||||
using System.Security.Policy;
|
||||
using System.Diagnostics;
|
||||
|
||||
using ExcelDna.Integration;
|
||||
using ExcelDna.IntelliSense;
|
||||
using ExcelDna.Logging;
|
||||
|
||||
namespace bts.excel
|
||||
{
|
||||
public class TestMethod
|
||||
{
|
||||
[ExcelFunction]
|
||||
static public string bts_excel_test_string(string x) { return "Hello " + x; }
|
||||
[ExcelFunction]
|
||||
static public object bts_excel_test_int(int x) { return x; }
|
||||
[ExcelFunction]
|
||||
static public object bts_excel_test_long(long x) { return x; }
|
||||
}
|
||||
|
||||
[System.Runtime.InteropServices.ComVisible(true)]
|
||||
public class ContextTeardown : ExcelComAddIn
|
||||
{
|
||||
private api.core.ServiceContext _context;
|
||||
public ContextTeardown(api.core.ServiceContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
//This is called on application shutdown
|
||||
public override void OnBeginShutdown(ref Array custom)
|
||||
{
|
||||
_context.Dispose();
|
||||
_context = null;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.InteropServices.ComVisible(true)]
|
||||
public class ExcelAddin : IExcelAddIn
|
||||
{
|
||||
public void AutoClose()
|
||||
{
|
||||
//don't do anything here, it's only called when the addin is removed, not on shutdown
|
||||
IntelliSenseServer.Uninstall();
|
||||
}
|
||||
public void AutoOpen() //This is called on EXCEL startup, when the addin is loaded
|
||||
{
|
||||
Trace.Listeners.Add(new LogDisplayTraceListener("bts"));
|
||||
IntelliSenseServer.Install();
|
||||
ExcelIntegration.RegisterUnhandledExceptionHandler(ex => ex.ToString());
|
||||
|
||||
load_assemblies();
|
||||
ExcelComAddInHelper.LoadComAddIn(new ContextTeardown(APIDispatch.service_context.Value));
|
||||
}
|
||||
|
||||
private void load_assemblies()
|
||||
{
|
||||
var config = System.Configuration.ConfigurationManager.AppSettings["load_assemblies"];
|
||||
if (config != null)
|
||||
{
|
||||
var asses = config.Split(new char[] { ';', ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (var ass in asses)
|
||||
Utilities.bts_load_assembly(ass);
|
||||
}
|
||||
}
|
||||
|
||||
public static void calculate_full_rebuild()
|
||||
{
|
||||
object app = ExcelDnaUtil.Application;
|
||||
var mi = app?.GetType().GetMethod("CalculateFullRebuild", BindingFlags.Instance | BindingFlags.Public);
|
||||
if(mi != null)
|
||||
mi.Invoke(app, null);
|
||||
}
|
||||
|
||||
public static void calculate_full()
|
||||
{
|
||||
object app = ExcelDnaUtil.Application;
|
||||
var mi = app?.GetType().GetMethod("CalculateFull", BindingFlags.Instance | BindingFlags.Public);
|
||||
if (mi != null)
|
||||
mi.Invoke(app, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("spark")]
|
||||
[assembly: InternalsVisibleTo("spark_core")]
|
||||
[assembly: InternalsVisibleTo("sparkcmd")]
|
||||
[assembly: InternalsVisibleTo("spark_test")]
|
||||
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("b319f835-7390-47e5-8093-461ed0dfce63")]
|
||||
@@ -1,49 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="ExcelDnaProps"> -->
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<!--
|
||||
If you change properties in this file, they may not come into effect until you:
|
||||
* Rebuild the solution/project
|
||||
|
||||
or
|
||||
|
||||
* Close Visual Studio
|
||||
* Delete .vs folder, if exists
|
||||
* Delete ProjectName.csproj.user (or equivalent for VB, F#, etc.), if exists
|
||||
* Delete SolutionName.suo, if exists
|
||||
* Open your solution/project again in Visual Studio
|
||||
-->
|
||||
|
||||
<!--
|
||||
Configuration properties for building .dna files
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
Enable/Disable automatic generation of platform-specific versions of .dna files
|
||||
-->
|
||||
<ExcelDnaCreate32BitAddIn Condition="'$(ExcelDnaCreate32BitAddIn)' == ''">false</ExcelDnaCreate32BitAddIn>
|
||||
<ExcelDnaCreate64BitAddIn Condition="'$(ExcelDnaCreate64BitAddIn)' == ''">true</ExcelDnaCreate64BitAddIn>
|
||||
|
||||
<!--
|
||||
Define the suffix used for each platform-specific file e.g. MyAddIn64.dna
|
||||
-->
|
||||
<ExcelDna32BitAddInSuffix Condition="'$(ExcelDna32BitAddInSuffix)' == ''"></ExcelDna32BitAddInSuffix>
|
||||
<ExcelDna64BitAddInSuffix Condition="'$(ExcelDna64BitAddInSuffix)' == ''">64</ExcelDna64BitAddInSuffix>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--
|
||||
Configuration properties for packing .dna files
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
Enable/Disable packing of .dna files
|
||||
-->
|
||||
<RunExcelDnaPack Condition="'$(RunExcelDnaPack)' == ''">true</RunExcelDnaPack>
|
||||
|
||||
<!--
|
||||
Suffix used for packed .xll files e.g. MyAddIn-packed.xll
|
||||
-->
|
||||
<ExcelDnaPackXllSuffix Condition="'$(ExcelDnaPackXllSuffix)' == ''">-packed</ExcelDnaPackXllSuffix>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace bts.excel.extensions
|
||||
{
|
||||
public static class EnumParser
|
||||
{
|
||||
public static T ToEnum<T>(this string val, T default_val = default(T)) where T : struct, IConvertible, IComparable
|
||||
{
|
||||
val = val ?? string.Empty;
|
||||
T eval;
|
||||
if (!Enum.TryParse(val, true, out eval))
|
||||
{
|
||||
string[] names = Enum.GetNames(typeof(T));
|
||||
val = names.FirstOrDefault(x => x.ToLower().Contains(val));
|
||||
if(val != null)
|
||||
Enum.TryParse(val, true, out eval);
|
||||
|
||||
if (eval.CompareTo(default(T)) == 0 && default_val.CompareTo(default(T)) != 0)
|
||||
eval = default_val;
|
||||
}
|
||||
return eval;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ExcelDna.Integration;
|
||||
using ExcelDna.Integration.Rtd;
|
||||
using ExcelDna.Registration.Utils;
|
||||
|
||||
using bts.api.admin;
|
||||
using bts.excel;
|
||||
using bts.excel.extensions;
|
||||
using bts.excel.rtd;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace bts.api.orderman
|
||||
{
|
||||
public partial class OrderService_Excel
|
||||
{
|
||||
readonly static Lazy<user.AuthService> _users = new Lazy<user.AuthService>(() => Locator.locate<user.AuthService>(), true);
|
||||
readonly static Lazy<admin.AdminService> _admin = new Lazy<admin.AdminService>(() => Locator.locate<admin.AdminService>(), true);
|
||||
|
||||
[ExcelFunction(Category = "BTS", Description = "Get All Accessible Accounts")]
|
||||
async public static void spark_get_accounts(string login_token, ExcelAsyncHandle handle)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<string> accts = new List<string>();
|
||||
var admin = await _admin.Value.get_filtered_admin_data_async(new FilteredAdminDataRequest());
|
||||
if (admin.success)
|
||||
{
|
||||
foreach (var acc in admin.value.Accounts)
|
||||
if(acc.IsPresent)
|
||||
accts.Add(acc.Name);
|
||||
}
|
||||
var res = Utilities.make_column_vector(accts.ToArray());
|
||||
handle.SetResult(res);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
handle.SetException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[ExcelFunction(Category = "BTS", Description = "Cancel an Order by Order ID", IsMacroType = true)]
|
||||
public static object spark_orderservice_cancel_order(long order_id)
|
||||
{
|
||||
var resp = _service.Value.cancel_order(new Cancel() { OrderKey = Convert.ToUInt32(order_id) });
|
||||
return parse_response(resp);
|
||||
}
|
||||
|
||||
[ExcelFunction(Category = "BTS", Description = "Update an Order by Order ID", IsMacroType = true)]
|
||||
public static object spark_orderservice_update_order(long order_id, double price, long quantity)
|
||||
{
|
||||
var resp = _service.Value.update_order(new Update() { OrderKey = Convert.ToUInt32(order_id), Price = price, Quantity = Convert.ToUInt32(quantity) });
|
||||
return parse_response(resp);
|
||||
}
|
||||
|
||||
[ExcelFunction(Category = "BTS", Description = "Send an Order to Spark via security_key", IsMacroType = true)]
|
||||
public static object spark_orderservice_send_order_key(
|
||||
[ExcelArgument("Required. Only send the order if > last")] long local_order_id,
|
||||
[ExcelArgument("Required. Security key")] long security_key,
|
||||
[ExcelArgument("Required. Side BUY or SELL")] string side,
|
||||
[ExcelArgument("Required. User")] string user,
|
||||
[ExcelArgument("Required. Account")] string account,
|
||||
[ExcelArgument("Required. Price")] double price,
|
||||
[ExcelArgument("Required. Quantity")] long quantity,
|
||||
[ExcelArgument("Required. OrderType (Limit, Stop, Stop_Limit, Iceberg) - Default Limit")] string order_type,
|
||||
[ExcelArgument("OPTIONAL. Order Params JSON (\"stop_price\" : 51.88)")] string order_params = null,
|
||||
|
||||
[ExcelArgument("OPTIONAL. (DAY,GTC,IOC) - Default DAY")] string time_in_force = null,
|
||||
[ExcelArgument("OPTIONAL. (YES,NO) - Default YES")] string manual_order_indicator = null,
|
||||
[ExcelArgument("OPTIONAL. (1,2,3,4) - Default 1")] string cti_code = null,
|
||||
[ExcelArgument("OPTIONAL. (CUSTOMER,FIRM) - Default FIRM")] string customer_or_firm = null)
|
||||
{
|
||||
if (local_order_id <= _local_order_id)
|
||||
return "local_order_id must be greater than " + _local_order_id;
|
||||
Create cr = new Create();
|
||||
cr.NewOrder = new OrderDefinition()
|
||||
{
|
||||
SecurityKey = Convert.ToUInt32(security_key),
|
||||
Side = EnumParser.ToEnum<api.Side>(side),
|
||||
TimeInForce = time_in_force.ToEnum<TimeInForce>(TimeInForce.Day),
|
||||
ManualOrderIndicator = manual_order_indicator.ToEnum<ManualOrderIndicator>(ManualOrderIndicator.Yes),
|
||||
CtiCode = cti_code.ToEnum<CTICode>(CTICode.CtiCode1),
|
||||
CustomerOrFirm = customer_or_firm.ToEnum<CustomerOrFirm>(CustomerOrFirm.Firm),
|
||||
};
|
||||
cr.Price = price;
|
||||
cr.Quantity = Convert.ToUInt32(quantity);
|
||||
|
||||
var btsuser = resolve_user(user);
|
||||
if(btsuser == null)
|
||||
return "Could not resolve user: " + user;
|
||||
cr.NewOrder.User = btsuser.Name;
|
||||
cr.NewOrder.UserId = btsuser.Id;
|
||||
var btaccount = resolve_account(account);
|
||||
if(btaccount == null)
|
||||
return "Could not resolve account: " + account;
|
||||
cr.NewOrder.Account = btaccount.Name;
|
||||
cr.NewOrder.AccountId = btaccount.Id;
|
||||
cr.NewOrder.CustomDef = custom_def(order_type, order_params);
|
||||
if(cr.NewOrder.CustomDef == null || cr.NewOrder.CustomDef.CustomCase == CustomOrderDefinition.CustomOneofCase.None)
|
||||
return "Could not parse order_type and/or order_params info";
|
||||
|
||||
var resp = _service.Value.create_order(cr);
|
||||
_local_order_id = local_order_id;
|
||||
return parse_response(resp, true);
|
||||
}
|
||||
|
||||
private static object parse_response(Response resp, bool show_vertically = false)
|
||||
{
|
||||
object[,] response_cells = new JsonFormatter(resp).format(false);
|
||||
if(show_vertically)
|
||||
response_cells = bts.excel.Utilities.transpose_keep_dimension(response_cells);
|
||||
return response_cells;
|
||||
}
|
||||
|
||||
static Lazy<AdminData> _admin_data = new Lazy<AdminData>(() => _admin.Value.get_admin_data(new VoidMessage()), true);
|
||||
static BTSUser resolve_user(string username)
|
||||
{
|
||||
var user = _admin_data.Value.Users.FirstOrDefault(x => username != null ? x.Name.ToLowerInvariant() == username.ToLowerInvariant() : true);
|
||||
return user;
|
||||
}
|
||||
|
||||
static BTSAccount resolve_account(string acctname)
|
||||
{
|
||||
var acc = _admin_data.Value.Accounts.FirstOrDefault(x => x.Name.ToLowerInvariant() == acctname.ToLowerInvariant());
|
||||
return acc;
|
||||
}
|
||||
|
||||
static CustomOrderDefinition custom_def(string order_type, string order_params)
|
||||
{
|
||||
var member = ReflectionExtensions.get_fields_or_properties(typeof(CustomOrderDefinition))
|
||||
.Where(x => x.Name.ToLower() == order_type.ToLower()).FirstOrDefault();
|
||||
if (member != null)
|
||||
{
|
||||
var mi = member.member_type();
|
||||
var instance = APIDispatch.generate_imessage(mi, order_params, false);
|
||||
var cust = new CustomOrderDefinition();
|
||||
ReflectionExtensions.set_value(member, cust, instance);
|
||||
return cust;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
static long _local_order_id = 0;
|
||||
|
||||
[ExcelFunction(Category = "BTS", Description = "Send an Order to Spark via security_key", IsMacroType = true)]
|
||||
public static object spark_orderservice_send_order(
|
||||
[ExcelArgument("Required. Only send the order if > last")] long local_order_id,
|
||||
[ExcelArgument("Required. Exchange (GLBX,SIM)")] string exchange,
|
||||
[ExcelArgument("Required. Security Desc (ZNZ9 or ZNZ9-ZNH0)")] string security_desc,
|
||||
[ExcelArgument("Required. Side BUY or SELL")] string side,
|
||||
[ExcelArgument("Required. User")] string user,
|
||||
[ExcelArgument("Required. Account")] string account,
|
||||
[ExcelArgument("Required. Price")] double price,
|
||||
[ExcelArgument("Required. Quantity")] long quantity,
|
||||
[ExcelArgument("Required. OrderType (Limit, Stop, Stop_Limit, Iceberg) - Default Limit")] string order_type,
|
||||
[ExcelArgument("OPTIONAL. Order Params JSON (\"stop_price\" : 51.88)")] string order_params = null,
|
||||
|
||||
[ExcelArgument("OPTIONAL. (DAY,GTC,IOC) - Default DAY")] string time_in_force = null,
|
||||
[ExcelArgument("OPTIONAL. (YES,NO) - Default YES")] string manual_order_indicator = null,
|
||||
[ExcelArgument("OPTIONAL. (1,2,3,4) - Default 1")] string cti_code = null,
|
||||
[ExcelArgument("OPTIONAL. (CUSTOMER,FIRM) - Default FIRM")] string customer_or_firm = null)
|
||||
{
|
||||
if (local_order_id <= _local_order_id)
|
||||
return "local_order_id must be greater than " + _local_order_id;
|
||||
Venue ven;
|
||||
if (!Utilities.parse_venue(exchange, out ven))
|
||||
return "Can't Parse Exchange: " + (exchange ?? string.Empty);
|
||||
|
||||
uint key;
|
||||
if (MDSubscribe.market_data(ven).lookup_security_key_from_desc(security_desc, out key))
|
||||
{
|
||||
return spark_orderservice_send_order_key(local_order_id, (long)key, side, user, account, price, quantity, order_type, order_params,
|
||||
time_in_force, manual_order_indicator, cti_code, customer_or_firm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Can't find security desc " + security_desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reflection;
|
||||
|
||||
namespace bts.excel.extensions
|
||||
{
|
||||
public static class ReflectionExtensions
|
||||
{
|
||||
public static void set_value(this MemberInfo info, object target, object value)
|
||||
{
|
||||
if (info is FieldInfo)
|
||||
((FieldInfo)info).SetValue(target, value);
|
||||
else if (info is PropertyInfo)
|
||||
((PropertyInfo)info).SetValue(target, value);
|
||||
}
|
||||
|
||||
public static object get_value(this MemberInfo info, object target)
|
||||
{
|
||||
if (info is FieldInfo)
|
||||
return ((FieldInfo)info).GetValue(target);
|
||||
else if (info is PropertyInfo)
|
||||
return ((PropertyInfo)info).GetValue(target);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MemberInfo[] get_fields_or_properties(this Type t)
|
||||
{
|
||||
MemberInfo[] mi = t.GetMembers(BindingFlags.Instance | BindingFlags.Public
|
||||
| BindingFlags.NonPublic).Where(m => (m.MemberType == MemberTypes.Field || m.MemberType == MemberTypes.Property)).ToArray();
|
||||
return mi;
|
||||
}
|
||||
|
||||
public static MemberInfo[] get_fields(this Type t)
|
||||
{
|
||||
MemberInfo[] mi = t.GetMembers(BindingFlags.Instance | BindingFlags.Public
|
||||
| BindingFlags.NonPublic).Where(m => (m.MemberType == MemberTypes.Field)).ToArray();
|
||||
return mi;
|
||||
}
|
||||
|
||||
public static MemberInfo[] get_properties(this Type t)
|
||||
{
|
||||
MemberInfo[] mi = t.GetMembers(BindingFlags.Instance | BindingFlags.Public
|
||||
| BindingFlags.NonPublic).Where(m => (m.MemberType == MemberTypes.Property)).ToArray();
|
||||
return mi;
|
||||
}
|
||||
|
||||
public static MemberInfo get_field_or_property(this Type t, string name)
|
||||
{
|
||||
MemberInfo[] mi = t.GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
|
||||
.Where(m => (m.MemberType == MemberTypes.Field || m.MemberType == MemberTypes.Property))
|
||||
.Where(m => (m.Name == name))
|
||||
.ToArray();
|
||||
if (mi != null && mi.Length > 0)
|
||||
return mi[0];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MemberInfo get_static_field_or_property(this Type t, string name)
|
||||
{
|
||||
MemberInfo[] mi = t.GetMembers(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
|
||||
.Where(m => (m.MemberType == MemberTypes.Field || m.MemberType == MemberTypes.Property))
|
||||
.Where(m => (m.Name == name))
|
||||
.ToArray();
|
||||
if (mi != null && mi.Length > 0)
|
||||
return mi[0];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MemberInfo[] search_field_or_property(this Type t, Func<MemberInfo, bool> criteria)
|
||||
{
|
||||
MemberInfo[] mi = t.GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
|
||||
.Where(m => (m.MemberType == MemberTypes.Field || m.MemberType == MemberTypes.Property))
|
||||
.Where(criteria)
|
||||
.ToArray();
|
||||
if (mi != null && mi.Length > 0)
|
||||
return mi;
|
||||
else
|
||||
return new MemberInfo[0];
|
||||
}
|
||||
|
||||
|
||||
public static Type member_type(this MemberInfo info)
|
||||
{
|
||||
if (info is FieldInfo)
|
||||
return ((FieldInfo)info).FieldType;
|
||||
else if (info is PropertyInfo)
|
||||
return ((PropertyInfo)info).PropertyType;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MethodInfo[] find_method(this Type t, Func<MethodInfo, bool> criteria)
|
||||
{
|
||||
var mi = t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
|
||||
.Where(criteria).ToArray();
|
||||
if (mi != null && mi.Length > 0)
|
||||
return mi;
|
||||
else
|
||||
return new MethodInfo[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="ExcelDna.AddIn" version="0.34.6" targetFramework="net471" />
|
||||
<package id="ExcelDna.Integration" version="0.34.6" targetFramework="net471" />
|
||||
</packages>
|
||||
@@ -1,127 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
|
||||
using ExcelDna.Integration;
|
||||
using ExcelDna.Integration.Rtd;
|
||||
using bts.excel.extensions;
|
||||
using bts.api.core;
|
||||
using bts.api;
|
||||
using bts.api.md;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
namespace bts.excel.rtd
|
||||
{
|
||||
[System.Runtime.InteropServices.ComVisible(true)]
|
||||
public class APIRTDServer : ExcelRtdServer
|
||||
{
|
||||
readonly Dictionary<int, IObservable<object>> _subs = new Dictionary<int, IObservable<object>>();
|
||||
readonly List<IDisposable> _disps = new List<IDisposable>();
|
||||
readonly static ConcurrentDictionary<string, object> data_store = new ConcurrentDictionary<string, object>();
|
||||
public APIRTDServer()
|
||||
{
|
||||
}
|
||||
|
||||
static public bool retrieve(string key, out object data)
|
||||
{
|
||||
return data_store.TryGetValue(key, out data);
|
||||
}
|
||||
|
||||
protected override bool ServerStart() { return true; }
|
||||
protected override void ServerTerminate() { }
|
||||
|
||||
protected override ExcelRtdServer.Topic CreateTopic(int topicId, IList<string> topicInfo)
|
||||
{
|
||||
string[] tagvals = new string[topicInfo.Count - 2];
|
||||
Array.Copy(topicInfo.ToArray(), 2, tagvals, 0, tagvals.Length);
|
||||
var bt = new APITopic(this, topicId, topicInfo[0], topicInfo[1], tagvals);
|
||||
return bt;
|
||||
}
|
||||
|
||||
protected override object ConnectData(Topic topic, IList<string> topicInfo, ref bool newValues)
|
||||
{
|
||||
//return ExcelErrorUtil.ToComError(ExcelError.ExcelErrorNA);
|
||||
newValues = true;
|
||||
TopicBase bt = (TopicBase)topic;
|
||||
IObservable<object> obs = null;
|
||||
try
|
||||
{
|
||||
string error = subscribe(bt, out obs);
|
||||
if (obs == null)
|
||||
return error;
|
||||
_subs[topic.TopicId] = obs;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return "PLEASE RESUBSCRIBE! Error: " + e.ToString();
|
||||
}
|
||||
_disps.Add(obs.Subscribe((data) =>
|
||||
{
|
||||
string gstring = bt.id.ToString();
|
||||
|
||||
data_store[gstring] = data;
|
||||
bt.UpdateValue(gstring);
|
||||
bt.UpdateNotify();
|
||||
},
|
||||
(error) =>
|
||||
{
|
||||
topic.UpdateValue(error.ToString());
|
||||
},
|
||||
() => { }));
|
||||
return ExcelErrorUtil.ToComError(ExcelError.ExcelErrorNA); //success!
|
||||
}
|
||||
|
||||
protected override void DisconnectData(ExcelRtdServer.Topic topic)
|
||||
{
|
||||
IObservable<object> sub;
|
||||
if (_subs.TryGetValue(topic.TopicId, out sub))
|
||||
{
|
||||
IDisposable disp = sub as IDisposable;
|
||||
if (disp != null)
|
||||
disp.Dispose();
|
||||
_subs.Remove(topic.TopicId);
|
||||
}
|
||||
}
|
||||
|
||||
protected override int Heartbeat()
|
||||
{
|
||||
return base.Heartbeat();
|
||||
}
|
||||
|
||||
|
||||
string subscribe(TopicBase topic, out IObservable<object> stream)
|
||||
{
|
||||
if(topic is APITopic apitopic)
|
||||
return subscribe(apitopic, out stream);
|
||||
else
|
||||
{
|
||||
stream = null;
|
||||
return "Unknown Topic Type";
|
||||
}
|
||||
}
|
||||
|
||||
string subscribe(APITopic topic, out IObservable<object> stream)
|
||||
{
|
||||
stream = null;
|
||||
if (topic.service_type == null)
|
||||
return "Unknown ServiceType: " + topic.service_type_string;
|
||||
if (topic.request_type == null)
|
||||
return "Unknown MethodName: " + topic.method_name;
|
||||
|
||||
var service = APIDispatch.locate_service(topic.service_type);
|
||||
var request = APIDispatch.generate_request(topic.service_type, topic.method_name, topic.parameters[0]);
|
||||
if (service != null) //request can be null here
|
||||
{
|
||||
var subscription = APIDispatch.invoke_service_call(service, topic.method_name, request);
|
||||
stream = subscription as IObservable<object>;
|
||||
if (stream != null)
|
||||
{
|
||||
dynamic dtable = ObservableUpdateExtensions.Table((dynamic)subscription);
|
||||
stream = dtable as IObservable<object>;
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using ExcelDna.Integration;
|
||||
using ExcelDna.Integration.Rtd;
|
||||
using bts.excel.extensions;
|
||||
using System.Reflection;
|
||||
|
||||
namespace bts.excel.rtd
|
||||
{
|
||||
class TopicBase : ExcelRtdServer.Topic
|
||||
{
|
||||
public Guid id { get; protected set; }
|
||||
|
||||
public TopicBase(ExcelRtdServer server, int topicid) : base(server, topicid)
|
||||
{
|
||||
id = Guid.NewGuid();
|
||||
}
|
||||
}
|
||||
|
||||
class APITopic : TopicBase
|
||||
{
|
||||
public Type service_type { get; private set; }
|
||||
public Type request_type { get; private set; }
|
||||
public string method_name { get; private set; }
|
||||
public string[] parameters { get; private set; }
|
||||
|
||||
public string service_type_string { get; private set; }
|
||||
public const string topic_type = "api";
|
||||
|
||||
public APITopic(ExcelRtdServer server, int topicid,
|
||||
string serv_type, string methodname, string[] param) : base(server, topicid)
|
||||
{
|
||||
service_type_string = serv_type;
|
||||
method_name = methodname;
|
||||
service_type = find_api_type(service_type_string, null, typeof(bts.api.core.IApiClient));
|
||||
request_type = APIDispatch.find_request_type(service_type, method_name);
|
||||
parameters = param;
|
||||
}
|
||||
|
||||
Type find_api_type(string type, string assem_regex = null, Type assignable = null)
|
||||
{
|
||||
return Utilities.find_full_type_in_all_assemblies(type, assem_regex, assignable);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
var h = service_type?.GetHashCode() ^ request_type?.GetHashCode() ^ all_params().GetHashCode();
|
||||
if (h.HasValue)
|
||||
return h.Value;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
string all_params()
|
||||
{
|
||||
if (parameters != null)
|
||||
return parameters.Aggregate((a, b) => a + b);
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
APITopic top = (obj as APITopic);
|
||||
if (top == null)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
return top.service_type.Equals(this.service_type) &&
|
||||
top.request_type.Equals(this.request_type) &&
|
||||
top.all_params().Equals(this.all_params());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,319 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using bts.excel.extensions;
|
||||
using System.Text.RegularExpressions;
|
||||
using bts.api.core;
|
||||
|
||||
namespace bts.excel
|
||||
{
|
||||
public class DataParser
|
||||
{
|
||||
private static Type analyze_type(Type type, out bool is_array)
|
||||
{
|
||||
Type element_type = type;
|
||||
is_array = false;
|
||||
if (element_type.IsArray)
|
||||
{
|
||||
is_array = true;
|
||||
element_type = element_type.GetElementType();
|
||||
}
|
||||
return element_type;
|
||||
}
|
||||
|
||||
public static bool supported_primitive(Type t)
|
||||
{
|
||||
bool dummy;
|
||||
return supported_primitive(t, out dummy);
|
||||
}
|
||||
|
||||
public static bool supported_primitive(Type t, out bool is_array)
|
||||
{
|
||||
is_array = t.IsArray;
|
||||
if (is_array)
|
||||
t = t.GetElementType();
|
||||
return t.IsPrimitive || t.IsEnum || t == typeof(string) || t == typeof(DateTime);
|
||||
}
|
||||
|
||||
public static bool excluded_member(MemberInfo s)
|
||||
{
|
||||
return s.Name.ToLower() == "extensionobject" ||
|
||||
s.Name.ToLower() == "proto" ||
|
||||
s.Name.ToLower() == "descriptor" ||
|
||||
|
||||
s.Name.Contains(".")
|
||||
;
|
||||
}
|
||||
|
||||
private static void analyze_fields(Type element_type,
|
||||
out List<MemberInfo> superduperfields, out List<MemberInfo> superfields, out List<MemberInfo> fields,
|
||||
out List<string> superdupernames, out List<string> supernames, out List<string> names, out List<string> combined)
|
||||
{
|
||||
var members = ReflectionExtensions.get_fields_or_properties(element_type);
|
||||
superduperfields = new List<MemberInfo>();
|
||||
superfields = new List<MemberInfo>();
|
||||
fields = new List<MemberInfo>();
|
||||
superdupernames = new List<string>();
|
||||
supernames = new List<string>();
|
||||
names = new List<string>();
|
||||
combined = new List<string>();
|
||||
foreach (var r in members)
|
||||
{
|
||||
if (excluded_member(r))
|
||||
continue;
|
||||
if (supported_primitive(ReflectionExtensions.member_type(r)))
|
||||
{
|
||||
superduperfields.Add(r);
|
||||
superdupernames.Add(r.Name);
|
||||
superfields.Add(r);
|
||||
supernames.Add(r.Name);
|
||||
fields.Add(r);
|
||||
names.Add(r.Name);
|
||||
combined.Add(r.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
var sub = ReflectionExtensions.get_fields_or_properties(ReflectionExtensions.member_type(r));
|
||||
foreach (var s in sub)
|
||||
{
|
||||
if (excluded_member(s))
|
||||
continue;
|
||||
if (supported_primitive(ReflectionExtensions.member_type(s)))
|
||||
{
|
||||
superduperfields.Add(r);
|
||||
superdupernames.Add(r.Name);
|
||||
superfields.Add(r);
|
||||
supernames.Add(r.Name);
|
||||
fields.Add(s);
|
||||
names.Add(s.Name);
|
||||
combined.Add(r.Name + "." + s.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
var subsub = ReflectionExtensions.get_fields_or_properties(ReflectionExtensions.member_type(s));
|
||||
foreach (var ss in subsub)
|
||||
{
|
||||
if (excluded_member(ss) || !supported_primitive(ReflectionExtensions.member_type(ss)))
|
||||
continue;
|
||||
superduperfields.Add(r);
|
||||
superdupernames.Add(r.Name);
|
||||
superfields.Add(s);
|
||||
supernames.Add(s.Name);
|
||||
fields.Add(ss);
|
||||
names.Add(ss.Name);
|
||||
combined.Add(r.Name + "." + s.Name + "." + ss.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public object gather_data(Type type, object[,] data)
|
||||
{
|
||||
if (type == null)
|
||||
return null;
|
||||
bool is_array;
|
||||
Type element_type = analyze_type(type, out is_array);
|
||||
|
||||
bool field_name_headers = true;
|
||||
List<MemberInfo> superduperfields, superfields, fields;
|
||||
List<string> superdupernames, supernames, names, combined;
|
||||
analyze_fields(element_type, out superduperfields, out superfields, out fields,
|
||||
out superdupernames, out supernames, out names, out combined);
|
||||
|
||||
int object_len = data.GetLength(1) - (field_name_headers ? 1 : 0);
|
||||
Array objects = Array.CreateInstance(element_type, object_len);
|
||||
for (int j = 0; j < objects.Length; j++)
|
||||
{
|
||||
object target = Activator.CreateInstance(element_type);
|
||||
for (int zz = 0; zz < superduperfields.Count; zz++)
|
||||
{
|
||||
if (Regex.Matches(combined[zz], @"\.").Count == 2)
|
||||
ReflectionExtensions.set_value(superduperfields[zz], target, Activator.CreateInstance(ReflectionExtensions.member_type(superduperfields[zz])));
|
||||
}
|
||||
for (int z = 0; z < superfields.Count; z++)
|
||||
{
|
||||
if (combined[z].Contains("."))
|
||||
ReflectionExtensions.set_value(superfields[z], target, Activator.CreateInstance(ReflectionExtensions.member_type(superfields[z])));
|
||||
}
|
||||
for (int i = 0; i < data.GetLength(0); i++)
|
||||
{
|
||||
string name = data[i, 0].ToString();
|
||||
int idx = combined.IndexOf(name);
|
||||
if (idx < 0 || idx >= combined.Count)
|
||||
continue;
|
||||
|
||||
MemberInfo fi = fields[idx];
|
||||
object val = val = data[i, j + (field_name_headers ? 1 : 0)];
|
||||
val = read_data(ReflectionExtensions.member_type(fi), val);
|
||||
int dotcount = Regex.Matches(combined[i], @"\.").Count;
|
||||
if (dotcount == 2)
|
||||
{
|
||||
object subsubtarget = ReflectionExtensions.get_value(superduperfields[i], target);
|
||||
if (subsubtarget != null)
|
||||
{
|
||||
object subtarget = ReflectionExtensions.get_value(superfields[i], subsubtarget);
|
||||
if (subtarget != null)
|
||||
ReflectionExtensions.set_value(fi, subtarget, val);
|
||||
}
|
||||
}
|
||||
else if (dotcount == 1)
|
||||
{
|
||||
object subtarget = ReflectionExtensions.get_value(superfields[i], target);
|
||||
if (subtarget != null)
|
||||
ReflectionExtensions.set_value(fi, subtarget, val);
|
||||
}
|
||||
else if (dotcount == 0)
|
||||
ReflectionExtensions.set_value(fi, target, val);
|
||||
}
|
||||
objects.SetValue(target, j);
|
||||
}
|
||||
|
||||
if (is_array)
|
||||
return objects;
|
||||
else if (objects.Length > 0)
|
||||
return objects.GetValue(0);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static object read_data(Type field_type, object val)
|
||||
{
|
||||
if (typeof(Array).IsAssignableFrom(field_type))
|
||||
val = unstringify_array(val, field_type);
|
||||
else if (field_type == typeof(DateTime))
|
||||
val = DateTime.FromOADate(Convert.ToDouble(val));
|
||||
else if (field_type.IsEnum)
|
||||
val = Enum.Parse(field_type, val.ToString());
|
||||
else
|
||||
val = Convert.ChangeType(val, field_type);
|
||||
return val;
|
||||
}
|
||||
|
||||
public static Tuple<object[], object[]> key_value_tuple<T, TKey>(TableUpdate<T, TKey> source) where TKey : IEquatable<TKey>
|
||||
{
|
||||
return Tuple.Create(source.state.Keys.Cast<object>().ToArray(), source.state.Values.Cast<object>().ToArray());
|
||||
}
|
||||
|
||||
public static object[,] scatter_data(object data, bool include_field_names = true, Type type_override = null)
|
||||
{
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
bool is_array;
|
||||
Type type = type_override ?? data.GetType();
|
||||
if (type.IsGenericType && type.GetGenericTypeDefinition().Equals(typeof(TableUpdate<,>)))
|
||||
{
|
||||
Tuple<object[], object[]> tup = key_value_tuple((dynamic)data);
|
||||
return scatter_data(tup.Item2, include_field_names, tup.Item2.FirstOrDefault()?.GetType().MakeArrayType());
|
||||
}
|
||||
Type element_type = analyze_type(type, out is_array);
|
||||
|
||||
List<MemberInfo> superduperfields, superfields, fields;
|
||||
List<string> superdupernames, supernames, names, combined;
|
||||
analyze_fields(element_type, out superduperfields, out superfields, out fields,
|
||||
out superdupernames, out supernames, out names, out combined);
|
||||
|
||||
Array the_data = (is_array) ? (Array)data : new object[] { data };
|
||||
int len = the_data.GetLength(0);
|
||||
|
||||
var ret = new object[fields.Count, len + (include_field_names ? 1 : 0)];
|
||||
for (int j = 0; j < ret.GetLength(1); j++)
|
||||
{
|
||||
for (int i = 0; i < ret.GetLength(0); i++)
|
||||
{
|
||||
object dat = "";
|
||||
int dotcount = Regex.Matches(combined[i], @"\.").Count;
|
||||
if (dotcount == 2)
|
||||
{
|
||||
if (j == 0 && include_field_names)
|
||||
dat = combined[i];
|
||||
else
|
||||
{
|
||||
object subsub = ReflectionExtensions.get_value(superduperfields[i], the_data.GetValue(j - (include_field_names ? 1 : 0)));
|
||||
if (subsub != null)
|
||||
{
|
||||
object sub = ReflectionExtensions.get_value(superfields[i], subsub);
|
||||
if (sub != null)
|
||||
dat = ReflectionExtensions.get_value(fields[i], sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dotcount == 1)
|
||||
{
|
||||
if (j == 0 && include_field_names)
|
||||
dat = combined[i];
|
||||
else
|
||||
{
|
||||
object sub = ReflectionExtensions.get_value(superfields[i], the_data.GetValue(j - (include_field_names ? 1 : 0)));
|
||||
if (sub != null)
|
||||
dat = ReflectionExtensions.get_value(fields[i], sub);
|
||||
}
|
||||
}
|
||||
else if (dotcount == 0)
|
||||
{
|
||||
if (j == 0 && include_field_names)
|
||||
dat = names[i];
|
||||
else
|
||||
dat = ReflectionExtensions.get_value(fields[i], the_data.GetValue(j - (include_field_names ? 1 : 0)));
|
||||
}
|
||||
else
|
||||
dat = "Unknown value: " + combined[i];
|
||||
write_data(out ret[i, j], dat);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void write_data(out object ret, object dat)
|
||||
{
|
||||
ret = dat;
|
||||
if (dat is DateTime)
|
||||
ret = ((DateTime)dat).ToOADate();
|
||||
else if (dat is Enum)
|
||||
ret = dat.ToString();
|
||||
else if (dat is Array)
|
||||
{
|
||||
Array ary = (Array)dat;
|
||||
ret = stringify_array(ary);
|
||||
}
|
||||
}
|
||||
|
||||
public static string stringify_array(Array array)
|
||||
{
|
||||
string stringify = "{ ";
|
||||
int idx = 0;
|
||||
foreach (object d in array)
|
||||
{
|
||||
object o;
|
||||
write_data(out o, d);
|
||||
stringify += o.ToString() + ((idx++ == array.Length - 1) ? string.Empty : ",");
|
||||
}
|
||||
stringify += " }";
|
||||
return stringify;
|
||||
}
|
||||
|
||||
public static Array unstringify_array(object val, Type field_type = null)
|
||||
{
|
||||
if (field_type == null)
|
||||
field_type = typeof(string[]);
|
||||
|
||||
string[] data = val.ToString().Split(new char[] { ',', '{', '}' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
Type dt = field_type.GetElementType();
|
||||
Array ary = Array.CreateInstance(dt, data.Length);
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
object entry = null;
|
||||
try
|
||||
{
|
||||
entry = read_data(dt, Convert.ChangeType(data[i], dt));
|
||||
}
|
||||
catch (FormatException) { }
|
||||
ary.SetValue(entry, i);
|
||||
}
|
||||
return ary;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using System;
|
||||
using bts.md;
|
||||
|
||||
namespace bts.excel.rtd
|
||||
{
|
||||
class BookMDFormatter : IExcelFormatter
|
||||
{
|
||||
readonly IMDBook _update;
|
||||
public BookMDFormatter(IMDBook upd)
|
||||
{
|
||||
_update = upd;
|
||||
}
|
||||
|
||||
public object[,] format(bool include_headers = false)
|
||||
{
|
||||
return format(_update, include_headers);
|
||||
}
|
||||
|
||||
static public object[,] format(IMDBook update, bool include_headers = false)
|
||||
{
|
||||
const int cols = 5;
|
||||
const int rows = 30;
|
||||
var ret = new object[rows, cols];
|
||||
for (int i = 0; i < rows; i++)
|
||||
for (int j = 0; j < cols; j++)
|
||||
ret[i, j] = string.Empty;
|
||||
|
||||
if (update != null)
|
||||
{
|
||||
int idx = 0;
|
||||
for (int j = update.asks.Count - 1; j >= 0 && idx < rows; j--)
|
||||
{
|
||||
var ask = update.asks[j];
|
||||
ret[idx, 1] = ask.price;
|
||||
ret[idx, 2] = ask.size;
|
||||
idx++;
|
||||
}
|
||||
for (int j = 0; j < update.bids.Count && idx < rows; j++)
|
||||
{
|
||||
var bid = update.bids[j];
|
||||
ret[idx, 1] = bid.price;
|
||||
ret[idx, 0] = bid.size;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using bts.md;
|
||||
|
||||
namespace bts.excel.rtd
|
||||
{
|
||||
class FormatterFactory
|
||||
{
|
||||
public static IExcelFormatter make_formatter(object data)
|
||||
{
|
||||
if(data is IMDBook upd)
|
||||
return new BookMDFormatter(upd);
|
||||
else
|
||||
{
|
||||
return new JsonFormatter(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace bts.excel.rtd
|
||||
{
|
||||
internal interface IExcelFormatter
|
||||
{
|
||||
object[,] format(bool include_headers = false);
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using Google.Protobuf;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using ExcelDna.Integration;
|
||||
|
||||
namespace bts.excel.rtd
|
||||
{
|
||||
class JsonFormatter : IExcelFormatter
|
||||
{
|
||||
private object _data;
|
||||
static Google.Protobuf.JsonFormatter _protoformatter =
|
||||
new Google.Protobuf.JsonFormatter(Google.Protobuf.JsonFormatter.Settings.Default.WithFormatDefaultValues(true));
|
||||
public JsonFormatter(object data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
#region parser
|
||||
static IDictionary<string, object> parse_dictionary(object[,] range)
|
||||
{
|
||||
Dictionary<string, object> dict = new Dictionary<string, object>();
|
||||
if (range.Rank > 1)
|
||||
{
|
||||
for (int i = 0; i < range.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 1; j < range.GetLength(1); j++)
|
||||
dict[range.GetValue(i, 0).ToString()] = range.GetValue(i, j);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 1; j < range.Length; j++)
|
||||
dict[range.GetValue(0).ToString()] = range.GetValue(j);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
public static string parse_json(Type type, object[,] range)
|
||||
{
|
||||
var dict = parse_dictionary(range);
|
||||
string str = JsonConvert.SerializeObject(dict);
|
||||
return str;
|
||||
}
|
||||
|
||||
public static object parse_json_object(Type type, object[,] range)
|
||||
{
|
||||
string json = parse_json(type, range);
|
||||
var obj = JsonConvert.DeserializeObject(json);
|
||||
return obj;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public object[,] format(bool include_headers = false)
|
||||
{
|
||||
if (_data is IEnumerable iem)
|
||||
return format_many(iem, include_headers);
|
||||
else
|
||||
return format_one(_data, include_headers);
|
||||
}
|
||||
|
||||
object[,] format_many(IEnumerable data, bool include_headers = false)
|
||||
{
|
||||
List<SortedDictionary<string, object>> res = new List<SortedDictionary<string, object>>();
|
||||
foreach (var d in data)
|
||||
res.Add(to_dictionary(d));
|
||||
object[,] ret = fill_object_array(res, include_headers);
|
||||
return ret;
|
||||
}
|
||||
|
||||
object[,] format_one(object data, bool include_headers = false)
|
||||
{
|
||||
var d = to_dictionary(data);
|
||||
object[,] ret = fill_object_array(new[] { d }, include_headers);
|
||||
return ret;
|
||||
}
|
||||
|
||||
SortedDictionary<string, object> to_dictionary(object data)
|
||||
{
|
||||
string json = null;
|
||||
if(data is IMessage imsg)
|
||||
json = _protoformatter.Format(imsg);
|
||||
else
|
||||
json = JsonConvert.SerializeObject(data);
|
||||
|
||||
JObject jo = JObject.Parse(json);
|
||||
SortedDictionary<string, object> results = new SortedDictionary<string, object>();
|
||||
parse_object(jo, results);
|
||||
return results;
|
||||
}
|
||||
|
||||
void parse_object(JObject jo, SortedDictionary<string, object> results)
|
||||
{
|
||||
foreach (var kvp in jo)
|
||||
{
|
||||
if (kvp.Value is JArray jar) //arrays we'll just leave
|
||||
{
|
||||
for (int i = 0; i < jar.Count; i++)
|
||||
results[kvp.Key + "_" + i] = jar[i].ToString();
|
||||
}
|
||||
else if (kvp.Value is JValue jv)
|
||||
results[kvp.Key] = jv.ToString();
|
||||
else if (kvp.Value.HasValues)
|
||||
parse_object((JObject)kvp.Value, results);
|
||||
}
|
||||
}
|
||||
|
||||
object[,] fill_object_array(IEnumerable<SortedDictionary<string, object>> data, bool include_headers = false)
|
||||
{
|
||||
int count = 0;
|
||||
SortedDictionary<string, string> keys = new SortedDictionary<string, string>();
|
||||
foreach (var d in data)
|
||||
{
|
||||
count++;
|
||||
foreach (var kv in d)
|
||||
keys[kv.Key] = null;
|
||||
}
|
||||
object[,] ret = new object[count + (include_headers ? 1 : 0), keys.Count];
|
||||
int r = 0, c = 0;
|
||||
if (include_headers)
|
||||
{
|
||||
foreach (var k in keys.Keys)
|
||||
ret[r, c++] = k;
|
||||
r++;
|
||||
}
|
||||
foreach (var d in data)
|
||||
{
|
||||
c = 0;
|
||||
foreach (var k in keys.Keys)
|
||||
{
|
||||
d.TryGetValue(k, out object val);
|
||||
ret[r, c++] = val; //It found me!
|
||||
}
|
||||
r++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using bts.md;
|
||||
|
||||
namespace bts.excel.rtd
|
||||
{
|
||||
class LastMDFormatter : IExcelFormatter
|
||||
{
|
||||
readonly IMDLast _update;
|
||||
public LastMDFormatter(IMDLast upd)
|
||||
{
|
||||
_update = upd;
|
||||
}
|
||||
|
||||
public object[,] format(bool include_headers = false)
|
||||
{
|
||||
return format(_update, include_headers);
|
||||
}
|
||||
|
||||
static public object[,] format(IMDLast update, bool include_headers = false)
|
||||
{
|
||||
const int cols = 3;
|
||||
const int rows = 1;
|
||||
var ret = new object[rows, cols];
|
||||
|
||||
if (update != null)
|
||||
{
|
||||
ret[0, 0] = update.last?.price;
|
||||
ret[0, 1] = update.last?.size;
|
||||
ret[0, 1] = update.last_time;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using bts.md;
|
||||
|
||||
namespace bts.excel.rtd
|
||||
{
|
||||
class MiscMDFormatter : IExcelFormatter
|
||||
{
|
||||
readonly IMDMisc _update;
|
||||
public MiscMDFormatter(IMDMisc upd)
|
||||
{
|
||||
_update = upd;
|
||||
}
|
||||
|
||||
public object[,] format(bool include_headers = false)
|
||||
{
|
||||
return format(_update, include_headers);
|
||||
}
|
||||
|
||||
static public object[,] format(IMDMisc update, bool include_headers = false)
|
||||
{
|
||||
return new object[0, 0];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using bts.md;
|
||||
|
||||
namespace bts.excel.rtd
|
||||
{
|
||||
class TopOfBookMDFormatter : IExcelFormatter
|
||||
{
|
||||
readonly IMDBook _update;
|
||||
public TopOfBookMDFormatter(IMDBook upd)
|
||||
{
|
||||
_update = upd;
|
||||
}
|
||||
|
||||
public object[,] format(bool include_headers = false)
|
||||
{
|
||||
return format(_update, include_headers);
|
||||
}
|
||||
|
||||
static public object[,] format(IMDBook update, bool include_headers = false)
|
||||
{
|
||||
const int cols = 4;
|
||||
const int rows = 1;
|
||||
var ret = new object[rows, cols];
|
||||
for (int i = 0; i < rows; i++)
|
||||
for (int j = 0; j < cols; j++)
|
||||
ret[i, j] = string.Empty;
|
||||
|
||||
if (update != null)
|
||||
{
|
||||
int idx = 0;
|
||||
for (int j = 0; j < update.asks.Count && idx < rows; j++)
|
||||
{
|
||||
var ask = update.asks[j];
|
||||
ret[idx, 2] = ask.price;
|
||||
ret[idx, 3] = ask.size;
|
||||
idx++;
|
||||
}
|
||||
idx = 0;
|
||||
for (int j = 0; j < update.bids.Count && idx < rows; j++)
|
||||
{
|
||||
var bid = update.bids[j];
|
||||
ret[idx, 1] = bid.price;
|
||||
ret[idx, 0] = bid.size;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
|
||||
using System;
|
||||
using bts.md;
|
||||
|
||||
namespace bts.excel.rtd
|
||||
{
|
||||
class TopicMDFormatter : IExcelFormatter
|
||||
{
|
||||
readonly IMDCombined _update;
|
||||
readonly string _topic;
|
||||
public TopicMDFormatter(IMDCombined upd, string topic)
|
||||
{
|
||||
_update = upd;
|
||||
_topic = topic;
|
||||
}
|
||||
|
||||
public object[,] format(bool include_headers = false)
|
||||
{
|
||||
return format(_update, _topic, include_headers);
|
||||
}
|
||||
|
||||
static public object[,] format(IMDCombined update, string topic, bool include_headers = false)
|
||||
{
|
||||
var retval = new object[1, 1];
|
||||
if(update == null || string.IsNullOrEmpty(topic))
|
||||
return retval;
|
||||
|
||||
switch (topic.ToLower())
|
||||
{
|
||||
case "bid":
|
||||
case "bidprice":
|
||||
retval[0, 0] = update.bids?[0]?.price;
|
||||
break;
|
||||
case "ask":
|
||||
case "askprice":
|
||||
retval[0, 0] = update.asks?[0]?.price;
|
||||
break;
|
||||
case "bidsize":
|
||||
case "bidqty":
|
||||
retval[0, 0] = update.bids?[0]?.size;
|
||||
break;
|
||||
case "asksize":
|
||||
case "askqty":
|
||||
retval[0, 0] = update.asks?[0]?.size;
|
||||
break;
|
||||
case "impliedbid":
|
||||
case "impliedbidprice":
|
||||
retval[0, 0] = update.bids?[0]?.price; //TODO is this the first price with impsz > 0?
|
||||
break;
|
||||
case "impliedask":
|
||||
case "impliedaskprice":
|
||||
retval[0, 0] = update.asks?[0]?.price;
|
||||
break;
|
||||
case "impliedbidsize":
|
||||
case "impliedbidqty":
|
||||
retval[0, 0] = update.bids?[0]?.implied_size;
|
||||
break;
|
||||
case "impliedasksize":
|
||||
case "impliedaskqty":
|
||||
retval[0, 0] = update.asks?[0]?.implied_size;
|
||||
break;
|
||||
case "settlement":
|
||||
case "settlementprice":
|
||||
retval[0, 0] = update.settlement_price;
|
||||
break;
|
||||
case "previoussettlement":
|
||||
case "previoussettlementprice":
|
||||
retval[0, 0] = update.previous_settlement_price;
|
||||
break;
|
||||
case "open":
|
||||
case "openprice":
|
||||
retval[0, 0] = update.open_price;
|
||||
break;
|
||||
case "close":
|
||||
case "closeprice":
|
||||
retval[0, 0] = update.close_price;
|
||||
break;
|
||||
case "high":
|
||||
case "highprice":
|
||||
retval[0, 0] = update.session_high;
|
||||
break;
|
||||
case "low":
|
||||
case "lowprice":
|
||||
retval[0, 0] = update.session_low;
|
||||
break;
|
||||
case "last":
|
||||
case "lastprice":
|
||||
retval[0, 0] = update?.last?.price;
|
||||
break;
|
||||
case "lastsize":
|
||||
case "lastqty":
|
||||
retval[0, 0] = update?.last?.size;
|
||||
break;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using ExcelDna.Integration;
|
||||
using ExcelDna.Integration.Rtd;
|
||||
using ExcelDna.Registration.Utils;
|
||||
using System.Reactive.Linq;
|
||||
using bts.api;
|
||||
using bts.md;
|
||||
using bts.api.orderman;
|
||||
|
||||
namespace bts.excel.rtd
|
||||
{
|
||||
public class MDSubscribe
|
||||
{
|
||||
[ExcelFunction(Category = "BTS", Description = "Log in to BTS Spark")]
|
||||
async public static void spark_login(string login, string password, ExcelAsyncHandle handle)
|
||||
{
|
||||
try
|
||||
{
|
||||
var res = await Locator.login(login, password);
|
||||
if (res.success && Locator.token.HasValue)
|
||||
{
|
||||
_md.set_auth_token(Locator.token);
|
||||
handle.SetResult("Login Successful");
|
||||
}
|
||||
else
|
||||
handle.SetResult("Login Error: Could not log in check user/pass " + res.reason);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
handle.SetException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
static MarketDataClient _md = new MarketDataClient();
|
||||
public static MarketDataClient market_data(api.Venue exchange)
|
||||
{
|
||||
return _md;
|
||||
}
|
||||
|
||||
static public object spark_lookup_security_desc(string exchange, long security_key)
|
||||
{
|
||||
Venue ven;
|
||||
if (!Utilities.parse_venue(exchange, out ven))
|
||||
return Observable.Return("Can't Parse Exchange: " + exchange ?? string.Empty);
|
||||
MDSubscribe.market_data(ven).lookup_security_desc((uint)security_key, out string desc);
|
||||
return desc ?? string.Empty;
|
||||
}
|
||||
|
||||
static IObservable<IEnumerable<object>> md_observable(string contract, string symbol, string security_type, string exchange)
|
||||
{
|
||||
security_type = string.IsNullOrEmpty(security_type) ? SecurityType.Future.ToString() : security_type;
|
||||
exchange = string.IsNullOrEmpty(exchange) ? Security.ExchangeDataOneofCase.Glbx.ToString() : exchange;
|
||||
symbol = string.IsNullOrEmpty(symbol) ? contract.Substring(0, 2) : symbol;
|
||||
|
||||
Venue ven;
|
||||
SecurityType sectype;
|
||||
if (!Utilities.parse_venue(exchange, out ven))
|
||||
return Observable.Return(new [] {"Can't Parse Exchange: " + exchange ?? string.Empty});
|
||||
if (!Utilities.parse_security_type(security_type, out sectype))
|
||||
return Observable.Return(new [] {"Can't Parse Security Type: " + security_type ?? string.Empty});
|
||||
if (string.IsNullOrEmpty(symbol))
|
||||
return Observable.Return(new []{"Can't Parse Symbol: " + symbol ?? string.Empty});
|
||||
if (string.IsNullOrEmpty(contract))
|
||||
return Observable.Return(new []{"Can't Parse Contract: " + contract ?? string.Empty});
|
||||
|
||||
Func<SecurityImmutable, bool> desc = null;
|
||||
switch(ven)
|
||||
{
|
||||
case Venue.Sim:
|
||||
case Venue.Glbx:
|
||||
desc = (x=> x.Glbx.SecurityDesc == contract);
|
||||
break;
|
||||
case Venue.Ice:
|
||||
desc = (x=> x.Ice.SecurityDesc == contract);
|
||||
break;
|
||||
default:
|
||||
desc = (x => true);
|
||||
break;
|
||||
}
|
||||
|
||||
Func<SecurityImmutable, bool> where = (x => x.Exchange == ven && x.Symbol == symbol && x.security_type() == sectype && desc(x) );
|
||||
|
||||
var stream = market_data(ven).subscribe_combined(where);
|
||||
return stream;
|
||||
}
|
||||
|
||||
[ExcelFunction(Category = "BTS", Description = "Subscribe to BTS Spark full depth market data")]
|
||||
public static object spark_md_book(
|
||||
[ExcelArgument("Required. The specific contract, GCZ8 or ZNU8-ZNZ8, etc")] string contract,
|
||||
[ExcelArgument("Required. The symbol, GC or ZN, etc")] string symbol,
|
||||
[ExcelArgument("Optional. The type, Future or Spread, default = Future")] string security_type = null,
|
||||
[ExcelArgument("Optional. The exchange, default = GLBX")] string exchange = null)
|
||||
{
|
||||
|
||||
var param = new object[] { contract, symbol, security_type, exchange };
|
||||
return ObservableRtdUtil.Observe(nameof(spark_md_book), param,
|
||||
() => md_observable(contract, symbol, security_type, exchange).Select(data =>
|
||||
{
|
||||
var x = data.FirstOrDefault();
|
||||
if (x != null && x is IMDBook upd)
|
||||
return BookMDFormatter.format(upd);
|
||||
return x;
|
||||
}));
|
||||
// security_type = string.IsNullOrEmpty(security_type) ? SecurityType.Future.ToString() : security_type;
|
||||
// exchange = string.IsNullOrEmpty(exchange) ? Security.ExchangeDataOneofCase.Glbx.ToString() : exchange;
|
||||
// symbol = string.IsNullOrEmpty(symbol) ? contract.Substring(0, 2) : symbol;
|
||||
// string[] topic = new[] { MDTopic.topic_type, MDTopic.book_request_type,
|
||||
// contract, symbol, security_type, exchange};
|
||||
// object val = XlCall.RTD(typeof(RTDServer).FullName, null, topic);
|
||||
// return Subscribe.spark_unpack(val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[ExcelFunction(Category = "BTS", Description = "Subscribe to BTS Spark top of book market data")]
|
||||
public static object spark_md_top_of_book(
|
||||
[ExcelArgument("Required. The specific contract, GCZ8 or ZNU8-ZNZ8, etc")] string contract,
|
||||
[ExcelArgument("Required. The symbol, GC or ZN, etc")] string symbol,
|
||||
[ExcelArgument("Optional. The type, Future or Spread, default = Future")] string security_type = null,
|
||||
[ExcelArgument("Optional. The exchange, default = GLBX")] string exchange = null)
|
||||
{
|
||||
var param = new object[] { contract, symbol, security_type, exchange };
|
||||
return ObservableRtdUtil.Observe(nameof(spark_md_top_of_book), param,
|
||||
() => md_observable(contract, symbol, security_type, exchange).Select(data =>
|
||||
{
|
||||
var x = data.FirstOrDefault();
|
||||
if (x != null && x is IMDBook upd)
|
||||
return TopOfBookMDFormatter.format(upd);
|
||||
return x;
|
||||
}));
|
||||
}
|
||||
|
||||
[ExcelFunction(Category = "BTS", Description = "Subscribe to BTS Spark last trade market data")]
|
||||
public static object spark_md_last(
|
||||
[ExcelArgument("Required. The specific contract, GCZ8 or ZNU8-ZNZ8, etc")] string contract,
|
||||
[ExcelArgument("Required. The symbol, GC or ZN, etc")] string symbol,
|
||||
[ExcelArgument("Optional. The type, Future or Spread, default = Future")] string security_type = null,
|
||||
[ExcelArgument("Optional. The exchange, default = GLBX")] string exchange = null)
|
||||
{
|
||||
var param = new object[] { contract, symbol, security_type, exchange };
|
||||
return ObservableRtdUtil.Observe(nameof(spark_md_last), param,
|
||||
() => md_observable(contract, symbol, security_type, exchange).Select(data =>
|
||||
{
|
||||
var x = data.FirstOrDefault();
|
||||
if (x != null && x is IMDLast upd)
|
||||
return LastMDFormatter.format(upd);
|
||||
return x;
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
[ExcelFunction(Category = "BTS", Description = "Subscribe to BTS Spark miscellaneous market data")]
|
||||
public static object spark_md_misc(
|
||||
[ExcelArgument("Required. The specific contract, GCZ8 or ZNU8-ZNZ8, etc")] string contract,
|
||||
[ExcelArgument("Required. The symbol, GC or ZN, etc")] string symbol,
|
||||
[ExcelArgument("Optional. The type, Future or Spread, default = Future")] string security_type = null,
|
||||
[ExcelArgument("Optional. The exchange, default = GLBX")] string exchange = null)
|
||||
{
|
||||
var param = new object[] { contract, symbol, security_type, exchange };
|
||||
return ObservableRtdUtil.Observe(nameof(spark_md_misc), param,
|
||||
() => md_observable(contract, symbol, security_type, exchange).Select(data =>
|
||||
{
|
||||
var x = data.FirstOrDefault();
|
||||
if (x != null && x is IMDMisc upd)
|
||||
return MiscMDFormatter.format(upd);
|
||||
return x;
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
[ExcelFunction(Category = "BTS", Description = "Subscribe to BTS Spark topic based market data")]
|
||||
public static object spark_md(
|
||||
[ExcelArgument("Required. The 'Topic' string, 'bid', 'ask', etc")] string topic,
|
||||
[ExcelArgument("Required. The specific contract, GCZ8 or ZNU8-ZNZ8, etc")] string contract,
|
||||
[ExcelArgument("Required. The symbol, GC or ZN, etc")] string symbol,
|
||||
[ExcelArgument("Optional. The type, Future or Spread, default = Future")] string security_type = null,
|
||||
[ExcelArgument("Optional. The exchange, default = GLBX")] string exchange = null)
|
||||
{
|
||||
var param = new object[] { topic, contract, symbol, security_type, exchange };
|
||||
return ObservableRtdUtil.Observe(nameof(spark_md), param,
|
||||
() => md_observable(contract, symbol, security_type, exchange).Select(data =>
|
||||
{
|
||||
var x = data.FirstOrDefault();
|
||||
if (x != null && x is IMDCombined upd)
|
||||
return TopicMDFormatter.format(upd, topic);
|
||||
return x;
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using ExcelDna.Integration;
|
||||
using ExcelDna.Integration.Rtd;
|
||||
using ExcelDna.Registration;
|
||||
using ExcelDna.Registration.Utils;
|
||||
using System.Reactive.Linq;
|
||||
using bts.api;
|
||||
using bts.api.md;
|
||||
using bts.api.core;
|
||||
using bts.api.orderman;
|
||||
using bts.co2;
|
||||
|
||||
namespace bts.excel.rtd
|
||||
{
|
||||
public class Subscribe
|
||||
{
|
||||
[ExcelFunction(Category = "BTS", Description = "Subscribe to BTS Spark API Service")]
|
||||
public static object spark_api_subscribe(string service_type, string method_name, object parameters)
|
||||
{
|
||||
IList<string> topic = Utilities.get_tokens(parameters);
|
||||
topic.Insert(0, method_name);
|
||||
topic.Insert(0, service_type);
|
||||
object val = XlCall.RTD(typeof(APIRTDServer).FullName, null, topic.ToArray());
|
||||
return val;
|
||||
}
|
||||
|
||||
[ExcelFunction(Category = "BTS", Description = "Unpacks BTS Spark data from a GUID reference")]
|
||||
public static object spark_unpack(object reference)
|
||||
{
|
||||
object data;
|
||||
if(unpack(reference, out data))
|
||||
return data;
|
||||
else
|
||||
return reference;
|
||||
}
|
||||
|
||||
public static bool unpack(object reference, out object data)
|
||||
{
|
||||
object tempdata; data = null;
|
||||
if (reference is string && APIRTDServer.retrieve(reference.ToString(), out tempdata))
|
||||
{
|
||||
if (tempdata is IExcelFormatter fdata)
|
||||
data = fdata.format();
|
||||
else
|
||||
data = DataParser.scatter_data(tempdata);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//[ExcelFunction]
|
||||
//public static object bts_subscribe_deprecated(string service_type, string request_type, object parameters)
|
||||
//{
|
||||
// IList<string> topic = Utilities.get_tokens(parameters);
|
||||
// topic.Insert(0, request_type);
|
||||
// topic.Insert(0, service_type);
|
||||
// object val = XlCall.RTD(typeof(APIRTDServer).FullName, null, topic.ToArray());
|
||||
|
||||
// if(val is string)
|
||||
// {
|
||||
// //I can't marshal just any old object through the excel machinery, so in order to retain a 'registration free'
|
||||
// //model, I have to pass this string-guid from the RTDServer, up through excel and back here.
|
||||
// object data;
|
||||
// if(APIRTDServer.retrieve(val.ToString(), out data))
|
||||
// {
|
||||
// object[,] ret = DataParser.scatter_data(data);
|
||||
// return ret;
|
||||
// }
|
||||
// }
|
||||
// return val;
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<DnaLibrary Name="spark_excel" RuntimeVersion="v4.0">
|
||||
<ExternalLibrary Path="spark_excel.dll" ExplicitExports="false" LoadFromBytes="true" Pack="true" />
|
||||
|
||||
<Reference Path="ExcelDna.IntelliSense.dll" Pack="true" />
|
||||
<Reference Path="ExcelDna.Registration.dll" Pack="true" />
|
||||
<Reference Path="ExcelDna.Integration.dll" Pack="true" />
|
||||
|
||||
<Reference Path="Google.Protobuf.dll" Pack="true" ExplicitExports="true" />
|
||||
<Reference Path="System.Linq.Dynamic.dll" Pack="true" ExplicitExports="true" />
|
||||
<Reference Path="Newtonsoft.Json.dll" Pack="true" ExplicitExports="true" />
|
||||
<Reference Path="nunit.framework.dll" Pack="true" ExplicitExports="true" />
|
||||
<Reference Path="System.Reactive.Core.dll" Pack="true" ExplicitExports="true" />
|
||||
<Reference Path="System.Reactive.Interfaces.dll" Pack="true" ExplicitExports="true" />
|
||||
<Reference Path="System.Reactive.Providers.dll" Pack="true" ExplicitExports="true" />
|
||||
<Reference Path="System.Reactive.Linq.dll" Pack="true" ExplicitExports="true" />
|
||||
<Reference Path="System.Reactive.Runtime.Remoting.dll" Pack="true" ExplicitExports="true" />
|
||||
|
||||
<!--
|
||||
The RuntimeVersion attribute above allows two settings:
|
||||
* RuntimeVersion="v2.0" - for .NET 2.0, 3.0 and 3.5
|
||||
* RuntimeVersion="v4.0" - for .NET 4 and 4.5
|
||||
|
||||
Additional referenced assemblies can be specified by adding 'Reference' tags.
|
||||
These libraries will not be examined and registered with Excel as add-in libraries,
|
||||
but will be packed into the -packed.xll file and loaded at runtime as needed.
|
||||
For example:
|
||||
|
||||
<Reference Path="Another.Library.dll" Pack="true" />
|
||||
|
||||
Excel-DNA also allows the xml for ribbon UI extensions to be specified in the .dna file.
|
||||
See the main Excel-DNA site at http://excel-dna.net for downloads of the full distribution.
|
||||
-->
|
||||
|
||||
</DnaLibrary>
|
||||
@@ -1,83 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
|
||||
<TargetFrameworks>net471</TargetFrameworks>
|
||||
<OutputType>Library</OutputType>
|
||||
<!-- <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<IncludeSource>true</IncludeSource>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput> -->
|
||||
|
||||
<Authors>Blue Trading Systems</Authors>
|
||||
<Company>Blue Trading Systems</Company>
|
||||
<Product>Spark</Product>
|
||||
<Description />
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Platforms>x64</Platforms>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<Version>$(major).$(minor).$(patch)</Version>
|
||||
<Version Condition="'$(version)'=='..'">1.0.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.6.1" />
|
||||
<PackageReference Include="System.Reactive" Version="3.1.1" />
|
||||
<PackageReference Include="System.Reactive.PlatformServices" Version="3.1.1" />
|
||||
<PackageReference Include="NUnit" Version="3.10.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
|
||||
<PackageReference Include="System.Linq.Dynamic" Version="1.0.7" />
|
||||
|
||||
<PackageReference Include="ExcelDna.AddIn" Version="0.34.6" />
|
||||
<PackageReference Include="ExcelDna.Integration" Version="0.34.6" />
|
||||
<PackageReference Include="ExcelDna.IntelliSense" Version="1.1.0" />
|
||||
<PackageReference Include="ExcelDna.Registration" Version="0.34.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="spark_excel-AddIn.dna" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\ExcelDna.Build.props" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../spark_api/spark_api.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Proto3Excel Include="**/*.proto" />
|
||||
<Proto3Excel Include="../../lib/api/services/*.proto" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="spark_excel_example_2019.xlsm"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></None>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- <Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
|
||||
<ItemGroup>
|
||||
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
|
||||
<BuildOutputInPackage Include="$(OutputPath)..\net471\libspark.dll"/>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
-->
|
||||
|
||||
<!-- <Import Project="$(NuGetPackageRoot)\ExcelDna.AddIn\0.34.6\tools\ExcelDna.AddIn.targets" Condition="Exists('$(NuGetPackageRoot)\ExcelDna.AddIn\0.34.6\tools\ExcelDna.AddIn.targets')" /> -->
|
||||
<Import Project="$(NuGetPackageRoot)\ExcelDna.AddIn\0.34.6\tools\ExcelDna.AddIn.targets"/>
|
||||
<Target Name="EnsureExcelDnaTargetsImported" BeforeTargets="BeforeBuild" Condition="'$(ExcelDnaTargetsImported)' == ''">
|
||||
<Error Condition="!Exists('$(NuGetPackageRoot)\ExcelDna.AddIn\0.34.6\tools\ExcelDna.AddIn.targets') And ('$(RunExcelDnaBuild)' != '' And $(RunExcelDnaBuild))" Text="You are trying to build with ExcelDna, but the NuGet targets file that ExcelDna depends on is not available on this computer. This is probably because the ExcelDna package has not been committed to source control, or NuGet Package Restore is not enabled. Please enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
|
||||
<Error Condition="Exists('$(NuGetPackageRoot)\ExcelDna.AddIn\0.34.6\tools\ExcelDna.AddIn.targets') And ('$(RunExcelDnaBuild)' != '' And $(RunExcelDnaBuild))" Text="ExcelDna cannot be run because NuGet packages were restored prior to the build running, and the targets file was unavailable when the build started. Please build the project again to include these packages in the build. You may also need to make sure that your build server does not delete packages prior to each build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
|
||||
</Target>
|
||||
</Project>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,134 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using ExcelDna.Integration;
|
||||
|
||||
using bts.api.core;
|
||||
using bts.excel.extensions;
|
||||
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.Reflection;
|
||||
|
||||
namespace bts.excel
|
||||
{
|
||||
public class APIDispatch
|
||||
{
|
||||
public static Lazy<ServiceContext> service_context = new Lazy<ServiceContext>(() => new ServiceContext(), true);
|
||||
static MethodInfo _locate_meth;
|
||||
readonly static Dictionary<object, object> _services = new Dictionary<object, object>();
|
||||
const string descriptor_property_name = "Descriptor";
|
||||
|
||||
static MethodInfo locate_method
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_locate_meth == null)
|
||||
{
|
||||
_locate_meth = service_context.Value.GetType().find_method((_) =>
|
||||
{
|
||||
return _.Name == nameof(ServiceContext.locate) && _.IsGenericMethod;
|
||||
})[0];
|
||||
}
|
||||
return _locate_meth;
|
||||
}
|
||||
}
|
||||
|
||||
static public object api_call_internal(Type service_type, string method_name, IMessage parameters)
|
||||
{
|
||||
object response = null;
|
||||
if (service_type != null && method_name != null)
|
||||
{
|
||||
object service = locate_service(service_type);
|
||||
response = invoke_service_call(service, method_name, parameters);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
//static public object invoke_service_call(object service, Type request_type, IMessage request)
|
||||
//{
|
||||
// var sub_method = service.GetType().GetMethods().Where(meth =>
|
||||
// {
|
||||
// var par = meth.GetParameters().FirstOrDefault();
|
||||
// return (par != null && par.ParameterType.IsAssignableFrom(request_type));
|
||||
// }).FirstOrDefault();
|
||||
// object subscription = null;
|
||||
// if(sub_method != null)
|
||||
// subscription = sub_method.Invoke(service, new[] { request });
|
||||
// return subscription;
|
||||
//}
|
||||
|
||||
static public object invoke_service_call(object service, string method_name, IMessage request)
|
||||
{
|
||||
var sub_method = service.GetType().GetMethod(method_name);
|
||||
object subscription = null;
|
||||
if (sub_method != null)
|
||||
subscription = sub_method.Invoke(service, new[] { request });
|
||||
return subscription;
|
||||
}
|
||||
|
||||
public static Type find_request_type(Type service_type, string method_name)
|
||||
{
|
||||
return service_type?.GetMethod(method_name)?.GetParameters().FirstOrDefault()?.ParameterType;
|
||||
}
|
||||
|
||||
static public IMessage generate_imessage(Type type, string json, bool null_for_empty = false)
|
||||
{
|
||||
IMessage request = null;
|
||||
var descproperty = type?.get_static_field_or_property(descriptor_property_name);
|
||||
if (descproperty != null)
|
||||
{
|
||||
MessageDescriptor desc = (MessageDescriptor)descproperty.get_value(null);
|
||||
if (null_for_empty)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(json) && json != "{ }" && json != "{}")
|
||||
request = JsonParser.Default.Parse(json, desc);
|
||||
else
|
||||
request = null; //TODO this is a workaround for Eric's bug that requires 'empty' requests to pass null instead
|
||||
}
|
||||
else
|
||||
{
|
||||
if(string.IsNullOrEmpty(json))
|
||||
json = "{}";
|
||||
request = JsonParser.Default.Parse(json, desc);
|
||||
}
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
||||
static public IMessage generate_request(Type service_type, string method_name, string request_json)
|
||||
{
|
||||
Type request_type = find_request_type(service_type, method_name);
|
||||
return generate_imessage(request_type, request_json, true);
|
||||
}
|
||||
|
||||
static public object locate_service(Type service_type)
|
||||
{
|
||||
//object svc = null;
|
||||
//if(service_type != null && !_services.TryGetValue(service_type, out svc))
|
||||
//{
|
||||
var method = locate_method?.MakeGenericMethod(service_type);
|
||||
object svc = method?.Invoke(service_context.Value, new object[] { null });
|
||||
if (svc != null)
|
||||
_services[svc] = null;
|
||||
return svc;
|
||||
}
|
||||
|
||||
|
||||
[ExcelFunction]
|
||||
static public object spark_api_call(string service_type, string method_name, object parameters)
|
||||
{
|
||||
Type svc = Utilities.find_full_type_in_all_assemblies(service_type, ".*api.*");
|
||||
|
||||
var tok = Utilities.get_tokens(parameters);
|
||||
string json = tok.FirstOrDefault();
|
||||
IMessage request = generate_request(svc, method_name, json);
|
||||
object resp = api_call_internal(svc, method_name, request);
|
||||
if (resp != null)
|
||||
return DataParser.scatter_data(resp);
|
||||
else
|
||||
return ExcelErrorUtil.ToComError(ExcelError.ExcelErrorNA);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,276 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using ExcelDna.Integration;
|
||||
using bts.api;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace bts.excel
|
||||
{
|
||||
public class Utilities
|
||||
{
|
||||
|
||||
[ExcelFunction]
|
||||
public static object bts_json_lookup(string json, string key1, string key2 = null, string key3 = null)
|
||||
{
|
||||
var jo = JObject.Parse(json);
|
||||
JToken val = json;
|
||||
if (!string.IsNullOrEmpty(key1) && !string.IsNullOrEmpty(key2) && !string.IsNullOrEmpty(key3))
|
||||
val = jo[key1][key2][key3];
|
||||
else if (!string.IsNullOrEmpty(key1) && !string.IsNullOrEmpty(key2))
|
||||
val = jo[key1][key2];
|
||||
else if (!string.IsNullOrEmpty(key1))
|
||||
val = jo[key1];
|
||||
return val.ToString();
|
||||
}
|
||||
|
||||
public static bool parse_venue(string exch, out Venue ven)
|
||||
{
|
||||
if (!Enum.TryParse(exch.ToUpper(), true, out ven))
|
||||
return Enum.TryParse("VENUE_" + exch.ToUpper(), true, out ven);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool parse_security_type(string sectype, out SecurityType st)
|
||||
{
|
||||
if (!Enum.TryParse(sectype.ToUpper(), true, out st))
|
||||
return Enum.TryParse("SECURITY_TYPE" + sectype.ToUpper(), true, out st);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
static ConcurrentDictionary<string, Type> _types = new ConcurrentDictionary<string, Type>();
|
||||
public static Type find_full_type_in_all_assemblies(string type, string assembly_regex = null, Type assignable_from = null)
|
||||
{
|
||||
if (assignable_from == null)
|
||||
assignable_from = typeof(object);
|
||||
if (type == null)
|
||||
return null;
|
||||
Type res = null;
|
||||
if (!_types.TryGetValue(type, out res))
|
||||
{
|
||||
int idx = type.IndexOf("<");
|
||||
if (idx > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] zargs = type.Substring(idx + 1, type.Length - idx - 1).Replace(">", string.Empty).Split(',');
|
||||
string gtstring = type.Substring(0, idx) + "`" + zargs.Length.ToString();
|
||||
var gt = find_full_type_in_all_assemblies(gtstring, assembly_regex);
|
||||
Type[] args = new Type[zargs.Length];
|
||||
for (int i = 0; i < zargs.Length; i++)
|
||||
args[i] = find_full_type_in_all_assemblies(zargs[i], assembly_regex);
|
||||
res = gt.MakeGenericType(args);
|
||||
}
|
||||
catch (Exception) { /*TODO log?*/ }
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Type> alltypes = find_all_types_in_all_assemblies(type, assembly_regex);
|
||||
foreach (Type at in alltypes)
|
||||
{
|
||||
if (!assignable_from.IsAssignableFrom(at))
|
||||
continue;
|
||||
res = at;
|
||||
_types[type] = res;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static public List<Type> find_all_types_in_all_assemblies(string type, string assembly_regex = null)
|
||||
{
|
||||
List<Type> res = new List<Type>();
|
||||
var asses = AppDomain.CurrentDomain.GetAssemblies();
|
||||
foreach (Assembly a in asses)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(assembly_regex))
|
||||
{
|
||||
if (!Regex.Match(a.GetName().Name, assembly_regex).Success)
|
||||
continue;
|
||||
}
|
||||
Type t = a.GetType(type, false, true);
|
||||
if (t != null)
|
||||
res.Add(t);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static public T[,] transpose_keep_dimension<T>(T[,] array)
|
||||
{
|
||||
var res = new T[array.GetLength(1), array.GetLength(0)];
|
||||
for (int i = 0; i < array.GetLength(1); i++)
|
||||
for (int j = 0; j < array.GetLength(0); j++)
|
||||
res[i, j] = array[j, i];
|
||||
return res;
|
||||
}
|
||||
|
||||
static public T[,] transpose<T>(T[,] array)
|
||||
{
|
||||
var res = new T[array.Length, 1];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
res[i, 0] = array[0, i];
|
||||
return res;
|
||||
}
|
||||
|
||||
static public T[,] transpose<T>(T[] array)
|
||||
{
|
||||
var res = new T[array.Length, 1];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
res[i, 0] = array[i];
|
||||
return res;
|
||||
}
|
||||
|
||||
static public object[,] transpose(Array array)
|
||||
{
|
||||
var res = new object[array.Length, 1];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
res[i, 0] = array.GetValue(i);
|
||||
return res;
|
||||
}
|
||||
|
||||
static public T[,] make_column_vector<T>(T[] row_array)
|
||||
{
|
||||
return transpose<T>(row_array);
|
||||
}
|
||||
|
||||
static public T[] make_row_vector<T>(T[,] col_array)
|
||||
{
|
||||
var res = new List<T>();
|
||||
for (int i = 0; i < col_array.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < col_array.GetLength(1); j++)
|
||||
{
|
||||
res.Add(col_array[i, j]);
|
||||
}
|
||||
}
|
||||
return res.ToArray();
|
||||
}
|
||||
|
||||
|
||||
static public Array make_row_vector(Type type, object[,] col_array)
|
||||
{
|
||||
var res = Array.CreateInstance(type, col_array.Length);
|
||||
int len = col_array.GetLength(1);
|
||||
for (int i = 0; i < col_array.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < len; j++)
|
||||
{
|
||||
var obj = col_array[i, j];
|
||||
if (type.IsAssignableFrom(obj.GetType()))
|
||||
res.SetValue(obj, i * len + j);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static public string bts_stringify_array_typed(object[,] data, string typename)
|
||||
{
|
||||
Type type = find_full_type_in_all_assemblies(typename);
|
||||
object array = DataParser.gather_data(type, data);
|
||||
|
||||
object ret;
|
||||
DataParser.write_data(out ret, array);
|
||||
return ret.ToString();
|
||||
}
|
||||
|
||||
static public string bts_stringify_array(object[] array)
|
||||
{
|
||||
object ret;
|
||||
DataParser.write_data(out ret, array);
|
||||
return ret.ToString();
|
||||
}
|
||||
|
||||
static public object[,] bts_read_stringified_array(object array, string typename)
|
||||
{
|
||||
Type type = find_full_type_in_all_assemblies(typename);
|
||||
object data = DataParser.read_data(type, array);
|
||||
object[,] ret = DataParser.scatter_data(data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static public object[,] bts_read_double_array(object array)
|
||||
{
|
||||
object data = DataParser.read_data(typeof(double[]), array);
|
||||
object[,] ret = DataParser.scatter_data(data, false);
|
||||
var t = transpose(ret);
|
||||
return t;
|
||||
}
|
||||
|
||||
static public object[,] bts_read_string_array(object array)
|
||||
{
|
||||
object data = DataParser.read_data(typeof(string[]), array);
|
||||
object[,] ret = DataParser.scatter_data(data, false);
|
||||
var t = transpose(ret);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
static public T[,] combine_arrays_vertically<T>(IEnumerable<T[,]> arrays)
|
||||
{
|
||||
int rows = 0, cols = 0;
|
||||
foreach (var a in arrays)
|
||||
{
|
||||
if (a.GetLength(1) > cols)
|
||||
cols = a.GetLength(1);
|
||||
rows += a.GetLength(0);
|
||||
}
|
||||
T[,] result = new T[rows, cols]; int idx = 0;
|
||||
foreach (T[,] a in arrays)
|
||||
{
|
||||
for (int i = 0; i < a.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < a.GetLength(1); j++)
|
||||
result[idx, j] = (T)a.GetValue(i, j);
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static private Dictionary<string, System.Reflection.Assembly> _ass = new Dictionary<string, System.Reflection.Assembly>();
|
||||
[ExcelFunction(IsMacroType = true)]
|
||||
public static string bts_load_assembly(string assembly_path)
|
||||
{
|
||||
//XlCall.Excel(XlCall.xlfVolatile, false);
|
||||
System.Reflection.Assembly ass;
|
||||
if (!_ass.TryGetValue(assembly_path, out ass))
|
||||
{
|
||||
ass = System.Reflection.Assembly.Load(assembly_path);
|
||||
_ass[assembly_path] = ass;
|
||||
}
|
||||
return (ass == null) ? "ERROR: Couldn't load assembly " + assembly_path : "Assembly Loaded: " + assembly_path + " " + DateTime.Now.ToLongTimeString();
|
||||
}
|
||||
|
||||
static public IList<string> get_tokens(object tag)
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
if (tag is Array)
|
||||
{
|
||||
Array array = (Array)tag;
|
||||
if (array.Rank > 1)
|
||||
{
|
||||
for (int i = 0; i < array.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < array.GetLength(1); j++)
|
||||
list.Add(array.GetValue(i, j).ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < array.Length; j++)
|
||||
list.Add(array.GetValue(j).ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
list.Add(tag.ToString());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.6.1" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.24.3" />
|
||||
<PackageReference Include="System.Reactive" Version="3.1.1" />
|
||||
<PackageReference Include="System.Reactive.PlatformServices" Version="3.1.1" />
|
||||
<PackageReference Include="NUnit" Version="3.10.1" />
|
||||
@@ -47,54 +47,39 @@
|
||||
</PropertyGroup>
|
||||
-->
|
||||
<!-- $(SparkRoot) is something we define on our build at BTS, if it's empty, this project file is in the wild-->
|
||||
<ItemGroup Condition= " '$(SparkRoot)' != '' ">
|
||||
<ProjectReference Include="../spark_api/spark_api.csproj"/>
|
||||
<ItemGroup Condition=" '$(SparkRoot)' != '' ">
|
||||
<ProjectReference Include="../spark_api/spark_api.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition= " '$(SparkRoot)' != '' and '$(TargetFramework)' == 'net471' ">
|
||||
<ItemGroup Condition=" '$(SparkRoot)' != '' and '$(TargetFramework)' == 'net471' ">
|
||||
<!-- This is so we can ship excel in the nupkg -->
|
||||
<ProjectReference Include="../spark_excel/spark_excel.csproj"/>
|
||||
<ProjectReference Include="../spark_excel/spark_excel.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition= " '$(SparkRoot)' != '' ">
|
||||
<None Include="README.md" pack="true" PackagePath="." />
|
||||
<None Include="$(OutputPath)\net471\spark_excel_example_2019.xlsm" pack="true" PackagePath=".\excel\spark_excel_example_2019.xlsm" />
|
||||
<None Include="$(OutputPath)\net471\spark_excel-addin64-packed.xll" pack="true" PackagePath=".\excel\spark_excel-addin64-packed.xll" />
|
||||
<None Include="$(OutputPath)\net471\spark_excel-addin64.dna" pack="true" PackagePath=".\excel\spark_excel-addin64.dna" />
|
||||
<None Include="doc/**" pack="true" PackagePath=".\doc\" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences" Condition= " '$(SparkRoot)' != '' ">
|
||||
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences" Condition=" '$(SparkRoot)' != '' ">
|
||||
<ItemGroup>
|
||||
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
|
||||
<BuildOutputInPackage Include="$(OutputPath)..\net471\libspark.dll"/>
|
||||
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
|
||||
<BuildOutputInPackage Include="$(OutputPath)..\net471\libspark.dll" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!-- deployed sdk build net471 -->
|
||||
<ItemGroup Condition= " '$(SparkRoot)' == '' and '$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition=" '$(SparkRoot)' == '' and '$(TargetFramework)' == 'net471'">
|
||||
<Reference Include="spark_api">
|
||||
<HintPath>..\..\lib\net471\spark_api.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- deployed sdk build netcoreapp2.1 -->
|
||||
<ItemGroup Condition= " '$(SparkRoot)' == '' and '$(TargetFramework)' == 'netcoreapp2.1'">
|
||||
<ItemGroup Condition=" '$(SparkRoot)' == '' and '$(TargetFramework)' == 'netcoreapp2.1'">
|
||||
<Reference Include="spark_api">
|
||||
<HintPath>..\..\lib\netcoreapp2.1\spark_api.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<Target Name="copy_lib_deployed" AfterTargets="PostBuildEvent" Condition= " '$(SparkRoot)' == '' " >
|
||||
<Target Name="copy_lib_deployed" AfterTargets="PostBuildEvent" Condition=" '$(SparkRoot)' == '' ">
|
||||
<Copy SourceFiles="..\..\lib\net471\libspark.dll" DestinationFolder="$(OutputPath)\" SkipUnchangedFiles="true" />
|
||||
</Target>
|
||||
|
||||
<Target Name="copy_lib_deployed471" AfterTargets="PostBuildEvent" Condition= " '$(SparkRoot)' == '' and '$(TargetFramework)' == 'net471'" >
|
||||
<Copy SourceFiles="..\..\lib\net471\spark_excel.dll" DestinationFolder="$(OutputPath)\" SkipUnchangedFiles="true" />
|
||||
<Copy SourceFiles="..\..\excel\spark_excel_example_2019.xlsm" DestinationFolder="$(OutputPath)\" SkipUnchangedFiles="true" />
|
||||
<Copy SourceFiles="..\..\excel\spark_excel-addin64-packed.xll" DestinationFolder="$(OutputPath)\" SkipUnchangedFiles="true" />
|
||||
<Copy SourceFiles="..\..\excel\spark_excel-addin64.dna" DestinationFolder="$(OutputPath)\" SkipUnchangedFiles="true" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
Binary file not shown.
@@ -1,12 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace bts.tests.security {
|
||||
public static class ContractSpecificationFiles {
|
||||
public const string
|
||||
Sim = "SimContractSpecifications.contract_spec_proto";
|
||||
|
||||
public static IEnumerable<string> all() {
|
||||
yield return Sim;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace bts.tests.security {
|
||||
public 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,12 @@
|
||||
using bts.api;
|
||||
using bts.collections;
|
||||
using bts.mcore;
|
||||
using bts.resources;
|
||||
using bts.test;
|
||||
using bts.utils;
|
||||
using bts.utils.proto;
|
||||
using mbts.spark;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace bts.tests.security {
|
||||
namespace bts.mcore {
|
||||
[TestGroup]
|
||||
class SecurityTests {
|
||||
[Test]
|
||||
@@ -37,18 +33,6 @@ namespace bts.tests.security {
|
||||
_test_security_compare(_read_securities(file_path));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void test_ticks() {
|
||||
var from_sec_files = SecurityFiles.all().SelectMany(_read_securities).Select(s => s.ContractSpec);
|
||||
var from_spec_files = ContractSpecificationFiles.all().SelectMany(TickTestHelper.read_contract_specs);
|
||||
var distinct_specs = new HashSet<ContractSpecificationImmutable>(from_sec_files.Concat(from_spec_files));
|
||||
foreach (var spec in distinct_specs)
|
||||
_test_ticks(spec);
|
||||
}
|
||||
|
||||
static IEnumerable<SecurityImmutable> _read_securities(string file_path) =>
|
||||
StreamHelper.ReadProtos<Security>(ResourceHelper.LoadResource(file_path)).Select(s => new SecurityImmutable(s));
|
||||
|
||||
void _test_security_compare(IEnumerable<SecurityImmutable> securities) {
|
||||
const int max_count = 2048;
|
||||
var sec_list = securities as IList<SecurityImmutable> ?? securities.ToList();
|
||||
@@ -58,101 +42,18 @@ namespace bts.tests.security {
|
||||
ComparisonTests.identity_comparison(sec_list, SecurityHelper.Comparer.InstanceImmutable);
|
||||
}
|
||||
|
||||
void _test_ticks(ContractSpecificationImmutable tick) {
|
||||
// the prices straddle a particular number (the radius determines how far above/below the straddle the price range spans)
|
||||
const int min_tick_radius = 200;
|
||||
// some ticks can have more than 200 prices between integers (n and n+1)
|
||||
const int min_int_radius = 2;
|
||||
// test price range about zero
|
||||
var prices_about_zero = TickTestHelper.generate_test_prices(tick.LowTick, radius: get_radius(tick.LowTick), origin_price: 0);
|
||||
_test_ticks(tick, prices_about_zero);
|
||||
// test price range about the price break
|
||||
if (tick.PriceBreak.is_real()) {
|
||||
var prices_about_break = TickTestHelper.generate_test_prices(tick.HighTick, radius: get_radius(tick.HighTick), origin_price: tick.PriceBreak);
|
||||
_test_ticks(tick, prices_about_break);
|
||||
}
|
||||
int get_radius(double tick_size) {
|
||||
Assert.That(tick_size.is_real_positive());
|
||||
return Math.Max(min_tick_radius, (int)(min_int_radius / tick_size));
|
||||
}
|
||||
}
|
||||
IEnumerable<SecurityImmutable> _read_securities(string file_path) =>
|
||||
StreamHelper.ReadProtos<Security>(ResourceHelper.LoadResource(file_path)).Select(s => new SecurityImmutable(s));
|
||||
|
||||
void _test_ticks(ContractSpecificationImmutable tick, IEnumerable<double> prices) {
|
||||
Assert.That(!(tick.LowTick < 0));
|
||||
Assert.That(!(tick.HighTick < 0));
|
||||
foreach (var p in prices) {
|
||||
var expected_ticks_from_zero = TickTestHelper.full_ticks_from_zero(tick, p);
|
||||
var actual_ticks_from_zero = TickUtils.full_ticks_from_zero(tick, p);
|
||||
if (expected_ticks_from_zero != actual_ticks_from_zero) {
|
||||
expected_ticks_from_zero = TickTestHelper.full_ticks_from_zero(tick, p);
|
||||
actual_ticks_from_zero = TickUtils.full_ticks_from_zero(tick, p);
|
||||
}
|
||||
Assert.That(expected_ticks_from_zero == actual_ticks_from_zero,
|
||||
$"Expected ticks from zero to be '{expected_ticks_from_zero}', actually '{actual_ticks_from_zero}' " +
|
||||
$"(low/high/pricebreak: {tick.LowTick}/{tick.HighTick}/{tick.PriceBreak}, price: {p}).");
|
||||
if (expected_ticks_from_zero.HasValue) {
|
||||
Assert.That(p.is_real());
|
||||
_test_tick_up(tick, p - 1, p);
|
||||
if (tick.PriceBreak.is_real() && tick.PriceBreak != double.MaxValue && tick.PriceBreak != double.MinValue) {
|
||||
// test both sides of the break with a few adjustments
|
||||
foreach (var adjustment in new[] { 1, tick.LowTick, tick.HighTick }) {
|
||||
_test_tick_up(tick, p, tick.PriceBreak + adjustment);
|
||||
_test_tick_up(tick, p, tick.PriceBreak - adjustment);
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void _test_tick_up(ContractSpecificationImmutable spec, double from, double to) {
|
||||
if (!from.is_real() || !to.is_real())
|
||||
return;
|
||||
var (min, max) = MathUtils.get_outliers(from, to);
|
||||
if (spec.PriceBreak.is_real()) {
|
||||
if (min >= spec.PriceBreak) {
|
||||
//_test_single_tick(spec.HighTick, min, max);
|
||||
} else if (max <= spec.PriceBreak) {
|
||||
_test_single_tick(spec, spec.LowTick, min, max);
|
||||
} else {
|
||||
//if (round_ticks(spec.LowTick, min, out var ))
|
||||
_test_dual_tick(spec, min, max);
|
||||
}
|
||||
} else {
|
||||
_test_single_tick(spec, spec.LowTick, min, max);
|
||||
}
|
||||
}
|
||||
|
||||
void _test_dual_tick(ContractSpecificationImmutable spec, double min, double max) {
|
||||
Assert.That(min < spec.PriceBreak);
|
||||
Assert.That(max > spec.PriceBreak);
|
||||
// 2 tick counts are used to determine the number of ticks between min and max,
|
||||
// 1) number of ticks from min to the price break
|
||||
// 2) number of ticks from the price break to max
|
||||
// if either min/max is beyond epsilon away from a real tick,
|
||||
// a partial tick is used to correct the rounding error.
|
||||
Assert.That(TickTestHelper.round_ticks(spec.LowTick, spec.PriceBreak - min, out var rounded_min, out var min_ticks_to_break));
|
||||
Assert.That(TickTestHelper.round_ticks(spec.HighTick, max - spec.PriceBreak, out var rounded_max, out var max_ticks_to_break));
|
||||
rounded_min = spec.PriceBreak - rounded_min;
|
||||
rounded_max = spec.PriceBreak + rounded_max;
|
||||
int min_partial_tick = TickTestHelper.check_partial_tick(spec, min, rounded_min, true);
|
||||
int max_partial_tick = TickTestHelper.check_partial_tick(spec, max, rounded_max, false);
|
||||
// assert that ticking up/down between min/max behaves expectedly.
|
||||
var batch_tick_up_result = spec.tickup(min, min_ticks_to_break + max_ticks_to_break + min_partial_tick);
|
||||
Assert.That(MathUtils.marginal_equals(batch_tick_up_result, rounded_max, TickUtils.precision_const));
|
||||
var batch_tick_down_result = spec.tickdown(max, min_ticks_to_break + max_ticks_to_break + max_partial_tick);
|
||||
Assert.That(MathUtils.marginal_equals(batch_tick_down_result, rounded_min, TickUtils.precision_const));
|
||||
}
|
||||
|
||||
void _test_single_tick(ContractSpecificationImmutable spec, double tick_size, double min, double max) {
|
||||
// min round/partial tick
|
||||
Assert.That(TickTestHelper.round_ticks(tick_size, min, out var rounded_min, out var rounded_min_ticks));
|
||||
var min_partial_tick = TickTestHelper.check_partial_tick(spec, min, rounded_min, true);
|
||||
// max round/partial tick
|
||||
Assert.That(TickTestHelper.round_ticks(tick_size, max, out var rounded_max, out var rounded_max_ticks));
|
||||
var max_partial_tick = TickTestHelper.check_partial_tick(spec, max, rounded_max, false);
|
||||
var full_ticks = rounded_max_ticks - rounded_min_ticks;
|
||||
Assert.That(MathUtils.marginal_equals(rounded_max, spec.tickup(min, full_ticks + min_partial_tick), TickUtils.precision_const));
|
||||
Assert.That(MathUtils.marginal_equals(rounded_min, spec.tickup(max, -(full_ticks + max_partial_tick)), TickUtils.precision_const));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
using bts.api;
|
||||
using bts.resources;
|
||||
using bts.test;
|
||||
using bts.utils;
|
||||
using bts.utils.proto;
|
||||
using mbts.spark;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace bts.tests.security {
|
||||
static class TickTestHelper {
|
||||
public static IEnumerable<double> generate_test_prices(double tick_size, int radius = 200, double origin_price = 0) {
|
||||
Assert.That(radius > 0);
|
||||
var price_base_set = Enumerable.Range(-radius, radius * 2).Select(
|
||||
n => origin_price + tick_size * n);
|
||||
return generate_test_prices(price_base_set, new[] {
|
||||
0,
|
||||
MathUtils.epsilon,
|
||||
-MathUtils.epsilon,
|
||||
MathUtils.epsilon * 100,
|
||||
-MathUtils.epsilon * 100,
|
||||
tick_size * 0.02,
|
||||
-tick_size * 0.02,
|
||||
tick_size * 0.49,
|
||||
-tick_size * 0.49,
|
||||
tick_size * 0.99,
|
||||
-tick_size * 0.99,
|
||||
});
|
||||
}
|
||||
|
||||
public static IEnumerable<double> generate_test_prices(IEnumerable<double> price_base_set, IEnumerable<double> adjustments) =>
|
||||
price_base_set.Concat(
|
||||
adjustments.SelectMany(a => price_base_set.Select(p => p + a)));
|
||||
|
||||
public static IEnumerable<ContractSpecificationImmutable> read_contract_specs(string file_path) =>
|
||||
StreamHelper.ReadProtos<ContractSpecification>(ResourceHelper.LoadResource(file_path)).Select(s => new ContractSpecificationImmutable(s));
|
||||
|
||||
public static int? full_ticks_from_zero(ContractSpecificationImmutable tick, double value) {
|
||||
if (!value.is_real())
|
||||
return null;
|
||||
if (MathUtils.marginal_equals(value, 0, TickUtils.precision_const))
|
||||
return 0;
|
||||
bool low_tick_valid = tick.LowTick.is_real_positive();
|
||||
bool high_tick_valid = tick.HighTick.is_real_positive();
|
||||
if (low_tick_valid) {
|
||||
if (high_tick_valid) {
|
||||
if (value < 0) {
|
||||
if (tick.PriceBreak > value) {
|
||||
if (tick.PriceBreak >= 0) {
|
||||
return (int)MathUtils.round_up(value / tick.LowTick, TickUtils.precision_const);
|
||||
} else {
|
||||
var high_ticks = (int)MathUtils.round_up(tick.PriceBreak / tick.HighTick, TickUtils.precision_const);
|
||||
var low_ticks = (int)MathUtils.round_up((value - tick.PriceBreak) / tick.LowTick, TickUtils.precision_const);
|
||||
return high_ticks + low_ticks;
|
||||
}
|
||||
} else {
|
||||
return (int)MathUtils.round_up(value / (tick.PriceBreak.is_real() ? tick.HighTick : tick.LowTick), TickUtils.precision_const);
|
||||
}
|
||||
} else {
|
||||
if (tick.PriceBreak < value) {
|
||||
if (tick.PriceBreak <= 0) {
|
||||
return (int)MathUtils.round_down(value / tick.HighTick, TickUtils.precision_const);
|
||||
} else {
|
||||
var low_ticks = (int)MathUtils.round_down(tick.PriceBreak / tick.LowTick, TickUtils.precision_const);
|
||||
var high_ticks = (int)MathUtils.round_down((value - tick.PriceBreak) / tick.HighTick, TickUtils.precision_const);
|
||||
return low_ticks + high_ticks;
|
||||
}
|
||||
} else {
|
||||
return (int)MathUtils.round_down(value / (tick.PriceBreak.is_real() ? tick.LowTick : tick.HighTick), TickUtils.precision_const);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return (int)MathUtils.round_down_abs(value / tick.LowTick, TickUtils.precision_const);
|
||||
}
|
||||
} else if (high_tick_valid) {
|
||||
return (int)MathUtils.round_down_abs(value / tick.HighTick, TickUtils.precision_const);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool round_ticks(double tick_size, double value, out double rounded_value, out int rounded_ticks) {
|
||||
if (!value.is_real() || !tick_size.is_real_positive()) {
|
||||
rounded_value = double.NaN;
|
||||
rounded_ticks = 0;
|
||||
return false;
|
||||
}
|
||||
var ticks_to_val = value / tick_size;
|
||||
ticks_to_val = ticks_to_val > 0 ? Math.Floor(ticks_to_val) : Math.Ceiling(ticks_to_val);
|
||||
var rounded_down = ticks_to_val * tick_size;
|
||||
var one_tick_up_abs = value > 0 ? rounded_down + tick_size : rounded_down - tick_size;
|
||||
if (MathUtils.marginal_equals(one_tick_up_abs, value, TickUtils.precision_const)) {
|
||||
rounded_value = one_tick_up_abs;
|
||||
rounded_ticks = (int)(value > 0 ? ticks_to_val + 1 : ticks_to_val - 1);
|
||||
} else {
|
||||
rounded_value = rounded_down;
|
||||
rounded_ticks = (int)ticks_to_val;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the first tick in the specified direction should be a partial tick (to correct a rounding discrepency).
|
||||
/// If this is so, it asserts that ticking up/down once in that direction corrects the rounding discrepency as expected.
|
||||
/// </summary>
|
||||
public static int check_partial_tick(ContractSpecificationImmutable spec, double value, double rounded_value, bool ticking_up) {
|
||||
var partial_tick = count_partial_tick(value, rounded_value, ticking_up);
|
||||
if (partial_tick != 0)
|
||||
Assert.That(MathUtils.marginal_equals(spec.tickup(value, ticking_up ? partial_tick : -partial_tick), rounded_value, TickUtils.precision_const));
|
||||
return partial_tick;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the first tick in the specified direction should be a partial tick (to correct a rounding discrepency).
|
||||
/// </summary>
|
||||
public static int count_partial_tick(double value, double rounded_value, bool ticking_up) =>
|
||||
(ticking_up ? (rounded_value - value) : (value - rounded_value)) > TickUtils.precision_const ?
|
||||
1 : 0;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
@@ -17,6 +17,5 @@
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\KrandallOrderBookCrash.security_proto" />
|
||||
<EmbeddedResource Include="Resources\NonDeterministicICEFutures.security_proto" />
|
||||
<EmbeddedResource Include="Resources\SimContractSpecifications.contract_spec_proto" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1 +0,0 @@
|
||||
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)
|
||||
@@ -0,0 +1,405 @@
|
||||
import json
|
||||
import csv
|
||||
import datetime, time
|
||||
import argparse, os
|
||||
|
||||
|
||||
def valid_file(f):
|
||||
if not os.path.exists(f):
|
||||
# Argparse uses the ArgumentTypeError to give a rejection message like:
|
||||
# error: argument input: x does not exist
|
||||
raise argparse.ArgumentTypeError("{0} does not exist".format(f))
|
||||
return f
|
||||
|
||||
def valid_date(s):
|
||||
try:
|
||||
return datetime.datetime.strptime(s, "%Y%m%d")
|
||||
except ValueError:
|
||||
raise argparse.ArgumentTypeError("Not a valid date: '{0}'.".format(s))
|
||||
|
||||
def print_headers():
|
||||
# From https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+-+Minimum+Acceptable+Audit+Trail+Elements+-+Data+Definitions+and+Validation+Rules
|
||||
line_to_write = "Sending Timestamps,Message Direction,Operator ID,Session ID,Manual Order Indicator,Message Type,Instrument,Order Flow ID,\
|
||||
CME Globex Order ID,Client Order ID,Order Request ID,Buy/Sell Indicator,Quantity,Limit Price,Stop Price,Order Type,Order Qualifier,IFM Flag,\
|
||||
Display Quantity,Minimum Quantity,Country of Origin,Fill Price,Fill Quantity,Cumulative Quantity,Remaining Quantity,Aggressor Flag,Source of Cancellation,\
|
||||
Reject Reason,CME Globex Message ID,Cross ID,Quote Request ID,Message Quote ID,Quote Set ID,Quote Entry ID,Bid Price,Bid Size,Offer Price,Offer Size,\
|
||||
Processed Entries,Party Details List Request ID,ListUpdateAction,Self-Matching Prevention ID,Self-Match Prevention Instr,Customer Type Indicator,\
|
||||
AvgPxGroupID,Average Px Ind,CmtaGiveUpCD,Origin,Clearing Trade Price Type,Customer Handling Instr,Executing Firm ID,Account Number,Take Up Firm,Take up Account"
|
||||
|
||||
with open (args.output_file, 'w') as the_file:
|
||||
the_file.write(line_to_write)
|
||||
the_file.write("\n")
|
||||
|
||||
def set_blanks():
|
||||
return ""
|
||||
|
||||
def get_value(json_key):
|
||||
prices = ["Price", "LastPx", "StopPx"]
|
||||
if json_key in json_data:
|
||||
if json_key in prices:
|
||||
x = json_data[json_key]
|
||||
return x['mantissa']/100000000000
|
||||
else:
|
||||
return json_data[json_key]
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
# Column 1 - Sending Timestamps
|
||||
def SendingTimeEpoch(epochtime): #1
|
||||
#TIME = time.strftime('%Y%m%d-%H:%M:%S.{}'.format(epochtime/1000000000), time.gmtime(epochtime/1000000000))
|
||||
TIME = datetime.datetime.fromtimestamp(int(epochtime) / 1e9).strftime('%Y%m%d-%H:%M:%S.%f')
|
||||
return TIME
|
||||
|
||||
# Column 2 - Message Direction
|
||||
def direction(whichway):
|
||||
if whichway == '<':
|
||||
DIRECTION = "FROM CME"
|
||||
else:
|
||||
DIRECTION = "TO CME"
|
||||
return DIRECTION
|
||||
|
||||
# Column 3 - Operator ID
|
||||
def SenderID(sender):
|
||||
if "SenderID" in json_data:
|
||||
SENDER = json_data["SenderID"]
|
||||
return SENDER
|
||||
else:
|
||||
return SESSIONID
|
||||
|
||||
|
||||
# Column 4 - Session ID
|
||||
|
||||
# Column 5 - Manual Order Indicator
|
||||
def ManualOrderIndicator(manual):
|
||||
if "ManualOrderIndicator" in json_data:
|
||||
if manual == "Manual":
|
||||
return "1"
|
||||
else:
|
||||
return "0"
|
||||
|
||||
# Column 6 - Message Type
|
||||
def MessageType(msg_type,orderstatus):
|
||||
if msg_type == "NewOrderSingle514":
|
||||
return "D"
|
||||
elif msg_type == "ExecutionReportNew522":
|
||||
return "8--0"
|
||||
if "ExecutionReportTrade" in msg_type:
|
||||
if orderstatus == "PartiallyFilled":
|
||||
return "8--1"
|
||||
else:
|
||||
return "8--2"
|
||||
elif msg_type == "ExecutionReportCancel534":
|
||||
return "8--4"
|
||||
elif msg_type == "ExecutionReportModify531":
|
||||
return "8--5"
|
||||
elif msg_type == "ExecutionReportCancel534":
|
||||
return "8--H"
|
||||
elif msg_type == "ExecutionReportReject523":
|
||||
return "8--8"
|
||||
elif msg_type == "OrderCancelReplaceReject536":
|
||||
return "9--2"
|
||||
elif msg_type == "OrderCancelReject535":
|
||||
return "9--1"
|
||||
elif msg_type == "PartyDetailsDefinitionRequest518":
|
||||
return "CX"
|
||||
elif msg_type == "PartyDetailsDefinitionRequestAck519":
|
||||
return "CY"
|
||||
elif msg_type == "OrderCancelRequest516":
|
||||
return "F"
|
||||
elif msg_type == "OrderCancelReplaceRequest515":
|
||||
return "G"
|
||||
|
||||
|
||||
|
||||
# Column 12 - Buy-Sell Indicator/Side
|
||||
def Side(indicator):
|
||||
if "Side" in json_data:
|
||||
if indicator == "Buy":
|
||||
return "1"
|
||||
else:
|
||||
return "2"
|
||||
|
||||
# Column 16 - Order Type/OrdType
|
||||
def OrdType(ordertype):
|
||||
if "OrdType" in json_data:
|
||||
if ordertype == "MarketWithProtection" or ordertype == "MarketwithProtection":
|
||||
return "1"
|
||||
elif ordertype == "Limit":
|
||||
return "2"
|
||||
elif ordertype == "StopWithProtection" or ordertype == "StopwithProtection":
|
||||
return "3"
|
||||
elif ordertype == "StopLimit":
|
||||
return "4"
|
||||
elif ordertype == "MarketLimit":
|
||||
return "K"
|
||||
else:
|
||||
return ""
|
||||
|
||||
# Column 17 - Order Qualifier/TimeInForce
|
||||
def TimeInForce(orderqual):
|
||||
if "TimeInForce" in json_data:
|
||||
if orderqual == "Day":
|
||||
return "0"
|
||||
elif orderqual == "GTC":
|
||||
return "1"
|
||||
elif orderqual == "FAK":
|
||||
return "3"
|
||||
elif orderqual == "GTD":
|
||||
return "6"
|
||||
else:
|
||||
return ""
|
||||
|
||||
# Column 18 IFM Flag/OFMOverride
|
||||
def OFMOverride(imfflag):
|
||||
if "OFMOverride" in json_data:
|
||||
if imfflag == "Enabled":
|
||||
return "1"
|
||||
else:
|
||||
return "0"
|
||||
|
||||
# Column 19 Display Quantity/DisplayQty
|
||||
def DisplayQty(qty):
|
||||
if "DisplayQty" in json_data:
|
||||
if str(qty) == "0":
|
||||
return ""
|
||||
elif str(qty) == "4294967295":
|
||||
return ""
|
||||
else:
|
||||
return qty
|
||||
|
||||
|
||||
# Column 26 - Aggressor Flag/AggressorIndicator
|
||||
def AggressorIndicator(aggressor):
|
||||
if "AggressorIndicator" in json_data:
|
||||
if aggressor == "True":
|
||||
return "1"
|
||||
else:
|
||||
return "0"
|
||||
|
||||
# Column 27 - Source of Cancellation/ExecRestatementReason
|
||||
def ExecRestatementReason(sourcecancel):
|
||||
if "ExecRestatementReason" in json_data:
|
||||
if sourcecancel == "Exchange":
|
||||
return "8"
|
||||
elif sourcecancel == "CancelledNotBest":
|
||||
return "9"
|
||||
elif sourcecancel == "CancelOnDisconnect":
|
||||
return "100"
|
||||
elif sourcecancel == "CancelRestingDueToSelfMatchPrevention":
|
||||
return "103"
|
||||
elif sourcecancel == "CancelFromCMEGlobexCreditControlsViolation":
|
||||
return "104"
|
||||
elif sourcecancel == "CancelFromCMEOne":
|
||||
return "105"
|
||||
elif sourcecancel == "CancelFromRiskManagementAPI":
|
||||
return "106"
|
||||
elif sourcecancel == "CancelAggressingDueToSelfMatchPrevention":
|
||||
return "107"
|
||||
elif sourcecancel == "CancelDueToVolatilityQuoteOptionLessThanMinOrderSize":
|
||||
return "108"
|
||||
else:
|
||||
return ""
|
||||
|
||||
# Column 43 - Self-Match Prevention Instr/SelfMatchPreventionInstruction
|
||||
def SelfMatchPreventionInstruction(instr):
|
||||
if "SelfMatchPreventionInstruction" in json_data:
|
||||
if instr == "CancelOldest":
|
||||
return "O"
|
||||
elif instr == "CancelNewest":
|
||||
return "N"
|
||||
else:
|
||||
return ""
|
||||
|
||||
# Column 44 - Customer Type Indicator/CustOrderCapacity
|
||||
def CustOrderCapacity(custord):
|
||||
if "CustOrderCapacity" in json_data:
|
||||
if custord == "NULL_VALUE":
|
||||
return ""
|
||||
elif custord == "Membertradingfortheirownaccount":
|
||||
return "1"
|
||||
elif custord == "ClearingFirmtradingforitsproprietaryaccount":
|
||||
return "2"
|
||||
elif custord == "Membertradingforanothermember":
|
||||
return "3"
|
||||
else:
|
||||
return "4"
|
||||
|
||||
# Column 46 - Average Px Ind/AvgPxInd
|
||||
def AvgPxInd(avgpxindicator):
|
||||
if "AvgPxInd" in json_data:
|
||||
if avgpxindicator == "NULL_VALUE":
|
||||
return ""
|
||||
else:
|
||||
return avgpxindicator
|
||||
|
||||
# Column 48 - Origin/ClearingAccountType
|
||||
def ClearingAccountType(accounttype):
|
||||
if "ClearingAccountType" in json_data:
|
||||
if accounttype == "Customer":
|
||||
return "0"
|
||||
elif accounttype == "Firm":
|
||||
return "1"
|
||||
else:
|
||||
return ""
|
||||
|
||||
# Column 49 - Clearing Trade Price Type/ClearingTradePriceType
|
||||
def ClearingTradePriceType(clrtrdprice):
|
||||
if "ClearingTradePriceType" in json_data:
|
||||
if clrtrdprice == "NULL_VALUE":
|
||||
return "0"
|
||||
else:
|
||||
return "3"
|
||||
|
||||
# Column 50 - Customer Handling Instr/CustOrderHandlingInst
|
||||
def CustOrderHandlingInst(custorderinst):
|
||||
if "CustOrderHandlingInst" in json_data:
|
||||
if custorderinst == "ClientElectronic":
|
||||
return "C"
|
||||
elif custorderinst == "TEST":
|
||||
return "D"
|
||||
else:
|
||||
return ""
|
||||
|
||||
# Column 51 and 52 - Getting the Firm and Account Number
|
||||
def partyid(partydetailid,column):
|
||||
for x in partydetailid:
|
||||
role = x['PartyDetailRole']
|
||||
id = x['PartyDetailID']
|
||||
if column == "51" and role == "ExecutingFirm":
|
||||
return id
|
||||
if column == "52" and role == "CustomerAccount":
|
||||
return id
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("json_log", help="the json log[.gz] you wish to process", type=valid_file)
|
||||
parser.add_argument("output_file", help="the destination csv file you wish to write")
|
||||
parser.add_argument("-d", "--date", help="the date you wish to parse from the log, specified as YYYYmmdd",
|
||||
default=datetime.datetime.today().strftime("%Y%m%d"), type=valid_date)
|
||||
args = parser.parse_args()
|
||||
|
||||
print_headers()
|
||||
|
||||
list_types = ['NewOrderSingle514', 'OrderCancelReplaceRequest515', 'OrderCancelRequest516', 'PartyDetailsDefinitionRequest518', 'PartyDetailsDefinitionRequestAck519', \
|
||||
'ExecutionReportNew522', 'ExecutionReportReject523', 'ExecutionReportTradeOutright525', 'ExecutionReportTradeSpread526', 'ExecutionReportTradeSpreadLeg527', \
|
||||
'ExecutionReportModify531', 'ExecutionReportCancel534', 'OrderCancelReject535', 'OrderCancelReplaceReject536', ]
|
||||
|
||||
# Note that the timedeltas specificed in trade_day_start and trade_day_end
|
||||
# are based on Chicago times; as such, this script should run on a machine
|
||||
# set to a Chicago timezone. A future impromovement would be to determine
|
||||
# the current machine's timezone and determine the appropriate offset
|
||||
# versus Chicago time, but for now we assume this will run on a Chicago
|
||||
# tz machine.
|
||||
input_as_datetime = args.date
|
||||
trade_day_start = input_as_datetime - datetime.timedelta(days=1) + datetime.timedelta(hours=16, minutes=30)
|
||||
trade_day_utc_start = time.gmtime((time.mktime(trade_day_start.timetuple())))
|
||||
trade_day_end = input_as_datetime + datetime.timedelta(hours=16)
|
||||
trade_day_utc_end = time.gmtime((time.mktime(trade_day_end.timetuple())))
|
||||
|
||||
file_opener = None
|
||||
if args.json_log.endswith(".gz"):
|
||||
import gzip
|
||||
file_opener = gzip.open
|
||||
else:
|
||||
file_opener = open
|
||||
|
||||
|
||||
#inputFile = open(fileInput) #open json file
|
||||
#outputFile = open(fileOutput, 'w') #load csv file
|
||||
# Get Session
|
||||
with file_opener(args.json_log) as json_file:
|
||||
for line in json_file:
|
||||
data = json.loads(line)
|
||||
json_data = data['msg_json']
|
||||
if "Session" in json_data:
|
||||
SESSIONID = json_data["Session"]
|
||||
|
||||
#inputFile = open(fileInput) #open json file
|
||||
#outputFile = open(fileOutput, 'w') #load csv file
|
||||
with file_opener(args.json_log) as json_file:
|
||||
for line in json_file:
|
||||
data = json.loads(line)
|
||||
line_timestamp = time.strptime(data['time'], "%Y%m%d-%H:%M:%S.%f")
|
||||
if trade_day_utc_start <= line_timestamp <= trade_day_utc_end:
|
||||
json_data = data['msg_json']
|
||||
NAME = json_data["Name"]
|
||||
if NAME in list_types:
|
||||
EXECUTING_FIRM_ID = ""
|
||||
ACCOUNT_NUMBER = ""
|
||||
DIRECTION = direction(data['direction'])
|
||||
# Set Blanks
|
||||
blank_json = {'QuoteReqID': '', 'QuoteID': '', 'QuoteSetID': '', 'QuoteEntryID': '', 'BidPx': '', 'BidSize': '', 'OfferPx': '', \
|
||||
'OfferSize': '', 'NoProcessedEntries': '', 'ListUpdateAction': '', 'MinQty': '', 'AvgPxGroupID': '', \
|
||||
'CmtaGiveUpCD': '', 'TAKE_UP_FIRM': '', 'TAKE_UP_ACCOUNT': '',}
|
||||
|
||||
# No Data Processing
|
||||
straight_json = {'SecurityID': '', 'ClOrdID': '', 'OrderID': '', 'OrderRequestID': '', 'OrderQty': '', \
|
||||
'Location': '', 'LastQty': '', 'CumQty': '', 'LeavesQty': '', 'Text': '', 'SideTradeID': '', 'CrossID': '', 'SelfMatchPreventionID': '', \
|
||||
'Price': '', 'StopPx': '', 'LastPx': '', 'PartyDetailsListReqID': '', 'OrdStatus': ''}
|
||||
|
||||
# Processing Data
|
||||
process_json = {'SendingTimeEpoch': '', 'ManualOrderIndicator': '', 'SenderID': '', 'Side': '', 'OrdType': '', 'TimeInForce': '', \
|
||||
'OFMOverride': '', 'AggressorIndicator': '', 'ExecRestatementReason': '', 'SelfMatchPreventionInstruction': '', 'CustOrderCapacity': '', \
|
||||
'AvgPxInd': '', 'ClearingAccountType': '', 'ClearingTradePriceType': '', 'CustOrderHandlingInst': '', 'DisplayQty': ''}
|
||||
|
||||
for d in straight_json:
|
||||
test = get_value(d)
|
||||
if test != "None" or test != "":
|
||||
if "," in str(test):
|
||||
test = test.replace(",",";")
|
||||
if "4294967295" in str(test):
|
||||
test = ""
|
||||
if "us;" in str(test):
|
||||
test = test.upper()
|
||||
if d == "SelfMatchPreventionID" and len(str(test)) > 8:
|
||||
test = ""
|
||||
straight_json[d] = test
|
||||
else:
|
||||
straight_json[d] = ''
|
||||
|
||||
for d in process_json:
|
||||
if d in json_data:
|
||||
function = locals()[d]
|
||||
test = function(json_data[d])
|
||||
if test != "None":
|
||||
process_json[d] = test
|
||||
else:
|
||||
process_json[d] = ''
|
||||
elif d == "SenderID":
|
||||
function = locals()[d]
|
||||
test = function(SenderID)
|
||||
if test != "None":
|
||||
process_json[d] = test
|
||||
|
||||
# Party Message Fields
|
||||
# Column 51 - Executing Firm ID
|
||||
if "NoPartyDetails" in json_data:
|
||||
EXECUTING_FIRM_ID = partyid(json_data['NoPartyDetails'], "51")
|
||||
# Column 52 - Party Account Number
|
||||
ACCOUNT_NUMBER = partyid(json_data['NoPartyDetails'], "52")
|
||||
|
||||
line_to_write = process_json['SendingTimeEpoch'] + "," + DIRECTION + "," + process_json['SenderID'] + "," + SESSIONID + "," + process_json['ManualOrderIndicator'] + "," + \
|
||||
MessageType(NAME,straight_json['OrdStatus']) + "," + str(straight_json['SecurityID']) + "," + str(straight_json['ClOrdID']) + "," + str(straight_json['OrderID']) + "," + str(straight_json['ClOrdID']) + "," + \
|
||||
str(straight_json['OrderRequestID']) + "," + process_json['Side'] + "," + str(straight_json['OrderQty']) + "," + str(straight_json['Price']) + "," + \
|
||||
str(straight_json['StopPx']) + "," + process_json['OrdType'] + "," + process_json['TimeInForce'] + "," + process_json['OFMOverride'] + "," + str(process_json['DisplayQty']) + "," + \
|
||||
blank_json['MinQty'] + "," + straight_json['Location'] + "," + str(straight_json['LastPx']) + "," + str(straight_json['LastQty']) + "," + str(straight_json['CumQty']) + "," + \
|
||||
str(straight_json['LeavesQty']) + "," + process_json['AggressorIndicator'] + "," + process_json['ExecRestatementReason'] + "," + str(straight_json['Text']) + "," + \
|
||||
str(straight_json['SideTradeID']) + "," + str(straight_json['CrossID']) + "," + blank_json['QuoteReqID'] + "," + blank_json['QuoteID'] + "," + blank_json['QuoteSetID'] + "," + \
|
||||
blank_json['QuoteEntryID'] + "," + blank_json['BidPx'] + "," + blank_json['BidSize'] + "," + blank_json['OfferPx'] + "," + blank_json['OfferSize'] + "," + \
|
||||
blank_json['NoProcessedEntries'] + "," + str(straight_json['PartyDetailsListReqID']) + "," + blank_json['ListUpdateAction'] + "," + str(straight_json['SelfMatchPreventionID']) + "," + \
|
||||
process_json['SelfMatchPreventionInstruction'] + "," + process_json['CustOrderCapacity'] + "," + blank_json['AvgPxGroupID'] + "," + process_json['AvgPxInd'] + "," + \
|
||||
blank_json['CmtaGiveUpCD'] + "," + str(process_json['ClearingAccountType']) + "," + process_json['ClearingTradePriceType'] + "," + process_json['CustOrderHandlingInst'] + "," + \
|
||||
EXECUTING_FIRM_ID + "," + str(ACCOUNT_NUMBER) + "," + blank_json['TAKE_UP_FIRM'] + "," + blank_json['TAKE_UP_ACCOUNT']
|
||||
|
||||
|
||||
#print(line_to_write)
|
||||
|
||||
with open (args.output_file, 'a') as the_file:
|
||||
the_file.write(line_to_write)
|
||||
the_file.write("\n")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
#/bin/bash
|
||||
|
||||
function help_and_exit()
|
||||
{
|
||||
echo
|
||||
echo Usage: $0 [option]... config_file
|
||||
echo
|
||||
echo Can also be used in cron like the following
|
||||
echo 40 16 * * 1-5 /usr/bin/docker exec spark_10000 bash /sparkbin/data_files/audit_upload.sh /sparkdata/data/audit_uploads/example.conf
|
||||
echo example.conf included. The location of the conf file should be relative to the docker container, not the host
|
||||
echo
|
||||
echo Options are as follows:
|
||||
echo " -d|--date YYYYMMDD Example is 20180731"
|
||||
echo " Help: "
|
||||
echo " -h|--help Display this message."
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
DATE=$(date +%Y%m%d)
|
||||
ORIG_DIR=$(pwd)
|
||||
ERROR_LEVEL="0"
|
||||
|
||||
while getopts "d:h" option; do
|
||||
case $option in
|
||||
d) DATE=$OPTARG ;;
|
||||
h) help_and_exit;;
|
||||
\?) echo "Invalid option: -$OPTARG" >&2;
|
||||
exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
|
||||
CONFIG_FILE=$1
|
||||
|
||||
declare -A conf_vars; while read line; do conf_vars[${line%=*}]=${line#*=}; done <$CONFIG_FILE
|
||||
|
||||
SESSION_ID=${conf_vars[session_id]}
|
||||
FCM=${conf_vars[fcm]}
|
||||
CLIENT=${conf_vars[client]}
|
||||
|
||||
cd /sparkbin/data_files
|
||||
|
||||
for SESSION in $(ls /sparkdata/data/ilink3/); do
|
||||
if [[ $SESSION == *$SESSION_ID* ]]; then
|
||||
echo "Session is $SESSION"
|
||||
SESSION_DAY=$(date +%Y-%m-%d)
|
||||
if [[ $SESSION == "cme_"* ]]; then
|
||||
SESSION_DAY=$(date -d "$DATE -$(date -d $DATE +%u) days" +"%Y-%m-%d")
|
||||
AUDIT_SCRIPT="audit_ilink3.py"
|
||||
fi
|
||||
echo $SESSION_DAY
|
||||
if [[ ! -d /sparkdata/data/ilink3/$SESSION/audit_logs ]]; then
|
||||
mkdir -p /sparkdata/data/ilink3/$SESSION/audit_logs
|
||||
fi
|
||||
if [[ -d /sparkdata/data/ilink3/$SESSION/$SESSION_DAY ]]; then
|
||||
echo "Starting the creation of the audit log"
|
||||
python $AUDIT_SCRIPT -d $DATE /sparkdata/data/ilink3/$SESSION/$SESSION_DAY/log /sparkdata/data/ilink3/$SESSION/audit_logs/"$FCM"_audit_"$SESSION"_"$DATE".csv
|
||||
fi
|
||||
if [[ ! -d /sparkdata/data/md_audit ]]; then
|
||||
mkdir /sparkdata/data/md_audit
|
||||
fi
|
||||
if [[ -d /sparkdata/data/md_audit ]]; then
|
||||
# Running the MD Audit csv generation
|
||||
cd /sparkbin
|
||||
./sparkd adminreport md > /sparkdata/data/md_audit/"$FCM"_md_"$CLIENT"_"$DATE".csv
|
||||
cd /sparkbin/data_files
|
||||
fi
|
||||
echo "Uploading to the (s)FTP Server"
|
||||
python audit_uploader.py --config_file="$CONFIG_FILE" --datestamp $DATE --session="$SESSION" --client="$CLIENT" --fcm="$FCM"
|
||||
fi
|
||||
done
|
||||
Executable
+150
@@ -0,0 +1,150 @@
|
||||
import getopt, sys, datetime
|
||||
import paramiko, ftplib
|
||||
|
||||
#########################################################
|
||||
# Commandline Args #
|
||||
#########################################################
|
||||
|
||||
def usage():
|
||||
print "-------------------------------------------------------"
|
||||
print "-Usage: -"
|
||||
print "-------------------------------------------------------"
|
||||
print "- --config_file= : Path to upload config file -"
|
||||
print "- -if no path is specified look -"
|
||||
print "- in the working directory. -"
|
||||
print "- -"
|
||||
print "- --help : Print this message -"
|
||||
print "- -"
|
||||
print "- --datestamp= : Optional, defaults to today -"
|
||||
print "- -replaces *datestamp in the -"
|
||||
print "- the upload config file -"
|
||||
print "- -"
|
||||
print "- --fcm : Optional, spark input -"
|
||||
print "- -"
|
||||
print "- --session : Optional, spark jf session -"
|
||||
print "-------------------------------------------------------"
|
||||
|
||||
fcm = ''
|
||||
session = ''
|
||||
|
||||
try:
|
||||
options, arguments = getopt.getopt(sys.argv[1:],"h",['config_file=', 'datestamp=', 'help', 'fcm=', 'client=', 'session='])
|
||||
except getopt.GetoptError, err:
|
||||
print str(err)
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
for option, value in options:
|
||||
if option in ("-h","--h","-help","--help"):
|
||||
usage()
|
||||
sys.exit()
|
||||
elif option in ("-config_file","--config_file"):
|
||||
config_file = value
|
||||
elif option in ("-datestamp","--datestamp"):
|
||||
datestamp = value
|
||||
elif option in ("-fcm","--fcm"):
|
||||
fcm = value
|
||||
elif option in ("-client","--client"):
|
||||
client = value
|
||||
elif option in ("-session","--session"):
|
||||
session = value
|
||||
|
||||
for argument in arguments:
|
||||
if argument in ("h", "help"):
|
||||
usage()
|
||||
sys.exit()
|
||||
else:
|
||||
print "Unrecognized commandline argument. Type help for usage."
|
||||
sys.exit()
|
||||
|
||||
if len(options) <= 0:
|
||||
print "Requires a config file to run."
|
||||
usage()
|
||||
sys.exit()
|
||||
|
||||
|
||||
#########################################################
|
||||
# Read Config Function #
|
||||
#########################################################
|
||||
|
||||
def read_config_file(config_file, datestamp=datetime.datetime.today().strftime('%Y%m%d'), fcm=fcm, session=session):
|
||||
'''
|
||||
Parse our config file that gets passed in as a commandline parameter.
|
||||
All config keys must be of the form key=value. White space is ignored.
|
||||
All config keys must be seperated by a newline character.
|
||||
Called during initialization.
|
||||
'''
|
||||
upload_config = {}
|
||||
config_file = open(config_file, 'r')
|
||||
config_file = config_file.read()
|
||||
for config in config_file.split("\n"):
|
||||
if '=' in config:
|
||||
cleaned_key = config.split('=')[0].strip().upper()
|
||||
cleaned_value = config.split('=')[1].strip()
|
||||
if '*datestamp*' in cleaned_value:
|
||||
cleaned_value = cleaned_value.replace('*datestamp*',datestamp)
|
||||
if '*fcm*' in cleaned_value:
|
||||
cleaned_value = cleaned_value.replace('*fcm*',fcm)
|
||||
if '*client*' in cleaned_value:
|
||||
cleaned_value = cleaned_value.replace('*client*',client)
|
||||
if '*session*' in cleaned_value:
|
||||
cleaned_value = cleaned_value.replace('*session*',session)
|
||||
upload_config[cleaned_key] = cleaned_value
|
||||
else:
|
||||
pass
|
||||
return upload_config
|
||||
|
||||
#########################################################
|
||||
# FTP File Transfer Function #
|
||||
#########################################################
|
||||
def putfile_ftp(file, put_path, site, user, password, port=21, verbose=True):
|
||||
if verbose: print 'Uploading', file
|
||||
local = open(file, 'rb')
|
||||
remote = ftplib.FTP(site)
|
||||
remote.login(user, password)
|
||||
remote.storbinary(put_path, local, 1024)
|
||||
remote.quit()
|
||||
local.close()
|
||||
if verbose: print 'Upload done.'
|
||||
|
||||
#########################################################
|
||||
# SFTP File Transfer Function #
|
||||
#########################################################
|
||||
def putfile_sftp(file, put_path, site, username, password, port=22, verbose=True):
|
||||
transport = paramiko.Transport((site, port))
|
||||
transport.connect(username = username, password = password)
|
||||
sftp = paramiko.SFTPClient.from_transport(transport)
|
||||
sftp.put(file, put_path)
|
||||
sftp.close()
|
||||
transport.close()
|
||||
|
||||
|
||||
#########################################################
|
||||
# Main #
|
||||
#########################################################
|
||||
#if datestamp != None:
|
||||
# upload_config = read_config_file(config_file, datestamp)
|
||||
#else:
|
||||
# upload_config = read_config_file(config_file)
|
||||
|
||||
try:
|
||||
datestamp
|
||||
except NameError:
|
||||
upload_config = read_config_file(config_file)
|
||||
else:
|
||||
upload_config = read_config_file(config_file, datestamp)
|
||||
|
||||
|
||||
|
||||
print upload_config
|
||||
|
||||
if upload_config["PROTOCOL_PUT"] in ['FTP','ftp']:
|
||||
print "Protocol = FTP"
|
||||
putfile_ftp(upload_config["GET_ILINK3_FILE_PATH"] + upload_config["GET_ILINK3_FILE_NAME"], upload_config["PUT_ILINK3_FILE_PATH"] + upload_config["PUT_ILINK3_FILE_NAME"], upload_config["PUT_HOST"], upload_config["USERNAME_PUT"], upload_config["PASSWORD_PUT"], upload_config["PORT_PUT"] )
|
||||
putfile_ftp(upload_config["GET_MD_FILE_PATH"] + upload_config["GET_MD_FILE_NAME"], upload_config["PUT_MD_FILE_PATH"] + upload_config["PUT_MD_FILE_NAME"], upload_config["PUT_HOST"], upload_config["USERNAME_PUT"], upload_config["PASSWORD_PUT"], upload_config["PORT_PUT"] )
|
||||
elif upload_config["PROTOCOL_PUT"] in ['SFTP','sftp']:
|
||||
print "Protocol = SFTP"
|
||||
putfile_sftp(upload_config["GET_ILINK3_FILE_PATH"] + upload_config["GET_ILINK3_FILE_NAME"], upload_config["PUT_ILINK3_FILE_PATH"] + upload_config["PUT_ILINK3_FILE_NAME"], upload_config["PUT_HOST"], upload_config["USERNAME_PUT"], upload_config["PASSWORD_PUT"], int(upload_config["PORT_PUT"]) )
|
||||
putfile_sftp(upload_config["GET_MD_FILE_PATH"] + upload_config["GET_MD_FILE_NAME"], upload_config["PUT_MD_FILE_PATH"] + upload_config["PUT_MD_FILE_NAME"], upload_config["PUT_HOST"], upload_config["USERNAME_PUT"], upload_config["PASSWORD_PUT"], int(upload_config["PORT_PUT"]) )
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,16 @@
|
||||
fcm=FCM
|
||||
client=NAME
|
||||
session_id=ses
|
||||
put_host=ftpc.example.com
|
||||
port_put=2222
|
||||
username_put=user
|
||||
password_put=password
|
||||
protocol_put=sftp
|
||||
get_ilink3_file_path=/sparkdata/data/ilink3/*session*/audit_logs/
|
||||
put_ilink3_file_path=/
|
||||
get_ilink3_file_name=*fcm*_audit_*session*_*datestamp*.csv
|
||||
put_ilink3_file_name=*fcm*_audit_*session*_*datestamp*.csv
|
||||
get_md_file_path=/sparkdata/data/md_audit/
|
||||
put_md_file_path=/
|
||||
get_md_file_name=*fcm*_md_*client*_*datestamp*.csv
|
||||
put_md_file_name=*fcm*_md_*client*_*datestamp*.csv
|
||||
@@ -1 +0,0 @@
|
||||
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;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.cLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
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
|
||||
+29
-5
@@ -4,6 +4,10 @@ set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
||||
include(${CMAKE_SOURCE_DIR}/tools/safe_dep_glob.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/tools/Protobuf.cmake)
|
||||
|
||||
if (DEFINED DOTNET_BINARY_DIR OR DEFINED DOTNET_WINDOWS_BINARY_DIR)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/AddCopyBinariesTarget.cmake)
|
||||
endif()
|
||||
|
||||
# DEPENDENCIES
|
||||
file(GLOB_RECURSE Config_Protos RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} config/protos/*.proto)
|
||||
file (GLOB_RECURSE Service_Protos RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} api/services/*.proto)
|
||||
@@ -18,6 +22,7 @@ if (WIN32)
|
||||
domain_model/*.cpp
|
||||
expression/*.cpp
|
||||
logging/*.cpp
|
||||
io/*.cpp
|
||||
md/*.cpp
|
||||
os/*.cpp
|
||||
quickbus/*.cpp
|
||||
@@ -97,7 +102,8 @@ target_include_directories( libspark PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINA
|
||||
if (WIN32)
|
||||
target_link_libraries( libspark
|
||||
libcurl
|
||||
libfmt
|
||||
debug fmtd
|
||||
optimized fmt
|
||||
libtbb
|
||||
libboost_system
|
||||
libboost_thread
|
||||
@@ -107,7 +113,11 @@ if (WIN32)
|
||||
libboost_date_time
|
||||
libboost_atomic
|
||||
libprotobuf
|
||||
)
|
||||
libprotoc
|
||||
libssl
|
||||
libcrypto
|
||||
crypt32
|
||||
)
|
||||
else ()
|
||||
target_link_libraries( libspark
|
||||
protobuf
|
||||
@@ -135,11 +145,25 @@ else ()
|
||||
-ldl
|
||||
-static-libgcc
|
||||
-static-libstdc++
|
||||
-pthread)
|
||||
-pthread)
|
||||
|
||||
install(TARGETS libspark DESTINATION bin)
|
||||
endif()
|
||||
|
||||
# Copy binaries to Dotnet build dirs (for csprojs that depend on libspark)
|
||||
if (DEFINED DOTNET_BINARY_DIR)
|
||||
add_copy_binaries_target(
|
||||
copy_to_dotnet_binary_dir
|
||||
${DOTNET_BINARY_DIR}
|
||||
"Copy ${PROJECT_NAME} bins to Dotnet build dir")
|
||||
endif()
|
||||
if (DEFINED DOTNET_WINDOWS_BINARY_DIR)
|
||||
add_copy_binaries_target(
|
||||
copy_to_dotnet_windows_binary_dir
|
||||
${DOTNET_WINDOWS_BINARY_DIR}
|
||||
"Copy ${PROJECT_NAME} bins to Dotnet Windows build dir")
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
include(${CMAKE_SOURCE_DIR}/tools/vs_filters.cmake)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "lib/config/protos/system.pb.h"
|
||||
#include "lib/config/protos/Ports.pb.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#include <excpt.h>
|
||||
#endif
|
||||
|
||||
@@ -60,8 +60,8 @@ CAPI Quickbus* api_create_quickbus(const char* qbconfig, long length) {
|
||||
return new Quickbus(temp_conf);
|
||||
}
|
||||
|
||||
CAPI void api_destroy_quickbus(Quickbus* qbus) {
|
||||
#ifndef WIN32
|
||||
CAPI void api_destroy_quickbus(Quickbus *qbus) {
|
||||
#ifndef _WIN32
|
||||
if (qbus != nullptr) {
|
||||
delete qbus;
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ protected:
|
||||
ResponseHeader header;
|
||||
header.set_code(ApiError::SUCCESS);
|
||||
header.set_request_id(request_id);
|
||||
int header_size = header.ByteSize() + 1;
|
||||
int body_size = response.ByteSize();
|
||||
int header_size = header.ByteSizeLong() + 1;
|
||||
int body_size = response.ByteSizeLong();
|
||||
int total_size = header_size + body_size;
|
||||
if (total_size <= 1024) {
|
||||
uint8_t buffer[1024];
|
||||
|
||||
@@ -40,11 +40,11 @@ public:
|
||||
header.set_request_id(++_id);
|
||||
auto ptoken = _context.token();
|
||||
if (ptoken) header.mutable_token()->CopyFrom(*ptoken);
|
||||
int header_size = header.ByteSize()+1;
|
||||
int header_size = header.ByteSizeLong()+1;
|
||||
assert(header_size < 128);
|
||||
|
||||
std::string request_buffer;
|
||||
request_buffer.reserve(header_size + request.ByteSize());
|
||||
request_buffer.reserve(header_size + request.ByteSizeLong());
|
||||
request_buffer += (char)(header_size);
|
||||
bool success = header.AppendToString(&request_buffer);
|
||||
success = success && request.AppendToString(&request_buffer);
|
||||
@@ -77,8 +77,8 @@ public:
|
||||
|
||||
|
||||
template <typename T>
|
||||
rxcpp::observable<RawUpdate<std::shared_ptr<const T>>> subscribe(int method_id, const char* method, const std::string& qualifier) {
|
||||
return rxcpp::observable<>::create<RawUpdate<std::shared_ptr<const T>>>([=](rxcpp::subscriber<RawUpdate<std::shared_ptr<const T>>> observer) {
|
||||
rxcpp::observable<RawUpdate<std::shared_ptr<T>>> subscribe(int method_id, const char* method, const std::string& qualifier) {
|
||||
return rxcpp::observable<>::create<RawUpdate<std::shared_ptr<T>>>([=](rxcpp::subscriber<RawUpdate<std::shared_ptr<T>>> observer) {
|
||||
StreamAccessRequest request;
|
||||
request.set_qualifier(qualifier);
|
||||
send<StreamAccessRequest,StreamAccessResponse>(method_id, request, [=](const Result<StreamAccessResponse>& response) {
|
||||
@@ -95,11 +95,12 @@ public:
|
||||
bool first_update = true;
|
||||
auto cb = [observer, first_update, qualifier](EventType event_type, const StreamUpdate* changes, int change_count) mutable {
|
||||
if (event_type == EventType::TABLE_UPDATED) {
|
||||
std::vector<std::shared_ptr<const T>> added_items, changed_items;
|
||||
std::vector<std::shared_ptr<T>> added_items, changed_items;
|
||||
std::vector<int> added_keys,
|
||||
changed_keys,
|
||||
removed_keys;
|
||||
for (size_t x = 0; x < change_count; ++x) {
|
||||
for (std::size_t x = 0;
|
||||
x < static_cast<std::size_t>(change_count); ++x) {
|
||||
const StreamUpdate& change = changes[x];
|
||||
switch(change.type) {
|
||||
case StreamUpdate::REMOVE:
|
||||
@@ -115,11 +116,11 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
observer.on_next(RawUpdate<std::shared_ptr<const T>>(added_items, added_keys, changed_items, changed_keys, removed_keys));
|
||||
observer.on_next(RawUpdate<std::shared_ptr<T>>(added_items, added_keys, changed_items, changed_keys, removed_keys));
|
||||
}
|
||||
else if (event_type == EventType::TABLE_CREATED) {
|
||||
if (!first_update) {
|
||||
observer.on_next(RawUpdate<std::shared_ptr<const T>>::Reset());
|
||||
observer.on_next(RawUpdate<std::shared_ptr<T>>::Reset());
|
||||
}
|
||||
first_update = false;
|
||||
}
|
||||
|
||||
+101
-92
@@ -1,112 +1,121 @@
|
||||
#pragma once
|
||||
|
||||
#include "RawUpdate.h"
|
||||
#include <rxcpp/rx.hpp>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <rxcpp/rx.hpp>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace bts {
|
||||
namespace api {
|
||||
|
||||
template <typename T>
|
||||
class Change {
|
||||
T _old, _new;
|
||||
public:
|
||||
Change(const T& old_value, const T& new_value) : _old(old_value), _new(new_value) { }
|
||||
const T& previous() const { return _old; }
|
||||
const T& current() const { return _new; }
|
||||
};
|
||||
template <typename T> class Change {
|
||||
T _old, _new;
|
||||
|
||||
template <typename T, typename TKey, typename ServiceType>
|
||||
struct Update {
|
||||
Update(std::vector<T>& all, std::vector<T>& added, std::vector<Change<T>> changed, std::vector<T>& removed) :
|
||||
_all_items(std::move(all)),
|
||||
_added_items(std::move(added)),
|
||||
public:
|
||||
Change(const T &old_value, const T &new_value)
|
||||
: _old(old_value), _new(new_value) {}
|
||||
const T &previous() const { return _old; }
|
||||
const T ¤t() const { return _new; }
|
||||
};
|
||||
|
||||
template <typename T, typename TKey, typename ServiceType> struct Update {
|
||||
Update(
|
||||
std::vector<T> &all,
|
||||
std::vector<T> &added,
|
||||
std::vector<Change<T>> changed,
|
||||
std::vector<T> &removed)
|
||||
: _all_items(std::move(all)), _added_items(std::move(added)),
|
||||
_changed_items(std::move(changed)),
|
||||
_removed_items(std::move(removed))
|
||||
{}
|
||||
_removed_items(std::move(removed)) {}
|
||||
|
||||
Update(const Update& other) : _all_items(other._all_items),
|
||||
_added_items(other._added_items),
|
||||
_changed_items(other._changed_items),
|
||||
_removed_items(other._removed_items)
|
||||
{}
|
||||
|
||||
Update(Update&& other) :
|
||||
_all_items(std::move(other._all_items)),
|
||||
Update(const Update &other)
|
||||
: _all_items(other._all_items), _added_items(other._added_items),
|
||||
_changed_items(other._changed_items),
|
||||
_removed_items(other._removed_items) {}
|
||||
|
||||
Update(Update &&other)
|
||||
: _all_items(std::move(other._all_items)),
|
||||
_added_items(std::move(other._added_items)),
|
||||
_changed_items(std::move(other._changed_items)),
|
||||
_removed_items(std::move(other._removed_items))
|
||||
{}
|
||||
_removed_items(std::move(other._removed_items)) {}
|
||||
|
||||
TKey key(const T& t) const { return ServiceType::key(t); }
|
||||
const std::vector<T>& all() const { return _all_items; }
|
||||
const std::vector<T>& added() const { return _added_items; }
|
||||
const std::vector<Change<T>>& changed() const { return _changed_items; }
|
||||
const std::vector<T>& removed() const { return _removed_items; }
|
||||
TKey key(const T &t) const { return ServiceType::key(t); }
|
||||
const std::vector<T> &all() const { return _all_items; }
|
||||
const std::vector<T> &added() const { return _added_items; }
|
||||
const std::vector<Change<T>> &changed() const { return _changed_items; }
|
||||
const std::vector<T> &removed() const { return _removed_items; }
|
||||
|
||||
private:
|
||||
std::vector<T> _all_items;
|
||||
std::vector<T> _added_items;
|
||||
std::vector<Change<T>> _changed_items;
|
||||
std::vector<T> _removed_items;
|
||||
private:
|
||||
std::vector<T> _all_items;
|
||||
std::vector<T> _added_items;
|
||||
std::vector<Change<T>> _changed_items;
|
||||
std::vector<T> _removed_items;
|
||||
};
|
||||
|
||||
template <typename T, typename TKey, typename ServiceType>
|
||||
std::function<rxcpp::observable<Update<T, TKey, ServiceType>>(
|
||||
const rxcpp::observable<RawUpdate<T>> &)>
|
||||
reconstitute() {
|
||||
return [](const rxcpp::observable<RawUpdate<T>> &inputi) {
|
||||
auto *input_ptr = const_cast<rxcpp::observable<RawUpdate<T>>*>(&inputi);
|
||||
auto &input = *input_ptr;
|
||||
auto state = std::make_shared<std::unordered_map<int, T>>();
|
||||
return input.map([state](const RawUpdate<T> &craw) {
|
||||
auto *raw_ptr = const_cast<RawUpdate<T>*>(&craw);
|
||||
RawUpdate<T> &raw = *raw_ptr;
|
||||
if (raw.is_reset) {
|
||||
std::vector<T> removed;
|
||||
removed.reserve(state->size());
|
||||
for (auto &t : *state) {
|
||||
removed.push_back(std::move(t.second));
|
||||
}
|
||||
state->clear();
|
||||
std::vector<T> all, added;
|
||||
std::vector<Change<T>> changed;
|
||||
return Update<T, TKey, ServiceType>(all, added, changed, removed);
|
||||
} else {
|
||||
//
|
||||
// Remove
|
||||
std::vector<T> removed;
|
||||
removed.reserve(raw.removed_keys.size());
|
||||
for (int key : raw.removed_keys) {
|
||||
auto iter = state->find(key);
|
||||
if (iter != state->end()) {
|
||||
removed.push_back(iter->second);
|
||||
state->erase(iter);
|
||||
}
|
||||
}
|
||||
//
|
||||
// Add
|
||||
for (size_t x = 0; x < raw.added_keys.size(); ++x) {
|
||||
(*state)[raw.added_keys[x]] = raw.added_items[x];
|
||||
}
|
||||
//
|
||||
// Change
|
||||
std::vector<Change<T>> changed;
|
||||
changed.reserve(raw.changed_keys.size());
|
||||
for (size_t x = 0; x < raw.changed_keys.size(); ++x) {
|
||||
changed.push_back(Change<T>{
|
||||
(*state)[raw.changed_keys[x]], raw.changed_items[x]});
|
||||
(*state)[raw.changed_keys[x]] = raw.changed_items[x];
|
||||
}
|
||||
//
|
||||
// All
|
||||
std::vector<T> all;
|
||||
all.reserve(state->size());
|
||||
for (const auto &item : *state) {
|
||||
all.push_back(item.second);
|
||||
}
|
||||
|
||||
return Update<T, TKey, ServiceType>(
|
||||
all, raw.added_items, changed, removed);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T, typename TKey, typename ServiceType>
|
||||
std::function<rxcpp::observable<Update<T,TKey,ServiceType>>(const rxcpp::observable<RawUpdate<T>>&)> reconstitute() {
|
||||
return [](const rxcpp::observable<RawUpdate<T>>& input) {
|
||||
auto state = std::make_shared<std::unordered_map<int, T>>();
|
||||
return input.map([state](RawUpdate<T>& raw) {
|
||||
if (raw.is_reset) {
|
||||
std::vector<T> removed;
|
||||
removed.reserve(state->size());
|
||||
for (auto& t : *state) {
|
||||
removed.push_back(std::move(t.second));
|
||||
}
|
||||
state->clear();
|
||||
std::vector<T> all, added;
|
||||
std::vector<Change<T>> changed;
|
||||
return Update<T, TKey, ServiceType>(all, added, changed, removed);
|
||||
}
|
||||
else {
|
||||
//
|
||||
// Remove
|
||||
std::vector<T> removed;
|
||||
removed.reserve(raw.removed_keys.size());
|
||||
for (int key : raw.removed_keys) {
|
||||
auto iter = state->find(key);
|
||||
if (iter != state->end()) {
|
||||
removed.push_back(iter->second);
|
||||
state->erase(iter);
|
||||
}
|
||||
}
|
||||
//
|
||||
// Add
|
||||
for (size_t x = 0; x < raw.added_keys.size(); ++x) {
|
||||
(*state)[raw.added_keys[x]] = raw.added_items[x];
|
||||
}
|
||||
//
|
||||
// Change
|
||||
std::vector<Change<T>> changed;
|
||||
changed.reserve(raw.changed_keys.size());
|
||||
for (size_t x = 0; x < raw.changed_keys.size(); ++x) {
|
||||
changed.push_back(Change<T>{(*state)[raw.changed_keys[x]], raw.changed_items[x]});
|
||||
(*state)[raw.changed_keys[x]] = raw.changed_items[x];
|
||||
}
|
||||
//
|
||||
// All
|
||||
std::vector<T> all;
|
||||
all.reserve(state->size());
|
||||
for (const auto& item : *state) {
|
||||
all.push_back(item.second);
|
||||
}
|
||||
|
||||
return Update<T, TKey, ServiceType>(all, raw.added_items, changed, removed);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
} // namespace api
|
||||
} // namespace bts
|
||||
|
||||
|
||||
}}//namespace
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python
|
||||
import os, sys
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -30,8 +30,7 @@ import apioptions_pb2
|
||||
def loadTemplate(lang, name):
|
||||
path = os.path.join("templates", lang, name)
|
||||
text = open(path).read()
|
||||
utext = unicode(text, "utf-8")
|
||||
return compiler.compile(utext)
|
||||
return compiler.compile(text)
|
||||
|
||||
def option(options, key, default=None):
|
||||
if options.HasExtension(key):
|
||||
@@ -307,10 +306,9 @@ def generate_code(request, response):
|
||||
|
||||
#### MAIN #########
|
||||
if __name__ == "__main__":
|
||||
if DEBUG:
|
||||
data = open("data", mode='rb').read()
|
||||
else:
|
||||
data = sys.stdin.read()
|
||||
data_in = open(0, mode='rb')
|
||||
data = data_in.read()
|
||||
data_in.close()
|
||||
request = plugin.CodeGeneratorRequest()
|
||||
# open("data", 'wb').write(data)
|
||||
request.ParseFromString(data)
|
||||
@@ -319,8 +317,8 @@ if __name__ == "__main__":
|
||||
|
||||
if DEBUG:
|
||||
for f in response.file:
|
||||
print f.content
|
||||
print (f.content)
|
||||
else:
|
||||
output = response.SerializeToString()
|
||||
sys.stdout.write(output)
|
||||
sys.stdout.buffer.write(output)
|
||||
|
||||
Loaded 100 of 455 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user