Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d1b03d1e2 | ||
|
|
9a677cf980 | ||
|
|
25445d58d0 | ||
|
|
0b313a8aa8 | ||
|
|
54f954fd4b | ||
|
|
980f38ba03 | ||
|
|
9eada2724b | ||
|
|
b5f53ee918 | ||
|
|
efc175f654 | ||
|
|
6074afd999 | ||
|
|
219dff4055 | ||
|
|
9a3b07b622 |
No files matched your search
@@ -1,10 +1 @@
|
||||
IndentWidth: 3
|
||||
BinPackArguments: true
|
||||
BinPackParameters: false
|
||||
AlignAfterOpenBracket: AlwaysBreak
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
PenaltyReturnTypeOnItsOwnLine: 140
|
||||
---
|
||||
Language: Proto
|
||||
IndentWidth: 2
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-format": {
|
||||
"version": "5.1.225507",
|
||||
"commands": [
|
||||
"dotnet-format"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
-251
@@ -1,251 +0,0 @@
|
||||
# Remove the line below if you want to inherit .editorconfig settings from higher directories
|
||||
root = true
|
||||
|
||||
# C# files
|
||||
[*.cs]
|
||||
|
||||
#### Core EditorConfig Options ####
|
||||
|
||||
# Indentation and spacing
|
||||
indent_size = 3
|
||||
indent_style = space
|
||||
tab_width = 3
|
||||
|
||||
# New line preferences
|
||||
end_of_line = crlf
|
||||
insert_final_newline = true
|
||||
|
||||
#### .NET Coding Conventions ####
|
||||
|
||||
# Organize usings
|
||||
dotnet_separate_import_directive_groups = true
|
||||
dotnet_sort_system_directives_first = false
|
||||
file_header_template = unset
|
||||
|
||||
# this. and Me. preferences
|
||||
dotnet_style_qualification_for_event = false:silent
|
||||
dotnet_style_qualification_for_field = false:silent
|
||||
dotnet_style_qualification_for_method = false:silent
|
||||
dotnet_style_qualification_for_property = false:silent
|
||||
|
||||
# Language keywords vs BCL types preferences
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
|
||||
dotnet_style_predefined_type_for_member_access = true:silent
|
||||
|
||||
# Parentheses preferences
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
|
||||
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
|
||||
|
||||
# Modifier preferences
|
||||
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
|
||||
|
||||
# Expression-level preferences
|
||||
dotnet_style_coalesce_expression = true:suggestion
|
||||
dotnet_style_collection_initializer = true:suggestion
|
||||
dotnet_style_explicit_tuple_names = true:suggestion
|
||||
dotnet_style_null_propagation = true:suggestion
|
||||
dotnet_style_object_initializer = true:suggestion
|
||||
dotnet_style_operator_placement_when_wrapping = beginning_of_line
|
||||
dotnet_style_prefer_auto_properties = true:silent
|
||||
dotnet_style_prefer_compound_assignment = true:suggestion
|
||||
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
|
||||
dotnet_style_prefer_conditional_expression_over_return = true:silent
|
||||
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
|
||||
dotnet_style_prefer_inferred_tuple_names = true:suggestion
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
|
||||
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
|
||||
dotnet_style_prefer_simplified_interpolation = true:suggestion
|
||||
|
||||
# Field preferences
|
||||
dotnet_style_readonly_field = true:suggestion
|
||||
|
||||
# Parameter preferences
|
||||
dotnet_code_quality_unused_parameters = all:suggestion
|
||||
|
||||
# Suppression preferences
|
||||
dotnet_remove_unnecessary_suppression_exclusions = none
|
||||
|
||||
#### C# Coding Conventions ####
|
||||
|
||||
# var preferences
|
||||
csharp_style_var_elsewhere = false:silent
|
||||
csharp_style_var_for_built_in_types = false:silent
|
||||
csharp_style_var_when_type_is_apparent = false:silent
|
||||
|
||||
# Expression-bodied members
|
||||
csharp_style_expression_bodied_accessors = true:silent
|
||||
csharp_style_expression_bodied_constructors = false:silent
|
||||
csharp_style_expression_bodied_indexers = true:silent
|
||||
csharp_style_expression_bodied_lambdas = true:silent
|
||||
csharp_style_expression_bodied_local_functions = false:silent
|
||||
csharp_style_expression_bodied_methods = false:silent
|
||||
csharp_style_expression_bodied_operators = false:silent
|
||||
csharp_style_expression_bodied_properties = true:silent
|
||||
|
||||
# Pattern matching preferences
|
||||
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
|
||||
csharp_style_prefer_not_pattern = true:suggestion
|
||||
csharp_style_prefer_pattern_matching = true:silent
|
||||
csharp_style_prefer_switch_expression = true:suggestion
|
||||
|
||||
# Null-checking preferences
|
||||
csharp_style_conditional_delegate_call = true:suggestion
|
||||
|
||||
# Modifier preferences
|
||||
csharp_prefer_static_local_function = true:suggestion
|
||||
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent
|
||||
|
||||
# Code-block preferences
|
||||
csharp_prefer_braces = true:silent
|
||||
csharp_prefer_simple_using_statement = true:suggestion
|
||||
|
||||
# Expression-level preferences
|
||||
csharp_prefer_simple_default_expression = true:suggestion
|
||||
csharp_style_deconstructed_variable_declaration = true:suggestion
|
||||
csharp_style_inlined_variable_declaration = true:suggestion
|
||||
csharp_style_pattern_local_over_anonymous_function = true:suggestion
|
||||
csharp_style_prefer_index_operator = true:suggestion
|
||||
csharp_style_prefer_range_operator = true:suggestion
|
||||
csharp_style_throw_expression = true:suggestion
|
||||
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
|
||||
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
|
||||
|
||||
# 'using' directive preferences
|
||||
csharp_using_directive_placement = inside_namespace:silent
|
||||
|
||||
#### C# Formatting Rules ####
|
||||
|
||||
# New line preferences
|
||||
csharp_new_line_before_catch = false
|
||||
csharp_new_line_before_else = false
|
||||
csharp_new_line_before_finally = false
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_open_brace = none
|
||||
csharp_new_line_between_query_expression_clauses = true
|
||||
|
||||
# Indentation preferences
|
||||
csharp_indent_block_contents = true
|
||||
csharp_indent_braces = false
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_case_contents_when_block = true
|
||||
csharp_indent_labels = one_less_than_current
|
||||
csharp_indent_switch_labels = true
|
||||
|
||||
# Space preferences
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_after_comma = true
|
||||
csharp_space_after_dot = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = true
|
||||
csharp_space_after_semicolon_in_for_statement = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_around_declaration_statements = false
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_before_comma = false
|
||||
csharp_space_before_dot = false
|
||||
csharp_space_before_open_square_brackets = false
|
||||
csharp_space_before_semicolon_in_for_statement = false
|
||||
csharp_space_between_empty_square_brackets = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_name_and_open_parenthesis = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = false
|
||||
csharp_space_between_square_brackets = false
|
||||
|
||||
# Wrapping preferences
|
||||
csharp_preserve_single_line_blocks = true
|
||||
csharp_preserve_single_line_statements = true
|
||||
|
||||
#### Naming styles ####
|
||||
|
||||
# Naming rules
|
||||
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
|
||||
|
||||
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
|
||||
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
|
||||
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
|
||||
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
|
||||
|
||||
# Symbol specifications
|
||||
|
||||
dotnet_naming_symbols.interface.applicable_kinds = interface
|
||||
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.interface.required_modifiers =
|
||||
|
||||
# user types
|
||||
dotnet_naming_symbols.user_types.applicable_kinds = class, struct, interface, enum
|
||||
dotnet_naming_symbols.user_types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.user_types.required_modifiers =
|
||||
|
||||
# non_field_members
|
||||
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
|
||||
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.non_field_members.required_modifiers =
|
||||
|
||||
# public symbols
|
||||
dotnet_naming_symbols.public_symbols.applicable_kinds = property,method,field,event,delegate
|
||||
dotnet_naming_symbols.public_symbols.applicable_accessibilities = public,internal
|
||||
|
||||
# parameters
|
||||
dotnet_naming_symbols.parameters.applicable_kinds = parameter
|
||||
dotnet_naming_symbols.parameters.applicable_accessibilities = public,internal,protected,private,protected_internal,private_internal
|
||||
|
||||
# private symbols
|
||||
dotnet_naming_symbols.private_symbols.applicable_kinds = property,method,field,event,delegate
|
||||
dotnet_naming_symbols.private_symbols.applicable_accessibilities = protected,private
|
||||
|
||||
# Naming styles
|
||||
|
||||
dotnet_naming_style.snake_case.required_prefix =
|
||||
dotnet_naming_style.snake_case.required_suffix =
|
||||
dotnet_naming_style.snake_case.word_separator = _
|
||||
dotnet_naming_style.snake_case.capitalization = all_lower
|
||||
|
||||
dotnet_naming_style.private_snake_case.required_prefix = _
|
||||
dotnet_naming_style.private_snake_case.required_suffix =
|
||||
dotnet_naming_style.private_snake_case.word_separator = _
|
||||
dotnet_naming_style.private_snake_case.capitalization = all_lower
|
||||
|
||||
dotnet_naming_style.user_types.required_prefix =
|
||||
dotnet_naming_style.user_types.required_suffix =
|
||||
dotnet_naming_style.user_types.word_separator =
|
||||
dotnet_naming_style.user_types.capitalization = pascal_case
|
||||
|
||||
dotnet_naming_style.interface.required_prefix = I
|
||||
dotnet_naming_style.interface.required_suffix =
|
||||
dotnet_naming_style.interface.word_separator =
|
||||
dotnet_naming_style.interface.capitalization = pascal_case
|
||||
|
||||
# rules
|
||||
dotnet_naming_rule.user_types.symbols = user_types
|
||||
dotnet_naming_rule.user_types.style = user_types
|
||||
dotnet_naming_rule.user_types.severity = suggestion
|
||||
|
||||
dotnet_naming_rule.interfaces.symbols = interface
|
||||
dotnet_naming_rule.interfaces.style = interface_style
|
||||
dotnet_naming_rule.interfaces.severity = suggestion
|
||||
|
||||
dotnet_naming_rule.public_members_snake_case.symbols = public_symbols
|
||||
dotnet_naming_rule.public_members_snake_case.style = snake_case
|
||||
dotnet_naming_rule.public_members_snake_case.severity = suggestion
|
||||
|
||||
dotnet_naming_rule.private_members_snake_case.symbols = private_symbols
|
||||
dotnet_naming_rule.private_members_snake_case.style = private_snake_case
|
||||
dotnet_naming_rule.private_members_snake_case.severity = suggestion
|
||||
|
||||
dotnet_naming_rule.parameters.symbols = parameters
|
||||
dotnet_naming_rule.parameters.style = snake_case
|
||||
dotnet_naming_rule.parameters.severity = suggestion
|
||||
+2
-18
@@ -1,13 +1,11 @@
|
||||
nohup.out
|
||||
build/
|
||||
.build_proxy/
|
||||
cmake-build-debug/
|
||||
.cache/
|
||||
.ipynb_checkpoints/
|
||||
.idea/
|
||||
.dir-locals.el
|
||||
*.pyc
|
||||
**.vscode
|
||||
.vscode/*
|
||||
!.vscode/*.json
|
||||
.vs
|
||||
obj/
|
||||
*.csproj.user
|
||||
@@ -19,13 +17,10 @@ vcxproj.user
|
||||
src/client/spark/Properties/launchSettings.json
|
||||
compile_commands.json
|
||||
.cquery_cached_index/
|
||||
.cache/*
|
||||
.clangd/*
|
||||
src/client/sparkcmd/Properties/launchSettings.json
|
||||
node_modules
|
||||
paket-files
|
||||
project.lock.json
|
||||
src/.clang-format
|
||||
src/server/sparkd/orderman/perf_analysis/data
|
||||
src/server/sparkd/orderman/perf_analysis/logs/
|
||||
src/server/sparkd/orderman/perf_analysis/trace_data/
|
||||
@@ -39,15 +34,4 @@ trace_data/
|
||||
/doc/user/public/*
|
||||
.ionide/*
|
||||
/.ignore
|
||||
*.rej
|
||||
/build
|
||||
/build.*/*
|
||||
.clangd/
|
||||
*CMakeDeps.cmake
|
||||
/sniper.ipynb
|
||||
/src/.clang-format
|
||||
/src/server/sparkd/cmds/spartan/analysis/.ipynb_checkpoints
|
||||
/src/server/sparkd/cmds/spartan/analysis/data
|
||||
*.tmp/*
|
||||
/.venv*/*
|
||||
.cache/
|
||||
@@ -7,6 +7,3 @@
|
||||
[submodule "docker/windows"]
|
||||
path = docker/windows
|
||||
url = git@bitbucket.org:bluetradesys/windows_docker.git
|
||||
[submodule "src/deribit-crypto-connector-demo-application"]
|
||||
path = src/deribit-crypto-connector-demo-application
|
||||
url = git@gitlab.com:cryptoexchanges1/deribit-crypto-connector-demo-application.git
|
||||
File renamed without changes.
+370
-401
@@ -1,402 +1,371 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Spark Local",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/build/gcc/debug/server/sparkd",
|
||||
"args": [
|
||||
"run",
|
||||
"test",
|
||||
"-a",
|
||||
"OutrightVanillaOrder"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}/build/gcc/debug/server/",
|
||||
"environment": [
|
||||
{
|
||||
"name": "TZ",
|
||||
"value": "America/Chicago"
|
||||
}
|
||||
],
|
||||
"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/gcc/debug/server/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"-a",
|
||||
"[ilink3]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/gcc/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/gcc/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/gcc/debug/server/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"[spreader]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/gcc/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/gcc/debug/server/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"[algo]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/gcc/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/gcc/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
|
||||
}
|
||||
]
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"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
|
||||
},
|
||||
]
|
||||
}
|
||||
+3
-3
@@ -7,9 +7,9 @@
|
||||
"vector": "cpp",
|
||||
"xhash": "cpp",
|
||||
"xstring": "cpp",
|
||||
"system_error": "cpp",
|
||||
"array": "cpp",
|
||||
"string_view": "cpp"
|
||||
"system_error": "cpp",
|
||||
"array": "cpp",
|
||||
"string_view": "cpp"
|
||||
"xutility": "cpp",
|
||||
"*.ipp": "cpp"
|
||||
}
|
||||
File renamed without changes.
+39
-68
@@ -1,94 +1,65 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(spark)
|
||||
|
||||
if(WIN32)
|
||||
set(platform "windows")
|
||||
else()
|
||||
set(platform "linux")
|
||||
endif()
|
||||
if (WIN32)
|
||||
set (platform "windows")
|
||||
else ()
|
||||
set (platform "linux")
|
||||
endif ()
|
||||
|
||||
set(EXTERNALS_ROOT "${CMAKE_SOURCE_DIR}/externals/${platform}")
|
||||
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")
|
||||
set (EXTERNALS_ROOT "${CMAKE_SOURCE_DIR}/externals/${platform}")
|
||||
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}")
|
||||
|
||||
include_directories(BEFORE SYSTEM ${SPARK_INCLUDE} ${EXTERNALS_ROOT}/include/zlib)
|
||||
link_directories(${SPARK_LIB})
|
||||
include_directories (BEFORE SYSTEM ${SPARK_INCLUDE} ${EXTERNALS_ROOT}/include/zlib)
|
||||
link_directories (${SPARK_LIB})
|
||||
|
||||
if(WIN32)
|
||||
# flags
|
||||
set(
|
||||
CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} \
|
||||
/MP \
|
||||
/WX /wd4251 /wd4250 /wd4251 /wd4244 /wd4267 /wd4355 /wd4275 /wd4345 \
|
||||
/bigobj \
|
||||
/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")
|
||||
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")
|
||||
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")
|
||||
|
||||
# subdirs
|
||||
add_subdirectory(src/lib)
|
||||
else()
|
||||
# make sparkd look for libspark.so in its directory
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
set(CMAKE_INSTALL_RPATH ".")
|
||||
else ()
|
||||
# so that sparkd looks for libspark.so in its directory
|
||||
set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
set (CMAKE_INSTALL_RPATH ".")
|
||||
|
||||
# flags
|
||||
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_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wno-undef")
|
||||
|
||||
# subdirs
|
||||
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")
|
||||
add_subdirectory(src/server/sparkd)
|
||||
add_subdirectory(src/lib)
|
||||
add_subdirectory(src/web)
|
||||
add_subdirectory(doc/user)
|
||||
if(BUILD_SDK)
|
||||
add_subdirectory(src/sdk)
|
||||
endif()
|
||||
add_subdirectory(src/sdk)
|
||||
add_subdirectory(src/data_files)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/server
|
||||
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/server/sparkd/sparkd ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/web ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/data_files ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/lib/libspark.so ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND
|
||||
ln ARGS -sf
|
||||
${EXTERNALS_ROOT}/lib/Release/libOnixS.IceImpactMulticastPriceFeedHandlerCpp.so.3.16.0.0
|
||||
${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${EXTERNALS_ROOT}/lib/Release/libOnixS.IceImpactMulticastPriceFeedHandlerCpp.so.3.13.0.0 ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${EXTERNALS_ROOT}/lib/Release/libACE-5.7.5.so ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND mkdir ARGS -p ${CMAKE_BINARY_DIR}/server/plugins
|
||||
COMMENT "Creating server runtime layout"
|
||||
DEPENDS sparkd data_files_dir)
|
||||
DEPENDS sparkd data_files_dir)
|
||||
|
||||
add_custom_target(server_layout ALL DEPENDS ${CMAKE_BINARY_DIR}/server)
|
||||
endif()
|
||||
@@ -1,54 +0,0 @@
|
||||
{
|
||||
"FormattingOptions": {
|
||||
"NewLine": "\n",
|
||||
"UseTabs": false,
|
||||
"TabSize": 3,
|
||||
"IndentationSize": 3,
|
||||
"SpacingAfterMethodDeclarationName": false,
|
||||
"SpaceWithinMethodDeclarationParenthesis": false,
|
||||
"SpaceBetweenEmptyMethodDeclarationParentheses": false,
|
||||
"SpaceAfterMethodCallName": false,
|
||||
"SpaceWithinMethodCallParentheses": false,
|
||||
"SpaceBetweenEmptyMethodCallParentheses": false,
|
||||
"SpaceAfterControlFlowStatementKeyword": true,
|
||||
"SpaceWithinExpressionParentheses": false,
|
||||
"SpaceWithinCastParentheses": false,
|
||||
"SpaceWithinOtherParentheses": false,
|
||||
"SpaceAfterCast": false,
|
||||
"SpacesIgnoreAroundVariableDeclaration": false,
|
||||
"SpaceBeforeOpenSquareBracket": false,
|
||||
"SpaceBetweenEmptySquareBrackets": false,
|
||||
"SpaceWithinSquareBrackets": false,
|
||||
"SpaceAfterColonInBaseTypeDeclaration": true,
|
||||
"SpaceAfterComma": true,
|
||||
"SpaceAfterDot": false,
|
||||
"SpaceAfterSemicolonsInForStatement": true,
|
||||
"SpaceBeforeColonInBaseTypeDeclaration": true,
|
||||
"SpaceBeforeComma": false,
|
||||
"SpaceBeforeDot": false,
|
||||
"SpaceBeforeSemicolonsInForStatement": false,
|
||||
"SpacingAroundBinaryOperator": "single",
|
||||
"IndentBraces": false,
|
||||
"IndentBlock": true,
|
||||
"IndentSwitchSection": true,
|
||||
"IndentSwitchCaseSection": true,
|
||||
"LabelPositioning": "oneLess",
|
||||
"WrappingPreserveSingleLine": true,
|
||||
"WrappingKeepStatementsOnSingleLine": true,
|
||||
"NewLinesForBracesInTypes": false,
|
||||
"NewLinesForBracesInMethods": false,
|
||||
"NewLinesForBracesInProperties": false,
|
||||
"NewLinesForBracesInAccessors": false,
|
||||
"NewLinesForBracesInAnonymousMethods": false,
|
||||
"NewLinesForBracesInControlBlocks": false,
|
||||
"NewLinesForBracesInAnonymousTypes": false,
|
||||
"NewLinesForBracesInObjectCollectionArrayInitializers": false,
|
||||
"NewLinesForBracesInLambdaExpressionBody": false,
|
||||
"NewLineForElse": false,
|
||||
"NewLineForCatch": false,
|
||||
"NewLineForFinally": false,
|
||||
"NewLineForMembersInObjectInit": true,
|
||||
"NewLineForMembersInAnonymousTypes": true,
|
||||
"NewLineForClausesInQuery": true
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
FROM spark-crypto_18.04
|
||||
|
||||
RUN \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get update \
|
||||
&& apt-get install -y \
|
||||
htop \
|
||||
locales \
|
||||
source-highlight \
|
||||
powerline \
|
||||
fonts-powerline
|
||||
|
||||
|
||||
# Hide these in the .docker directory to avoid conflicts with existing repos on
|
||||
# this computer (in case a parent dir, such as $HOME, is mounted inside a
|
||||
# container)
|
||||
ARG repo_root="/home/john/Documents/repos/.docker"
|
||||
|
||||
# Create dirs for public/private repos
|
||||
USER john
|
||||
RUN \
|
||||
mkdir -p $repo_root/public \
|
||||
&& mkdir -p $repo_root/private
|
||||
|
||||
|
||||
## Get latest fish (build from source)
|
||||
# 1) get build deps
|
||||
USER root
|
||||
RUN \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get update \
|
||||
&& apt-get install -y software-properties-common
|
||||
RUN \
|
||||
apt-add-repository ppa:fish-shell/release-3 \
|
||||
&& sed -i "s/^# deb/deb/g" /etc/apt/sources.list
|
||||
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get build-dep -y fish
|
||||
|
||||
|
||||
# 2) Clone repo
|
||||
USER john
|
||||
RUN \
|
||||
cd $repo_root/public \
|
||||
&& git clone https://github.com/fish-shell/fish-shell.git
|
||||
|
||||
RUN \
|
||||
cd $repo_root/public/fish-shell \
|
||||
&& mkdir build \
|
||||
&& cd build \
|
||||
&& cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_DOCS=0 .. \
|
||||
&& cmake --build .
|
||||
|
||||
# Switch to root, rather than running inline w/ sudo cmd, to avoid having to
|
||||
# enter a password
|
||||
USER root
|
||||
RUN \
|
||||
cd $repo_root/public/fish-shell/build \
|
||||
&& make install
|
||||
USER john
|
||||
|
||||
|
||||
## Get oh-my-fish
|
||||
RUN \
|
||||
cd $repo_root/public \
|
||||
&& git clone https://github.com/oh-my-fish/oh-my-fish.git
|
||||
|
||||
RUN \
|
||||
cd $repo_root/public/oh-my-fish \
|
||||
&& ./bin/install --noninteractive --yes
|
||||
|
||||
|
||||
## Get my fish config
|
||||
RUN \
|
||||
cd $repo_root/private \
|
||||
&& git clone https://github.com/johncolvin-og/myfishconfig
|
||||
|
||||
RUN \
|
||||
cd $repo_root/private/myfishconfig \
|
||||
&& cp src/config.fish /home/john/.config/fish/ \
|
||||
&& cp src/aliases.fish /home/john/.config/fish/ \
|
||||
&& cp -r src/functions /home/john/.config/fish/ \
|
||||
&& cp -r src/themes/johncolvin /home/john/.local/share/omf/themes/ \
|
||||
&& fish --command "omf theme johncolvin"
|
||||
|
||||
|
||||
## Get my bash config (back up existing)
|
||||
RUN \
|
||||
cd $repo_root/private \
|
||||
&& git clone https://github.com/johncolvin-og/mybashconfig \
|
||||
&& cd mybashconfig \
|
||||
&& cp src/* /home/john/
|
||||
|
||||
|
||||
# Get vim files/tools
|
||||
USER root
|
||||
RUN \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get update \
|
||||
&& apt-get install -y curl
|
||||
USER john
|
||||
RUN curl -fLo home/john/.vim/autoload/plug.vim --create-dirs \
|
||||
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
|
||||
|
||||
# Some fonts look sketchy if the language isn't set to english:
|
||||
# * The powerline git glyphs in the fish prompt are all displayed as question
|
||||
# marks.
|
||||
#
|
||||
# * The shell confuses the position of the cursor, so characters are left
|
||||
# around when they should have been cleared, and the cursor's home position
|
||||
# is pushed one or two places to the right.
|
||||
#
|
||||
# * Most likely, the bad cursor position is caused by some dependencies the
|
||||
# interpretation of escape sequences have on the language setting. At this
|
||||
# point I don't even care anymore (literally took 8 hours to figure this
|
||||
# out). I just know this shit is needed to make the prompt work correctly.
|
||||
USER root
|
||||
RUN locale-gen "en_US.UTF-8"
|
||||
USER john
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LANGUAGE en_US:en
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
RUN fc-cache -vf
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env fish
|
||||
|
||||
set this_dir (realpath (dirname (status -f)))
|
||||
set image_working_dir (realpath "$this_dir/../..")
|
||||
|
||||
set image_name $argv[1]
|
||||
if test (count $argv) -eq 0
|
||||
set image_name_cmd "$this_dir/docker_image_name.fish"
|
||||
set image_name (eval $image_name_cmd)
|
||||
end
|
||||
|
||||
docker build \
|
||||
-f "$this_dir/Dockerfile" \
|
||||
-t "$image_name" \
|
||||
"$image_working_dir"
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env fish
|
||||
|
||||
if test (count $argv) -gt 0
|
||||
echo $argv
|
||||
exit 0
|
||||
end
|
||||
|
||||
set image_name_cmd (realpath (dirname (status -f)))"/docker_image_name.fish"
|
||||
set image_name (eval $image_name_cmd)
|
||||
echo $image_name
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env fish
|
||||
|
||||
echo "$USER""s_"(basename (git rev-parse --show-toplevel))"-dev"
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/usr/bin/env fish
|
||||
|
||||
set inst_name $argv[1]
|
||||
if test (count $argv) -eq 0
|
||||
set script_dir (realpath (dirname (status -f)))
|
||||
set inst_name (eval $script_dir"/docker_container_name.fish")
|
||||
end
|
||||
|
||||
set working_dir (realpath (pwd))
|
||||
echo $inst_name
|
||||
docker exec -w $working_dir -it "$inst_name" bash
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
#!/usr/bin/env fish
|
||||
|
||||
function print_help_and_exit
|
||||
echo "\
|
||||
Usage: setup_builds.sh [OPTIONS] compiler build-type
|
||||
|
||||
Positionals:
|
||||
gcc Compile with gcc
|
||||
clang Compile with clang
|
||||
debug Build debug
|
||||
release Build release
|
||||
|
||||
Options:
|
||||
--compiler <clang|gcc> Specify the compiler
|
||||
--type <debug|release> Specify the type of build
|
||||
-f,--force Overwrite existing build directories
|
||||
-h,--help Print this help message and exit
|
||||
|
||||
"
|
||||
exit $argv[1]
|
||||
end
|
||||
|
||||
function assert_dir
|
||||
if test ! -d "$argv[1]"
|
||||
if test -n "$argv[2]"
|
||||
echo "Invalid variable "$argv[2]": '"$argv[1]"' is not a directory"
|
||||
else
|
||||
echo "'"$argv[1]"' is not a directory"
|
||||
end
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
# common variables
|
||||
|
||||
set tools_path (realpath (dirname (status -f)))
|
||||
set spartan_path_cmd $tools_path/spartan_path.fish
|
||||
set repo_root (eval $spartan_path_cmd "repo-root")
|
||||
set build_root "$repo_root"/"build"
|
||||
mkdir -p "$build_root"
|
||||
|
||||
# Initialize the build directory. Expected arguments: <compiler>, <build_type>
|
||||
# Note: this method assumes the variables 'repot_root' and 'build_root' have
|
||||
# already been properly initialized
|
||||
function setup_build
|
||||
assert_dir $repo_root
|
||||
assert_dir $build_root
|
||||
set compiler "$argv[1]"
|
||||
set build_type "$argv[2]"
|
||||
|
||||
if test \( -z "$build_type" \) -o \( \( "$build_type" != debug \) -a \( "$build_type" != release \) \)
|
||||
print_help_and_exit 1
|
||||
end
|
||||
|
||||
if test "$build_type" = debug
|
||||
set build_type_arg Debug
|
||||
if test "$compiler" = gcc
|
||||
set compiler_arg "/usr/lib/ccache/g++"
|
||||
else
|
||||
# set compiler_arg "/usr/lib/ccache/clang++"
|
||||
set compiler_arg "clang++"
|
||||
end
|
||||
else if test "$build_type" = release
|
||||
set build_type_arg Release
|
||||
if test "$compiler" = gcc
|
||||
set compiler_arg "g++"
|
||||
else
|
||||
set compiler_arg "clang++"
|
||||
end
|
||||
end
|
||||
|
||||
if test \( -z "$compiler" \) -o \( \( "$compiler" != gcc \) -a \( "$compiler" != clang \) \)
|
||||
print_help_and_exit 1
|
||||
end
|
||||
|
||||
set build_dest $build_root"/"$compiler"/"$build_type
|
||||
|
||||
echo "Set up build: "$compiler" "$build_type
|
||||
|
||||
if test \( -z "$force" \) -a \( -d $build_dest \)
|
||||
echo "The build directory '"$build_dest"' already exists (use -f to overwrite)"
|
||||
return 1
|
||||
end
|
||||
|
||||
rm -rf "$build_dest"
|
||||
mkdir -p "$build_dest"
|
||||
cd "$build_dest"
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=$build_type_arg -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_COMPILER=$compiler_arg $repo_root
|
||||
end
|
||||
|
||||
# The while loop below removes arguments (via shift) as it parses them.
|
||||
# Additional information that needs to be extracted from the arguments must be
|
||||
# done so before the loop is executed.
|
||||
|
||||
set i 1
|
||||
while test $i -le (count $argv)
|
||||
switch $argv[$i]
|
||||
case --compiler
|
||||
set i (math "$i + 1")
|
||||
set compiler $argv[$i]
|
||||
case clang
|
||||
set compiler clang
|
||||
case gcc
|
||||
set compiler gcc
|
||||
case --type
|
||||
set i (math "$i + 1")
|
||||
set build_type $argv[$i]
|
||||
case release
|
||||
set build_type release
|
||||
case debug
|
||||
set build_type debug
|
||||
case -f
|
||||
set force 1
|
||||
case --force
|
||||
set force 1
|
||||
case -h
|
||||
print_help_and_exit 0
|
||||
case --help
|
||||
print_help_and_exit 0
|
||||
case '*'
|
||||
print_help_and_exit 1
|
||||
end
|
||||
set i (math "$i + 1")
|
||||
end
|
||||
|
||||
echo "compiler in "$compiler
|
||||
echo "build type in "$build_type
|
||||
if test -n "$compiler"
|
||||
if test -n "$build_type"
|
||||
setup_build $compiler $build_type
|
||||
else
|
||||
# all builds for the specified compiler
|
||||
setup_build $compiler debug
|
||||
setup_build $compiler release
|
||||
end
|
||||
else if test -n "$build_type"
|
||||
# all builds for the specified build type
|
||||
setup_build gcc $build_type
|
||||
setup_build clang $build_type
|
||||
else
|
||||
# all builds
|
||||
setup_build gcc debug
|
||||
setup_build gcc release
|
||||
setup_build clang debug
|
||||
setup_build clang release
|
||||
end
|
||||
@@ -1,153 +0,0 @@
|
||||
#!/usr/bin/env fish
|
||||
|
||||
function print_help_and_exit
|
||||
echo "\
|
||||
Usage: setup_builds.sh [OPTIONS] compiler build-type
|
||||
|
||||
Positionals:
|
||||
gcc Compile with gcc
|
||||
clang Compile with clang
|
||||
debug Build debug
|
||||
release Build release
|
||||
|
||||
Options:
|
||||
--compiler <clang|gcc> Specify the compiler
|
||||
--type <debug|release> Specify the type of build
|
||||
-f,--force Overwrite existing build directories
|
||||
-h,--help Print this help message and exit
|
||||
|
||||
"
|
||||
exit $argv[1]
|
||||
end
|
||||
|
||||
function assert_dir
|
||||
if test ! -d "$argv[1]"
|
||||
if test -n "$argv[2]"
|
||||
echo "Invalid variable "$argv[2]": '"$argv[1]"' is not a directory"
|
||||
else
|
||||
echo "'"$argv[1]"' is not a directory"
|
||||
end
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
# common variables
|
||||
|
||||
#set tools_path (readlink -f (pwd))
|
||||
#set tools_path (cd (dirname (status --current-filename)); and pwd)
|
||||
set tools_path (realpath (dirname (status -f)))
|
||||
set spartan_path_cmd $tools_path/spartan_path.fish
|
||||
set repo_root (eval $spartan_path_cmd "repo-root")
|
||||
# Don't call 'spartan_path_cmd "build"' bc it returns specific build path
|
||||
# (i.e., for a particular compiler/build type), not the root build path
|
||||
# set build_root (eval $spartan_path_cmd "build")
|
||||
set build_root "$repo_root"/"build"
|
||||
mkdir -p "$build_root"
|
||||
|
||||
# Initialize the build directory. Expected arguments: <compiler>, <build_type>
|
||||
# Note: this method assumes the variables 'repot_root' and 'build_root' have
|
||||
# already been properly initialized
|
||||
function setup_build
|
||||
assert_dir $repo_root
|
||||
assert_dir $build_root
|
||||
set compiler "$argv[1]"
|
||||
set build_type "$argv[2]"
|
||||
|
||||
if test \( -z "$build_type" \) -o \( \( "$build_type" != "debug" \) -a \( "$build_type" != "release" \) \)
|
||||
print_help_and_exit 1
|
||||
end
|
||||
|
||||
if test "$build_type" = "debug"
|
||||
set build_type_arg "Debug"
|
||||
if test "$compiler" = "gcc"
|
||||
set compiler_arg "/usr/lib/ccache/g++"
|
||||
else
|
||||
set compiler_arg "/usr/lib/ccache/clang++"
|
||||
end
|
||||
else if test "$build_type" = "release"
|
||||
set build_type_arg "Release"
|
||||
if test "$compiler" = "gcc"
|
||||
set compiler_arg "g++"
|
||||
else
|
||||
set compiler_arg "clang++"
|
||||
end
|
||||
end
|
||||
|
||||
if test \( -z "$compiler" \) -o \( \( "$compiler" != "gcc" \) -a \( "$compiler" != "clang" \) \)
|
||||
print_help_and_exit 1
|
||||
end
|
||||
|
||||
set build_dest $build_root"/"$compiler"/"$build_type
|
||||
set conan_dest $repo_root"/conan/"$compiler"_"$build_type
|
||||
|
||||
echo "Set up build: "$compiler" "$build_type
|
||||
|
||||
if test \( -z "$force" \) -a \( -d $build_dest \)
|
||||
echo "The build directory '"$build_dest"' already exists (use -f to overwrite)"
|
||||
return 1
|
||||
end
|
||||
|
||||
rm -rf "$build_dest"
|
||||
mkdir -p "$build_dest"
|
||||
mkdir -p "$conan_dest"
|
||||
cd "$build_dest"
|
||||
conan install --build missing --profile $conan_dest $repo_root
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=$build_type_arg -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_COMPILER=$compiler_arg $repo_root
|
||||
end
|
||||
|
||||
# The while loop below removes arguments (via shift) as it parses them.
|
||||
# Additional information that needs to be extracted from the arguments must be
|
||||
# done so before the loop is executed.
|
||||
|
||||
set i 1
|
||||
while test $i -le (count $argv)
|
||||
switch $argv[$i]
|
||||
case '--compiler'
|
||||
set i (math "$i + 1")
|
||||
set compiler $argv[$i]
|
||||
case 'clang'
|
||||
set compiler 'clang'
|
||||
case 'gcc'
|
||||
set compiler 'gcc'
|
||||
case '--type'
|
||||
set i (math "$i + 1")
|
||||
set build_type $argv[$i]
|
||||
case 'release'
|
||||
set build_type 'release'
|
||||
case 'debug'
|
||||
set build_type 'debug'
|
||||
case '-f'
|
||||
set force 1
|
||||
case '--force'
|
||||
set force 1
|
||||
case '-h'
|
||||
print_help_and_exit 0
|
||||
case '--help'
|
||||
print_help_and_exit 0
|
||||
case '*'
|
||||
print_help_and_exit 1
|
||||
end
|
||||
set i (math "$i + 1")
|
||||
end
|
||||
|
||||
echo "compiler in "$compiler
|
||||
echo "build type in "$build_type
|
||||
if test -n "$compiler"
|
||||
if test -n "$build_type"
|
||||
setup_build $compiler $build_type
|
||||
else
|
||||
# all builds for the specified compiler
|
||||
setup_build $compiler "debug"
|
||||
setup_build $compiler "release"
|
||||
end
|
||||
else if test -n "$build_type"
|
||||
# all builds for the specified build type
|
||||
setup_build "gcc" $build_type
|
||||
setup_build "clang" $build_type
|
||||
else
|
||||
# all builds
|
||||
setup_build "gcc" "debug"
|
||||
setup_build "gcc" "release"
|
||||
setup_build "clang" "debug"
|
||||
setup_build "clang" "release"
|
||||
end
|
||||
@@ -1,92 +0,0 @@
|
||||
#!/usr/bin/env fish
|
||||
|
||||
#basename (git rev-parse --show-toplevel)
|
||||
|
||||
function print_help_and_exit
|
||||
echo "\
|
||||
Print paths to core parts of the repository
|
||||
Usage: sparkd_path.sh SUBCOMMAND
|
||||
|
||||
Subcommands:
|
||||
build Print build path
|
||||
repo-root Print repo root path
|
||||
|
||||
"
|
||||
exit $argv[1]
|
||||
end
|
||||
|
||||
function print_build_help_and_exit
|
||||
echo "\
|
||||
Print build path
|
||||
Usage: sparkd_path.sh build [OPTIONS] compiler build-type
|
||||
|
||||
Positionals:
|
||||
gcc Print gcc build path
|
||||
clang Print clang build path
|
||||
debug Print debug build path
|
||||
release Print release build path
|
||||
|
||||
Options:
|
||||
--compiler <clang|gcc> Specify the compiler
|
||||
--type <debug|release> Specify the type of build
|
||||
-h,--help Print this help message and exit
|
||||
|
||||
"
|
||||
exit $argv[1]
|
||||
end
|
||||
|
||||
function print_repo_root
|
||||
git rev-parse --show-toplevel
|
||||
end
|
||||
|
||||
function run_repo_root
|
||||
print_repo_root
|
||||
end
|
||||
|
||||
function run_build
|
||||
set compiler "gcc"
|
||||
set build_type "release"
|
||||
set i 1
|
||||
while test $i -lt (count $argv)
|
||||
switch $argv[$i]
|
||||
case '--compiler'
|
||||
set i (math "$i + 1")
|
||||
set compiler $argv[$i]
|
||||
case 'clang'
|
||||
set compiler 'clang'
|
||||
case 'gcc'
|
||||
set compiler 'gcc'
|
||||
case '--type'
|
||||
set i (math "$i + 1")
|
||||
set build_type $argv[$i]
|
||||
case 'release'
|
||||
set build_type 'release'
|
||||
case 'debug'
|
||||
set build_type 'debug'
|
||||
'-h'
|
||||
print_build_help_and_exit 0
|
||||
'--help'
|
||||
print_build_help_and_exit 0
|
||||
'*'
|
||||
print_build_help_and_exit 1
|
||||
end
|
||||
set i (math "$i + 1")
|
||||
end
|
||||
if test \( $compiler = "clang" \) -o \( $compiler = "gcc" \)
|
||||
set comp_path $compiler
|
||||
else
|
||||
print_build_help_and_exit 1
|
||||
end
|
||||
set src_root (print_repo_root)
|
||||
set build_root (readlink -f "$src_root""/build")
|
||||
set build_dest $build_root"/"$compiler"/"$build_type
|
||||
echo $build_dest
|
||||
end
|
||||
|
||||
if test "$argv[1]" = "repo-root"
|
||||
print_repo_root $argv[2..-1]
|
||||
else if test "$argv[1]" = "build"
|
||||
run_build $argv[2..-1]
|
||||
else
|
||||
print_help_and_exit 1
|
||||
end
|
||||
@@ -1,43 +0,0 @@
|
||||
#!/usr/bin/env fish
|
||||
|
||||
set image_name $argv[1]
|
||||
set cont_name $argv[2]
|
||||
|
||||
if test (count $argv) -lt 2
|
||||
if test (count $argv) -lt 1
|
||||
set image_name_cmd (realpath (dirname (status -f)))"/docker_image_name.fish"
|
||||
set image_name (eval $image_name_cmd)
|
||||
end
|
||||
set cont_name_cmd (realpath (dirname (status -f)))"/docker_container_name.fish "$image_name
|
||||
set cont_name (eval $cont_name_cmd)
|
||||
end
|
||||
|
||||
set working_dir (realpath (pwd))
|
||||
|
||||
set home_path /home/john
|
||||
set repo_path (git rev-parse --show-toplevel)
|
||||
set repo_path_out /home/john/Documents/repos/bts/(basename $repo_path)
|
||||
set working_dir $repo_path_out
|
||||
|
||||
echo "starting docker instance '"$cont_name"' (image '"$image_name"')"
|
||||
echo "working dir "$working_dir
|
||||
|
||||
docker run \
|
||||
--rm \
|
||||
--net host \
|
||||
-h (hostname) \
|
||||
-e "TZ=America/New_York" \
|
||||
--cap-add=SYS_PTRACE \
|
||||
--security-opt seccomp=unconfined \
|
||||
--name $cont_name \
|
||||
-v $repo_path:$repo_path_out \
|
||||
-u (id -u $USER) \
|
||||
-w $working_dir \
|
||||
--shm-size=4024m \
|
||||
-t \
|
||||
-i \
|
||||
-d \
|
||||
-e DISPLAY="$DISPLAY" \
|
||||
"$image_name" \
|
||||
bash
|
||||
|
||||
@@ -1,513 +0,0 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Spark Local",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/build/gcc/debug/server/sparkd",
|
||||
"args": [
|
||||
"run",
|
||||
"test",
|
||||
"-a",
|
||||
"OutrightVanillaOrder"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}/build/gcc/debug/server/",
|
||||
"environment": [
|
||||
{
|
||||
"name": "TZ",
|
||||
"value": "America/Chicago"
|
||||
}
|
||||
],
|
||||
"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/gcc/debug/server/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"-a",
|
||||
"[ilink3]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/gcc/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/gcc/debug/server/sparkd/sparkd",
|
||||
"args": [
|
||||
"run"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}/build/gcc/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/gcc/debug/server/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"[spreader]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/gcc/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": "MD Synthetic Tests",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "/home/bts/spark/build/gcc/debug/server/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"[md][synthetic]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/gcc/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": "Spartan Tests",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "/home/bts/spark/build/gcc/debug/server/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"[spartan_md]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/gcc/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": "Matcher Tests",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "/home/bts/spark/build/gcc/debug/server/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"[matcher]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/gcc/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/gcc/debug/src/server/sparkd/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"[admin_service]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/gcc/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/gcc/debug/src/server/sparkd/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"[limiter]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/gcc/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/gcc/debug/server/sparkd",
|
||||
"args": [
|
||||
"test",
|
||||
"[algo]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/gcc/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/gcc/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,
|
||||
"python": "${command:python.interpreterPath}",
|
||||
"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/gcc/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
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Touch CMakeLists.txt",
|
||||
"type": "process",
|
||||
"promptOnClose": false,
|
||||
"isBackground": true,
|
||||
"command": "touch",
|
||||
"args": ["${workspaceRoot}/CMakeLists.txt"],
|
||||
"problemMatcher": [],
|
||||
"presentation": {
|
||||
"echo": false,
|
||||
"revealProblems": "onProblem",
|
||||
"reveal": "silent",
|
||||
"focus": false,
|
||||
"panel": "shared",
|
||||
"showReuseMessage": false,
|
||||
"clear": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
{
|
||||
"id": "build_configuration",
|
||||
"type": "pickString",
|
||||
"default": "debug",
|
||||
"description": "Configuration:",
|
||||
"options": ["debug", "release"]
|
||||
},
|
||||
{
|
||||
"id": "compiler",
|
||||
"type": "pickString",
|
||||
"default": "gcc",
|
||||
"description": "Compiler",
|
||||
"options": ["clang", "gcc"]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -124,17 +124,4 @@ service OrderService {
|
||||
```
|
||||
### C++ Example
|
||||
```cpp
|
||||
#include "lib/api/public/ServiceContext.h"
|
||||
#include "lib/api/services/OrderService.client.pb.h"
|
||||
using namespace bts::api;
|
||||
ServiceContext ctx;
|
||||
auto orders = ctx.locate<orderman::OrderService>();
|
||||
auto unsub = orders.subscribe_fills().subscribe([](const auto& update) {
|
||||
std::cout
|
||||
<< "Added " << update.added().size() << " items, "
|
||||
<< "Removed " << update.removed().size() << " items, "
|
||||
<< "Updated " << update.updated().size() << " items, "
|
||||
<< "Total items " << update.all().size() << std::endl;
|
||||
});
|
||||
std::this_thread::sleep_for(std::chrono::minutes(5));
|
||||
```
|
||||
@@ -1,51 +1,3 @@
|
||||
+++
|
||||
title = "Market Data"
|
||||
+++
|
||||
|
||||
|
||||
Use the MarketDataService to subscribe enumerate all available securities.
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using System.Threading;
|
||||
using bts.api;
|
||||
using bts.api.core;
|
||||
|
||||
namespace sample {
|
||||
class Program {
|
||||
static void Main(string[] args) {
|
||||
using var context = new ServiceContext();
|
||||
var md = context.locate<MarketDataService>();
|
||||
using var sub = md.subscribe_securities().Subscribe(update => {
|
||||
foreach (var security in update.added) {
|
||||
Console.WriteLine($"Added security {security.Id}: {security.Symbol}");
|
||||
}
|
||||
});
|
||||
|
||||
Thread.Sleep(TimeSpan.FromMinutes(5));
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```cpp
|
||||
#include "lib/api/public/ServiceContext.h"
|
||||
#include "spark/lib/domain_model/Security.h"
|
||||
#include "lib/api/services/MarketDataService.client.pb.h"
|
||||
#include <thread>
|
||||
|
||||
using namespace bts::api;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
ServiceContext ctx;
|
||||
auto md_service = ctx.locate<bts::api::MarketDataService>();
|
||||
auto sub = md_service.subscribe_securities().subscribe([](const auto& update) {
|
||||
for (const auto& s : update.added()) {
|
||||
std::cout << "Added security: " << s->id() << ": " << s->symbol() << std::endl;
|
||||
}
|
||||
});
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::minutes(5));
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
+++
|
||||
@@ -68,21 +68,12 @@ To update your Spark SDK simply download an unzip a new [spark_sdk.zip](https://
|
||||
|
||||
To preserve the old image so you can go back to it later run `docker tag spark_sdk spark_sdk:your_custom_tag` before loading the new SDK image.
|
||||
|
||||
### Re-build the Dev Container
|
||||
|
||||
If you are using Visual Studio Code you also need to rebuild the dev-container so it picks up the new image.
|
||||
|
||||
#### Inside VSCode
|
||||
To re-build from inside Visual Studio Code. Click the 'Remote Explorer' icon on the left hand side.
|
||||
You should see your spark_sdk project listed under the Containers section. Right click on it and select **rebuild-container**.
|
||||
|
||||
#### Command Line
|
||||
To re-build from the command line run `docker ps -a` and find the row with the spark_sdk image.
|
||||
<!--
|
||||
Then stop, remove and restart spark_sdk.
|
||||
```
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
54d96cfa3888 spark_sdk "/bin/sh -c 'echo Co…" About a minute ago Up About a minute 127.0.0.1:9000-9001->9000-9001/tcp quizzical_lichterman
|
||||
```
|
||||
Then run `docker rm 54d96cfa3888` (use your container id instead of 54d96cfa3888) or `docker rm quizzical_lichterman` (use your container name).
|
||||
|
||||
c:\bts> docker stop spark_sdk
|
||||
c:\bts> docker rm spark_sdk
|
||||
c:\bts> docker run -d -v %cd%:/sdk --name spark_sdk bluetradingsytems/spark_sdk
|
||||
|
||||
``` -->
|
||||
|
||||
@@ -1 +1 @@
|
||||
set(sources /home/taha/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)
|
||||
set(sources /home/ppinto/Dropbox/bts/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,29 +1,9 @@
|
||||
+++
|
||||
+++
|
||||
title = "Release notes"
|
||||
weight = 3
|
||||
sort_by = "weight"
|
||||
insert_anchor_links = "right"
|
||||
+++
|
||||
## 2.16.2
|
||||
### User Visible Change
|
||||
- Synthetic creation dialog has a "fractional" checkbox next to the tick settings. Users may uncheck this box to enter integer tick sizes, so the synthetic security's prices will be displayed without decimals, or fractional units.
|
||||
## 2.16.1
|
||||
### Bug Fixes
|
||||
- OrderBook's algo state parameters (in the panel on the right side) are sorted alphabetically
|
||||
## 2.16.0
|
||||
### Bug Fixes
|
||||
- Solved an issue that could result in incorrect ladder levels
|
||||
- Solved an issue that could lead to incorrect routing of orders in the event of certain MSGW changes
|
||||
### API Changes
|
||||
- Add C# client side API samples for order entry, position monitoring and market data observation
|
||||
|
||||
## 2.15.10
|
||||
### Bug Fixes
|
||||
- Solved an issue that could cause the user interface to fail when playing some alert sounds
|
||||
### API Changes
|
||||
- Added settlement and position information to the API
|
||||
- Added the ability for user algos to report custom state to the user interface
|
||||
- Added the ability for algos to discover all active securities
|
||||
## 2.15.3
|
||||
### Bug Fixes
|
||||
- Fixed a bug where some CME currency spreads exhibited incorrect tick values
|
||||
@@ -728,4 +708,3 @@ insert_anchor_links = "right"
|
||||
- Start, Day and Total PnL columns are painted with a red or green background color based on if the pnl value is negative or positive respectively
|
||||
- Corrected cash per point values, used in pnl calculations, for a number of products
|
||||
- PnL report will now remember any customizations you make to filtering and/or sorting criteria
|
||||
|
||||
+1
-1
Submodule docker/linux updated: 05967d0f18...0df20ec20a.
+1
-1
Submodule externals updated: 1dffb78a8e...c695e96940.
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "2.1.508",
|
||||
"rollForward": "latestMajor"
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"FormattingOptions": {
|
||||
"NewLineForCatch": false,
|
||||
"NewLineForClausesInQuery": true,
|
||||
"NewLineForElse": false,
|
||||
"NewLineForFinally": false,
|
||||
"NewLineForMembersInAnonymousTypes": true,
|
||||
"NewLineForMembersInObjectInit": true,
|
||||
"NewLinesForBracesInAccessors": false,
|
||||
"NewLinesForBracesInAnonymousMethods": false,
|
||||
"NewLinesForBracesInAnonymousTypes": false,
|
||||
"NewLinesForBracesInControlBlocks": false,
|
||||
"NewLinesForBracesInLambdaExpressionBody": false,
|
||||
"NewLinesForBracesInMethods": false,
|
||||
"NewLinesForBracesInObjectCollectionArrayInitializers": false,
|
||||
"NewLinesForBracesInProperties": false,
|
||||
"NewLinesForBracesInTypes": false,
|
||||
"TabSize": 3
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
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
|
||||
+163
-37
@@ -1,10 +1,10 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
# 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", "{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}"
|
||||
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
|
||||
@@ -12,87 +12,213 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sparkcmd", "src\client\spar
|
||||
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", "{A1B7276B-8F81-3D58-A22E-870AF28DF9B9}"
|
||||
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
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40} = {9FA60215-26AF-3EB7-AB89-D4F4B126EF40}
|
||||
{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
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.Debug|x64.Build.0 = Debug|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.Release|x64.ActiveCfg = Release|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.Release|x64.Build.0 = Release|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|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
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|x64.Build.0 = Debug|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|x64.ActiveCfg = Debug|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|x64.Build.0 = Debug|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|x64.ActiveCfg = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|x64.Build.0 = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.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
|
||||
{A1B7276B-8F81-3D58-A22E-870AF28DF9B9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{A1B7276B-8F81-3D58-A22E-870AF28DF9B9}.Debug|x64.Build.0 = Debug|x64
|
||||
{A1B7276B-8F81-3D58-A22E-870AF28DF9B9}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
|
||||
{A1B7276B-8F81-3D58-A22E-870AF28DF9B9}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
|
||||
{A1B7276B-8F81-3D58-A22E-870AF28DF9B9}.Release|x64.ActiveCfg = Release|x64
|
||||
{A1B7276B-8F81-3D58-A22E-870AF28DF9B9}.Release|x64.Build.0 = Release|x64
|
||||
{A1B7276B-8F81-3D58-A22E-870AF28DF9B9}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{A1B7276B-8F81-3D58-A22E-870AF28DF9B9}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|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
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Debug|x64.Build.0 = Debug|x64
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.MinSizeRel|x64.ActiveCfg = Debug|x64
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.MinSizeRel|x64.Build.0 = Debug|x64
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|x64.ActiveCfg = Release|x64
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|x64.Build.0 = Release|x64
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.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
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26730.10
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sparkd", "src\server\sparkd\sparkd.vcxproj", "{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspark", "build\src\lib\libspark.vcxproj", "{502FD050-679A-3B50-B438-098500700919}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
MinSizeRel|x64 = MinSizeRel|x64
|
||||
Release|x64 = Release|x64
|
||||
RelWithDebInfo|x64 = RelWithDebInfo|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.Debug|x64.Build.0 = Debug|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.Release|x64.ActiveCfg = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.Release|x64.Build.0 = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Debug|x64.Build.0 = Debug|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Release|x64.ActiveCfg = Release|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Release|x64.Build.0 = Release|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {6A7249D7-B40C-4656-9347-60072D0B8FDB}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26730.10
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sparkd", "src\server\sparkd\sparkd.vcxproj", "{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspark", "build\src\lib\libspark.vcxproj", "{502FD050-679A-3B50-B438-098500700919}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
MinSizeRel|x64 = MinSizeRel|x64
|
||||
Release|x64 = Release|x64
|
||||
RelWithDebInfo|x64 = RelWithDebInfo|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.Debug|x64.Build.0 = Debug|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.Release|x64.ActiveCfg = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.Release|x64.Build.0 = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Debug|x64.Build.0 = Debug|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Release|x64.ActiveCfg = Release|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Release|x64.Build.0 = Release|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {6A7249D7-B40C-4656-9347-60072D0B8FDB}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"chrono": "cpp",
|
||||
"future": "cpp",
|
||||
"system_error": "cpp",
|
||||
"ios": "cpp",
|
||||
"utility": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"xhash": "cpp",
|
||||
"xstring": "cpp",
|
||||
"xtree": "cpp",
|
||||
"xutility": "cpp",
|
||||
"exception": "cpp",
|
||||
"bitset": "cpp",
|
||||
"xlocale": "cpp"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ComputerSpecificConfig>..\..\tools\override\$(computername).props</ComputerSpecificConfig>
|
||||
<SparkRoot>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\..\..))</SparkRoot>
|
||||
<SourceRoot>$([System.IO.Path]::GetFullPath($(SparkRoot)\src))</SourceRoot>
|
||||
@@ -12,41 +12,53 @@
|
||||
<EnableDefaultContentItems>False</EnableDefaultContentItems>
|
||||
<ShowMissingItemTypes>false</ShowMissingItemTypes>
|
||||
<Configuration Condition="'$(configuration)'==''">Debug</Configuration>
|
||||
</PropertyGroup>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Label="Output">
|
||||
<PropertyGroup Label="Output">
|
||||
<BaseOutputPath>$(SparkRoot)\build\$(Configuration)</BaseOutputPath>
|
||||
<OutputPath>$(BaseOutputPath)\bin</OutputPath>
|
||||
<BaseIntermediateOutputPath>$(BaseOutputPath)\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<IntermediateOutputPath>$(BaseOutputPath)\obj\$(MSBuildProjectName)</IntermediateOutputPath>
|
||||
<GenDir>$(BaseOutputPath)\gen\$(MSBuildProjectName)</GenDir>
|
||||
</PropertyGroup>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import
|
||||
Project="$(ComputerSpecificConfig)"
|
||||
Condition="Exists($(ComputerSpecificConfig))" />
|
||||
<Import Project="$(ComputerSpecificConfig)" Condition="Exists($(ComputerSpecificConfig))" />
|
||||
|
||||
<PropertyGroup Label="ProtoBuf">
|
||||
<ItemGroup>
|
||||
<AvailableItemName Include="Proto2">
|
||||
<Targets>CompileProto3</Targets>
|
||||
</AvailableItemName>
|
||||
<AvailableItemName Include="Proto3">
|
||||
<Targets>CompileProto3</Targets>
|
||||
</AvailableItemName>
|
||||
<AvailableItemName Include="Proto3Excel">
|
||||
<Targets>CompileProto3Excel</Targets>
|
||||
</AvailableItemName>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Label="ProtoBuf">
|
||||
<ProtocPluginBase>$(SparkRoot)\src\lib\api\service_compiler</ProtocPluginBase>
|
||||
<ProtoInclude>$(Externals)\include</ProtoInclude>
|
||||
<protoc>$(Externals)\bin\protoc.exe</protoc>
|
||||
<protogen>$(Externals)\bin\protogen.exe</protogen>
|
||||
</PropertyGroup>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemDefinitionGroup>
|
||||
<Proto2></Proto2>
|
||||
<ItemDefinitionGroup>
|
||||
<Proto2>
|
||||
</Proto2>
|
||||
<Proto3>
|
||||
<OutBase>$(IntermediateOutputPath)\gen\%(relativedir)</OutBase>
|
||||
<OutCS>%(OutBase)%(FileName).cs</OutCS>
|
||||
<OutCSClient>%(OutBase)%(FileName).client.pb.cs</OutCSClient>
|
||||
<OutCSServer>%(OutBase)%(FileName).server.pb.cs</OutCSServer>
|
||||
<OutCSImmutable>%(OutBase)%(FileName).immutable.pb.cs</OutCSImmutable>
|
||||
<CompileOptions></CompileOptions>
|
||||
<OutBase>$(IntermediateOutputPath)\gen\%(relativedir)</OutBase>
|
||||
<OutCS>%(OutBase)%(FileName).cs</OutCS>
|
||||
<OutCSClient>%(OutBase)%(FileName).client.pb.cs</OutCSClient>
|
||||
<OutCSServer>%(OutBase)%(FileName).server.pb.cs</OutCSServer>
|
||||
<OutCSImmutable>%(OutBase)%(FileName).immutable.pb.cs</OutCSImmutable>
|
||||
<CompileOptions></CompileOptions>
|
||||
</Proto3>
|
||||
<Proto3Excel>
|
||||
<OutBase>$(IntermediateOutputPath)\gen\%(relativedir)</OutBase>
|
||||
<OutCSExcel>%(OutBase)%(FileName).excel.pb.cs</OutCSExcel>
|
||||
<CompileOptions></CompileOptions>
|
||||
</Proto3Excel>
|
||||
</ItemDefinitionGroup>
|
||||
<OutBase>$(IntermediateOutputPath)\gen\%(relativedir)</OutBase>
|
||||
<OutCSExcel>%(OutBase)%(FileName).excel.pb.cs</OutCSExcel>
|
||||
<CompileOptions></CompileOptions>
|
||||
</Proto3Excel>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,85 +1,97 @@
|
||||
<Project>
|
||||
|
||||
<Target
|
||||
Name="CompileProto2"
|
||||
Condition="'@(Proto2)'!=''"
|
||||
Inputs="$(MSBuildProjectFile);$(protogen);%(Proto2.FullPath)"
|
||||
Outputs="$(GenDir)\proto2\%(Proto2.filename).cs"
|
||||
AfterTargets="PreBuildEvent">
|
||||
<PropertyGroup>
|
||||
<SourceRelativeFile>$([System.String]::Copy('%(proto2.fullpath)').Replace($(SourceRoot), ''))</SourceRelativeFile>
|
||||
<SourceRelativeDir>$([System.IO.Path]::GetDirectoryName($(SourceRelativeFile)))</SourceRelativeDir>
|
||||
<WorkingDirectory>$(GenDir)\proto2</WorkingDirectory>
|
||||
</PropertyGroup>
|
||||
<MakeDir Directories="$(WorkingDirectory)" />
|
||||
<Copy
|
||||
SourceFiles="%(Proto2.FullPath)"
|
||||
DestinationFolder="$(WorkingDirectory)"
|
||||
SkipUnchangedFiles="True"
|
||||
UseHardLinksIfPossible="True" />
|
||||
<Error
|
||||
Text="protogen.exe does not exist. If you forgot to clone with externals try: git submodule update --init --recursive"
|
||||
Condition="!Exists($(protogen))" />
|
||||
<Exec
|
||||
Command="$(Protogen) %(Proto2.filename)%(proto2.extension) --csharp_out=. -I. -I$(SourceRoot) -I$(Externals)\include"
|
||||
WorkingDirectory="$(WorkingDirectory)" />
|
||||
<ItemGroup>
|
||||
<Compile Include="$(WorkingDirectory)\%(Proto2.filename).cs" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Run this after GetAssemblyVersion because it happens after the Xaml compiler
|
||||
and exists in both xaml and non-xaml projects. One of the (many) xaml compile
|
||||
passes wipes out the additional compile includes that we add.
|
||||
-->
|
||||
<Target
|
||||
Name="CompileProto3"
|
||||
AfterTargets="GetAssemblyVersion"
|
||||
Condition="'@(Proto3)'!=''"
|
||||
Inputs="$(protoc);
|
||||
%(Proto3.Identity);$(ProtocPluginBase)\plugin.py;
|
||||
$(ProtocPluginBase)\templates\c#\client.pb.cs;
|
||||
$(ProtocPluginBase)\templates\c#\server.pb.cs;
|
||||
$(ProtocPluginBase)\templates\c#\immutable.pb.cs;"
|
||||
Outputs="%(Proto3.OutCS);%(Proto3.OutCSServer);%(Proto3.OutCSClient);%(Proto3.OutCSImmutable)">
|
||||
<MakeDir Directories="%(Proto3.OutBase)" />
|
||||
|
||||
<Message
|
||||
Importance="High"
|
||||
Text="Generating service %(Proto3.FileName)" />
|
||||
<Exec Command="$(SparkRoot)\.venv\Scripts\activate.bat" />
|
||||
<Exec Command="set PYTHONPATH=$(SparkRoot)\.venv\Scripts\python" />
|
||||
<Exec
|
||||
Command="
|
||||
$(SparkRoot)\tools\build_protos.cmd ^
|
||||
%(Proto3.FullPath) ^
|
||||
--error_format=msvs ^
|
||||
--proto_path=$(SourceRoot) ^
|
||||
--plugin="protoc-gen-service=$(ProtocPluginBase)\plugin.cmd" ^
|
||||
--service_out=lang=c#,strip_out_path=1:%(Proto3.OutBase) ^
|
||||
--csharp_out=%(CompileOptions)%(Proto3.OutBase)"
|
||||
WorkingDirectory="%(relativedir)" />
|
||||
<ItemGroup>
|
||||
<Compile Include="%(Proto3.OutCS)" />
|
||||
<Compile Include="%(Proto3.OutCSClient)" />
|
||||
<Compile Include="%(Proto3.OutCSServer)" />
|
||||
<Compile Include="%(Proto3.OutCSImmutable)" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<Target
|
||||
Name="AfterClean"
|
||||
AfterTargets="Clean">
|
||||
<Delete Files="%(Proto3.OutCS)" />
|
||||
<Delete Files="%(Proto3.OutCSClient)" />
|
||||
<Delete Files="%(Proto3.OutCSServer)" />
|
||||
<Delete Files="%(Proto3.OutCSImmutable)" />
|
||||
<Delete Files="$(GenDir)\proto2\*" />
|
||||
</Target>
|
||||
|
||||
<Target
|
||||
Name="Test"
|
||||
DependsOnTargets="Build"></Target>
|
||||
|
||||
</Project>
|
||||
<Project>
|
||||
|
||||
|
||||
|
||||
<Target Name="CompileProto2"
|
||||
Condition="'@(Proto2)'!=''"
|
||||
Inputs="$(MSBuildProjectFile);$(protogen);%(Proto2.FullPath)"
|
||||
Outputs="$(GenDir)\proto2\%(Proto2.filename).cs"
|
||||
AfterTargets="PreBuildEvent">
|
||||
<PropertyGroup>
|
||||
<SourceRelativeFile>$([System.String]::Copy('%(proto2.fullpath)').Replace($(SourceRoot), ''))</SourceRelativeFile>
|
||||
<SourceRelativeDir>$([System.IO.Path]::GetDirectoryName($(SourceRelativeFile)))</SourceRelativeDir>
|
||||
<WorkingDirectory>$(GenDir)\proto2</WorkingDirectory>
|
||||
</PropertyGroup>
|
||||
<MakeDir Directories="$(WorkingDirectory)" />
|
||||
<Copy SourceFiles="%(Proto2.FullPath)" DestinationFolder="$(WorkingDirectory)" SkipUnchangedFiles="True" UseHardLinksIfPossible="True" />
|
||||
<Error Text="protogen.exe does not exist. If you forgot to clone with externals try: git submodule update --init --recursive" Condition="!Exists($(protogen))" />
|
||||
<Exec Command="$(Protogen) %(Proto2.filename)%(proto2.extension) --csharp_out=. -I. -I$(SourceRoot) -I$(Externals)\include"
|
||||
WorkingDirectory="$(WorkingDirectory)" />
|
||||
<ItemGroup>
|
||||
<Compile Include="$(WorkingDirectory)\%(Proto2.filename).cs" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Run this after GetAssemblyVersion because it happens after the Xaml compiler
|
||||
and exists in both xaml and non-xaml projects. One of the (many) xaml compile
|
||||
passes wipes out the additional compile includes that we add.
|
||||
-->
|
||||
<Target Name="CompileProto3" AfterTargets="GetAssemblyVersion"
|
||||
Condition="'@(Proto3)'!=''"
|
||||
Inputs="$(protoc);
|
||||
%(Proto3.Identity);$(ProtocPluginBase)\plugin.py;
|
||||
$(ProtocPluginBase)\templates\c#\client.pb.cs;
|
||||
$(ProtocPluginBase)\templates\c#\server.pb.cs;
|
||||
$(ProtocPluginBase)\templates\c#\immutable.pb.cs;"
|
||||
Outputs="%(Proto3.OutCS);%(Proto3.OutCSServer);%(Proto3.OutCSClient);%(Proto3.OutCSImmutable)">
|
||||
<MakeDir Directories="%(Proto3.OutBase)" />
|
||||
|
||||
<Message Importance="High" Text="Generating service %(Proto3.FileName)" />
|
||||
<Exec Command="
|
||||
set PATH=$(spark_build_python_path);%path% &
|
||||
set PYTHONPATH=$(Externals)\python &
|
||||
$(protoc) ^
|
||||
%(Proto3.FullPath) ^
|
||||
--error_format=msvs ^
|
||||
--proto_path=$(protoinc);$(SourceRoot) ^
|
||||
--plugin="protoc-gen-service=$(ProtocPluginBase)\plugin.cmd" ^
|
||||
--service_out=lang=c#,strip_out_path=1:%(Proto3.OutBase) ^
|
||||
--csharp_out=%(CompileOptions)%(Proto3.OutBase)"
|
||||
WorkingDirectory="%(relativedir)" />
|
||||
<ItemGroup>
|
||||
<Compile Include="%(Proto3.OutCS)" />
|
||||
<Compile Include="%(Proto3.OutCSClient)" />
|
||||
<Compile Include="%(Proto3.OutCSServer)" />
|
||||
<Compile Include="%(Proto3.OutCSImmutable)" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<Target Name="CompileProto3Excel" AfterTargets="GetAssemblyVersion"
|
||||
Condition="'@(Proto3Excel)'!=''"
|
||||
Inputs="$(protoc);
|
||||
%(Proto3Excel.Identity);$(ProtocPluginBase)\plugin.py;
|
||||
$(ProtocPluginBase)\templates\excel\excel.pb.cs;"
|
||||
Outputs="%(Proto3Excel.OutCSExcel)">
|
||||
<MakeDir Directories="%(Proto3Excel.OutBase)" />
|
||||
|
||||
<Message Importance="High" Text="Generating excel service %(Proto3Excel.FileName)" />
|
||||
<Exec Command="
|
||||
set PATH=$(spark_build_python_path);%path% &
|
||||
set PYTHONPATH=$(Externals)\python &
|
||||
$(protoc) ^
|
||||
%(Proto3Excel.FullPath) ^
|
||||
--error_format=msvs ^
|
||||
--proto_path=$(protoinc);$(SourceRoot) ^
|
||||
--plugin="protoc-gen-service=$(ProtocPluginBase)\plugin.cmd" ^
|
||||
--service_out=lang=excel,strip_out_path=1:%(Proto3Excel.OutBase) ^
|
||||
"
|
||||
WorkingDirectory="%(relativedir)" />
|
||||
<ItemGroup>
|
||||
<Compile Include="%(Proto3Excel.OutCSExcel)" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<Target Name="AfterClean" AfterTargets="Clean">
|
||||
<Delete Files="%(Proto3.OutCS)" />
|
||||
<Delete Files="%(Proto3.OutCSClient)" />
|
||||
<Delete Files="%(Proto3.OutCSServer)" />
|
||||
<Delete Files="%(Proto3.OutCSImmutable)" />
|
||||
<Delete Files="$(GenDir)\proto2\*" />
|
||||
<Delete Files="%(Proto3Excel.OutCSExcel)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="Test" DependsOnTargets="Build">
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
@@ -1,146 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using mbts.analytics;
|
||||
using mbts.ui;
|
||||
using mbts.ui.shell;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
class AnalyticsExpirationParametersRowVM : DisposableViewModelBase, ISelectable, IEquatable<AnalyticsExpirationParametersRowVM> {
|
||||
readonly AnalyticsExpirationParameters _committed_value;
|
||||
readonly Property<bool> _is_selected;
|
||||
|
||||
readonly Property<SecurityExpiration> _driver;
|
||||
readonly Property<SecurityExpiration> _deliverable;
|
||||
readonly Property<SecurityExpiration> _roll_schedule;
|
||||
readonly Property<double> _roll_target;
|
||||
readonly Property<double> _riskless_rate;
|
||||
readonly Property<double> _settlement_price;
|
||||
readonly Property<double> _delta_beta;
|
||||
readonly Property<double> _vega_beta;
|
||||
|
||||
readonly Property<bool> _is_driver_dirty;
|
||||
readonly Property<bool> _is_deliverable_dirty;
|
||||
readonly Property<bool> _is_roll_schedule_dirty;
|
||||
readonly Property<bool> _is_roll_target_dirty;
|
||||
readonly Property<bool> _is_riskless_rate_dirty;
|
||||
readonly Property<bool> _is_settlement_price_dirty;
|
||||
readonly Property<bool> _is_delta_beta_dirty;
|
||||
readonly Property<bool> _is_vega_beta_dirty;
|
||||
readonly Property<bool> _is_dirty;
|
||||
|
||||
bool _is_last_row_of_month_group;
|
||||
|
||||
public AnalyticsExpirationParametersRowVM(AnalyticsExpirationParametersVM owner, AnalyticsExpirationParameters committed_value) {
|
||||
this.owner = owner ?? throw new ArgumentNullException(nameof(owner));
|
||||
_committed_value = committed_value ?? throw new ArgumentNullException(nameof(committed_value));
|
||||
security = committed_value.security ?? throw new ArgumentException("security must be non-null", nameof(committed_value));
|
||||
|
||||
_is_selected = backing(nameof(is_selected), false);
|
||||
_is_selected.Changed += (oldval, newval) => is_selected_changed?.Invoke(newval);
|
||||
|
||||
var is_dirty_srcs = new List<IObservable<bool>>();
|
||||
(_driver, _is_driver_dirty) = mk_cell_props(nameof(driver), committed_value.driver_security);
|
||||
(_deliverable, _is_deliverable_dirty) = mk_cell_props(nameof(deliverable), committed_value.deliverable_security);
|
||||
(_roll_schedule, _is_roll_schedule_dirty) = mk_cell_props(nameof(roll_schedule), committed_value.roll_schedule_expiration);
|
||||
(_roll_target, _is_roll_target_dirty) = mk_cell_props(nameof(roll_target), committed_value.roll_target);
|
||||
(_riskless_rate, _is_riskless_rate_dirty) = mk_cell_props(nameof(riskless_rate), committed_value.riskless_rate);
|
||||
(_settlement_price, _is_settlement_price_dirty) = mk_cell_props(nameof(settlement_price), committed_value.settlement_price);
|
||||
(_delta_beta, _is_delta_beta_dirty) = mk_cell_props(nameof(delta_beta), committed_value.delta_beta);
|
||||
(_vega_beta, _is_vega_beta_dirty) = mk_cell_props(nameof(vega_beta), committed_value.vega_beta);
|
||||
|
||||
_is_dirty = backing(
|
||||
nameof(is_dirty),
|
||||
Observable.CombineLatest(is_dirty_srcs).Select(dirties => dirties.Any()).OnDispatcher());
|
||||
|
||||
(Property<T> prop, Property<bool> dirty_prop) mk_cell_props<T>(string name, T orig_val) {
|
||||
var prop = backing(name, orig_val);
|
||||
var dirty_src = prop.observe_current(true).Select(new_val => !Equals(new_val, orig_val));
|
||||
is_dirty_srcs.Add(dirty_src);
|
||||
var dirty_prop = backing($"is_{prop.name}_dirty", dirty_src);
|
||||
return (prop, dirty_prop);
|
||||
}
|
||||
}
|
||||
|
||||
public event Action<bool> is_selected_changed;
|
||||
|
||||
public AnalyticsExpirationParametersVM owner { get; }
|
||||
public SecurityExpiration security { get; }
|
||||
public SecurityExpiration driver { get => _driver.Value; set => _driver.set(value); }
|
||||
public SecurityExpiration deliverable { get => _deliverable.Value; set => _deliverable.set(value); }
|
||||
public SecurityExpiration roll_schedule { get => _roll_schedule.Value; set => _roll_schedule.set(value); }
|
||||
public AnalyticsExpirationParameters original_params => _committed_value;
|
||||
|
||||
public double roll_target { get => _roll_target.Value; set => _roll_target.set(value); }
|
||||
public double riskless_rate { get => _riskless_rate.Value; set => _riskless_rate.set(value); }
|
||||
public double settlement_price { get => _settlement_price.Value; set => _settlement_price.set(value); }
|
||||
public double delta_beta { get => _delta_beta.Value; set => _delta_beta.set(value); }
|
||||
public double vega_beta { get => _vega_beta.Value; set => _vega_beta.set(value); }
|
||||
|
||||
public bool is_driver_dirty => _is_driver_dirty.Value;
|
||||
public bool is_deliverable_dirty => _is_deliverable_dirty.Value;
|
||||
public bool is_roll_schedule_dirty => _is_roll_schedule_dirty.Value;
|
||||
public bool is_roll_target_dirty => _is_roll_target_dirty.Value;
|
||||
public bool is_riskless_rate_dirty => _is_riskless_rate_dirty.Value;
|
||||
public bool is_settlement_price_dirty => _is_settlement_price_dirty.Value;
|
||||
public bool is_delta_beta_dirty => _is_delta_beta_dirty.Value;
|
||||
public bool is_vega_beta_dirty => _is_vega_beta_dirty.Value;
|
||||
public bool is_dirty => _is_dirty.Value;
|
||||
|
||||
public bool is_selected {
|
||||
get => _is_selected.Value;
|
||||
set => _is_selected.set(value);
|
||||
}
|
||||
|
||||
public bool is_last_row_of_month_group {
|
||||
get => _is_last_row_of_month_group;
|
||||
set => Set(ref _is_last_row_of_month_group, value);
|
||||
}
|
||||
|
||||
public AnalyticsExpirationParameters candidate_value => new(
|
||||
security,
|
||||
driver,
|
||||
deliverable.is_empty() ? null : deliverable,
|
||||
roll_schedule.is_empty() ? null : roll_schedule,
|
||||
roll_target,
|
||||
riskless_rate,
|
||||
settlement_price,
|
||||
delta_beta,
|
||||
vega_beta);
|
||||
|
||||
public IObservable<SecurityExpiration> observe_roll_schedule() =>
|
||||
_roll_schedule.observe_current(true);
|
||||
|
||||
public IObservable<bool> observe_roll_schedule_dirty() =>
|
||||
_is_roll_schedule_dirty.observe_current(true);
|
||||
|
||||
public IObservable<bool> observe_is_dirty() =>
|
||||
_is_dirty.observe_current(true);
|
||||
|
||||
public void revert() {
|
||||
driver = _committed_value.driver_security;
|
||||
deliverable = _committed_value.deliverable_security;
|
||||
roll_schedule = _committed_value.roll_schedule_expiration;
|
||||
roll_target = _committed_value.roll_target;
|
||||
riskless_rate = _committed_value.riskless_rate;
|
||||
settlement_price = _committed_value.settlement_price;
|
||||
delta_beta = _committed_value.delta_beta;
|
||||
vega_beta = _committed_value.vega_beta;
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
$"sec: {security}; drv: {driver}; dlv: {deliverable}; roll: {roll_schedule} @ {roll_target}";
|
||||
|
||||
public bool Equals(AnalyticsExpirationParametersRowVM other) =>
|
||||
other is not null &&
|
||||
security.Equals(other.security);
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
Equals(obj as AnalyticsExpirationParametersRowVM);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
security.GetHashCode();
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using ProtoBuf;
|
||||
|
||||
[ProtoContract]
|
||||
class AnalyticsExpirationParametersSettings {
|
||||
public const int VERSION = 1;
|
||||
|
||||
public static AnalyticsExpirationParametersSettings Default => new();
|
||||
|
||||
[ProtoMember(10)]
|
||||
public string[] selected_symbols {get;set;}
|
||||
|
||||
[ProtoMember(20)]
|
||||
public bool auto_copy_rates_is_checked {get;set;}
|
||||
|
||||
[ProtoMember(30)]
|
||||
public bool auto_copy_rolls_is_checked {get;set;}
|
||||
}
|
||||
}
|
||||
@@ -1,236 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using bts.api;
|
||||
using bts.reactive;
|
||||
using bts.utils;
|
||||
|
||||
using mbts;
|
||||
using mbts.analytics;
|
||||
using mbts.collections;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.utility;
|
||||
using mbts.utils;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
class AnalyticsExpirationParametersVM : DisposableViewModelBase, IHandleRowSelection {
|
||||
readonly IBus _bus;
|
||||
readonly ObservableCollection<AnalyticsExpirationParameters> _parameters = new();
|
||||
readonly DeferrableActionWrapper _sync_visible_rows;
|
||||
readonly Property<AnalyticsExpirationParametersRowVM> _copy_row_source;
|
||||
readonly DelegateProperty<bool> _is_dirty;
|
||||
readonly HashSet<AnalyticsExpirationParametersRowVM> _selected_rows = new();
|
||||
|
||||
AnalyticsExpirationParametersMap _parameter_map;
|
||||
bool _auto_copy_rolls_is_checked;
|
||||
bool _auto_copy_rates_is_checked;
|
||||
(ICommand cmd, IDisposable can_exe_sub)? _smart_copy_roll_target_to_selection_cmd;
|
||||
(ICommand cmd, IDisposable can_exe_sub)? _smart_copy_riskless_rate_to_selection_cmd;
|
||||
|
||||
public AnalyticsExpirationParametersVM(IBus bus, AnalyticsExpirationParametersSettings startup_data) {
|
||||
_bus = bus ?? throw new ArgumentNullException(nameof(bus));
|
||||
var selected_symbol_ref_count = new RefCountMap<string>();
|
||||
_sync_visible_rows = new(() =>
|
||||
visible_rows.sync_with(rows.Where(x => selected_symbol_ref_count.ContainsKey(x.security.symbol))));
|
||||
non_options_with_empty = new ObservableAggregateCollection<SecurityExpiration>(
|
||||
new() { SecurityExpiration.empty }, non_options);
|
||||
_copy_row_source = backing<AnalyticsExpirationParametersRowVM>(nameof(copy_row_source));
|
||||
_is_dirty = backing(nameof(is_dirty), () => rows.Any(r => r.is_dirty));
|
||||
|
||||
if (startup_data is not null) {
|
||||
if (!startup_data.selected_symbols.is_null_or_empty()) {
|
||||
selected_symbols.AddRange(startup_data.selected_symbols);
|
||||
}
|
||||
auto_copy_rolls_is_checked = startup_data.auto_copy_rolls_is_checked;
|
||||
auto_copy_rates_is_checked = startup_data.auto_copy_rates_is_checked;
|
||||
}
|
||||
|
||||
commit_cmd = ObservantCommand.create(_commit, out var can_commit_observer);
|
||||
revert_cmd = ObservantCommand.create(_revert, out var can_revert_observer);
|
||||
|
||||
_dispose = Disposable.Create(
|
||||
ObservableAutoWrapper.connect(_parameters, rows, p => new(this, p), r => r.Dispose()),
|
||||
rows.Subscribe((s, e) => _sync_visible_rows.execute()),
|
||||
_bus.subscribe(SparkTags.ExpirationParametersInputTag).OnDispatcher().Subscribe(
|
||||
CompositeObserver.create(
|
||||
Observer.Create<AnalyticsExpirationParametersMap>(_on_parameter_map),
|
||||
can_commit_observer.wrap<bool, AnalyticsExpirationParametersMap>(m => m is not null))),
|
||||
ObservableAutoWrapper.connect_item_hooks(selected_symbols, sym => {
|
||||
if (selected_symbol_ref_count.increment_adds_key(sym)) {
|
||||
_sync_visible_rows.execute();
|
||||
}
|
||||
return Disposable.Create(() => {
|
||||
if (selected_symbol_ref_count.decrement_removes_key(sym)) {
|
||||
_sync_visible_rows.execute();
|
||||
}
|
||||
});
|
||||
}),
|
||||
ObservableAutoWrapper.connect_item_hooks(rows, r => r.observe_is_dirty().Subscribe(_ => _is_dirty.refresh())),
|
||||
_is_dirty.observe_current(true).OnDispatcher().Subscribe(can_revert_observer),
|
||||
Disposable.wrap_collection(rows),
|
||||
Disposable.Create(() => {
|
||||
_smart_copy_roll_target_to_selection_cmd?.can_exe_sub?.Dispose();
|
||||
_smart_copy_riskless_rate_to_selection_cmd?.can_exe_sub?.Dispose();
|
||||
}));
|
||||
}
|
||||
|
||||
public ObservableCollection<SecurityExpiration> non_options { get; } = new();
|
||||
public ObservableCollection<SecurityExpiration> non_options_with_empty { get; } = new();
|
||||
|
||||
public ObservableCollection<AnalyticsExpirationParametersRowVM> rows { get; } = new();
|
||||
public ObservableCollection<AnalyticsExpirationParametersRowVM> visible_rows { get; } = new();
|
||||
public AnalyticsExpirationParametersRowVM copy_row_source {
|
||||
get => _copy_row_source.Value;
|
||||
set => _copy_row_source.set(value);
|
||||
}
|
||||
|
||||
public ObservableCollection<string> symbols { get; } = new();
|
||||
public ObservableCollection<string> selected_symbols { get; } = new();
|
||||
|
||||
public bool is_dirty => _is_dirty.Value;
|
||||
|
||||
public bool auto_copy_rolls_is_checked {
|
||||
get => _auto_copy_rolls_is_checked;
|
||||
set => Set(ref _auto_copy_rolls_is_checked, value);
|
||||
}
|
||||
|
||||
public bool auto_copy_rates_is_checked {
|
||||
get => _auto_copy_rates_is_checked;
|
||||
set => Set(ref _auto_copy_rates_is_checked, value);
|
||||
}
|
||||
|
||||
public ICommand commit_cmd { get; }
|
||||
public ICommand revert_cmd { get; }
|
||||
|
||||
public ICommand copy_driver_to_selection_cmd => _copy_to_selection_cmd((f, t) => t.driver = f.driver);
|
||||
public ICommand copy_deliverable_to_selection_cmd => _copy_to_selection_cmd((f, t) => t.deliverable = f.deliverable);
|
||||
public ICommand copy_roll_schedule_to_selection_cmd => _copy_to_selection_cmd((f, t) => t.roll_schedule = f.roll_schedule);
|
||||
public ICommand copy_roll_target_to_selection_cmd => _copy_to_selection_cmd((f, t) => t.roll_target = f.roll_target);
|
||||
public ICommand copy_riskless_rate_to_selection_cmd => _copy_to_selection_cmd((f, t) => t.riskless_rate = f.riskless_rate);
|
||||
public ICommand copy_settlement_price_to_selection_cmd => _copy_to_selection_cmd((f, t) => t.settlement_price = f.settlement_price);
|
||||
public ICommand copy_delta_beta_to_selection_cmd => _copy_to_selection_cmd((f, t) => t.delta_beta = f.delta_beta);
|
||||
public ICommand copy_vega_beta_to_selection_cmd => _copy_to_selection_cmd((f, t) => t.vega_beta = f.vega_beta);
|
||||
|
||||
public ICommand smart_copy_roll_target_to_selection_cmd =>
|
||||
(_smart_copy_roll_target_to_selection_cmd ??= _smart_copy_to_selection_cmd(
|
||||
(f, t) => t.roll_target = f.roll_target)).cmd;
|
||||
|
||||
public ICommand smart_copy_riskless_rate_to_selection_cmd =>
|
||||
(_smart_copy_riskless_rate_to_selection_cmd ??= _smart_copy_to_selection_cmd(
|
||||
(f, t) => t.riskless_rate = f.riskless_rate)).cmd;
|
||||
|
||||
public void commit(IEnumerable<AnalyticsExpirationParameters> data) =>
|
||||
_bus.post(SparkTags.ExpirationParametersCommitTag, data);
|
||||
|
||||
public IEnumerable<SecurityExpiration> get_smart_copy_roll_exps(
|
||||
AnalyticsExpirationParameters source) =>
|
||||
get_smart_copy_roll_exps(source.roll_schedule_expiration);
|
||||
|
||||
public IEnumerable<SecurityExpiration> get_smart_copy_roll_exps(
|
||||
SecurityExpiration roll_schedule_expiration) {
|
||||
foreach (var (exp, exp_params) in _parameter_map?.exp_map.empty_if_null()) {
|
||||
if (exp_params.roll_schedule_expiration.Equals(roll_schedule_expiration)) {
|
||||
yield return exp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AnalyticsExpirationParametersSettings get_state() =>
|
||||
new() {
|
||||
selected_symbols = selected_symbols.Cast<string>().ToArray(),
|
||||
auto_copy_rates_is_checked = auto_copy_rates_is_checked,
|
||||
auto_copy_rolls_is_checked = auto_copy_rolls_is_checked
|
||||
};
|
||||
|
||||
Action<AnalyticsExpirationParametersRowVM> _copy_to_selection(Action<AnalyticsExpirationParametersRowVM, AnalyticsExpirationParametersRowVM> copy_to_row) =>
|
||||
from_row => {
|
||||
foreach (var to_row in _selected_rows) {
|
||||
copy_to_row(from_row, to_row);
|
||||
}
|
||||
};
|
||||
|
||||
ICommand _copy_to_selection_cmd(Action<AnalyticsExpirationParametersRowVM, AnalyticsExpirationParametersRowVM> copy_to_row) =>
|
||||
Command.create(_copy_to_selection(copy_to_row));
|
||||
|
||||
Action<AnalyticsExpirationParametersRowVM> _smart_copy_to_selection(Action<AnalyticsExpirationParametersRowVM, AnalyticsExpirationParametersRowVM> copy_to_row) =>
|
||||
from_row => {
|
||||
foreach (var to_row in _get_smart_copy_roll_target_rows(from_row)) {
|
||||
copy_to_row(from_row, to_row);
|
||||
}
|
||||
};
|
||||
|
||||
(ICommand cmd, IDisposable can_exe_sub) _smart_copy_to_selection_cmd(
|
||||
Action<AnalyticsExpirationParametersRowVM, AnalyticsExpirationParametersRowVM> copy_to_row) {
|
||||
var cmd = ObservantCommand.create(
|
||||
_smart_copy_to_selection(copy_to_row), observe_can_execute, out var can_exe_observer);
|
||||
var can_exe_sub = _copy_row_source.observe_current(true).OnDispatcher().Subscribe(can_exe_observer);
|
||||
return (cmd, can_exe_sub);
|
||||
|
||||
static IObservable<bool> observe_can_execute(AnalyticsExpirationParametersRowVM row) =>
|
||||
row is null ?
|
||||
Observable.Return(false) :
|
||||
row.observe_roll_schedule()
|
||||
.CombineLatest(row.observe_roll_schedule_dirty(), (rs, rs_dirty) => (rs, rs_dirty))
|
||||
.Select(tup => !tup.rs.is_empty() && !tup.rs_dirty)
|
||||
.OnDispatcher();
|
||||
}
|
||||
|
||||
IEnumerable<AnalyticsExpirationParametersRowVM> _get_smart_copy_roll_target_rows(AnalyticsExpirationParametersRowVM row) {
|
||||
var target_exps = get_smart_copy_roll_exps(
|
||||
row.original_params.roll_schedule_expiration)
|
||||
.ToHashSet();
|
||||
return rows.Where(r => target_exps.Contains(r.security));
|
||||
}
|
||||
|
||||
void _commit() {
|
||||
if (_parameter_map is null) {
|
||||
// Don't commit before [any] data has been received from the server
|
||||
return;
|
||||
}
|
||||
var new_params = rows.Select(r => r.candidate_value).ToImmutableList();
|
||||
_bus.post(SparkTags.ExpirationParametersCommitTag, new_params);
|
||||
}
|
||||
|
||||
void _revert() {
|
||||
foreach (var r in rows) {
|
||||
r.revert();
|
||||
}
|
||||
}
|
||||
|
||||
void _on_parameter_map(AnalyticsExpirationParametersMap parameter_map) {
|
||||
bool is_first_update = _parameter_map is null;
|
||||
_parameter_map = parameter_map ?? throw new ArgumentNullException(nameof(parameter_map));
|
||||
_parameters.sync_with(parameter_map.get_sorted_exps().Select(parameter_map.get_parameter));
|
||||
non_options.sync_with(parameter_map.get_sorted_exps().Where(exp => exp.security_type != SecurityType.Option));
|
||||
|
||||
// Set `is_last_row_of_month_group` for each row
|
||||
foreach (var exp_rows in rows.GroupBy(r => r.security.expiration.Month)) {
|
||||
var sorted_exp_rows = exp_rows.OrderBy(r => r.security.expiration).ToList();
|
||||
foreach (var row in sorted_exp_rows.Take(sorted_exp_rows.Count - 1)) {
|
||||
row.is_last_row_of_month_group = false;
|
||||
}
|
||||
sorted_exp_rows.Last().is_last_row_of_month_group = true;
|
||||
}
|
||||
|
||||
symbols.sync_with(_parameters.Select(p => p.security.symbol).Distinct().Ordered());
|
||||
using var _ = _sync_visible_rows.defer_execution();
|
||||
if (is_first_update) {
|
||||
// select all symbols on first update
|
||||
selected_symbols.sync_with(symbols);
|
||||
}
|
||||
}
|
||||
|
||||
public void row_selection_changed(SelectionChangedEventArgs e) =>
|
||||
RowSelectionHelper.apply_changes(_selected_rows, e);
|
||||
}
|
||||
}
|
||||
@@ -1,547 +0,0 @@
|
||||
<UserControl
|
||||
x:Class="mbts.ui.shell.AnalyticsExpirationParametersView"
|
||||
x:ClassModifier="internal"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
xmlns:shell="clr-namespace:mbts.ui.shell"
|
||||
Background="{StaticResource CommonBackground}">
|
||||
<UserControl.Resources>
|
||||
<cv:DoubleTextConverter x:Key="DoubleTextConverter" />
|
||||
<cv:DoubleTextConverter
|
||||
x:Key="RisklessRateConverter"
|
||||
Multiplier="100" />
|
||||
<shell:ExpTextConverter
|
||||
x:Key="ExpirationTextConverter"
|
||||
ShowSymbol="True"
|
||||
MapExp="True" />
|
||||
<DataTemplate x:Key="ExpirationTemplate">
|
||||
<TextBlock Text="{Binding Converter={StaticResource ExpirationTextConverter}}">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Style.Triggers>
|
||||
<Trigger
|
||||
Property="Text"
|
||||
Value="None">
|
||||
<Setter
|
||||
Property="FontStyle"
|
||||
Value="Italic" />
|
||||
<Setter
|
||||
Property="Foreground"
|
||||
Value="Gray" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
|
||||
<ContextMenu x:Key="DriverContextMenu">
|
||||
<MenuItem
|
||||
Header="Copy Driver to Selection"
|
||||
Command="{Binding owner.copy_driver_to_selection_cmd}"
|
||||
CommandParameter="{Binding}"
|
||||
/>
|
||||
</ContextMenu>
|
||||
<ContextMenu x:Key="DeliverableContextMenu">
|
||||
<MenuItem
|
||||
Header="Copy Deliverable to Selection"
|
||||
Command="{Binding owner.copy_deliverable_to_selection_cmd}"
|
||||
CommandParameter="{Binding}"
|
||||
/>
|
||||
</ContextMenu>
|
||||
<ContextMenu x:Key="RollScheduleContextMenu">
|
||||
<MenuItem
|
||||
Header="Copy Roll Schedule to Selection"
|
||||
Command="{Binding owner.copy_roll_schedule_to_selection_cmd}"
|
||||
CommandParameter="{Binding}"
|
||||
/>
|
||||
</ContextMenu>
|
||||
<ContextMenu x:Key="RollTargetContextMenu">
|
||||
<MenuItem
|
||||
Header="Copy Roll Target to Selection"
|
||||
Command="{Binding owner.copy_roll_target_to_selection_cmd}"
|
||||
CommandParameter="{Binding}"
|
||||
/>
|
||||
<MenuItem
|
||||
Header="Smart Copy Roll Target"
|
||||
Command="{Binding owner.smart_copy_roll_target_cmd}"
|
||||
CommandParameter="{Binding}"
|
||||
/>
|
||||
</ContextMenu>
|
||||
<ContextMenu x:Key="RisklessRateContextMenu">
|
||||
<MenuItem
|
||||
Header="Copy Riskless Rate to Selection"
|
||||
Command="{Binding owner.copy_riskless_rate_to_selection_cmd}"
|
||||
CommandParameter="{Binding}"
|
||||
/>
|
||||
</ContextMenu>
|
||||
<ContextMenu x:Key="SettlementPriceContextMenu">
|
||||
<MenuItem
|
||||
Header="{Binding security}"
|
||||
HeaderStringFormat="Copy '{0}' Settlement to Selection"
|
||||
Command="{Binding owner.copy_settlement_price_to_selection_cmd}"
|
||||
CommandParameter="{Binding}"
|
||||
/>
|
||||
</ContextMenu>
|
||||
<ContextMenu x:Key="DeltaBetaContextMenu">
|
||||
<MenuItem
|
||||
Header="Copy Delta Beta to Selection"
|
||||
Command="{Binding owner.copy_delta_beta_to_selection_cmd}"
|
||||
CommandParameter="{Binding}"
|
||||
/>
|
||||
</ContextMenu>
|
||||
<ContextMenu x:Key="VegaBetaContextMenu">
|
||||
<MenuItem
|
||||
Header="Copy Vega Beta to Selection"
|
||||
Command="{Binding owner.copy_vega_beta_to_selection_cmd}"
|
||||
CommandParameter="{Binding}"
|
||||
/>
|
||||
</ContextMenu>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<cv:BooleanToVisibilityConverter x:Key="TrueVisibilityConverter" />
|
||||
<cv:BooleanToVisibilityConverter x:Key="FalseVisibilityConverter" VisibilityForFalse="Visible" VisibilityForTrue="Collapsed" />
|
||||
</Grid.Resources>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
Orientation="Horizontal"
|
||||
Margin="0,5,0,5">
|
||||
|
||||
<c:ComboCheckBox
|
||||
ItemsSource="{Binding symbols}"
|
||||
SelectedItems="{Binding selected_symbols}"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="5,2,2,2"
|
||||
TextBlock.Foreground="Black"
|
||||
HeaderContent="Symbols"
|
||||
ShowSelectAll="True"
|
||||
/>
|
||||
|
||||
<WrapPanel>
|
||||
<TextBlock Margin="5,5,0,0" Text="Auto copy rolls:" />
|
||||
<CheckBox Margin="5,5,10,0" IsChecked="{Binding auto_copy_rolls_is_checked}" />
|
||||
</WrapPanel>
|
||||
<WrapPanel>
|
||||
<TextBlock Margin='0,5,0,0' Text="Auto copy rates:" />
|
||||
<CheckBox Margin="5,5,0,0" IsChecked="{Binding auto_copy_rates_is_checked}" />
|
||||
</WrapPanel>
|
||||
</StackPanel>
|
||||
<c:DataGridEx
|
||||
x:Name="_grid"
|
||||
Grid.Row="1"
|
||||
ItemsSource="{Binding visible_rows}"
|
||||
AlternatingRowBackground="{u:BTSColor MarketData.driver_background}"
|
||||
VerticalGridLinesBrush="Gray"
|
||||
EnableRowVirtualization="True"
|
||||
EnableColumnVirtualization="True"
|
||||
CanUserAddRows="False"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserReorderColumns="False"
|
||||
CanUserSortColumns="False"
|
||||
CanUserDeleteRows="False"
|
||||
RowHeaderWidth="0"
|
||||
GridLinesVisibility="Vertical"
|
||||
SelectionUnit="FullRow"
|
||||
SelectedUnits="{Binding selected_rows}"
|
||||
PreviewMouseRightButtonUp="_grid_PreviewMouseRightButtonUp">
|
||||
<DataGrid.Resources>
|
||||
<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource {x:Type DataGridCell}}">
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Style.Triggers>
|
||||
<Trigger
|
||||
Property="IsSelected"
|
||||
Value="True">
|
||||
<Setter
|
||||
Property="Background"
|
||||
Value="{u:BTSColor Grid.grid_selection_background}" />
|
||||
<Setter
|
||||
Property="BorderBrush"
|
||||
Value="{u:BTSColor Grid.grid_selection_background}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.Resources>
|
||||
<DataGrid.RowStyle>
|
||||
<Style TargetType="DataGridRow">
|
||||
<Setter Property="IsSelected" Value="{Binding is_selected, Mode=TwoWay}"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Style.Triggers>
|
||||
<Trigger
|
||||
Property="IsSelected"
|
||||
Value="true">
|
||||
<Setter
|
||||
Property="Background"
|
||||
Value="{u:BTSColor Grid.grid_selection_background}" />
|
||||
</Trigger>
|
||||
<DataTrigger
|
||||
Binding="{Binding is_last_row_of_month_group}"
|
||||
Value="True">
|
||||
<Setter
|
||||
Property="BorderThickness"
|
||||
Value="0,0,0,1" />
|
||||
<Setter
|
||||
Property="BorderBrush"
|
||||
Value="Black" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.ColumnHeaderStyle>
|
||||
<Style TargetType="DataGridColumnHeader">
|
||||
<Setter
|
||||
Property="Background"
|
||||
Value="{u:BTSColor Name=header}" />
|
||||
<Setter
|
||||
Property="Foreground"
|
||||
Value="{u:BTSColor Name=header_text}" />
|
||||
<Setter
|
||||
Property="HorizontalContentAlignment"
|
||||
Value="Center" />
|
||||
<Setter
|
||||
Property="BorderThickness"
|
||||
Value="0,0,1,0" />
|
||||
<Setter
|
||||
Property="BorderBrush"
|
||||
Value="Black" />
|
||||
<Setter
|
||||
Property="Padding"
|
||||
Value="3" />
|
||||
<Setter
|
||||
Property="MinWidth"
|
||||
Value="80" />
|
||||
</Style>
|
||||
</DataGrid.ColumnHeaderStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Header="Security"
|
||||
Binding="{Binding security, Converter={StaticResource ExpirationTextConverter}}"
|
||||
IsReadOnly="True">
|
||||
<DataGridTextColumn.CellStyle>
|
||||
<Style
|
||||
TargetType="DataGridCell"
|
||||
BasedOn="{StaticResource {x:Type DataGridCell}}">
|
||||
<Setter
|
||||
Property="Background"
|
||||
Value="{u:BTSColor Name=header}" />
|
||||
<Setter
|
||||
Property="Foreground"
|
||||
Value="{u:BTSColor Name=header_text}" />
|
||||
<Setter
|
||||
Property="BorderThickness"
|
||||
Value="0" />
|
||||
<Setter
|
||||
Property="VerticalContentAlignment"
|
||||
Value="Center" />
|
||||
<Setter
|
||||
Property="Padding"
|
||||
Value="3" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding security.security_type}"
|
||||
Value="OPTION">
|
||||
<Setter
|
||||
Property="Foreground"
|
||||
Value="{u:BTSColor Name=header_text}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger
|
||||
Binding="{Binding security.security_type}"
|
||||
Value="FUTURE">
|
||||
<Setter
|
||||
Property="Foreground"
|
||||
Value="Gold" />
|
||||
</DataTrigger>
|
||||
<DataTrigger
|
||||
Binding="{Binding security.security_type}"
|
||||
Value="UNSET">
|
||||
<Setter
|
||||
Property="Foreground"
|
||||
Value="PaleGreen" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGridTextColumn.CellStyle>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTemplateColumn
|
||||
Header="Driver"
|
||||
MinWidth="105">
|
||||
<DataGridTemplateColumn.CellStyle>
|
||||
<Style
|
||||
TargetType="DataGridCell"
|
||||
BasedOn="{StaticResource {x:Type DataGridCell}}">
|
||||
<Setter
|
||||
Property="ContextMenu"
|
||||
Value="{StaticResource DriverContextMenu}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding is_driver_dirty}"
|
||||
Value="True">
|
||||
<Setter
|
||||
Property="BorderBrush"
|
||||
Value="Red" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGridTemplateColumn.CellStyle>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox
|
||||
ItemsSource="{Binding DataContext.non_options, RelativeSource={RelativeSource AncestorType=c:DataGridEx}}"
|
||||
ItemTemplate="{StaticResource ExpirationTemplate}"
|
||||
SelectedItem="{Binding driver, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="2" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn
|
||||
Header="Deliverable"
|
||||
MinWidth="105">
|
||||
<DataGridTemplateColumn.CellStyle>
|
||||
<Style
|
||||
TargetType="DataGridCell"
|
||||
BasedOn="{StaticResource {x:Type DataGridCell}}">
|
||||
<Setter
|
||||
Property="ContextMenu"
|
||||
Value="{StaticResource DeliverableContextMenu}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding is_deliverable_dirty}"
|
||||
Value="True">
|
||||
<Setter
|
||||
Property="BorderBrush"
|
||||
Value="Red" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGridTemplateColumn.CellStyle>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox
|
||||
ItemsSource="{Binding DataContext.non_options_with_empty, RelativeSource={RelativeSource AncestorType=c:DataGridEx}}"
|
||||
ItemTemplate="{StaticResource ExpirationTemplate}"
|
||||
SelectedItem="{Binding deliverable, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="2" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn
|
||||
Header="Roll Schedule"
|
||||
MinWidth="105">
|
||||
<DataGridTemplateColumn.CellStyle>
|
||||
<Style
|
||||
TargetType="DataGridCell"
|
||||
BasedOn="{StaticResource {x:Type DataGridCell}}">
|
||||
<Setter
|
||||
Property="ContextMenu"
|
||||
Value="{StaticResource RollScheduleContextMenu}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding is_roll_schedule_dirty}"
|
||||
Value="True">
|
||||
<Setter
|
||||
Property="BorderBrush"
|
||||
Value="Red" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGridTemplateColumn.CellStyle>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox
|
||||
ItemsSource="{Binding DataContext.non_options_with_empty, RelativeSource={RelativeSource AncestorType=c:DataGridEx}}"
|
||||
ItemTemplate="{StaticResource ExpirationTemplate}"
|
||||
SelectedItem="{Binding roll_schedule, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="2" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="Roll Target $">
|
||||
<DataGridTemplateColumn.CellStyle>
|
||||
<Style
|
||||
TargetType="DataGridCell"
|
||||
BasedOn="{StaticResource {x:Type DataGridCell}}">
|
||||
<Setter
|
||||
Property="ContextMenu"
|
||||
Value="{StaticResource RollTargetContextMenu}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding is_roll_target_dirty}"
|
||||
Value="True">
|
||||
<Setter
|
||||
Property="BorderBrush"
|
||||
Value="Red" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGridTemplateColumn.CellStyle>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
Text="{Binding roll_target, Converter={StaticResource DoubleTextConverter}}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="2,0,2,0"
|
||||
ContextMenu="{StaticResource RollTargetContextMenu}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
<DataGridTemplateColumn.CellEditingTemplate>
|
||||
<DataTemplate>
|
||||
<TextBox
|
||||
Text="{Binding roll_target, Converter={StaticResource DoubleTextConverter}}"
|
||||
Margin="2" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="Riskless Rate %">
|
||||
<DataGridTemplateColumn.CellStyle>
|
||||
<Style
|
||||
TargetType="DataGridCell"
|
||||
BasedOn="{StaticResource {x:Type DataGridCell}}">
|
||||
<Setter
|
||||
Property="ContextMenu"
|
||||
Value="{StaticResource RisklessRateContextMenu}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding is_riskless_rate_dirty}"
|
||||
Value="True">
|
||||
<Setter
|
||||
Property="BorderBrush"
|
||||
Value="Red" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGridTemplateColumn.CellStyle>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
Text="{Binding riskless_rate, Converter={StaticResource RisklessRateConverter}}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="2,0,2,0"
|
||||
ContextMenu="{StaticResource RisklessRateContextMenu}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
<DataGridTemplateColumn.CellEditingTemplate>
|
||||
<DataTemplate>
|
||||
<TextBox Text="{Binding riskless_rate, Converter={StaticResource RisklessRateConverter}}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="Settlement Price $">
|
||||
<DataGridTemplateColumn.CellStyle>
|
||||
<Style
|
||||
TargetType="DataGridCell"
|
||||
BasedOn="{StaticResource {x:Type DataGridCell}}">
|
||||
<Setter
|
||||
Property="ContextMenu"
|
||||
Value="{StaticResource SettlementPriceContextMenu}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding is_settlement_price_dirty}"
|
||||
Value="True">
|
||||
<Setter
|
||||
Property="BorderBrush"
|
||||
Value="Red" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGridTemplateColumn.CellStyle>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
Text="{Binding settlement_price, Converter={StaticResource DoubleTextConverter}}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="2,0,2,0"
|
||||
ContextMenu="{StaticResource SettlementPriceContextMenu}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
<DataGridTemplateColumn.CellEditingTemplate>
|
||||
<DataTemplate>
|
||||
<TextBox Text="{Binding settlement_price, Converter={StaticResource DoubleTextConverter}}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Header="Delta Beta">
|
||||
<DataGridTemplateColumn.CellStyle>
|
||||
<Style
|
||||
TargetType="DataGridCell"
|
||||
BasedOn="{StaticResource {x:Type DataGridCell}}">
|
||||
<Setter
|
||||
Property="ContextMenu"
|
||||
Value="{StaticResource DeltaBetaContextMenu}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding is_delta_beta_dirty}"
|
||||
Value="True">
|
||||
<Setter
|
||||
Property="BorderBrush"
|
||||
Value="Red" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGridTemplateColumn.CellStyle>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
Text="{Binding delta_beta, Converter={StaticResource DoubleTextConverter}}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="2,0,2,0"
|
||||
ContextMenu="{StaticResource DeltaBetaContextMenu}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
<DataGridTemplateColumn.CellEditingTemplate>
|
||||
<DataTemplate>
|
||||
<TextBox Text="{Binding delta_beta, Converter={StaticResource DoubleTextConverter}}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Header="Vega Beta">
|
||||
<DataGridTemplateColumn.CellStyle>
|
||||
<Style
|
||||
TargetType="DataGridCell"
|
||||
BasedOn="{StaticResource {x:Type DataGridCell}}">
|
||||
<Setter
|
||||
Property="ContextMenu"
|
||||
Value="{StaticResource VegaBetaContextMenu}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding is_vega_beta_dirty}"
|
||||
Value="True">
|
||||
<Setter
|
||||
Property="BorderBrush"
|
||||
Value="Red" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGridTemplateColumn.CellStyle>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
Text="{Binding vega_beta, Converter={StaticResource DoubleTextConverter}}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="2,0,2,0"
|
||||
ContextMenu="{StaticResource VegaBetaContextMenu}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
<DataGridTemplateColumn.CellEditingTemplate>
|
||||
<DataTemplate>
|
||||
<TextBox Text="{Binding vega_beta, Converter={StaticResource DoubleTextConverter}}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
</DataGrid.Columns>
|
||||
</c:DataGridEx>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,76 +0,0 @@
|
||||
namespace mbts.ui.shell {
|
||||
using bts.api;
|
||||
|
||||
using mbts.spark;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.extensions;
|
||||
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for AnalyticsExpirationParametersView.xaml
|
||||
/// </summary>
|
||||
partial class AnalyticsExpirationParametersView : UserControl {
|
||||
IDisposable _context_menu_op;
|
||||
IDisposable _data_context_hooks;
|
||||
|
||||
public AnalyticsExpirationParametersView() {
|
||||
InitializeComponent();
|
||||
DataContextChanged += on_data_context_changed;
|
||||
void on_data_context_changed(object sender, DependencyPropertyChangedEventArgs e) {
|
||||
Disposable.dispose(ref _data_context_hooks);
|
||||
if (e.NewValue is IHandleRowSelection hrs) {
|
||||
hrs.row_selection_changed(new(Selector.SelectionChangedEvent, Array.Empty<object>(), _grid.SelectedItems));
|
||||
_data_context_hooks = _grid.SubscribeSelectionChanged((s, e) => hrs.row_selection_changed(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _grid_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e) {
|
||||
Disposable.dispose(ref _context_menu_op);
|
||||
if (e.OriginalSource is not FrameworkElement el || DataContext is not AnalyticsExpirationParametersVM vm) {
|
||||
return;
|
||||
}
|
||||
var cell = el.find_ancestor_of_type<DataGridCell>();
|
||||
if (cell?.ContextMenu is not ContextMenu cm || cell.DataContext is not AnalyticsExpirationParametersRowVM row) {
|
||||
return;
|
||||
}
|
||||
vm.copy_row_source = row;
|
||||
cm.DataContext = row;
|
||||
cm.IsOpen = true;
|
||||
_context_menu_op = cm.SubscribeClosed((s, e) => vm.copy_row_source = null);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
class ExpTextConverter : IValueConverter {
|
||||
public ExpTextConverter() {
|
||||
NullOrEmptyText = "None";
|
||||
}
|
||||
|
||||
public bool ShowType { get; set; }
|
||||
public bool ShowSymbol { get; set; }
|
||||
public bool MapExp { get; set; }
|
||||
public string NullOrEmptyText { get; set; }
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
|
||||
var exp = value as SecurityExpiration;
|
||||
if (exp == null || exp.is_empty()) {
|
||||
return NullOrEmptyText;
|
||||
}
|
||||
return ShowSymbol ?
|
||||
SecurityFormatter.format_future(exp.symbol, exp.expiration) :
|
||||
DateFormatter.Format(exp.expiration, DateFormat.MonthCodeLastDigitYear);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using bts.api;
|
||||
using bts.spark;
|
||||
|
||||
using mbts.ui;
|
||||
using mbts.ui.shell;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
class AnalyticsExpirationParametersWindow : SparkWindow<AnalyticsExpirationParametersSettings>, ISharedWindow {
|
||||
public const string WINDOW_TYPE = "AnalyticsExpirationParameters";
|
||||
|
||||
readonly AnalyticsExpirationParametersSettings _init_settings;
|
||||
List<SparkCommand> _commands;
|
||||
|
||||
AnalyticsExpirationParametersVM _vm;
|
||||
AnalyticsExpirationParametersView _view;
|
||||
|
||||
public AnalyticsExpirationParametersWindow(
|
||||
IBus bus, AnalyticsExpirationParametersWindowFactory factory, AnalyticsExpirationParametersSettings settings)
|
||||
: base("Analytics Exp Params", bus, factory) {
|
||||
_init_settings = settings;
|
||||
_dispose = Disposable.Create(() => _vm?.Dispose());
|
||||
}
|
||||
|
||||
public override string window_type => WINDOW_TYPE;
|
||||
public string thread_id => WINDOW_TYPE;
|
||||
|
||||
public override AnalyticsExpirationParametersSettings SaveState =>
|
||||
_vm?.get_state();
|
||||
|
||||
public override UIElement Content =>
|
||||
_view;
|
||||
|
||||
public override IEnumerable<SparkCommand> Commands => _commands.empty_if_null();
|
||||
|
||||
public void thread_init() {
|
||||
_vm = new AnalyticsExpirationParametersVM(_bus, _init_settings);
|
||||
_view = new AnalyticsExpirationParametersView { DataContext = _vm };
|
||||
_commands = new() {
|
||||
new SparkCommandCommand("Commit", Icons.Disk, _vm.commit_cmd, new KeyGesture(Key.S, ModifierKeys.Control)),
|
||||
new SparkCommandCommand("Revert", Icons.UndoCircular, _vm.revert_cmd, new KeyGesture(Key.Z, ModifierKeys.Control)),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using bts.api;
|
||||
using bts.shell;
|
||||
using bts.spark;
|
||||
|
||||
using mbts.ui;
|
||||
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
class AnalyticsExpirationParametersWindowFactory : ShellWindowFactory<AnalyticsExpirationParametersSettings> {
|
||||
readonly IBus _bus;
|
||||
|
||||
public AnalyticsExpirationParametersWindowFactory(IShellModule module, IBus bus)
|
||||
: base(module, SparkCommands.show_vol_surface.title) {
|
||||
_bus = bus;
|
||||
_dispose = bus.subscribe(SparkTags.show_analytics_exp_params).OnDispatcher().Subscribe(_show);
|
||||
}
|
||||
|
||||
public override Task<IShellWindow> load(AnalyticsExpirationParametersSettings state) =>
|
||||
Task.FromResult(_create(state));
|
||||
|
||||
void _show(AnalyticsExpirationParametersSettings _) =>
|
||||
_bus.post(SparkTags.ShowWindow, _create(new()));
|
||||
|
||||
IShellWindow _create(AnalyticsExpirationParametersSettings startup_data) =>
|
||||
new AnalyticsExpirationParametersWindow(_bus, this, startup_data);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using bts.api;
|
||||
|
||||
using mbts;
|
||||
using mbts.analytics;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
class AnalyticsParametersUIModel : IDisposable {
|
||||
AnalyticsExpirationParametersMap _curr_val = null;
|
||||
readonly IBus _bus;
|
||||
readonly IDisposable _sub;
|
||||
|
||||
public event Action<AnalyticsExpirationParametersMap> on_expiration_parameters;
|
||||
|
||||
public AnalyticsParametersUIModel(IBus bus) {
|
||||
_bus = bus;
|
||||
_sub = _bus.subscribe(SparkTags.ExpirationParametersInputTag)
|
||||
.Subscribe(d => on_expiration_parameters?.Invoke(d));
|
||||
}
|
||||
|
||||
public void commit(IEnumerable<AnalyticsExpirationParameters> data) =>
|
||||
_bus.post(SparkTags.ExpirationParametersCommitTag, data);
|
||||
|
||||
public IEnumerable<mbts.SecurityExpiration> get_smart_copy_roll_exps(AnalyticsExpirationParameters source) {
|
||||
if (_curr_val != null) {
|
||||
foreach (var kv in _curr_val.exp_map)
|
||||
if (kv.Value.roll_schedule_expiration.Equals(source.roll_schedule_expiration))
|
||||
yield return kv.Key;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() =>
|
||||
_sub.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using bts;
|
||||
using mbts.analytics;
|
||||
using bts.api.analytics;
|
||||
using System.Reactive.Linq;
|
||||
using bts.api;
|
||||
using System.Threading;
|
||||
|
||||
namespace mbts.spark {
|
||||
// 1. Reads exp params from the network and publishes
|
||||
// it to the BB
|
||||
// 2. Listens to ExpirationParametersCommitTag and
|
||||
// writes the calls into persistence to save the data
|
||||
public class AnalyticsParametersManager : IDisposable {
|
||||
private readonly ThreadedBlackboard _bb;
|
||||
private AnalyticsService _analytics_service;
|
||||
private List<IDisposable> _disposables = new List<IDisposable>();
|
||||
private IDictionary<mbts.SecurityExpiration, AnalyticsExpirationParameters>
|
||||
_data = new Dictionary<mbts.SecurityExpiration, AnalyticsExpirationParameters>();
|
||||
private readonly ITag<IEnumerable<AnalyticsExpirationParameters>>
|
||||
_in_bb_exp_params_commit_tag = SparkTags.ExpirationParametersCommitTag;
|
||||
private readonly ITag<SystemContractData> _in_contracts_tag = SparkTags.SystemContractsTag;
|
||||
private readonly ITag<AnalyticsExpirationParametersMap> _out_exp_params_tag =
|
||||
SparkTags.ExpirationParametersInputTag;
|
||||
private HighPerformanceTimer _timer = new HighPerformanceTimer();
|
||||
|
||||
public AnalyticsParametersManager(ThreadedBlackboard bb,
|
||||
AnalyticsService analytics_server) {
|
||||
_bb = bb;
|
||||
_analytics_service = analytics_server;
|
||||
var exp_params_sub = _analytics_service.subscribei_exp_parameters()
|
||||
.ObserveOn(SynchronizationContext.Current)
|
||||
.Subscribe(_on_exp_parameters);
|
||||
_disposables.Add(exp_params_sub);
|
||||
_bb.subscribe(_in_bb_exp_params_commit_tag);
|
||||
_bb.subscribe(_in_contracts_tag);
|
||||
_bb.data_callback += _on_bb_data;
|
||||
}
|
||||
|
||||
private void _on_bb_data(object tag, object data) {
|
||||
if (_in_contracts_tag.Equals(tag)) {
|
||||
_assemble_and_publish();
|
||||
} else if (_in_bb_exp_params_commit_tag == tag) {
|
||||
// listens to the commit tag and saves it
|
||||
IEnumerable<AnalyticsExpirationParameters> exp_params =
|
||||
data as IEnumerable<AnalyticsExpirationParameters>;
|
||||
exp_params = exp_params.Where(e => e.security.expiration.Date >=
|
||||
DateTime.Now.Date.Subtract(TimeSpan.FromDays(1)));
|
||||
bts.Log.Gen.info(
|
||||
String.Format("AnalyticsParametersManager._on_bb_data received commit count:{0}",
|
||||
exp_params.Count()));
|
||||
ExpirationParameterEntryList to_save = new ExpirationParameterEntryList();
|
||||
to_save.ParamList.AddRange(exp_params.Select(i => i.to_exp_param_entry()));
|
||||
_timer.start();
|
||||
_analytics_service.set_exp_parameters(to_save);
|
||||
_timer.stop();
|
||||
bts.Log.Gen.info(
|
||||
String.Format("AnalyticsParametersManager saved exp_params count:{0} t:{1} msecs",
|
||||
exp_params.Count(), _timer.lastIntervalTime));
|
||||
}
|
||||
}
|
||||
|
||||
void _on_exp_parameters(bts.api.core.Update<ExpirationParameterEntryListImmutable, int> update) {
|
||||
_data = new Dictionary<mbts.SecurityExpiration, AnalyticsExpirationParameters>();
|
||||
bts.Log.Gen.info(String.Format("AnalyticsParametersManager._on_exp_parameters received count:{0}",
|
||||
update.all.Count()));
|
||||
bts.Log.assert(update.all.Count() == 0 || update.all.Count() == 1);
|
||||
foreach (ExpirationParameterEntryListImmutable l in update.all) {
|
||||
foreach (ExpirationParameterEntryImmutable e in l.ParamList) {
|
||||
AnalyticsExpirationParameters new_entry = new AnalyticsExpirationParameters(e);
|
||||
_data[new_entry.security] = new_entry;
|
||||
}
|
||||
break;
|
||||
}
|
||||
Log.Gen.info($"AnalyticsParametersManager._on_exp_parameters count: {_data.Count}");
|
||||
_assemble_and_publish();
|
||||
// _bb.post(_out_exp_params_tag, new AnalyticsExpirationParametersMap(_data));
|
||||
}
|
||||
|
||||
private void _assemble_and_publish() {
|
||||
if (_data != null) {
|
||||
SystemContractData sc_data = _bb.read_state(_in_contracts_tag);
|
||||
if (sc_data != null) {
|
||||
_bb.post(_out_exp_params_tag, new AnalyticsExpirationParametersMap(_data, sc_data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
public void Dispose() {
|
||||
_bb.data_callback -= _on_bb_data;
|
||||
foreach (IDisposable d in _disposables) {
|
||||
d.Dispose();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using mbts.analytics;
|
||||
|
||||
namespace mbts.spark
|
||||
{
|
||||
/// UI (VolSurfaceDisplayModel) publishes this to the request calculator
|
||||
/// (This is published in response to user typing in, or any of the macro
|
||||
/// actions on the right)
|
||||
public class VolSurfaceCalculationRequest : ICloneable
|
||||
{
|
||||
public readonly VolSurfaceInput volsurface_input;
|
||||
public readonly int request_id;
|
||||
public readonly IDictionary<VolSurfaceExpiration, VolCurveAction> action_map;
|
||||
public readonly bool cascade_up, cascade_down;
|
||||
|
||||
public VolSurfaceCalculationRequest(VolSurfaceInput this_volsurface_input, int this_request_id)
|
||||
: this(this_volsurface_input, this_request_id, new Dictionary<VolSurfaceExpiration, VolCurveAction>())
|
||||
{ }
|
||||
|
||||
public VolSurfaceCalculationRequest(VolSurfaceInput this_volsurface_input, int this_request_id,
|
||||
IDictionary<VolSurfaceExpiration, VolCurveAction> this_action_map,
|
||||
bool this_cascade_up = false, bool this_cascade_down = false)
|
||||
{
|
||||
request_id = this_request_id;
|
||||
volsurface_input = VolSurfaceUtilityFunctions.clone_proto(this_volsurface_input);
|
||||
action_map = this_action_map;
|
||||
cascade_up = this_cascade_up;
|
||||
cascade_down = this_cascade_down;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new VolSurfaceCalculationRequest(VolSurfaceUtilityFunctions.clone_proto(volsurface_input),
|
||||
request_id,
|
||||
action_map != null ? new Dictionary<VolSurfaceExpiration, VolCurveAction>(action_map) : null,
|
||||
cascade_up, cascade_down);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using mbts.analytics;
|
||||
|
||||
namespace mbts.spark
|
||||
{
|
||||
public class VolSurfaceCalculationResponse : ICloneable
|
||||
{
|
||||
public readonly VolSurfaceOutput volsurface_calculation_output;
|
||||
public readonly int request_id;
|
||||
public VolSurfaceCalculationResponse(VolSurfaceOutput this_volsurface_calculation_output, int this_request_id)
|
||||
{
|
||||
request_id = this_request_id;
|
||||
volsurface_calculation_output = this_volsurface_calculation_output;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new VolSurfaceCalculationResponse(volsurface_calculation_output != null ? volsurface_calculation_output.Clone() as VolSurfaceOutput : null, request_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using mbts.analytics;
|
||||
using bts.api;
|
||||
using bts.api.analytics;
|
||||
|
||||
public class DriverMD {
|
||||
public readonly DriverCalculationType calc_type = DriverCalculationType.Direct;
|
||||
public readonly Nullable<SecurityImmutable> driver_security = null;
|
||||
public readonly VolSurfaceMDUnit md = null;
|
||||
public readonly Nullable<double> calculated_driver = null;
|
||||
public static DriverMD empty = new DriverMD(
|
||||
DriverCalculationType.Direct, null, null, null);
|
||||
public DriverMD(DriverCalculationType calc_type,
|
||||
Nullable<SecurityImmutable> driver_security,
|
||||
VolSurfaceMDUnit md,
|
||||
Nullable<double> calculated_driver) {
|
||||
this.calc_type = calc_type;
|
||||
this.driver_security = driver_security;
|
||||
this.md = md;
|
||||
this.calculated_driver = calculated_driver;
|
||||
}
|
||||
public DriverMD(SecurityImmutable driver_security,
|
||||
VolSurfaceMDUnit md)
|
||||
:
|
||||
this(DriverCalculationType.Direct, driver_security, md, null) {
|
||||
|
||||
}
|
||||
public DriverMD(double driver)
|
||||
:
|
||||
this(DriverCalculationType.TimeWeightedInterp, null, null, driver) {
|
||||
}
|
||||
public double get_driver() {
|
||||
switch (calc_type) {
|
||||
case DriverCalculationType.Direct:
|
||||
return VolSurfaceCoreFunctions.get_driver(md);
|
||||
case DriverCalculationType.TimeWeightedInterp:
|
||||
return calculated_driver.HasValue ? calculated_driver.Value : Double.NaN;
|
||||
}
|
||||
return Double.NaN;
|
||||
}
|
||||
}
|
||||
|
||||
namespace mbts.spark {
|
||||
// Publishes the driver prices for expirations of a single option (this is not AW2 specific)
|
||||
// f(AnalyticsExpirationParametersMap, SystemContractData) -> OptionDriverPriceMap
|
||||
// This is constructed by the ResourceAllocator
|
||||
public class SingleOptionDriverPricePublisher {
|
||||
private readonly SecurityTuple _sec_tup;
|
||||
private ThreadedBlackboard _bb;
|
||||
// tags
|
||||
private ITag<AnalyticsExpirationParametersMap> _in_bb_exp_params_tag =
|
||||
SparkTags.ExpirationParametersInputTag;
|
||||
private ITag<SystemContractData> _in_bb_contracts_tag =
|
||||
SparkTags.SystemContractsTag;
|
||||
private OptionDriverPriceMap _last_published;
|
||||
private readonly PerfStatsLogger _logger;
|
||||
private readonly TimeSpan _fire_period = TimeSpan.FromMilliseconds(300);
|
||||
private DateTime _last_fire_time = DateTime.MinValue;
|
||||
|
||||
public SingleOptionDriverPricePublisher(SecurityTuple sec_tup,
|
||||
ThreadedBlackboard bb) {
|
||||
bts.Log.Gen.info($"SingleOptionDriverPricePublisher initialized st:{sec_tup}");
|
||||
_sec_tup = sec_tup;
|
||||
_bb = bb;
|
||||
_logger = new PerfStatsLogger(50, 50,
|
||||
$"SingleOptionDriverPricePublisher_{sec_tup.security_name}_{GetHashCode()}");
|
||||
_last_published = new OptionDriverPriceMap(sec_tup.security_name,
|
||||
new Dictionary<SecurityExpiration, DriverMD>());
|
||||
_bb.subscribe(_in_bb_exp_params_tag);
|
||||
_bb.subscribe(_in_bb_contracts_tag);
|
||||
_bb.data_callback += _on_bb_data;
|
||||
_bb.timer_callback += _on_bb_timer;
|
||||
_compute_and_fire();
|
||||
}
|
||||
|
||||
private void _on_bb_data(object tag, object data) {
|
||||
if (_in_bb_exp_params_tag == tag || _in_bb_contracts_tag == tag) {
|
||||
_on_bb_timer();
|
||||
}
|
||||
}
|
||||
|
||||
private void _on_bb_timer() {
|
||||
if (DateTime.Now - _last_fire_time >= _fire_period) {
|
||||
_last_fire_time = DateTime.Now;
|
||||
_compute_and_fire();
|
||||
}
|
||||
}
|
||||
|
||||
private void _compute_and_fire() {
|
||||
_logger.start_default_timer();
|
||||
AnalyticsExpirationParametersMap param_map = _bb.read_state(_in_bb_exp_params_tag);
|
||||
SystemContractData sc_data = _bb.read_state(_in_bb_contracts_tag);
|
||||
if (param_map == null || sc_data == null) {
|
||||
return;
|
||||
}
|
||||
IDictionary<mbts.SecurityExpiration, mbts.SecurityExpiration> driver_map =
|
||||
param_map.get_option_to_driver_map(_sec_tup.security_name);
|
||||
// look up the market data
|
||||
IDictionary<SecurityExpiration, DriverMD> res =
|
||||
new Dictionary<SecurityExpiration, DriverMD>();
|
||||
foreach (var kv in driver_map) {
|
||||
SecurityExpiration option_exp = kv.Key;
|
||||
SecurityExpiration driver = kv.Value;
|
||||
if (_direct_valid_driver(driver)) {
|
||||
Tuple<SecurityImmutable, VolSurfaceMDUnit> md_tup = sc_data.get_exp_md(driver);
|
||||
// to deal with expired expirations
|
||||
if (md_tup != null) {
|
||||
res.Add(option_exp, new DriverMD(md_tup.Item1, md_tup.Item2));
|
||||
}
|
||||
} else {
|
||||
// SecurityTuple driver_sectup = _get_option_driver(driver_map, option_exp);
|
||||
// bts.Log.Gen.info("SingleOptionDriverPricePublisher._compute_and_fire " +
|
||||
// $"option_exp: {option_exp} driver: {driver_sectup}");
|
||||
//
|
||||
double interp_pr = interp_driver(sc_data, driver_map, option_exp);
|
||||
res.Add(option_exp, new DriverMD(interp_pr));
|
||||
}
|
||||
// for exps with interp_drivers (right represented by invalid driver) find the
|
||||
// neighboring option's future. then find the nearest 2 future exps (nearest
|
||||
// to this option's exp) and do a tim weighted interp
|
||||
// if not neighboring driver then calculate it from the spot
|
||||
}
|
||||
if (_is_different(res)) {
|
||||
_last_published = new OptionDriverPriceMap(_sec_tup.security_name, res);
|
||||
var to_fire = new OptionDriverPriceMap(_sec_tup.security_name, res);
|
||||
bts.Log.Gen.info("SingleOptionDriverPricePublisher._compute_and_fire \n" +
|
||||
$"map:{to_fire.log_string()}");
|
||||
_logger.stop_default_timer();
|
||||
_bb.post(SparkTags.OptionDriverBBOTag(_sec_tup.security_name),
|
||||
new OptionDriverPriceMap(_sec_tup.security_name, res));
|
||||
}
|
||||
}
|
||||
|
||||
// compares the new values to the previous
|
||||
private bool _is_different(IDictionary<SecurityExpiration, DriverMD> new_dic) {
|
||||
Func<DriverMD, DriverMD, bool> is_dmd_diff = (d1, d2) => {
|
||||
bool eq = VolSurfaceUtilityFunctions.compare_doubles(d1.get_driver(), d2.get_driver());
|
||||
return !eq;
|
||||
};
|
||||
new_dic.Difference(_last_published.exp_price_map, out var ex_left, out var ex_right, out var overlap);
|
||||
return ex_left.Count() != 0 || ex_right.Count() != 0 ||
|
||||
overlap.Where(v => is_dmd_diff(v.Value.left, v.Value.right)).Count() > 0;
|
||||
}
|
||||
|
||||
#region driver interp
|
||||
private static bool _direct_valid_driver(SecurityExpiration driver_exp) {
|
||||
return driver_exp != null && /*driver_exp.expiration >= DateTime.Now.Date &&*/
|
||||
(driver_exp.security_tuple.security_type == SecurityType.Future ||
|
||||
driver_exp.security_tuple.security_type == SecurityType.Stock);
|
||||
}
|
||||
// returns the driver sectup (it assumes all expirations of this option sectup
|
||||
// are being driven by the same sectup)
|
||||
public static SecurityTuple get_driver_sectup(
|
||||
IDictionary<mbts.SecurityExpiration, mbts.SecurityExpiration> driver_map,
|
||||
SecurityExpiration exp) {
|
||||
foreach (var kv in driver_map) {
|
||||
SecurityExpiration driver = kv.Value;
|
||||
if (_direct_valid_driver(driver) &&
|
||||
exp.security_tuple.Equals(kv.Key.security_tuple)) {
|
||||
return driver.security_tuple;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Tuple<SecurityExpiration, SecurityExpiration>
|
||||
find_neighbors(SystemContractData sc_data,
|
||||
SecurityTuple sec_tup, DateTime exp) {
|
||||
var exps = sc_data.exp_map.Where(
|
||||
kv => sec_tup.Equals(kv.Key.security_tuple)).Select(kv => kv.Key);
|
||||
if (exps == null) {
|
||||
return null;
|
||||
}
|
||||
SecurityExpiration low, high;
|
||||
VolSurfaceUtilityFunctions.find_neighbors(exps, exp,
|
||||
(t, p) => t.expiration.Subtract(p).TotalMilliseconds, out low, out high);
|
||||
return Tuple.Create(low, high);
|
||||
}
|
||||
|
||||
public static double interp_driver(SystemContractData sc_data,
|
||||
IDictionary<SecurityExpiration, SecurityExpiration> driver_map,
|
||||
SecurityExpiration option_exp) {
|
||||
SecurityTuple driver_sectup = get_driver_sectup(driver_map, option_exp);
|
||||
if (driver_sectup == null)
|
||||
return Double.NaN;
|
||||
var ngh_drivers = find_neighbors(sc_data, driver_sectup, option_exp.expiration);
|
||||
if (ngh_drivers == null || ngh_drivers.Item1 == null || ngh_drivers.Item2 == null)
|
||||
return Double.NaN;
|
||||
var low = sc_data.get_exp_md(ngh_drivers.Item1);
|
||||
var high = sc_data.get_exp_md(ngh_drivers.Item2);
|
||||
if (low == null || low.Item2 == null)
|
||||
return Double.NaN;
|
||||
if (high == null || high.Item2 == null)
|
||||
return Double.NaN;
|
||||
// finally we have the value we need, interp it now
|
||||
return VolSurfaceCoreFunctions.linear_interpolate_time(
|
||||
ngh_drivers.Item1.expiration, VolSurfaceCoreFunctions.get_driver(low.Item2),
|
||||
ngh_drivers.Item2.expiration, VolSurfaceCoreFunctions.get_driver(high.Item2),
|
||||
option_exp.expiration);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using mbts.analytics;
|
||||
|
||||
namespace mbts.spark {
|
||||
// UNUSED
|
||||
// This class is held by the SingleVolSurfaceClientPrecomputedTheosPublisher
|
||||
// and acts as a buffer for publishing values. If wait_for_theo_confirmation
|
||||
// setting is true, it publshes an alert tag, otherwise publishes the theos
|
||||
// directly
|
||||
public class SingleVolSurfaceClientTheosPublishHelper {
|
||||
private readonly int _vs_id;
|
||||
private readonly ThreadedBlackboard _bb;
|
||||
private int _n_updates = 0;
|
||||
|
||||
public SingleVolSurfaceClientTheosPublishHelper(int vs_id, ThreadedBlackboard bb) {
|
||||
bts.Log.assert(false);
|
||||
_vs_id = vs_id;
|
||||
_bb = bb;
|
||||
}
|
||||
|
||||
public void publish(IDictionary<VolSurfaceExpiration, IEnumerable<Theos>> exp_theo_map) {
|
||||
if (_n_updates == 0)
|
||||
/// If its the first theos send it rightaway
|
||||
_bb.post(SparkTags.VolSurfaceInterpGreeksTag(_vs_id), exp_theo_map);
|
||||
else {
|
||||
if (_is_theo_acceptance_confirmation_on)
|
||||
_bb.post(SparkTags.VolSurfaceTheoAlertTag,
|
||||
new VolSurfaceTheoAlertData(Guid.NewGuid().ToString(), _vs_id, exp_theo_map));
|
||||
else
|
||||
_bb.post(SparkTags.VolSurfaceInterpGreeksTag(_vs_id), exp_theo_map);
|
||||
}
|
||||
_n_updates++;
|
||||
}
|
||||
|
||||
private bool _is_theo_acceptance_confirmation_on {
|
||||
get {
|
||||
// in edge this was in a TC2 setting
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using mbts.analytics;
|
||||
using bts.api;
|
||||
|
||||
namespace mbts.spark {
|
||||
// Publishes the vol outputs for a single vol surface.
|
||||
// Despite of the name Retriever, this class computes the vols
|
||||
// - f (vs_input, aux_data, securities) -> vs_output
|
||||
// and publishes it
|
||||
// Subs :
|
||||
// 1. Committed VS Input
|
||||
// 3. VS Nonvol Data
|
||||
// Pubs :
|
||||
// 1. VS Out
|
||||
public class SingleVolSurfaceCommittedOutputRetriever : IDisposable {
|
||||
private readonly int _vs_id;
|
||||
private readonly ITag<VolSurfaceInput> _in_bb_vs_input_tag;
|
||||
private readonly ITag<VolSurfaceNonVolData> _in_bb_nonvol_data_tag;
|
||||
private readonly ITag<VolSurfaceStandardTime> _in_vs_standard_time_tag;
|
||||
private readonly ITag<VolSurfaceOutput> _out_bb_computed_vol_tag;
|
||||
private readonly ThreadedBlackboard _bb;
|
||||
private readonly HighPerformanceTimer _timer = new HighPerformanceTimer();
|
||||
private readonly PerfStatsLogger _logger = new PerfStatsLogger(50, 100);
|
||||
private readonly string _log_id;
|
||||
|
||||
public SingleVolSurfaceCommittedOutputRetriever(int vs_id,
|
||||
ThreadedBlackboard threaded_bb, IEnumerable<string> symbols) {
|
||||
bts.Log.Gen.info($"SingleVolSurfaceCommittedOutputRetriever cons vs_id:{vs_id} tid:{_tid()}");
|
||||
_vs_id = vs_id;
|
||||
_bb = threaded_bb;
|
||||
_in_bb_vs_input_tag = SparkTags.VolSurfaceCommittedInputTag(vs_id);
|
||||
_in_bb_nonvol_data_tag = SparkTags.VolSurfaceNonVolDataTag(vs_id);
|
||||
_in_vs_standard_time_tag = SparkTags.VolSurfaceStandardTimeTag(vs_id);
|
||||
_out_bb_computed_vol_tag = SparkTags.VolSurfaceCommittedOutputTag(vs_id);
|
||||
_log_id = String.Format("SingleVolSurfaceCommittedOutputRetriever_{0}", vs_id);
|
||||
_bb.subscribe(_in_bb_vs_input_tag);
|
||||
_bb.subscribe(_in_bb_nonvol_data_tag);
|
||||
_bb.subscribe(_in_vs_standard_time_tag);
|
||||
_bb.data_callback += _on_bb_data;
|
||||
_recompute_and_publish();
|
||||
}
|
||||
private static int _tid() { return VolSurfaceTroubleshootingFunctions.tid(); }
|
||||
private void _on_bb_data(object tag, object data) {
|
||||
if (_in_bb_vs_input_tag.Equals(tag) || _in_bb_nonvol_data_tag.Equals(tag) ||
|
||||
_in_vs_standard_time_tag.Equals(tag))
|
||||
_recompute_and_publish(tag);
|
||||
}
|
||||
|
||||
private void _recompute_and_publish(object tag = null) {
|
||||
VolSurfaceInput vs_input = _bb.read_state(_in_bb_vs_input_tag);
|
||||
VolSurfaceNonVolData vs_nonvol_data = _bb.read_state(_in_bb_nonvol_data_tag);
|
||||
VolSurfaceStandardTime vs_standard_time = _bb.read_state(_in_vs_standard_time_tag);
|
||||
if (vs_input != null && vs_nonvol_data != null && vs_standard_time != null) {
|
||||
_timer.start();
|
||||
IDictionary<VolSurfaceExpiration, VolSurfaceExpirationAuxiliaryData> aux_data_map =
|
||||
VolSurfaceUtilityFunctions.compute_aux_data(vs_input,
|
||||
vs_nonvol_data.input, vs_nonvol_data.driver_price_map, vs_standard_time);
|
||||
VolSurfaceOutput vs_output = GeneralVolSurfaceCalculator.compute(
|
||||
vs_input, vs_nonvol_data.contracts, aux_data_map);
|
||||
_timer.stop();
|
||||
var tag_str = tag == null ? "Null" : tag.ToString();
|
||||
bts.Log.Gen.info($"SingleVolSurfaceCommittedOutputRetriever._recompute_and_publish " +
|
||||
$"vs_id: {_vs_id} time:{_timer.lastIntervalTime} ms tag:{tag_str} " +
|
||||
$"tid:{_tid()}"); //output: {vs_output.log_string()}*/");
|
||||
_logger.log(_log_id, _log_id, _timer.lastIntervalTime);
|
||||
_bb.post(_out_bb_computed_vol_tag, vs_output);
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
public void Dispose() { _bb.data_callback -= _on_bb_data; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using mbts.analytics;
|
||||
using bts;
|
||||
using bts.utils;
|
||||
using bts.api;
|
||||
|
||||
|
||||
namespace mbts.spark {
|
||||
/// Listens to the input (either committed or candidate depending on the arg)
|
||||
/// and creates the actual source that is immutable wrt the symbol list.
|
||||
/// (Making the real sources immutable wrt to the symbol list simplifies
|
||||
/// things a lot. Symbol lists rarely every change, but its a pain to
|
||||
/// handle such changes)
|
||||
public class SingleVolSurfaceDataSource : IDisposable {
|
||||
public enum SymbolListType {
|
||||
Committed,
|
||||
Candidate,
|
||||
Combined,
|
||||
}
|
||||
private readonly SymbolListType _list_type;
|
||||
private readonly int _vs_id;
|
||||
private readonly ThreadedBlackboard _bb;
|
||||
private readonly Func<IEnumerable<string>, IDisposable> _create_func;
|
||||
private readonly ITag<VolSurfaceInput> _in_bb_committed_data_tag;
|
||||
private readonly ITag<VolSurfaceCalculationRequest> _in_bb_calc_req_tag;
|
||||
|
||||
private HashSet<string> _option_symbols = new HashSet<string>();
|
||||
private IDisposable _source = null;
|
||||
|
||||
public SingleVolSurfaceDataSource(SymbolListType list_type, int vs_id, ThreadedBlackboard threaded_bb,
|
||||
Func<IEnumerable<string>, IDisposable> create_func) {
|
||||
Log.Gen.info(String.Format("SingleVolSurfaceDataSource constructed vs_id {0}", vs_id));
|
||||
_list_type = list_type;
|
||||
_vs_id = vs_id;
|
||||
_bb = threaded_bb;
|
||||
_create_func = create_func;
|
||||
_in_bb_committed_data_tag = SparkTags.VolSurfaceCommittedInputTag(vs_id);
|
||||
_in_bb_calc_req_tag = SparkTags.VolSurfaceCalculationRequestTag(vs_id);
|
||||
_bb.subscribe(_in_bb_committed_data_tag);
|
||||
_bb.subscribe(_in_bb_calc_req_tag);
|
||||
_bb.data_callback += _on_bb_data;
|
||||
_recompute();
|
||||
}
|
||||
|
||||
private void _on_bb_data(object tag, object data) {
|
||||
if (_in_bb_committed_data_tag.Equals(tag) || _in_bb_calc_req_tag.Equals(tag))
|
||||
_recompute();
|
||||
}
|
||||
|
||||
private void _recompute() {
|
||||
VolSurfaceCalculationRequest vs_calc_req = _bb.read_state(_in_bb_calc_req_tag);
|
||||
VolSurfaceInput vs_comm_inp = _bb.read_state(_in_bb_committed_data_tag);
|
||||
if (_list_type == SymbolListType.Candidate) {
|
||||
if (vs_calc_req != null && vs_calc_req.volsurface_input != null) {
|
||||
HashSet<string> new_sym_map = new HashSet<string>(VolSurfaceDataFunctions.get_symbols(vs_calc_req.volsurface_input));
|
||||
_create_if_needed(new_sym_map);
|
||||
}
|
||||
} else if (_list_type == SymbolListType.Committed) {
|
||||
if (vs_comm_inp != null) {
|
||||
HashSet<string> new_sym_map = new HashSet<string>(VolSurfaceDataFunctions.get_symbols(vs_comm_inp));
|
||||
_create_if_needed(new_sym_map);
|
||||
}
|
||||
} else if (_list_type == SymbolListType.Combined) {
|
||||
List<string> new_sym_list = new List<string>();
|
||||
if (vs_calc_req != null && vs_calc_req.volsurface_input != null)
|
||||
new_sym_list.AddRange(VolSurfaceDataFunctions.get_symbols(vs_calc_req.volsurface_input));
|
||||
if (vs_comm_inp != null)
|
||||
new_sym_list.AddRange(VolSurfaceDataFunctions.get_symbols(vs_comm_inp));
|
||||
_create_if_needed(new HashSet<string>(new_sym_list));
|
||||
}
|
||||
}
|
||||
|
||||
private void _create_if_needed(HashSet<string> new_sym_map) {
|
||||
if (!CollectionHelper.hashset_equals(_option_symbols, new_sym_map)) {
|
||||
_option_symbols = new HashSet<string>(new_sym_map);
|
||||
if (_source != null)
|
||||
_source.Dispose();
|
||||
_source = _create_func(_option_symbols);
|
||||
_bb.post(SparkTags.AquireTag(Guid.NewGuid().ToString()),
|
||||
new SymbolResourceAllocationUnit(
|
||||
_option_symbols.Select(i => new mbts.SecurityTuple(SecurityType.Option, i, Venue.Unset)), this, true));
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
public void Dispose() {
|
||||
if (_source != null)
|
||||
_source.Dispose();
|
||||
_bb.data_callback -= _on_bb_data;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using mbts.analytics;
|
||||
using bts;
|
||||
using bts.api.analytics;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading;
|
||||
using bts.api;
|
||||
using System.Collections;
|
||||
|
||||
namespace mbts.spark {
|
||||
// For a single VolSurface this class
|
||||
// 1. Listents to commmits and calls the service to persist data
|
||||
// 2. Gathers the vol surface input from the nw and publishes it
|
||||
// 3. Gathers the vol surface list and publishes it
|
||||
public class SingleVolSurfaceGateway : IDisposable {
|
||||
private readonly int _volsurface_id;
|
||||
private readonly ThreadedBlackboard _bb;
|
||||
private readonly ITag<VolSurfaceInput> _in_bb_committ_tag;
|
||||
private readonly AnalyticsService _analytics_service;
|
||||
private readonly HighPerformanceTimer _timer = new HighPerformanceTimer();
|
||||
private readonly string _user;
|
||||
private readonly List<IDisposable> _disposables = new List<IDisposable>();
|
||||
private IDictionary<UInt64, VolSurfaceInputSnapshot> _snp_shot_map = new
|
||||
Dictionary<UInt64, VolSurfaceInputSnapshot>();
|
||||
|
||||
public SingleVolSurfaceGateway(int volsurface_id, ThreadedBlackboard threaded_bb,
|
||||
AnalyticsService analytics_service) {
|
||||
bts.Log.Gen.info(String.Format("SingleVolSurfaceGateway created for vs_id:{0}",
|
||||
volsurface_id));
|
||||
_volsurface_id = volsurface_id;
|
||||
_bb = threaded_bb;
|
||||
_user = "TEST_USER"; // TODO
|
||||
_in_bb_committ_tag = SparkTags.VolSurfaceCommitTag(volsurface_id);
|
||||
_analytics_service = analytics_service;
|
||||
_bb.subscribe(_in_bb_committ_tag);
|
||||
_bb.data_callback += _on_bb_data;
|
||||
var vs_sub = _analytics_service.subscribei_volsurfaces()
|
||||
.ObserveOn(SynchronizationContext.Current)
|
||||
.Subscribe(_on_vss);
|
||||
_disposables.Add(vs_sub);
|
||||
}
|
||||
|
||||
private void _log_basic_vs_info(VolSurfaceInput vs_inp) {
|
||||
bts.Log.Gen.info(String.Format("SingleVolSurfaceGateway vs_id:{0} vs:{1}",
|
||||
vs_inp.surface_settings.core_settings.vol_surface_id, vs_inp.log_string()));
|
||||
}
|
||||
|
||||
private void _on_vss(bts.api.core.Update<VolSurfaceEntryImmutable, UInt64> update) {
|
||||
IEnumerable<VolSurfaceEntryImmutable> all_vss = update.all;
|
||||
var this_vs_vss = all_vss.Where(vs => vs.VsId == _volsurface_id);
|
||||
bts.Log.Gen.info(String.Format("SingleVolSurfaceGateway._on_vss count:{0} vs_count:{1}",
|
||||
all_vss.Count(), this_vs_vss.Count()));
|
||||
if (this_vs_vss.Count() == 0) {
|
||||
return;
|
||||
}
|
||||
VolSurfaceEntryImmutable vs = this_vs_vss.MaxElement(vs => vs.SaveTime);
|
||||
VolSurfaceInput vs_input = _to_vs_input(vs);
|
||||
_log_basic_vs_info(vs_input);
|
||||
_bb.post(
|
||||
SparkTags.VolSurfaceCommittedInputTag(_volsurface_id), vs_input);
|
||||
_update_publish_snapshots(this_vs_vss);
|
||||
}
|
||||
|
||||
private void _update_publish_snapshots(IEnumerable<VolSurfaceEntryImmutable> vss) {
|
||||
foreach (VolSurfaceEntryImmutable vse in vss) {
|
||||
if (!_snp_shot_map.ContainsKey(vse.SaveTime)) {
|
||||
VolSurfaceInputSnapshot snp = new VolSurfaceInputSnapshot(vse);
|
||||
_snp_shot_map.Add(vse.SaveTime, snp);
|
||||
}
|
||||
}
|
||||
bts.Log.Gen.info(String.Format("SingleVolSurfaceGateway._update_publish_snapshots count:{0}",
|
||||
_snp_shot_map.Count));
|
||||
_bb.post(SparkTags.VolSurfaceInputSnapshotListTag(_volsurface_id),
|
||||
_snp_shot_map.Values);
|
||||
}
|
||||
|
||||
static VolSurfaceInput _to_vs_input(VolSurfaceEntryImmutable vs) {
|
||||
byte[] vs_bytes = vs.Volsurface.ToByteArray();
|
||||
return
|
||||
mbts.analytics.VolSurfaceUtilityFunctions.deserialize_proto<VolSurfaceInput>(vs_bytes);
|
||||
}
|
||||
|
||||
private void _on_bb_data(object tag, object data) {
|
||||
if (_in_bb_committ_tag.Equals(tag)) {
|
||||
try {
|
||||
_timer.start();
|
||||
VolSurfaceInput vs_input = data as VolSurfaceInput;
|
||||
_sanitize_input(ref vs_input);
|
||||
vs_input = VolSurfaceDataFunctions.unset_driver_overrides(vs_input);
|
||||
vs_input.saver_login = _user;
|
||||
VolSurfaceUtilityFunctions.save_volsurface(vs_input, _analytics_service, _user);
|
||||
_timer.stop();
|
||||
Log.Gen.info(String.Format(
|
||||
"SingleVolSurfaceGateway._on_bb_data Time to commit volsurface {0} {1} msecs",
|
||||
_volsurface_id, _timer.lastIntervalTime));
|
||||
var archived_theos = _get_theos();
|
||||
if (archived_theos != null)
|
||||
_analytics_service.archive_theos(archived_theos);
|
||||
} catch (Exception ex) {
|
||||
Log.Gen.warn(ex.ToString());
|
||||
_bb.post(SparkTags.MessageDisplayTag,
|
||||
new MessageDisplayData("Vol Surface Addition",
|
||||
String.Format("Could not create Vol Surface, Error : {0}", ex.Message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _sanitize_input(ref VolSurfaceInput vs_input) {
|
||||
vs_input.surface_settings.core_settings.time_settings = vs_input.surface_settings.core_settings.time_settings ?? new VolSurfaceTimeSettings() { time_mode = VolSurfaceEnums.VolSurfaceTimeMode.Manual };
|
||||
if (vs_input.surface_settings.core_settings.master_slave_relationships != null)
|
||||
foreach (VolSurfaceSymbolRelationship vssr in vs_input.surface_settings.core_settings.master_slave_relationships)
|
||||
_force_distinct_connected_symbols(vssr);
|
||||
if (vs_input.surface_settings.core_settings.implied_vol_marketdata_relationships != null)
|
||||
foreach (VolSurfaceSymbolRelationship vssr in vs_input.surface_settings.core_settings.implied_vol_marketdata_relationships)
|
||||
_force_distinct_connected_symbols(vssr);
|
||||
}
|
||||
|
||||
private void _force_distinct_connected_symbols(VolSurfaceSymbolRelationship vssr) {
|
||||
var distinct_syms = vssr.connected_symbols.Distinct().ToList();
|
||||
if (distinct_syms.Count != vssr.connected_symbols.Count)
|
||||
vssr.connected_symbols = distinct_syms;
|
||||
}
|
||||
|
||||
private ArchivedTheoList _get_theos() {
|
||||
var cand_theos = SingleVolSurfaceTheoSource.compute_cand_theos(_volsurface_id, _bb);
|
||||
SystemContractData sc_data = _bb.read_state(SparkTags.SystemContractsTag);
|
||||
var rv = SingleVolSurfaceTheoSource.convert_to_id_map(cand_theos, sc_data);
|
||||
rv.SaveTime = VolSurfaceUtilityFunctions.get_unix_epoch_msecs();
|
||||
var sec_tups = SingleVolSurfaceTheoSource.get_vs_sectups(_volsurface_id, _bb);
|
||||
rv.SecTups.AddRange(sec_tups);
|
||||
return rv;
|
||||
}
|
||||
|
||||
#region Disposable
|
||||
public void Dispose() {
|
||||
_bb.data_callback -= _on_bb_data;
|
||||
_disposables.ForEach(d => d.Dispose());
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using mbts.analytics;
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using mbts.ui.converters;
|
||||
|
||||
namespace mbts.spark {
|
||||
// This class gathers all the inputs needed to calculate InterpGreeks, pass it to
|
||||
// VolSurfacePrecomputedTheosProducer, and publishes the InterpGreeks to the bus
|
||||
// (called SingleVolSurfaceClientPrecomputedTheosPublisher in Edge)
|
||||
// It listens to
|
||||
// a. vol surface inputs
|
||||
// b. exp params (roll, rates etc)
|
||||
// c. securities (exp, strikes) for options in the vs
|
||||
// d. driver prices for options in vs
|
||||
// and passes the data above to VolSurfacePrecomputedTheosProducer where
|
||||
// the real calculations take place.
|
||||
public class SingleVolSurfaceInterpGreeksPublisher : IDisposable {
|
||||
private readonly int _vs_id;
|
||||
private readonly ThreadedBlackboard _bb;
|
||||
private HashSet<string> _all_symbols;
|
||||
private VolSurfaceInterpGreeksProducer _theo_producer;
|
||||
private readonly ITag<VolSurfaceInput> _in_vs_input_tag;
|
||||
private readonly ITag<VolSurfaceNonVolInput> _in_vs_nonvol_input_tag;
|
||||
private readonly ITag<VolSurfaceStrikeMap> _in_vs_contracts_tag;
|
||||
private ITag<IReadOnlyDictionary<string, OptionDriverPriceMap>>
|
||||
_in_all_syms_driver_price_tag = SparkTags.AllOptionDriverBBOTag;
|
||||
private readonly ITag<VolSurfaceStandardTime> _in_vs_standard_time_tag;
|
||||
private readonly ITag<bool> _in_ui_up_tag;
|
||||
private readonly string _user;
|
||||
private readonly PerfStatsLogger _logger;
|
||||
|
||||
public SingleVolSurfaceInterpGreeksPublisher(int vs_id,
|
||||
ThreadedBlackboard threaded_bb, IEnumerable<string> symbols) {
|
||||
bts.Log.Gen.info($"SingleVolSurfaceInterpGreeksPublisher cons {vs_id}");
|
||||
_vs_id = vs_id;
|
||||
_bb = threaded_bb;
|
||||
_all_symbols = new HashSet<string>(symbols);
|
||||
_logger = new PerfStatsLogger(10, 100,
|
||||
$"SingleVolSurfaceInterpGreeksPublisher_{vs_id}");
|
||||
_theo_producer = new VolSurfaceInterpGreeksProducer(vs_id);
|
||||
// TODO
|
||||
_user = String.Empty; // get current user from somewhere (ask John)
|
||||
_theo_producer.on_theos += _theo_producer_on_theos;
|
||||
_theo_producer.on_vols += _theo_producer_on_vols;
|
||||
_in_vs_input_tag = SparkTags.VolSurfaceCommittedInputTag(vs_id);
|
||||
_in_vs_nonvol_input_tag = SparkTags.VolSurfaceNonVolInputTag;
|
||||
_in_vs_contracts_tag = SparkTags.VolSurfaceContractsTag(vs_id);
|
||||
_in_vs_standard_time_tag = SparkTags.VolSurfaceStandardTimeTag(vs_id);
|
||||
_in_ui_up_tag = SparkTags.VolSurfaceActiveUITag(_vs_id);
|
||||
_bb.subscribe(_in_vs_input_tag);
|
||||
_bb.subscribe(_in_vs_nonvol_input_tag);
|
||||
_bb.subscribe(_in_vs_contracts_tag);
|
||||
_bb.subscribe(_in_all_syms_driver_price_tag);
|
||||
_bb.subscribe(_in_vs_standard_time_tag);
|
||||
_bb.subscribe(_in_ui_up_tag);
|
||||
_bb.data_callback += _on_bb_data;
|
||||
_init();
|
||||
}
|
||||
|
||||
// reading all the data from the bus and setting up the producer
|
||||
private void _init() {
|
||||
var vs_inp = _bb.read_state(_in_vs_input_tag);
|
||||
if (vs_inp != null)
|
||||
_theo_producer.set_vol_data(vs_inp);
|
||||
var vs_nonvol_input = _bb.read_state(_in_vs_nonvol_input_tag);
|
||||
if (vs_nonvol_input != null)
|
||||
_theo_producer.set_nonvol_parameters((vs_nonvol_input).exp_input_map);
|
||||
_set_contracts();
|
||||
_read_and_set_drivers();
|
||||
var vs_standard_time = _bb.read_state(_in_vs_standard_time_tag);
|
||||
if (vs_standard_time != null)
|
||||
_theo_producer.set_system_vol_time(vs_standard_time);
|
||||
}
|
||||
|
||||
private void _read_and_set_drivers() {
|
||||
var all_sym_price_map = _bb.read_state(_in_all_syms_driver_price_tag);
|
||||
IDictionary<VolSurfaceExpiration, DriverMD> exp_price_map =
|
||||
OptionDriverPriceMap.get_vs_price_map(all_sym_price_map,
|
||||
(s) => _all_symbols.Contains(s));
|
||||
_theo_producer.set_driver_price(
|
||||
exp_price_map.ToDictionary(kv => kv.Key, kv => kv.Value.get_driver()));
|
||||
}
|
||||
|
||||
#region Blackboard Callbacks
|
||||
private void _on_bb_data(object tag, object data) {
|
||||
if (_in_vs_input_tag.Equals(tag)) {
|
||||
var vs_inp = _bb.read_state(_in_vs_input_tag);
|
||||
_theo_producer.set_vol_data(vs_inp);
|
||||
} else if (_in_vs_nonvol_input_tag.Equals(tag)) {
|
||||
var vs_nonvol_input = _bb.read_state(_in_vs_nonvol_input_tag);
|
||||
if (vs_nonvol_input != null)
|
||||
_theo_producer.set_nonvol_parameters((vs_nonvol_input).exp_input_map);
|
||||
} else if (_in_vs_contracts_tag.Equals(tag))
|
||||
_set_contracts();
|
||||
else if (_in_all_syms_driver_price_tag.Equals(tag))
|
||||
_read_and_set_drivers();
|
||||
else if (_in_vs_standard_time_tag.Equals(tag))
|
||||
_theo_producer.set_system_vol_time(_bb.read_state(_in_vs_standard_time_tag));
|
||||
}
|
||||
|
||||
private void _set_contracts() {
|
||||
// in edge this used to filter exps that were active in TC2
|
||||
var all_contracts = _bb.read_state(_in_vs_contracts_tag);
|
||||
if (all_contracts != null) {
|
||||
_theo_producer.set_contracts(all_contracts.strike_map);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void _log_data<T>(
|
||||
IDictionary<VolSurfaceExpiration, IEnumerable<T>> theos,
|
||||
DateTime exp_filter,
|
||||
string prefix,
|
||||
Func<T, string> log_func,
|
||||
Comparison<T> sort_func) {
|
||||
string rv = prefix + "\n";
|
||||
foreach (var kv in theos) {
|
||||
var exp = kv.Key;
|
||||
if (exp.expiration != exp_filter) {
|
||||
continue;
|
||||
}
|
||||
var sorted = new List<T>(kv.Value);
|
||||
sorted.Sort(sort_func);
|
||||
foreach (var t in sorted) {
|
||||
rv += "\n" + $"exp: {exp} {log_func(t)}";
|
||||
}
|
||||
}
|
||||
Log.Gen.info(rv);
|
||||
}
|
||||
|
||||
private void _log_vol_matrix(
|
||||
IDictionary<VolSurfaceExpiration, IEnumerable<VolMatrix>> vols,
|
||||
DateTime exp_filter) {
|
||||
_log_data(vols, exp_filter, "InterpGreeks VolMatrix", (t) => t.log_string(),
|
||||
(t1, t2) => {
|
||||
var rv = t1.expiration.CompareTo(t2.expiration);
|
||||
if (rv == 0)
|
||||
rv = t1.strike.CompareTo(t2.strike);
|
||||
if (rv == 0)
|
||||
rv = t1.driver.CompareTo(t2.driver);
|
||||
return rv;
|
||||
});
|
||||
}
|
||||
|
||||
private void _log_theos(
|
||||
IDictionary<VolSurfaceExpiration, IEnumerable<Theos>> theos,
|
||||
DateTime exp_filter) {
|
||||
_log_data(theos, exp_filter, "InterpGreeks Theos", (t) => t.log_string(),
|
||||
(t1, t2) => {
|
||||
var rv = t1.expiration.CompareTo(t2.expiration);
|
||||
if (rv == 0)
|
||||
rv = t1.strike.CompareTo(t2.strike);
|
||||
if (rv == 0)
|
||||
rv = t1.driver.CompareTo(t2.driver);
|
||||
return rv;
|
||||
});
|
||||
}
|
||||
|
||||
private int _n_updates = 0;
|
||||
private void _theo_producer_on_theos(
|
||||
IDictionary<VolSurfaceExpiration, IEnumerable<Theos>> exp_theo_map,
|
||||
double vol_compute_time, double theo_compute_time) {
|
||||
Log.Gen.info("SingleVolSurfaceInterpGreeksPublisher._theo_producer_on_theos " +
|
||||
$"vs_id: {_vs_id} n_updates: {++_n_updates} " +
|
||||
$"vol_compute_time: {vol_compute_time} " +
|
||||
$"theo_compute_time: {theo_compute_time}");
|
||||
_logger.log_default(theo_compute_time);
|
||||
_bb.post(SparkTags.VolSurfaceInterpGreeksTag(_vs_id), exp_theo_map);
|
||||
}
|
||||
|
||||
private void _theo_producer_on_vols(
|
||||
IDictionary<VolSurfaceExpiration, IEnumerable<mbts.analytics.VolMatrix>> exp_vol_map,
|
||||
double vol_compute_time, double theo_compute_time) {
|
||||
Log.Gen.info("SingleVolSurfaceInterpGreeksPublisher._theo_producer_on_vols " +
|
||||
$"vs_id: {_vs_id} vol_compute_time: {vol_compute_time} " +
|
||||
$"theo_compute_time: {theo_compute_time}");
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
public void Dispose() {
|
||||
_bb.data_callback -= _on_bb_data;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using bts.api.analytics;
|
||||
using bts.api;
|
||||
|
||||
namespace mbts.spark {
|
||||
public class SingleVolSurfaceManager : IDisposable {
|
||||
private readonly int _vs_id;
|
||||
private IEnumerable<IDisposable> _resources;
|
||||
private readonly ThreadedBlackboard _bb;
|
||||
private readonly AnalyticsService _analytics_service;
|
||||
private ITag<bool> _vs_activation_tag;
|
||||
private bool _activated = false;
|
||||
|
||||
public SingleVolSurfaceManager(int vs_id, ThreadedBlackboard t_bb,
|
||||
AnalyticsService analytics_service) {
|
||||
var tid = System.Threading.Thread.CurrentThread.ManagedThreadId;
|
||||
bts.Log.Ui.info($"SingleVolSurfaceManager.cons vs_id:{vs_id} tid:{tid}");
|
||||
_vs_id = vs_id;
|
||||
_bb = t_bb;
|
||||
_analytics_service = analytics_service;
|
||||
_vs_activation_tag = SparkTags.VolSurfaceActiveUITag(vs_id);
|
||||
_bb.subscribe(_vs_activation_tag);
|
||||
_bb.data_callback += _on_data;
|
||||
}
|
||||
|
||||
private void _spin_resources() {
|
||||
bts.Log.Ui.info($"SingleVolSurfaceManager._spin_resources vs_id:{_vs_id}");
|
||||
_resources = new IDisposable[]
|
||||
{
|
||||
new SingleVolSurfaceGateway(_vs_id, _bb, _analytics_service),
|
||||
new SingleVolSurfaceTimeSource(_vs_id,_bb),
|
||||
new SingleVolSurfaceDataSource(SingleVolSurfaceDataSource.SymbolListType.Combined,
|
||||
_vs_id, _bb, syms => new SingleVolSurfaceNonVolDataSource(_vs_id, syms, _bb)),
|
||||
new SingleVolSurfaceDataSource(SingleVolSurfaceDataSource.SymbolListType.Committed, _vs_id, _bb,
|
||||
a_syms => new SingleVolSurfaceCommittedOutputRetriever(_vs_id, _bb, a_syms)),
|
||||
new SingleVolSurfaceDataSource(SingleVolSurfaceDataSource.SymbolListType.Combined, _vs_id, _bb,
|
||||
a_syms => new SingleVolSurfaceRequestCalculator(_vs_id, a_syms, _bb)),
|
||||
new SingleVolSurfaceMarketImpliedVolSource(_vs_id, _bb),
|
||||
// new SingleVolSurfaceTheoSource(_vs_id, _bb),
|
||||
// TODO: suspending heatmaps for now (12/24/21)
|
||||
// new SingleVolSurfaceHeatmapManager (vs_id, t_bb),
|
||||
// server work that can optionally be done on the client
|
||||
new SingleVolSurfaceDataSource (SingleVolSurfaceDataSource.SymbolListType.Committed, _vs_id, _bb,
|
||||
a_syms => new SingleVolSurfaceInterpGreeksPublisher (_vs_id, _bb, a_syms)),
|
||||
};
|
||||
}
|
||||
|
||||
private void _on_data(object tag, object data) {
|
||||
if (_vs_activation_tag.Equals(tag)) {
|
||||
if (_activated) {
|
||||
// TODO: not cleaning up recources
|
||||
return;
|
||||
}
|
||||
bool is_activation_signal = data is Boolean && (Boolean)data;
|
||||
if (is_activation_signal) {
|
||||
_activated = true;
|
||||
_spin_resources();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
private bool _is_disposed = false;
|
||||
public void Dispose() {
|
||||
if (!_is_disposed) {
|
||||
_is_disposed = true;
|
||||
_resources.ToList().ForEach(d => d.Dispose());
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,236 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using bts;
|
||||
using bts.api;
|
||||
|
||||
using mbts;
|
||||
using mbts.analytics;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
|
||||
/// This class publishes the market implied vols for the
|
||||
/// selected expiration.
|
||||
public class SingleVolSurfaceMarketImpliedVolSource : IDisposable {
|
||||
// This keeps the last computed exp and its bbo
|
||||
#region MD caching
|
||||
private class CachedExpMD {
|
||||
public SecurityExpiration exp = SecurityExpiration.empty;
|
||||
public IDictionary<double, Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit>> k_md_map =
|
||||
new Dictionary<double, Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit>>();
|
||||
private bool _has_changed(
|
||||
SecurityExpiration new_exp,
|
||||
IDictionary<double, Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit>> new_k_md_map) {
|
||||
if (new_exp != exp) {
|
||||
return true;
|
||||
}
|
||||
if (k_md_map.Count() != new_k_md_map.Count) {
|
||||
return true;
|
||||
}
|
||||
foreach (var kv in k_md_map) {
|
||||
Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit> k_md;
|
||||
if (!new_k_md_map.TryGetValue(kv.Key, out k_md)) {
|
||||
return true;
|
||||
}
|
||||
if (!kv.Value.Item1.Equals(k_md.Item1) ||
|
||||
!kv.Value.Item2.Equals(k_md.Item2)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public bool set(
|
||||
SecurityExpiration new_exp,
|
||||
IDictionary<double, Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit>> new_k_md_map) {
|
||||
bool has_changed = _has_changed(new_exp, new_k_md_map);
|
||||
if (has_changed) {
|
||||
exp = new_exp;
|
||||
k_md_map = new_k_md_map;
|
||||
}
|
||||
return has_changed;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
private readonly int _vs_id;
|
||||
private readonly ITag<IReadOnlyDictionary<uint, SecurityMD>> _in_bb_sec_map_tag;
|
||||
private readonly ITag<mbts.analytics.VolSurfaceOutput> _in_bb_committed_output_tag;
|
||||
private readonly ITag<VolSurfaceCalculationResponse> _in_bb_calc_resp_tag;
|
||||
private readonly ITag<bool> _in_bb_inp_dirty_tag;
|
||||
private readonly ITag<Tuple<VolSurfaceDisplayGridExpiration, bool>>
|
||||
_in_bb_selected_exp_tag;
|
||||
private readonly ITag<mbts.analytics.VolSurfaceEnums.MarketSide>
|
||||
_in_bb_market_impliedvol_side_tag;
|
||||
private readonly ITag<bool> _in_bb_ignore_market_implied_vol_source_settings_tag;
|
||||
private CachedExpMD _cached_exp_md = new CachedExpMD();
|
||||
private readonly ThreadedBlackboard _bb;
|
||||
private readonly HighPerformanceTimer _timer = new HighPerformanceTimer();
|
||||
private readonly PerfStatsLogger _logger = new PerfStatsLogger(50, 50);
|
||||
private TimeSpan _compute_period = TimeSpan.FromMilliseconds(333);
|
||||
private bool _is_dirty = true;
|
||||
|
||||
public SingleVolSurfaceMarketImpliedVolSource(int vs_id, ThreadedBlackboard bb) {
|
||||
bts.Log.Gen.info($"SingleVolSurfaceMarketImpliedVolSource cons vs_id:{vs_id}");
|
||||
_vs_id = vs_id;
|
||||
_bb = bb;
|
||||
_in_bb_sec_map_tag = SparkTags.SecuritiesTag;
|
||||
_in_bb_committed_output_tag = SparkTags.VolSurfaceCommittedOutputTag(vs_id);
|
||||
_in_bb_calc_resp_tag = SparkTags.VolSurfaceCalculationResponseTag(vs_id);
|
||||
_in_bb_inp_dirty_tag = SparkTags.VolSurfaceDirtyStateTag(vs_id);
|
||||
_in_bb_selected_exp_tag = SparkTags.VolSurfaceGridSelectionTag(_vs_id);
|
||||
_in_bb_market_impliedvol_side_tag = SparkTags.VolSurfaceMarketImpliedVolSide(_vs_id);
|
||||
_in_bb_ignore_market_implied_vol_source_settings_tag =
|
||||
SparkTags.VolSurfaceIgnoreImpliedVolSettingsTag(vs_id);
|
||||
_bb.subscribe(_in_bb_committed_output_tag);
|
||||
_bb.subscribe(_in_bb_calc_resp_tag);
|
||||
_bb.subscribe(_in_bb_inp_dirty_tag);
|
||||
_bb.subscribe(_in_bb_selected_exp_tag);
|
||||
_bb.subscribe(_in_bb_market_impliedvol_side_tag);
|
||||
_bb.subscribe(_in_bb_ignore_market_implied_vol_source_settings_tag);
|
||||
_bb.data_callback += _on_bb_data;
|
||||
_bb.timer_callback += _on_bb_timer;
|
||||
}
|
||||
|
||||
private void _on_bb_data(object tag, object data) {
|
||||
if (tag != null)
|
||||
if (_in_bb_committed_output_tag.Equals(tag) ||
|
||||
_in_bb_calc_resp_tag.Equals(tag) ||
|
||||
_in_bb_inp_dirty_tag.Equals(tag) || _in_bb_selected_exp_tag.Equals(tag) ||
|
||||
_in_bb_market_impliedvol_side_tag.Equals(tag) ||
|
||||
_in_bb_ignore_market_implied_vol_source_settings_tag.Equals(tag))
|
||||
_is_dirty = true;
|
||||
}
|
||||
|
||||
private void _check_bbo_change() {
|
||||
var sc_data = _bb.read_state(SparkTags.SystemContractsTag);
|
||||
Tuple<VolSurfaceDisplayGridExpiration, bool> sel_exp_tup =
|
||||
_bb.read_state(_in_bb_selected_exp_tag);
|
||||
if (sc_data == null || sel_exp_tup == null) {
|
||||
return;
|
||||
}
|
||||
VolSurfaceExpiration new_sel_exp = sel_exp_tup.Item1.ToVSExp();
|
||||
var new_md = sc_data.get_option_bbo_vsexp(new_sel_exp);
|
||||
bool bbo_dirty = _cached_exp_md.set(new_md.Item1, new_md.Item2);
|
||||
_is_dirty = _is_dirty || bbo_dirty;
|
||||
}
|
||||
|
||||
private DateTime _last_publish_time = DateTime.MinValue;
|
||||
private void _on_bb_timer() {
|
||||
if (DateTime.Now - _last_publish_time >= _compute_period) {
|
||||
_check_bbo_change();
|
||||
if (_is_dirty)
|
||||
_recompute_and_publish();
|
||||
_is_dirty = false;
|
||||
_last_publish_time = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
private void _recompute_and_publish() {
|
||||
Tuple<VolSurfaceDisplayGridExpiration, bool> sel_exp =
|
||||
_bb.read_state(_in_bb_selected_exp_tag);
|
||||
VolSurfaceOutput vs_output = _resolve_curr_cand();
|
||||
if (vs_output != null && vs_output.volsurface_input != null &&
|
||||
vs_output.aux_data_map != null &&
|
||||
sel_exp != null && sel_exp.Item1 != null) {
|
||||
var impliedvol_side = _get_market_impliedvol_side(_bb, _vs_id);
|
||||
VolSurfaceExpiration orig_exp = new VolSurfaceExpiration() {
|
||||
symbol = sel_exp.Item1.symbol,
|
||||
expiration = sel_exp.Item1.expiration
|
||||
};
|
||||
_timer.start();
|
||||
VolSurfaceExpiration md_exp;
|
||||
VolCurveMarketImpliedVolData exp_impl_vol_map =
|
||||
VolSurfaceCoreFunctions.compute_implied_vols(
|
||||
vs_output.volsurface_input,
|
||||
orig_exp, vs_output.aux_data_map,
|
||||
arg_exp => _get_bbo(arg_exp),
|
||||
impliedvol_side,
|
||||
_ignore_market_implied_vol_source_settings(_bb, _vs_id),
|
||||
out md_exp);
|
||||
_timer.stop();
|
||||
_logger.log("SingleVolSurfaceMarketImpliedVolSource",
|
||||
"SingleVolSurfaceMarketImpliedVolSource",
|
||||
_timer.lastIntervalTime);
|
||||
if (exp_impl_vol_map is null) {
|
||||
return;
|
||||
}
|
||||
bts.Log.Gen.info(
|
||||
$"SingleVolSurfaceMarketImpliedVolSource._recompute_and_publish " +
|
||||
exp_impl_vol_map.log_string());
|
||||
_bb.post(SparkTags.VolSurfaceMarketImpliedVolTag(_vs_id),
|
||||
new Dictionary<VolSurfaceExpiration,
|
||||
Tuple<VolSurfaceExpiration, VolCurveMarketImpliedVolData>>() {
|
||||
{ orig_exp, Tuple.Create(md_exp, exp_impl_vol_map) }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the candidate or committed VolSurface depending
|
||||
private VolSurfaceOutput _resolve_curr_cand() {
|
||||
bool is_dirty = _bb.read_state(_in_bb_inp_dirty_tag, false);
|
||||
if (is_dirty) {
|
||||
VolSurfaceCalculationResponse vs_resp = _bb.read_state(_in_bb_calc_resp_tag);
|
||||
return vs_resp != null ? vs_resp.volsurface_calculation_output : null;
|
||||
} else
|
||||
return _bb.read_state(_in_bb_committed_output_tag);
|
||||
}
|
||||
|
||||
private IDictionary<double, Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit>>
|
||||
_get_bbo(VolSurfaceExpiration vs_exp) {
|
||||
return get_option_bbo(_bb, vs_exp);
|
||||
}
|
||||
|
||||
private static bool _normalize_bbo = true;
|
||||
#region Static helpers
|
||||
|
||||
// for some markets (crypto ie), the options prices are not in
|
||||
// the same terms as strikes, ie strikes are in USD whereras the
|
||||
// option prices are in BTC
|
||||
internal static double get_option_price_mult(
|
||||
ThreadedBlackboard bb,
|
||||
VolSurfaceExpiration option_exp) {
|
||||
var driver_map = bb.read_state(SparkTags.AllOptionDriverBBOTag);
|
||||
if (driver_map != null &&
|
||||
driver_map.TryGetValue(option_exp.symbol, out var sym_map)) {
|
||||
var vs_md = sym_map.get_driver_md(option_exp.expiration);
|
||||
return vs_md.get_driver();
|
||||
}
|
||||
return Double.NaN;
|
||||
}
|
||||
internal static
|
||||
IDictionary<double, Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit>>
|
||||
get_option_bbo(ThreadedBlackboard bb, VolSurfaceExpiration vs_exp) {
|
||||
var sc_data = bb.read_state(SparkTags.SystemContractsTag);
|
||||
IDictionary<double, Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit>> rv =
|
||||
sc_data.get_option_bbo_vsexp(vs_exp).Item2;
|
||||
double mult = get_option_price_mult(bb, vs_exp);
|
||||
if (_normalize_bbo)
|
||||
return rv.ToDictionary(kv => kv.Key, kv =>
|
||||
Tuple.Create(kv.Value.Item1.mult_price(mult),
|
||||
kv.Value.Item2.mult_price(mult)));
|
||||
return rv;
|
||||
}
|
||||
|
||||
internal static bool _ignore_market_implied_vol_source_settings(
|
||||
ThreadedBlackboard bb, int vs_id) {
|
||||
return bb.read_state(
|
||||
SparkTags.VolSurfaceIgnoreImpliedVolSettingsTag(vs_id), false);
|
||||
}
|
||||
|
||||
internal static VolSurfaceEnums.MarketSide
|
||||
_get_market_impliedvol_side(ThreadedBlackboard bb, int vs_id) {
|
||||
return bb.read_state(
|
||||
SparkTags.VolSurfaceMarketImpliedVolSide(vs_id),
|
||||
VolSurfaceEnums.MarketSide.Mid);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
public void Dispose() {
|
||||
_bb.data_callback -= _on_bb_data;
|
||||
_bb.timer_callback -= _on_bb_timer;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using mbts.analytics;
|
||||
using bts.api;
|
||||
using System.Linq;
|
||||
|
||||
namespace mbts.spark {
|
||||
// f (SystemContractData,
|
||||
// VolSurfaceNonVolInput,
|
||||
// IDictionary<mbts.analytics.VolSurfaceExpiration, double>) -> VolSurfaceNonVolData
|
||||
// Subs :
|
||||
// 1. Securities (SystemContractsTag)
|
||||
// 2. NonVolInput (VolSurfaceNonVolInputTag)
|
||||
// 3. Driver prices (VolSurfaceOptionDriverTag)
|
||||
// Publishes :
|
||||
// 1. VolSurfaceNonVolData which is simply a union of the 3 inputs
|
||||
// 2. VolSurfaceStrikeMap
|
||||
public class SingleVolSurfaceNonVolDataSource : IDisposable {
|
||||
private readonly int _vs_id;
|
||||
private readonly IEnumerable<string> _option_symbols;
|
||||
private readonly ThreadedBlackboard _bb;
|
||||
private readonly ITag<SystemContractData> _in_bb_contract_data_tag;
|
||||
private readonly ITag<VolSurfaceNonVolInput> _in_bb_vs_nonvol_input_tag;
|
||||
private readonly ITag<IReadOnlyDictionary<string, OptionDriverPriceMap>> _in_bb_all_driver_price_tag;
|
||||
private readonly ITag<mbts.analytics.VolSurfaceNonVolData> _out_bb_vs_nonvol_data_tag;
|
||||
private readonly ITag<mbts.analytics.VolSurfaceStrikeMap> _out_bb_vs_contracts_tag;
|
||||
|
||||
public SingleVolSurfaceNonVolDataSource(int vs_id, IEnumerable<string> option_symbols,
|
||||
ThreadedBlackboard bb) {
|
||||
bts.Log.Gen.info($"SingleVolSurfaceNonVolDataSource vs_id:{vs_id}");
|
||||
_vs_id = vs_id;
|
||||
_option_symbols = option_symbols;
|
||||
_bb = bb;
|
||||
_in_bb_contract_data_tag = SparkTags.SystemContractsTag;
|
||||
_in_bb_vs_nonvol_input_tag = SparkTags.VolSurfaceNonVolInputTag;
|
||||
_in_bb_all_driver_price_tag = SparkTags.AllOptionDriverBBOTag;
|
||||
_out_bb_vs_nonvol_data_tag = SparkTags.VolSurfaceNonVolDataTag(vs_id);
|
||||
_out_bb_vs_contracts_tag = SparkTags.VolSurfaceContractsTag(vs_id);
|
||||
_bb.subscribe(_in_bb_contract_data_tag);
|
||||
_bb.subscribe(_in_bb_vs_nonvol_input_tag);
|
||||
_bb.subscribe(_in_bb_all_driver_price_tag);
|
||||
_bb.data_callback += _on_bb_data;
|
||||
_init();
|
||||
}
|
||||
|
||||
private void _init() {
|
||||
_publish_vs_strike_map();
|
||||
_recompute_and_fire();
|
||||
}
|
||||
|
||||
private void _publish_vs_strike_map() {
|
||||
SystemContractData sc_data = _bb.read_state(_in_bb_contract_data_tag);
|
||||
if (sc_data != null) {
|
||||
var k_map = new VolSurfaceStrikeMap(_option_symbols, sc_data);
|
||||
bts.Log.Gen.info($"SingleVolSurfaceNonVolDataSource vs_id:{_vs_id} " +
|
||||
"publishing strike_map sz:{k_map.strike_map.Count()}");
|
||||
_bb.post(_out_bb_vs_contracts_tag, new VolSurfaceStrikeMap(_option_symbols, sc_data));
|
||||
}
|
||||
}
|
||||
|
||||
private void _on_bb_data(object tag, object data) {
|
||||
if (_in_bb_contract_data_tag.Equals(tag)) {
|
||||
_publish_vs_strike_map();
|
||||
_recompute_and_fire();
|
||||
} else if (_in_bb_vs_nonvol_input_tag.Equals(tag) ||
|
||||
_in_bb_all_driver_price_tag.Equals(tag))
|
||||
_recompute_and_fire();
|
||||
}
|
||||
|
||||
private void _recompute_and_fire() {
|
||||
SystemContractData sc_data = _bb.read_state(_in_bb_contract_data_tag);
|
||||
VolSurfaceNonVolInput vs_nonvol_input = _bb.read_state(_in_bb_vs_nonvol_input_tag);
|
||||
var all_sym_price_map = _bb.read_state(_in_bb_all_driver_price_tag);
|
||||
var exp_price_map = OptionDriverPriceMap.get_vs_price_map(
|
||||
all_sym_price_map, (s) => _option_symbols.Contains(s));
|
||||
if (sc_data != null && vs_nonvol_input != null && exp_price_map != null) {
|
||||
bts.Log.Gen.info($"SingleVolSurfaceNonVolDataSource vs_id:{_vs_id} " +
|
||||
"publishing VolSurfaceNonVolData");
|
||||
_bb.post(_out_bb_vs_nonvol_data_tag,
|
||||
new VolSurfaceNonVolData(
|
||||
vs_nonvol_input, exp_price_map,
|
||||
new VolSurfaceStrikeMap(_option_symbols, sc_data).strike_map));
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
public void Dispose() { _bb.data_callback -= _on_bb_data; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using bts.api;
|
||||
|
||||
using mbts.analytics;
|
||||
|
||||
namespace mbts.spark {
|
||||
// All local changes to the VolSurface that trigger calculations
|
||||
// are handled here.
|
||||
// Subs :
|
||||
// 1. VS Calc Req
|
||||
// 2. VS Nonvol Data
|
||||
// 3. Dirty
|
||||
// Pubs :
|
||||
// 1. Calc Resp
|
||||
public class SingleVolSurfaceRequestCalculator : IDisposable {
|
||||
private readonly int _vs_id;
|
||||
private readonly HashSet<string> _symbols;
|
||||
private readonly ThreadedBlackboard _bb;
|
||||
private readonly ITag<VolSurfaceCalculationRequest> _in_bb_request_tag;
|
||||
private readonly ITag<VolSurfaceNonVolData> _in_bb_nonvol_data_tag;
|
||||
private readonly ITag<VolSurfaceStandardTime> _in_bb_vs_standard_time_tag;
|
||||
private readonly ITag<VolSurfaceEnums.MarketSide> _in_bb_market_impliedvol_side_tag;
|
||||
private readonly ITag<bool> _in_bb_dirty_tag;
|
||||
private HighPerformanceTimer _timer = new HighPerformanceTimer();
|
||||
/// data
|
||||
private VolSurfaceOutput _last_output;
|
||||
|
||||
public SingleVolSurfaceRequestCalculator(int vs_id, IEnumerable<string> symbols,
|
||||
ThreadedBlackboard threaded_bb) {
|
||||
bts.Log.Gen.info($"SingleVolSurfaceRequestCalculator cons vs_id:{vs_id}");
|
||||
_vs_id = vs_id;
|
||||
_symbols = new HashSet<string>(symbols);
|
||||
_bb = threaded_bb;
|
||||
_in_bb_request_tag = SparkTags.VolSurfaceCalculationRequestTag(vs_id);
|
||||
_in_bb_nonvol_data_tag = SparkTags.VolSurfaceNonVolDataTag(vs_id);
|
||||
_in_bb_vs_standard_time_tag = SparkTags.VolSurfaceStandardTimeTag(vs_id);
|
||||
_in_bb_market_impliedvol_side_tag = SparkTags.VolSurfaceMarketImpliedVolSide(vs_id);
|
||||
_in_bb_dirty_tag = SparkTags.VolSurfaceDirtyStateTag(vs_id);
|
||||
_bb.subscribe(_in_bb_request_tag);
|
||||
_bb.subscribe(_in_bb_nonvol_data_tag);
|
||||
_bb.subscribe(_in_bb_vs_standard_time_tag);
|
||||
_bb.subscribe(_in_bb_vs_standard_time_tag);
|
||||
_bb.subscribe(_in_bb_dirty_tag);
|
||||
_bb.data_callback += _on_bb_data;
|
||||
_recompute_and_publish(true);
|
||||
}
|
||||
|
||||
private void _on_bb_data(object tag, object data) {
|
||||
if (_in_bb_request_tag.Equals(tag) || _in_bb_dirty_tag.Equals(tag))
|
||||
_recompute_and_publish(true);
|
||||
else if (_in_bb_nonvol_data_tag.Equals(tag) || _in_bb_vs_standard_time_tag.Equals(tag))
|
||||
_recompute_and_publish(false);
|
||||
|
||||
}
|
||||
|
||||
private void _recompute_and_publish(bool is_new_request) {
|
||||
bool is_dirty = _bb.read_state(_in_bb_dirty_tag, false);
|
||||
VolSurfaceNonVolData nonvol_data = _bb.read_state(_in_bb_nonvol_data_tag);
|
||||
VolSurfaceStandardTime vs_standard_time = _bb.read_state(_in_bb_vs_standard_time_tag);
|
||||
if (is_dirty && nonvol_data != null) {
|
||||
_timer.start();
|
||||
VolSurfaceCalculationRequest curr_req = _bb.read_state(_in_bb_request_tag),
|
||||
effective_req = null;
|
||||
if (is_new_request)
|
||||
effective_req = curr_req;
|
||||
else {
|
||||
if (_last_output != null)
|
||||
effective_req =
|
||||
new VolSurfaceCalculationRequest(_last_output.volsurface_input, curr_req.request_id);
|
||||
}
|
||||
if (effective_req != null) {
|
||||
IDictionary<VolSurfaceExpiration, VolSurfaceExpirationAuxiliaryData> aux_data_map =
|
||||
VolSurfaceUtilityFunctions.compute_aux_data(effective_req.volsurface_input,
|
||||
nonvol_data.input,
|
||||
nonvol_data.driver_price_map,
|
||||
vs_standard_time, true);
|
||||
IDictionary<VolSurfaceExpiration, VolCurveAction> action_map =
|
||||
_post_process_action(effective_req, aux_data_map);
|
||||
_last_output = GeneralVolSurfaceCalculator.compute(effective_req.volsurface_input,
|
||||
nonvol_data.contracts,
|
||||
aux_data_map,
|
||||
action_map,
|
||||
null,
|
||||
effective_req.cascade_up,
|
||||
effective_req.cascade_down);
|
||||
_timer.stop();
|
||||
bts.Log.Gen.info($"SingleVolSurfaceRequestCalculator._recompute_and_publish time:" +
|
||||
$"{_timer.lastIntervalTime} vs_output:{_last_output.log_string()}");
|
||||
_bb.post(SparkTags.VolSurfaceCalculationResponseTag(_vs_id),
|
||||
new VolSurfaceCalculationResponse(_last_output, effective_req.request_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Computes the impl vol if the action is fit to market
|
||||
private IDictionary<VolSurfaceExpiration, VolCurveAction> _post_process_action(
|
||||
VolSurfaceCalculationRequest req,
|
||||
IDictionary<VolSurfaceExpiration, VolSurfaceExpirationAuxiliaryData> aux_data_map) {
|
||||
IDictionary<VolSurfaceExpiration, VolCurveAction> rv = req.action_map;
|
||||
/// TODO : VolCurveAction needs to be structured better. The UI enforces that
|
||||
/// all exps have the same action, but the structure doesnt. So here the UI
|
||||
/// constraint is flowing in
|
||||
if (rv != null && rv.Count > 0) {
|
||||
VolCurveAction rep_action = rv.ElementAt(0).Value;
|
||||
if (rep_action.action_type == VolCurveAction.ActionType.FitToMarket) {
|
||||
IDictionary<VolSurfaceExpiration, VolCurveMarketImpliedVolData> impl_vol_map =
|
||||
_fill_in_implied_vols(req.volsurface_input, req.action_map, aux_data_map,
|
||||
req.cascade_up, req.cascade_down);
|
||||
rv = impl_vol_map.ToDictionary(kv => kv.Key, kv => new VolCurveAction(
|
||||
new VolCurveMarketFitAction(rep_action.market_fit_action.fit_action, kv.Value,
|
||||
rep_action.market_fit_action.use_weighted_regression)));
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
private IDictionary<VolSurfaceExpiration, VolCurveMarketImpliedVolData> _fill_in_implied_vols(
|
||||
VolSurfaceInput vs_inp,
|
||||
IDictionary<VolSurfaceExpiration, VolCurveAction> action_map,
|
||||
IDictionary<VolSurfaceExpiration, VolSurfaceExpirationAuxiliaryData> aux_data_map,
|
||||
bool cascade_up, bool cascade_down) {
|
||||
IDictionary<VolSurfaceExpiration, VolCurveMarketImpliedVolData> rv =
|
||||
new Dictionary<VolSurfaceExpiration, VolCurveMarketImpliedVolData>();
|
||||
VolCurveAction rep_action = action_map.ElementAt(0).Value;
|
||||
HashSet<VolSurfaceExpiration> master_exps =
|
||||
VolSurfaceUtilityFunctions.get_master_expirations(vs_inp, true);
|
||||
IEnumerable<VolSurfaceExpiration> applicable_exps;
|
||||
if (cascade_up || cascade_down)
|
||||
applicable_exps =
|
||||
VolSurfaceUtilityFunctions.get_exp_list_from_cascade(
|
||||
vs_inp.surface_parameters.curve_parameters_map.Select(t => t.Item1),
|
||||
action_map.Keys, cascade_up, cascade_down);
|
||||
else
|
||||
applicable_exps = action_map.Keys;
|
||||
applicable_exps = applicable_exps.Where(vs_exp => master_exps.Contains(vs_exp));
|
||||
|
||||
VolSurfaceEnums.MarketSide impliedvol_side =
|
||||
SingleVolSurfaceMarketImpliedVolSource._get_market_impliedvol_side(_bb, _vs_id);
|
||||
foreach (VolSurfaceExpiration vs_exp in applicable_exps) {
|
||||
VolSurfaceExpiration md_exp;
|
||||
VolCurveMarketImpliedVolData exp_impl_data =
|
||||
VolSurfaceCoreFunctions.compute_implied_vols(vs_inp, vs_exp, aux_data_map,
|
||||
arg_vs_exp => SingleVolSurfaceMarketImpliedVolSource.get_option_bbo(_bb, arg_vs_exp),
|
||||
impliedvol_side,
|
||||
SingleVolSurfaceMarketImpliedVolSource._ignore_market_implied_vol_source_settings(
|
||||
_bb, _vs_id),
|
||||
out md_exp);
|
||||
rv[vs_exp] = exp_impl_data;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
private bool _disposed = false;
|
||||
public void Dispose() {
|
||||
if (!_disposed) {
|
||||
_disposed = true;
|
||||
_bb.data_callback -= _on_bb_data;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,245 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using mbts.analytics;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.api.analytics;
|
||||
|
||||
namespace mbts.spark {
|
||||
// Publishes the committed and candidate greeks in the
|
||||
// form of VolSurfaceTheoData
|
||||
// (this was the data that was published in the winform syncfusion grid,
|
||||
// with the candidate/committed next to each other)
|
||||
// Subs :
|
||||
// 1. Comm Vol Output
|
||||
// 2. Cand Calc Response
|
||||
// 3. Is Dirty (ie a pending change?)
|
||||
// 4. Detailed Window State
|
||||
// Pubs :
|
||||
// 1. VolSurfaceTheoData (cand and comm theos)
|
||||
public class SingleVolSurfaceTheoSource : IDisposable {
|
||||
private readonly int _vs_id;
|
||||
private readonly ThreadedBlackboard _bb;
|
||||
private readonly ITag<VolSurfaceOutput> _in_committed_vol_output_tag;
|
||||
private readonly ITag<VolSurfaceCalculationResponse> _in_candidate_vol_output_tag;
|
||||
private readonly ITag<bool> _in_input_dirty_tag;
|
||||
private readonly ITag<bool> _in_window_state_tag;
|
||||
private readonly HighPerformanceTimer _timer = new HighPerformanceTimer();
|
||||
private bool _is_dirty = true;
|
||||
private static readonly IDictionary<VolSurfaceExpiration, IEnumerable<Theos>>
|
||||
_empty_theos = new Dictionary<VolSurfaceExpiration, IEnumerable<Theos>>();
|
||||
private VolSurfaceTheoData _last_data =
|
||||
new VolSurfaceTheoData(new Dictionary<VolSurfaceExpiration, HashSet<double>>(),
|
||||
_empty_theos, _empty_theos, false);
|
||||
private uint _n_comps = 0;
|
||||
|
||||
public SingleVolSurfaceTheoSource(int vs_id, ThreadedBlackboard threaded_bb) {
|
||||
bts.Log.Gen.info($"SingleVolSurfaceTheoSource cons vs_id:{vs_id}");
|
||||
_vs_id = vs_id;
|
||||
_bb = threaded_bb;
|
||||
_in_committed_vol_output_tag = SparkTags.VolSurfaceCommittedOutputTag(_vs_id);
|
||||
_in_candidate_vol_output_tag = SparkTags.VolSurfaceCalculationResponseTag(_vs_id);
|
||||
_in_input_dirty_tag = SparkTags.VolSurfaceDirtyStateTag(_vs_id);
|
||||
_in_window_state_tag = SparkTags.VolSurfaceTheoWindowStateTag(_vs_id);
|
||||
_bb.subscribe(_in_committed_vol_output_tag);
|
||||
_bb.subscribe(_in_candidate_vol_output_tag);
|
||||
_bb.subscribe(_in_input_dirty_tag);
|
||||
_bb.subscribe(_in_window_state_tag);
|
||||
_bb.data_callback += _on_data;
|
||||
_bb.timer_callback += _on_timer;
|
||||
// (TODO) forcing computing of theos by publishing an
|
||||
// active theos window tag, remove it
|
||||
_bb.post(_in_window_state_tag, true);
|
||||
}
|
||||
|
||||
#region Blackboard
|
||||
private void _on_data(object tag, object data) {
|
||||
if (_in_candidate_vol_output_tag.Equals(tag) ||
|
||||
_in_committed_vol_output_tag.Equals(tag) ||
|
||||
_in_input_dirty_tag.Equals(tag) || _in_window_state_tag.Equals(tag)) {
|
||||
_is_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void _on_timer() {
|
||||
if (_is_dirty) {
|
||||
// publishes new values when there is an
|
||||
// 1. theos window up
|
||||
// 2. waiting candidate change
|
||||
_compute_and_publish(_is_active_candidate(), _is_active_theos_window());
|
||||
_is_dirty = false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void _compute_and_publish(bool is_active_candidate,
|
||||
bool is_active_theos_window) {
|
||||
VolSurfaceCalculationResponse calc_resp =
|
||||
_bb.read_state(_in_candidate_vol_output_tag);
|
||||
VolSurfaceOutput candidate_output =
|
||||
calc_resp != null ? calc_resp.volsurface_calculation_output : null,
|
||||
committed_output = _bb.read_state(_in_committed_vol_output_tag);
|
||||
IDictionary<VolSurfaceExpiration, HashSet<double>> secs =
|
||||
_get_securities(committed_output, candidate_output);
|
||||
IDictionary<VolSurfaceExpiration, IEnumerable<Theos>> comm_theo_map =
|
||||
_empty_theos, cand_theo_map = _empty_theos;
|
||||
if (is_active_theos_window) {
|
||||
comm_theo_map = _compute_theos(committed_output, secs);
|
||||
if (is_active_candidate)
|
||||
cand_theo_map = _compute_theos(candidate_output, secs);
|
||||
} else {
|
||||
if (is_active_candidate)
|
||||
cand_theo_map = _compute_theos(candidate_output, secs);
|
||||
}
|
||||
var new_data = new VolSurfaceTheoData(secs, comm_theo_map,
|
||||
cand_theo_map, is_active_candidate);
|
||||
if (_is_valid_update(new_data))
|
||||
_bb.post(SparkTags.VolSurfaceTheoOutputTag(_vs_id), new_data);
|
||||
}
|
||||
|
||||
private bool _is_valid_update(VolSurfaceTheoData new_data) {
|
||||
bool is_spurious = _last_data.committed_theo_map.Count == 0 &&
|
||||
_last_data.candidate_theo_map.Count == 0 &&
|
||||
new_data.committed_theo_map.Count == 0 &&
|
||||
new_data.candidate_theo_map.Count == 0;
|
||||
_last_data = new_data;
|
||||
return !is_spurious;
|
||||
}
|
||||
|
||||
private IDictionary<VolSurfaceExpiration, IEnumerable<Theos>> _compute_theos(
|
||||
VolSurfaceOutput vs_output,
|
||||
IDictionary<VolSurfaceExpiration, HashSet<double>> exp_strikes) {
|
||||
if (vs_output != null) {
|
||||
_timer.start();
|
||||
var exp_volmat_map = VolSurfaceVolMatrixCalculator.generate_volmatrix(
|
||||
vs_output.volsurface_input,
|
||||
exp_strikes.ToDictionary(kv => kv.Key,
|
||||
kv => kv.Value as IEnumerable<double>),
|
||||
vs_output.aux_data_map,
|
||||
new double[] { 0.0 }, false, true, false, false, false);
|
||||
_timer.stop();
|
||||
_n_comps++;
|
||||
Log.Gen.info($"SingleVolSurfaceTheoSource._compute_theos vs_id:{_vs_id} " +
|
||||
$"vol time:{ _timer.lastIntervalTime} msecs n_comps: {_n_comps}");
|
||||
_timer.start();
|
||||
var theo_map = VolSurfaceTheoCalculator.compute_standard_greeks(
|
||||
vs_output.volsurface_input.surface_settings, exp_volmat_map, true);
|
||||
_timer.stop();
|
||||
Log.Gen.info($"SingleVolSurfaceTheoSource._compute_theos vs_id:{_vs_id} " +
|
||||
$"theo time:{ _timer.lastIntervalTime} msecs n_comps: {_n_comps}");
|
||||
return theo_map;
|
||||
}
|
||||
return new Dictionary<VolSurfaceExpiration, IEnumerable<Theos>>();
|
||||
}
|
||||
|
||||
// plucks the data off the bus, computes the theos and returns it
|
||||
public static IDictionary<VolSurfaceExpiration, IEnumerable<Theos>> compute_cand_theos(
|
||||
int vs_id, ThreadedBlackboard bb) {
|
||||
VolSurfaceCalculationResponse calc_resp =
|
||||
bb.read_state(SparkTags.VolSurfaceCalculationResponseTag(vs_id));
|
||||
VolSurfaceOutput vs_output =
|
||||
calc_resp != null ? calc_resp.volsurface_calculation_output : null;
|
||||
IDictionary<VolSurfaceExpiration, HashSet<double>> exp_strikes =
|
||||
VolSurfaceUtilityFunctions.get_contracts(vs_output);
|
||||
if (vs_output != null && exp_strikes != null) {
|
||||
var exp_volmat_map = VolSurfaceVolMatrixCalculator.generate_volmatrix(
|
||||
vs_output.volsurface_input,
|
||||
exp_strikes.ToDictionary(kv => kv.Key,
|
||||
kv => kv.Value as IEnumerable<double>),
|
||||
vs_output.aux_data_map,
|
||||
new double[] { 0.0 }, false, true, false, false, false);
|
||||
var theo_map = VolSurfaceTheoCalculator.compute_standard_greeks(
|
||||
vs_output.volsurface_input.surface_settings, exp_volmat_map, true);
|
||||
return theo_map;
|
||||
}
|
||||
return new Dictionary<VolSurfaceExpiration, IEnumerable<Theos>>();
|
||||
}
|
||||
|
||||
public static IEnumerable<bts.api.SecurityTuple> get_vs_sectups(
|
||||
int vs_id, ThreadedBlackboard bb) {
|
||||
VolSurfaceUsageListImmutable vs_usage_list = bb.read_state(SparkTags.VolSurfaceUsageTag);
|
||||
return vs_usage_list.get_sectups(vs_id);
|
||||
}
|
||||
|
||||
|
||||
// old -> new transformation, this is slow ! transforms data from one
|
||||
// form to another
|
||||
public static ArchivedTheoList
|
||||
convert_to_id_map(IDictionary<VolSurfaceExpiration, IEnumerable<Theos>> theos,
|
||||
SystemContractData sc_data) {
|
||||
Func<Theos, PutOrCall, uint, ArchivedSecurityTheo> mk_theo = (t, cp, id) => {
|
||||
ArchivedSecurityTheo rv = new ArchivedSecurityTheo();
|
||||
rv.Id = id;
|
||||
rv.Driver = t.driver;
|
||||
rv.Vol = t.vol;
|
||||
if (cp == PutOrCall.Call) {
|
||||
rv.Theo = t.call;
|
||||
rv.Theo = t.cdelta;
|
||||
} else {
|
||||
rv.Theo = t.put;
|
||||
rv.Theo = t.pdelta;
|
||||
}
|
||||
return rv;
|
||||
};
|
||||
Func<string, DateTime, double, Tuple<uint?, uint?>> get_id = (s, e, k) => {
|
||||
foreach (Venue v in Enum.GetValues(typeof(Venue))) {
|
||||
var rv = sc_data.get_option_sec_id(v, s, e, k);
|
||||
if (rv != null)
|
||||
return rv;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
var rv = new List<ArchivedSecurityTheo>();
|
||||
foreach (var exp_kv in theos) {
|
||||
var exp = exp_kv.Key;
|
||||
foreach (var t in exp_kv.Value) {
|
||||
var strike = t.strike;
|
||||
var cp_id = get_id(exp.symbol, exp.expiration, strike);
|
||||
if (cp_id != null) {
|
||||
if (cp_id.Item1.HasValue) {
|
||||
var c_theo = mk_theo(t, PutOrCall.Call, cp_id.Item1.Value);
|
||||
rv.Add(c_theo);
|
||||
}
|
||||
if (cp_id.Item2.HasValue) {
|
||||
var p_theo = mk_theo(t, PutOrCall.Call, cp_id.Item2.Value);
|
||||
rv.Add(p_theo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ArchivedTheoList rv_list = new ArchivedTheoList();
|
||||
rv_list.SecTheo.AddRange(rv);
|
||||
return rv_list;
|
||||
}
|
||||
|
||||
private IDictionary<VolSurfaceExpiration, HashSet<double>> _get_securities(
|
||||
VolSurfaceOutput commited_output, VolSurfaceOutput candidate_output) {
|
||||
if (candidate_output != null)
|
||||
/// candidate output wins if its active
|
||||
return VolSurfaceUtilityFunctions.get_contracts(candidate_output);
|
||||
else if (commited_output != null)
|
||||
return VolSurfaceUtilityFunctions.get_contracts(commited_output);
|
||||
else
|
||||
return new Dictionary<VolSurfaceExpiration, HashSet<double>>();
|
||||
}
|
||||
|
||||
/// If the details window is not active, the calculations are suspended
|
||||
private bool _is_active_theos_window() {
|
||||
return _bb.read_state(_in_window_state_tag, false);
|
||||
}
|
||||
|
||||
private bool _is_active_candidate() {
|
||||
return _bb.read_state(_in_input_dirty_tag, false);
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
public void Dispose() {
|
||||
_bb.data_callback -= _on_data;
|
||||
_bb.timer_callback -= _on_timer;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
using System;
|
||||
|
||||
using mbts.analytics;
|
||||
|
||||
namespace mbts.spark {
|
||||
public class SingleVolSurfaceTimeSource : IDisposable {
|
||||
private readonly int _vs_id;
|
||||
private readonly ThreadedBlackboard _bb;
|
||||
private readonly TimeSpan _publish_period = TimeSpan.FromMinutes(VolSurfaceConstants.vol_time_sample_mins);
|
||||
private DateTime _last_publish_time = DateTime.MinValue;
|
||||
|
||||
public SingleVolSurfaceTimeSource(int vs_id, ThreadedBlackboard bb) {
|
||||
bts.Log.Gen.info($"SingleVolSurfaceTimeSource cons vs_id:{vs_id}");
|
||||
_vs_id = vs_id;
|
||||
_bb = bb;
|
||||
_bb.timer_callback += _on_timer;
|
||||
}
|
||||
|
||||
private void _on_timer() {
|
||||
if (DateTime.Now - _last_publish_time >= _publish_period) {
|
||||
_last_publish_time = DateTime.Now;
|
||||
VolSurfaceStandardTime time = VolSurfaceStandardTime.get_local_default();
|
||||
bts.Log.Gen.info($"SingleVolSurfaceTimeSource vs_id:{_vs_id} posting time:{time.ToString()}");
|
||||
_bb.post(SparkTags.VolSurfaceStandardTimeTag(_vs_id), time);
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
public void Dispose() {
|
||||
_bb.timer_callback -= _on_timer;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
using mbts.spark;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using bts.api;
|
||||
using System.Linq;
|
||||
|
||||
namespace mbts.analytics {
|
||||
|
||||
// Thin class that assembles all symbol based data published on different
|
||||
// tags, into IReadOnlyDictionary of symbol vs data publsihed under one tag
|
||||
public class SymbolAggregationPublisher<TData> : IDisposable {
|
||||
private readonly ThreadedBlackboard _bb;
|
||||
private readonly ITag<SystemContractData> _sc_data_tag;
|
||||
Func<string, ITag<TData>> _get_tag;
|
||||
ITag<IReadOnlyDictionary<string, TData>> _out_tag;
|
||||
private Dictionary<string, ITag<TData>> _tag_map =
|
||||
new Dictionary<string, ITag<TData>>();
|
||||
private HashSet<object> _obj_tags = new HashSet<object>();
|
||||
private bool _dirty = true;
|
||||
public SymbolAggregationPublisher(
|
||||
ThreadedBlackboard bb,
|
||||
Func<string, ITag<TData>> get_tag,
|
||||
ITag<IReadOnlyDictionary<string, TData>> out_tag) {
|
||||
_bb = bb;
|
||||
_get_tag = get_tag;
|
||||
_out_tag = out_tag;
|
||||
_sc_data_tag = SparkTags.SystemContractsTag;
|
||||
_bb.subscribe(SparkTags.SystemContractsTag);
|
||||
_bb.data_callback += _on_bb_data;
|
||||
_bb.timer_callback += _on_timer;
|
||||
_handle_sc_data();
|
||||
}
|
||||
|
||||
private void _on_bb_data(object tag, object data) {
|
||||
if (_sc_data_tag.Equals(tag)) {
|
||||
_handle_sc_data();
|
||||
} else {
|
||||
if (_obj_tags.Contains(tag)) {
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _handle_sc_data() {
|
||||
var sc_data = _bb.read_state(_sc_data_tag);
|
||||
if (sc_data == null) {
|
||||
return;
|
||||
}
|
||||
foreach (var st in sc_data.sectup_map) {
|
||||
// this is not correct since it is assuming symbol/name is
|
||||
// unique across securty_tuples
|
||||
string symbol = st.security_name;
|
||||
if (!_tag_map.ContainsKey(symbol)) {
|
||||
var symbol_tag = _get_tag(symbol);
|
||||
_tag_map.Add(symbol, symbol_tag);
|
||||
_obj_tags.Add(symbol_tag);
|
||||
_bb.subscribe(symbol_tag);
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _on_timer() {
|
||||
if (_dirty) {
|
||||
_dirty = false;
|
||||
Dictionary<string, TData> output = new Dictionary<string, TData>();
|
||||
foreach (var kv in _tag_map) {
|
||||
var symbol = kv.Key;
|
||||
var symbol_tag = kv.Value;
|
||||
TData symbol_data = _bb.read_state(symbol_tag);
|
||||
output.Add(symbol, symbol_data);
|
||||
}
|
||||
IReadOnlyDictionary<string, TData> ro_output = output;
|
||||
bts.Log.Gen.info($"SymbolAggregationPublisher._on_timer publishing " +
|
||||
$"tag: {_out_tag} sz: {ro_output.Count}");
|
||||
_bb.post(_out_tag, ro_output);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
_bb.data_callback -= _on_bb_data;
|
||||
_bb.timer_callback -= _on_timer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,257 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using mbts.analytics;
|
||||
using bts.api;
|
||||
using bts;
|
||||
using bts.api.analytics;
|
||||
using bts.api.core;
|
||||
using bts.api.position;
|
||||
using mbts;
|
||||
using System.Reactive.Linq;
|
||||
using System.Collections;
|
||||
using mbts.spark;
|
||||
using System.DirectoryServices.ActiveDirectory;
|
||||
// using mbts.bb;
|
||||
|
||||
namespace mbts.spark {
|
||||
internal class ResourceAllocator : IDisposable {
|
||||
private List<IDisposable> _disps = new List<IDisposable>();
|
||||
private Dictionary<SecurityTuple, SingleOptionDriverPricePublisher> _option_driver_map =
|
||||
new Dictionary<SecurityTuple, SingleOptionDriverPricePublisher>();
|
||||
ThreadedBlackboard _bb;
|
||||
public ResourceAllocator(IBus bus, ThreadedBlackboard bb) {
|
||||
bts.Log.Gen.info("ResourceAllocator started");
|
||||
_bb = bb;
|
||||
var s = bus.subscribe(SparkTags.SystemContractsTag).OnDispatcher().Subscribe(_on_data);
|
||||
_disps.Add(s);
|
||||
}
|
||||
private void _on_data(SystemContractData d) {
|
||||
bts.Log.Gen.info(String.Format("ResourceAllocator._on_data sz: {0}", d.sec_md_map.Count()));
|
||||
foreach (SecurityTuple sec_tup in d.get_options()) {
|
||||
if (!_option_driver_map.ContainsKey(sec_tup)) {
|
||||
bts.Log.Gen.info($"ResourceAllocator._on_data allocating SingleOptionDriverPricePublisher for '{sec_tup}'");
|
||||
_option_driver_map.Add(sec_tup, new SingleOptionDriverPricePublisher(sec_tup, _bb));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Dispose() {
|
||||
_disps.ForEach(d => d.Dispose());
|
||||
}
|
||||
}
|
||||
// This is the anologous to the QuoteSetBlackboardManager. There
|
||||
// is only instance of this per running app and it does the folliwing
|
||||
// 1. Publishes
|
||||
// - SystemContractsData
|
||||
// - Vol Surface symbol usage tag (VolSurfaceUsageTag)
|
||||
// - Vol Surface List tag (VolSurfaceListTag)
|
||||
// - Vol Surface Non Vol Input (config + exp_params) (VolSurfaceNonVolInputTag)
|
||||
// - Activation Tag for newly created VS's (VolSurfaceActivationTag) (retired)
|
||||
// 2. Listens to the activation tag (also published by the UI) and
|
||||
// creates the SingleVolSurfaceManager for the VS
|
||||
public class VolSurfaceBusManager : IDisposable {
|
||||
private ThreadedBlackboard _bb;
|
||||
private bts.api.analytics.AnalyticsService _analytics_service;
|
||||
// in tags
|
||||
private readonly ITag<SystemContractData> _in_scdata_tag =
|
||||
SparkTags.SystemContractsTag;
|
||||
private readonly ITag<VolSurfaceSettings> _in_bb_create_tag = SparkTags.VolSurfaceCreateTag;
|
||||
private readonly ITag<int> _in_bb_delete_tag = SparkTags.VolSurfaceDeleteTag;
|
||||
private readonly ITag<AnalyticsExpirationParametersMap> _in_bb_exp_params_tag =
|
||||
SparkTags.ExpirationParametersInputTag;
|
||||
private readonly ITag<ClientArchivedVolRequest> _in_bb_req_vol = SparkTags.RequestArchivedVols;
|
||||
// state
|
||||
private SystemContractData _contract_data = null;
|
||||
private IDictionary<int, SingleVolSurfaceManager> _vs_manager_map =
|
||||
new Dictionary<int, SingleVolSurfaceManager>();
|
||||
private Queue<mbts.analytics.VolSurfaceSettings> _waiting_creations =
|
||||
new Queue<mbts.analytics.VolSurfaceSettings>();
|
||||
private bts.api.IBus _bus;
|
||||
private List<IDisposable> _subs = new List<IDisposable>();
|
||||
private HighPerformanceTimer _timer = new HighPerformanceTimer();
|
||||
|
||||
public VolSurfaceBusManager(bts.api.IBus bus,
|
||||
bts.api.analytics.AnalyticsService analytics_service) {
|
||||
bts.Log.Ui.info("VSBusManager cons tid:{VolSurfaceTroubleshootingFunctions.tid()}");
|
||||
_bus = bus;
|
||||
_bb = new ThreadedBlackboard(bus);
|
||||
_analytics_service = analytics_service;
|
||||
// subs to bb
|
||||
_bb.subscribe(_in_scdata_tag);
|
||||
_bb.subscribe(_in_bb_create_tag);
|
||||
_bb.subscribe(_in_bb_delete_tag);
|
||||
_bb.subscribe(_in_bb_exp_params_tag);
|
||||
_bb.subscribe(_in_bb_req_vol);
|
||||
_bb.data_callback += _on_bb_update;
|
||||
_bb.timer_callback += _on_timer;
|
||||
// sub to service
|
||||
var vs_sub = _analytics_service.subscribei_volsurfaces()
|
||||
.ObserveOn(SynchronizationContext.Current)
|
||||
.Subscribe(_on_vss);
|
||||
var vs_usage_sub = _analytics_service.subscribei_volsurface_usage()
|
||||
.ObserveOn(SynchronizationContext.Current)
|
||||
.Subscribe(_on_vs_usage_update);
|
||||
_subs.Add(vs_sub);
|
||||
_subs.Add(vs_usage_sub);
|
||||
_subs.Add(new AnalyticsParametersManager(_bb, _analytics_service));
|
||||
_subs.Add(new ResourceAllocator(bus, _bb));
|
||||
_subs.Add(new SymbolAggregationPublisher<OptionDriverPriceMap>(
|
||||
_bb, (sym) => SparkTags.OptionDriverBBOTag(sym),
|
||||
SparkTags.AllOptionDriverBBOTag));
|
||||
_subs.Add(new SymbolAggregationPublisher<OptionTheoInterpolationData>(
|
||||
_bb, (sym) => SparkTags.SymbolInterpGreeksTag(sym),
|
||||
SparkTags.AllInterpGreeks));
|
||||
_subs.Add(new LiveTheoPublisher(_bb));
|
||||
_subs.Add(new VolSurfaceInterpGreeksMultiplexer(_bb));
|
||||
//_subs.Add(new AnalyticsServiceTester(_bb));
|
||||
// TODO: temporatily publish values
|
||||
VolSurfaceUsageList ulist = new VolSurfaceUsageList();
|
||||
ulist.UsageList.Add(new VolSurfaceUsageEntry() {
|
||||
VsId = 6,
|
||||
SecTup = new bts.api.SecurityTuple() {
|
||||
Type = SecurityType.Option,
|
||||
Venue = VolSurfaceTemp.get_default_venue(SecurityType.Option, "BTC"),
|
||||
Symbol = "BTC"
|
||||
}
|
||||
});
|
||||
ulist.UsageList.Add(new VolSurfaceUsageEntry() {
|
||||
VsId = 7,
|
||||
SecTup = new bts.api.SecurityTuple() {
|
||||
Type = SecurityType.Option,
|
||||
Venue = VolSurfaceTemp.get_default_venue(SecurityType.Option, "ETH"),
|
||||
Symbol = "ETH"
|
||||
}
|
||||
});
|
||||
_bb.post(SparkTags.VolSurfaceUsageTag, new VolSurfaceUsageListImmutable(ulist));
|
||||
}
|
||||
|
||||
void _on_vs_usage_update(Update<VolSurfaceUsageListImmutable, int> update) {
|
||||
// TODO
|
||||
return;
|
||||
// int vs_count = update.all.Count();
|
||||
// Log.Gen.info($"VSBusManager._on_vs_usage_update " +
|
||||
// $"tid:{Thread.CurrentThread.ManagedThreadId} count:{update.all.Count()}");
|
||||
// Log.assert(vs_count <= 1);
|
||||
// if (update.all.TryGetSingle(out var to_write)) {
|
||||
// _bb.post(SparkTags.VolSurfaceUsageTag, to_write);
|
||||
// }
|
||||
}
|
||||
|
||||
void _on_vss(bts.api.core.Update<VolSurfaceEntryImmutable, UInt64> update) {
|
||||
bts.Log.Gen.info(String.Format("VSBusManager._on_vss tid:{0} count:{1}",
|
||||
System.Threading.Thread.CurrentThread.ManagedThreadId, update.all.Count()));
|
||||
IDictionary<int, string> to_publish = new Dictionary<int, string>();
|
||||
// publish a dictionary of vs id vs vs names
|
||||
foreach (VolSurfaceEntryImmutable vs in update.all) {
|
||||
to_publish[vs.VsId] = vs.VsName;
|
||||
}
|
||||
_bb.post(SparkTags.VolSurfaceListTag, to_publish);
|
||||
_init_vss(to_publish.Keys);
|
||||
}
|
||||
|
||||
private void _init_vss(IEnumerable<int> vs_ids) {
|
||||
// we consider every vs in the db as "activated" which might prove to be expensive
|
||||
// (will take care of it later)
|
||||
foreach (var vs_id in vs_ids) {
|
||||
if (!_vs_manager_map.ContainsKey(vs_id)) {
|
||||
_vs_manager_map.Add(vs_id, new SingleVolSurfaceManager(
|
||||
vs_id, _bb, _analytics_service));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _on_bb_update(object tag, object data) {
|
||||
if (_in_scdata_tag.Equals(tag)) {
|
||||
_contract_data = _bb.read_state(_in_scdata_tag);
|
||||
}
|
||||
if (_in_bb_create_tag.Equals(tag)) {
|
||||
// creations are written in a queue and handled later in the timer
|
||||
// callback
|
||||
mbts.analytics.VolSurfaceSettings vs_settings = data as mbts.analytics.VolSurfaceSettings;
|
||||
bts.Log.Gen.info(String.Format("VSBusManager._on_bb_update received vs creation tag vs:{0}",
|
||||
VolSurfaceUtilityFunctions.serialize_proto_to_text(vs_settings)));
|
||||
_waiting_creations.Enqueue(vs_settings);
|
||||
} else if (_in_bb_delete_tag.Equals(tag)) {
|
||||
int vs_id = (int)data;
|
||||
try {
|
||||
IntWrapper vs_id_w = new IntWrapper();
|
||||
vs_id_w.Data = vs_id;
|
||||
_analytics_service.delete_volsurface(vs_id_w);
|
||||
} catch (Exception ex) {
|
||||
Log.Gen.error(String.Format("Vol Surface deletion failed with exception:{0}", ex.Message));
|
||||
_bb.post(SparkTags.MessageDisplayTag,
|
||||
new MessageDisplayData("Vol Surface Deletion",
|
||||
String.Format("Could not delete Vol Surface, Error : {0}", ex.Message)));
|
||||
}
|
||||
} else if (_in_bb_exp_params_tag.Equals(tag)) {
|
||||
AnalyticsExpirationParametersMap exp_param_map = data as AnalyticsExpirationParametersMap;
|
||||
// TODO, add whatever else is needed to AnalyticsExpirationParametersMap -> VolSurfaceNonVolInputTag
|
||||
_bb.post(SparkTags.VolSurfaceNonVolInputTag,
|
||||
new mbts.analytics.VolSurfaceNonVolInput(exp_param_map.exp_map.ToDictionary()));
|
||||
} else if (_in_bb_req_vol.Equals(tag)) {
|
||||
ClientArchivedVolRequest client_req = _bb.read_state(_in_bb_req_vol);
|
||||
ArchivedTheoRetrieval ret = client_req.ret;
|
||||
if (ret == null || ret.SecTup == null) {
|
||||
bts.Log.Ui.warn($"VolSurfaceBusManager malformed ArchivedTheoRetrieval");
|
||||
ArchivedTheoList empty = new ArchivedTheoList();
|
||||
_bb.post(SparkTags.ResponseArchivedVols, Tuple.Create(client_req, empty));
|
||||
return;
|
||||
}
|
||||
bts.Log.Ui.info($"VolSurfaceBusManager ArchivedTheoRetrieval id: {client_req.id} save_time: {ret.SaveTime} " +
|
||||
$"sec_tup: {ret.SecTup.Venue}_{ret.SecTup.Type}_{ret.SecTup.Symbol}");
|
||||
_timer.start();
|
||||
ArchivedTheoList arch_theos = _analytics_service.get_archived_theos(ret);
|
||||
_timer.stop();
|
||||
bts.Log.Ui.info($"VolSurfaceBusManager ArchivedTheoRetrieval time: {_timer.lastIntervalTime} " +
|
||||
$"n_entries: {arch_theos.SecTheo.Count}");
|
||||
_bb.post(SparkTags.ResponseArchivedVols, Tuple.Create(client_req, arch_theos));
|
||||
}
|
||||
}
|
||||
|
||||
private int _timer_count = 0;
|
||||
private void _on_timer() {
|
||||
Action<string> report_err = (string err_txt) => {
|
||||
Log.Gen.error(String.Format("VSBusManager, creation failed with message:{0}", err_txt));
|
||||
_bb.post(SparkTags.MessageDisplayTag, new MessageDisplayData("Vol Surface Addition",
|
||||
String.Format("Could not create Vol Surface, Error : {0}", err_txt)));
|
||||
};
|
||||
bts.Log.Gen.diag(String.Format("VSBusManager._on_timer tid:{0} count:{1}",
|
||||
System.Threading.Thread.CurrentThread.ManagedThreadId, _timer_count++));
|
||||
if (_waiting_creations.Count == 0) {
|
||||
return;
|
||||
}
|
||||
if (_contract_data == null) {
|
||||
return;
|
||||
}
|
||||
mbts.analytics.VolSurfaceSettings vs_settings = _waiting_creations.Dequeue();
|
||||
IDictionary<string, IEnumerable<DateTime>> exp_map = _contract_data.get_option_expirations(VolSurfaceDataFunctions.get_symbols(vs_settings), false);
|
||||
VolSurfaceInput vs_input = mbts.analytics.VolSurfaceDataFunctions.get_default_vs_input(vs_settings, exp_map);
|
||||
var reply = _analytics_service.get_new_volsurface_id(new VoidMessage());
|
||||
if (!reply.Ok) {
|
||||
report_err("Could not obtain new ID");
|
||||
return;
|
||||
}
|
||||
bts.Log.Gen.info(String.Format("VSBusManager, successfully obtained new vs_id:{0}", reply.NewId));
|
||||
vs_input.surface_settings.core_settings.vol_surface_id = reply.NewId;
|
||||
_timer.start();
|
||||
ResultMessage res = VolSurfaceUtilityFunctions.save_volsurface(vs_input, _analytics_service);
|
||||
_timer.stop();
|
||||
if (!res.Success) {
|
||||
report_err(res.ErrorMessage);
|
||||
return;
|
||||
}
|
||||
Log.Gen.info(String.Format("VSBusManager, successfully created vol surface, vs_id:{0} ts:{1} msecs",
|
||||
vs_input.surface_settings.core_settings.vol_surface_id,
|
||||
_timer.lastIntervalTime.ToString()));
|
||||
_bb.post(SparkTags.VolSurfaceActivationTag(reply.NewId), true, false);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
_subs.ForEach(s => s.Dispose());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using bts.api.analytics;
|
||||
|
||||
using mbts.analytics;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace mbts.spark {
|
||||
/// Conveniance wrapper around the VolSurfaceInputSnapshotListStream rows
|
||||
public class VolSurfaceInputSnapshot {
|
||||
public readonly int volsurface_id;
|
||||
public readonly int transaction_id;
|
||||
public readonly DateTime save_time_utc;
|
||||
public readonly string save_marker;
|
||||
public readonly byte[] data;
|
||||
|
||||
public VolSurfaceInputSnapshot(bts.api.analytics.VolSurfaceEntryImmutable vs) {
|
||||
volsurface_id = vs.VsId;
|
||||
transaction_id = 0;
|
||||
save_time_utc = VolSurfaceUtilityFunctions.from_unix_epoch_msecs(vs.SaveTime);
|
||||
data = vs.Volsurface.ToByteArray();
|
||||
save_marker = save_time_utc.ToShortDateString() + " " +
|
||||
save_time_utc.ToLocalTime().ToLongTimeString();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using mbts.analytics;
|
||||
|
||||
namespace mbts.spark
|
||||
{
|
||||
public class VolSurfaceTheoAlertData
|
||||
{
|
||||
public readonly string guid;
|
||||
public readonly int vs_id;
|
||||
public readonly IDictionary<VolSurfaceExpiration, IEnumerable<Theos>> theos;
|
||||
|
||||
public VolSurfaceTheoAlertData(string guid,
|
||||
int vs_id,
|
||||
IDictionary<VolSurfaceExpiration, IEnumerable<Theos>> theos)
|
||||
{
|
||||
this.guid = guid;
|
||||
this.vs_id = vs_id;
|
||||
this.theos = theos;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using mbts.analytics;
|
||||
|
||||
namespace mbts.spark
|
||||
{
|
||||
public class VolSurfaceTheoData
|
||||
{
|
||||
/// This is the set of all contracts in the
|
||||
public readonly IDictionary<VolSurfaceExpiration, HashSet<double>> all_contracts;
|
||||
public readonly Dictionary<VolSurfaceExpiration, Dictionary<double, Theos>> committed_theo_map, candidate_theo_map;
|
||||
private readonly bool _is_dirty;
|
||||
|
||||
public VolSurfaceTheoData(IDictionary<VolSurfaceExpiration, HashSet<double>> this_all_contracts,
|
||||
IDictionary<VolSurfaceExpiration, IEnumerable<Theos>> this_committed_theo_map,
|
||||
IDictionary<VolSurfaceExpiration, IEnumerable<Theos>> this_candidate_theo_map,
|
||||
bool this_is_dirty)
|
||||
{
|
||||
all_contracts = this_all_contracts;
|
||||
committed_theo_map = this_committed_theo_map.ToDictionary(kv => kv.Key, kv => kv.Value.ToDictionary(i => i.strike, i => i));
|
||||
candidate_theo_map = this_candidate_theo_map.ToDictionary(kv => kv.Key, kv => kv.Value.ToDictionary(i => i.strike, i => i));
|
||||
_is_dirty = this_is_dirty;
|
||||
}
|
||||
|
||||
// TODO
|
||||
// public IBlueRowCollection get_rows()
|
||||
// {
|
||||
// List<IBlueRow> rows = new List<IBlueRow>();
|
||||
// IBlueTableSchema schema = new VolSurfaceTheoPointRow(-1, String.Empty, true, null, null, _is_dirty).schema;
|
||||
// foreach (KeyValuePair<VolSurfaceExpiration, HashSet<double>> kvp in all_contracts)
|
||||
// {
|
||||
// VolSurfaceExpiration exp = kvp.Key;
|
||||
// Dictionary<double, Theos> exp_comm_map, exp_cand_map;
|
||||
// committed_theo_map.TryGetValue(exp, out exp_comm_map);
|
||||
// candidate_theo_map.TryGetValue(exp, out exp_cand_map);
|
||||
// foreach (double k in kvp.Value)
|
||||
// {
|
||||
// Theos committed_tp = null, candidate_tp = null;
|
||||
// committed_tp = (exp_comm_map != null && exp_comm_map.TryGetValue(k, out committed_tp)) ? committed_tp : null;
|
||||
// if (_is_dirty)
|
||||
// candidate_tp = (exp_cand_map != null && exp_cand_map.TryGetValue(k, out candidate_tp)) ? candidate_tp : null;
|
||||
// rows.Add(new VolSurfaceTheoPointRow(rows.Count, exp.symbol, true, committed_tp, candidate_tp, _is_dirty));
|
||||
// rows.Add(new VolSurfaceTheoPointRow(rows.Count, exp.symbol, false, committed_tp, candidate_tp, _is_dirty));
|
||||
// }
|
||||
// }
|
||||
// return new SequentialIDBlueTable(schema, rows.ToArray());
|
||||
// }
|
||||
|
||||
public IEnumerable<VolSurfaceExpiration> get_all_expirations() { return all_contracts.Keys; }
|
||||
|
||||
// TODO
|
||||
// public ExpStrikeKeyedData<Theos> get_exp_mapped_data(string option_sym, bool is_cand)
|
||||
// {
|
||||
// ExpStrikeKeyedData<Theos> rv = new ExpStrikeKeyedData<Theos>();
|
||||
// IDictionary<VolSurfaceExpiration, Dictionary<double, Theos>> map = is_cand ? candidate_theo_map : committed_theo_map;
|
||||
// if (map != null)
|
||||
// foreach (KeyValuePair<VolSurfaceExpiration, Dictionary<double, Theos>> kv in map)
|
||||
// {
|
||||
// VolSurfaceExpiration exp = kv.Key;
|
||||
// if (exp.symbol == option_sym)
|
||||
// rv.set_data_for_expiration(exp.expiration, kv.Value);
|
||||
// }
|
||||
// return rv;
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
enum AxisPosition {
|
||||
None,
|
||||
TopLeftToRight,
|
||||
TopRightToLeft,
|
||||
BottomLeftToRight,
|
||||
BottomRightToLeft,
|
||||
LeftTopToBottom,
|
||||
LeftBottomToTop,
|
||||
RightTopToBottom,
|
||||
RightBottomToTop
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
enum DateTimeIntervalType {
|
||||
Auto,
|
||||
Seconds,
|
||||
Minutes,
|
||||
Hours,
|
||||
Days,
|
||||
Weeks,
|
||||
Months,
|
||||
Years
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using mbts.ui.shell;
|
||||
|
||||
/// ** BTSGraphPoint in edge **
|
||||
/// <summary>
|
||||
/// Represents a point in a graph
|
||||
/// </summary>
|
||||
class GraphPointVM : ViewModelBase {
|
||||
object _x;
|
||||
object _y;
|
||||
|
||||
public GraphPointVM() { }
|
||||
|
||||
public GraphPointVM(object x, object y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public object x { get => _x; set => Set(ref _x, value); }
|
||||
public object y { get => _y; set => Set(ref _y, value); }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
interface IVolTermsSeries {
|
||||
bool is_committed { get; }
|
||||
void update_points(IReadOnlyDictionary<DateTime, double> vol_map);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using mbts.ui;
|
||||
|
||||
using ProtoBuf;
|
||||
|
||||
using System;
|
||||
|
||||
[ProtoContract]
|
||||
class LineSeriesSettings : IEquatable<LineSeriesSettings>, ICloneable {
|
||||
[ProtoMember(1)]
|
||||
public LineStyle line_style { get; set; }
|
||||
[ProtoMember(2)]
|
||||
public double stroke_thickness { get; set; }
|
||||
[ProtoMember(3)]
|
||||
public BTSColor color { get; set; }
|
||||
|
||||
public object Clone() =>
|
||||
new LineSeriesSettings {
|
||||
line_style = line_style,
|
||||
stroke_thickness = stroke_thickness,
|
||||
color = color.clone()
|
||||
};
|
||||
|
||||
public bool Equals(LineSeriesSettings other) =>
|
||||
other != null &&
|
||||
line_style == other.line_style &&
|
||||
stroke_thickness.Equals(other.stroke_thickness) &&
|
||||
color == other.color;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
Equals(obj as LineSeriesSettings);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
GetType().GetHashCode();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
enum LineStyle {
|
||||
None,
|
||||
Solid,
|
||||
Dashed,
|
||||
Dot,
|
||||
DashDot,
|
||||
DashDashDot,
|
||||
DashDotDot,
|
||||
DashDashDotDot,
|
||||
LongDash,
|
||||
LongDashDot,
|
||||
LongDashDotDot,
|
||||
Automatic
|
||||
};
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
enum MarkerShape {
|
||||
None,
|
||||
Circle,
|
||||
Cross, Diamond,
|
||||
Plus,
|
||||
Square,
|
||||
Star,
|
||||
Triangle
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using mbts.ui;
|
||||
|
||||
using ProtoBuf;
|
||||
|
||||
using System;
|
||||
|
||||
[ProtoContract]
|
||||
class ScatterSeriesSettings : IEquatable<ScatterSeriesSettings>, ICloneable {
|
||||
[ProtoMember(1)]
|
||||
public MarkerShape shape { get; set; }
|
||||
[ProtoMember(2)]
|
||||
public double size { get; set; }
|
||||
[ProtoMember(3)]
|
||||
public BTSColor fill { get; set; }
|
||||
[ProtoMember(4)]
|
||||
public BTSColor stroke { get; set; }
|
||||
|
||||
public object Clone() =>
|
||||
new ScatterSeriesSettings {
|
||||
shape = shape,
|
||||
size = size,
|
||||
fill = fill.clone(),
|
||||
stroke = stroke.clone()
|
||||
};
|
||||
|
||||
public bool Equals(ScatterSeriesSettings other) =>
|
||||
other != null &&
|
||||
shape == other.shape &&
|
||||
size.Equals(other.size) &&
|
||||
fill == other.fill &&
|
||||
stroke == other.stroke;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
Equals(obj as ScatterSeriesSettings);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
GetType().GetHashCode();
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using mbts.spark;
|
||||
|
||||
namespace mbts.ui.controls
|
||||
{
|
||||
/// This is all the general data that is needed to display
|
||||
/// a vol curve - committed or candidate.
|
||||
/// The special_call/put_points depend on the model - there
|
||||
/// might not be any.
|
||||
public class VolCurveDisplayGraph
|
||||
{
|
||||
public readonly IEnumerable<Tuple<double, double>> all_points;
|
||||
/// Scatter points, ex in polynomial and spline models these
|
||||
/// will be the control points (could be null or empty)
|
||||
public readonly IEnumerable<Tuple<double, double>> special_call_points, special_put_points;
|
||||
/// Could also be null or Double.NaN's
|
||||
public readonly Tuple<double, double> atm_point;
|
||||
public readonly double call_wing_start, put_wing_start;
|
||||
|
||||
public VolCurveDisplayGraph (IEnumerable<Tuple<double, double>> this_all_points,
|
||||
IEnumerable<Tuple<double, double>> this_special_call_points,
|
||||
IEnumerable<Tuple<double, double>> this_special_put_points,
|
||||
Tuple<double, double> this_atm_point,
|
||||
double this_meat_left_x, double this_meat_right_x)
|
||||
{
|
||||
all_points = this_all_points ?? Enumerable.Empty<Tuple<double, double>>();
|
||||
special_call_points = this_special_call_points ?? Enumerable.Empty<Tuple<double, double>>();
|
||||
special_put_points = this_special_put_points ?? Enumerable.Empty<Tuple<double, double>>();
|
||||
atm_point = this_atm_point;
|
||||
call_wing_start = this_meat_left_x;
|
||||
put_wing_start = this_meat_right_x;
|
||||
}
|
||||
}
|
||||
|
||||
public class VolSurfaceTermsStructure
|
||||
{
|
||||
public VolSurfaceTermsStructure(double vol, double vega, double straddle) {
|
||||
this.vol = vol;
|
||||
this.vega = vega;
|
||||
this.straddle = straddle;
|
||||
}
|
||||
|
||||
public readonly double vol, vega, straddle;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using bts.collections;
|
||||
|
||||
using mbts.ui;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
/// ** VolTermsLineSeries in edge **
|
||||
/// <summary>
|
||||
/// Represents a scatter series in a graph
|
||||
/// </summary>
|
||||
class VolTermsLineSeriesVM : LineSeriesVM, IVolTermsSeries {
|
||||
bool _is_committed;
|
||||
// public VolTermsLineSeriesVM(bool is_committed) {
|
||||
// this.is_committed = is_committed;
|
||||
// name = is_committed ? "Committed" : "Candidate";
|
||||
// is_visible = true;
|
||||
// color = BTSColors.VolSurfaceGraph.main_curve;
|
||||
// line_style = is_committed ? LineStyle.Solid : LineStyle.Dashed;
|
||||
// stroke_thickness = 1.5;
|
||||
// }
|
||||
|
||||
public bool is_committed {
|
||||
get => _is_committed;
|
||||
set {
|
||||
if (Set(ref _is_committed, value)) {
|
||||
name = value ? "Committed" : "Candidate";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void update_points(IReadOnlyDictionary<DateTime, double> vol_map) =>
|
||||
points.SetItems(vol_map
|
||||
.Where(kv => !double.IsNaN(kv.Value))
|
||||
.OrderBy(kv => kv.Key)
|
||||
.Select(kv => new GraphPointVM(OxyPlot.Axes.DateTimeAxis.ToDouble(kv.Key), kv.Value)));
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using bts.collections;
|
||||
|
||||
using mbts.ui;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
class VolTermsScatterSeriesVM : ScatterSeriesVM, IVolTermsSeries {
|
||||
bool _is_committed;
|
||||
|
||||
// public VolTermsScatterSeriesVM(bool is_committed) {
|
||||
// this.is_committed = is_committed;
|
||||
// name = is_committed ? "Committed" : "Candidate";
|
||||
// is_visible = true;
|
||||
// marker_color = BTSColors.VolSurfaceGraph.main_curve_atm;
|
||||
// marker_shape = MarkerShape.Circle;
|
||||
// marker_size = 3.0;
|
||||
// }
|
||||
|
||||
public bool is_committed {
|
||||
get => _is_committed;
|
||||
set {
|
||||
if (Set(ref _is_committed, value)) {
|
||||
name = value ? "Committed" : "Candidate";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void update_points(IReadOnlyDictionary<DateTime, double> vol_map) =>
|
||||
points.SetItems(vol_map
|
||||
.Where(kv => !double.IsNaN(kv.Value))
|
||||
.OrderBy(kv => kv.Key)
|
||||
.Select(kv => new GraphPointVM(OxyPlot.Axes.DateTimeAxis.ToDouble(kv.Key), kv.Value)));
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
namespace mbts.ui.controls {
|
||||
using bts.utils;
|
||||
|
||||
using mbts.spark;
|
||||
using mbts.spark.VolSurface;
|
||||
using mbts.user.settings;
|
||||
|
||||
using System;
|
||||
|
||||
public class VolSurfaceDisplayGridColumn : IEquatable<VolSurfaceDisplayGridColumn> {
|
||||
public readonly Func<object, string> format;
|
||||
public readonly Func<string, object> parse;
|
||||
public readonly Func<object, bool, object> tick_move;
|
||||
|
||||
internal readonly VolSurfaceColumnSettings settings;
|
||||
|
||||
internal VolSurfaceDisplayGridColumn(
|
||||
VolSurfaceColumnSettings settings,
|
||||
Func<object, string> format = null,
|
||||
Func<string, object> parse = null,
|
||||
Func<object, bool, object> tick_move = null) {
|
||||
this.settings = settings;
|
||||
this.format = format ?? (v => v?.ToString() ?? string.Empty);
|
||||
this.parse = parse ?? (v => v);
|
||||
this.tick_move = tick_move ?? ((v, is_up) => v);
|
||||
}
|
||||
|
||||
public string unique_col_name => settings.id;
|
||||
public string display_name => settings.display_name;
|
||||
public string group => settings.group;
|
||||
|
||||
internal VolSurfaceColumnType type => settings.type;
|
||||
|
||||
public TickDisplaySettings tick_display {
|
||||
get => settings.tick_display;
|
||||
set => settings.tick_display = value;
|
||||
}
|
||||
|
||||
public TickFactors tick_factors {
|
||||
get => settings.tick_factors;
|
||||
set => settings.tick_factors = value;
|
||||
}
|
||||
|
||||
public int tick_move_units {
|
||||
get => settings.tick_move;
|
||||
set => settings.tick_move = value;
|
||||
}
|
||||
|
||||
public override int GetHashCode() =>
|
||||
unique_col_name.GetHashCode();
|
||||
|
||||
public override string ToString() =>
|
||||
unique_col_name;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
Equals(obj as VolSurfaceDisplayGridColumn);
|
||||
|
||||
public bool Equals(VolSurfaceDisplayGridColumn other) =>
|
||||
other is not null &&
|
||||
settings.safe_equals(other.settings);
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.utils;
|
||||
|
||||
using mbts.spark.VolSurface;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.settings;
|
||||
using mbts.user.settings;
|
||||
|
||||
using ProtoBuf;
|
||||
|
||||
using System;
|
||||
|
||||
[ProtoContract]
|
||||
class VolSurfaceColumnSettings : ICloneable<VolSurfaceColumnSettings>, IEquatable<VolSurfaceColumnSettings> {
|
||||
public static VolSurfaceColumnSettings Default(GridColumnSettings core = null) =>
|
||||
new() {
|
||||
core = core,
|
||||
tick_factors = new(100, 1),
|
||||
tick_move = 1,
|
||||
tick_display = TickDisplaySettings.Default.with(nan_text: string.Empty)
|
||||
};
|
||||
|
||||
public string id => core?.id;
|
||||
public string display_name => core?.display_name;
|
||||
public string group => core?.group;
|
||||
public bool is_visible => core?.is_visible ?? false;
|
||||
public VolSurfaceColumnType type { get; set; }
|
||||
|
||||
[ProtoMember(1)]
|
||||
public GridColumnSettings core { get; set; }
|
||||
|
||||
[ProtoMember(2)]
|
||||
public TickFactors tick_factors { get; set; }
|
||||
|
||||
[ProtoMember(3)]
|
||||
public int tick_move { get; set; }
|
||||
|
||||
[ProtoMember(4)]
|
||||
public TickDisplaySettings tick_display { get; set; }
|
||||
|
||||
[ProtoMember(5)]
|
||||
public DateFormat date_formatting { get; set; }
|
||||
|
||||
public static VolSurfaceColumnSettings from_column_model(VolSurfaceDisplayGridColumn model) {
|
||||
var rv = Default(new GridColumnSettings(
|
||||
model.unique_col_name,
|
||||
model.display_name,
|
||||
is_visible: true,
|
||||
is_expanded: true
|
||||
));
|
||||
rv.type = model.type;
|
||||
rv.tick_display = model.tick_display;
|
||||
rv.tick_factors = model.tick_factors;
|
||||
rv.tick_move = model.tick_move_units;
|
||||
return rv;
|
||||
}
|
||||
|
||||
public VolSurfaceDisplayGridColumn to_column_model() =>
|
||||
type switch {
|
||||
VolSurfaceColumnType.ReadOnly => VolSurfaceDisplayUtilities.get_double_col(
|
||||
true, group, id, display_name, this, tick_factors, tick_display),
|
||||
VolSurfaceColumnType.ReadWriteTick => VolSurfaceDisplayUtilities.get_double_col(
|
||||
false, group, id, display_name, this, tick_factors, tick_display),
|
||||
_ => null
|
||||
};
|
||||
|
||||
public VolSurfaceColumnSettings Clone() =>
|
||||
new() {
|
||||
type = type,
|
||||
core = core?.Clone(),
|
||||
tick_factors = tick_factors,
|
||||
tick_move = tick_move,
|
||||
tick_display = tick_display.Clone(),
|
||||
date_formatting = date_formatting
|
||||
};
|
||||
|
||||
object ICloneable.Clone() =>
|
||||
Clone();
|
||||
|
||||
public bool Equals(VolSurfaceColumnSettings other) =>
|
||||
other is not null &&
|
||||
type == other.type &&
|
||||
core.safe_equals(other.core) &&
|
||||
tick_factors.safe_equals(other.tick_factors) &&
|
||||
tick_display.safe_equals(other.tick_display) &&
|
||||
tick_move == other.tick_move &&
|
||||
date_formatting == other.date_formatting;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
Equals(obj as VolSurfaceColumnSettings);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
EqualityComparer.auto_phase(id.GetHashCode(), display_name.GetHashCode());
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using mbts.spark;
|
||||
|
||||
namespace mbts.ui.controls
|
||||
{
|
||||
/// This contains the list of global values for the vol
|
||||
/// surface (whereas VolSurfaceDisplayGrid has exp keyed
|
||||
/// values)
|
||||
public class VolSurfaceDisplayGlobalGrid : ICloneable
|
||||
{
|
||||
private IEnumerable<VolSurfaceDisplayGridColumn> _ordered_columns = null;
|
||||
private IDictionary<VolSurfaceDisplayGridColumn, object> _data_map = new Dictionary<VolSurfaceDisplayGridColumn, object>();
|
||||
|
||||
public VolSurfaceDisplayGlobalGrid(IEnumerable<VolSurfaceDisplayGridColumn> this_ordered_cols,
|
||||
IDictionary<VolSurfaceDisplayGridColumn, object> this_data_map)
|
||||
{
|
||||
_ordered_columns = this_ordered_cols;
|
||||
_data_map = this_data_map;
|
||||
}
|
||||
|
||||
public IEnumerable<VolSurfaceDisplayGridColumn> get_ordered_columns() { return _ordered_columns; }
|
||||
|
||||
public bool get_grid_data(VolSurfaceDisplayGridColumn col, out object data)
|
||||
{
|
||||
return _data_map.TryGetValue(col, out data) ? true : false;
|
||||
}
|
||||
|
||||
public bool set_grid_data(VolSurfaceDisplayGridColumn col, object data)
|
||||
{
|
||||
if (_data_map.ContainsKey(col))
|
||||
{
|
||||
_data_map[col] = data;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public string format(VolSurfaceDisplayGridColumn col, object data)
|
||||
{
|
||||
return data != null ? data.ToString() : String.Empty;
|
||||
}
|
||||
|
||||
public object unformat(VolSurfaceDisplayGridExpiration exp, VolSurfaceDisplayGridColumn col, string data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
#region ICloneable
|
||||
public object Clone()
|
||||
{
|
||||
return new VolSurfaceDisplayGlobalGrid(new List<VolSurfaceDisplayGridColumn>(_ordered_columns),
|
||||
new Dictionary<VolSurfaceDisplayGridColumn, object>(_data_map));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
namespace mbts.ui.controls {
|
||||
using bts;
|
||||
using bts.utils;
|
||||
|
||||
using mbts.spark;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
/// Encapsulates the vol data that would show up in the top grid
|
||||
public class VolSurfaceDisplayGrid :
|
||||
ICellDataStore<VolSurfaceDisplayGridExpiration, VolSurfaceDisplayGridColumn, object>,
|
||||
ICloneable<VolSurfaceDisplayGrid> {
|
||||
readonly IEnumerable<VolSurfaceDisplayGridExpiration> _ordered_expirations = null;
|
||||
readonly IEnumerable<VolSurfaceDisplayGridColumn> _ordered_columns = null;
|
||||
readonly IDictionary<string, VolSurfaceDisplayGridColumn> _column_map;
|
||||
readonly IDictionary<VolSurfaceDisplayGridExpiration, IDictionary<string, object>> _data_map =
|
||||
new Dictionary<VolSurfaceDisplayGridExpiration, IDictionary<string, object>>();
|
||||
public IEnumerable<VolSurfaceDisplayGridExpiration> get_ordered_expirations() { return _ordered_expirations; }
|
||||
public IEnumerable<VolSurfaceDisplayGridColumn> get_ordered_columns() { return _ordered_columns; }
|
||||
|
||||
public IDictionary<VolSurfaceDisplayGridExpiration, IDictionary<string, object>> data_map {
|
||||
get {
|
||||
return _data_map;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: get rid of this constructor. The VolSurfaceDisplayGridColumn
|
||||
// keys in the data contain more information than neccessary, a column id
|
||||
// string will suffice.
|
||||
public VolSurfaceDisplayGrid(
|
||||
IEnumerable<VolSurfaceDisplayGridExpiration> ordered_expirations,
|
||||
IEnumerable<VolSurfaceDisplayGridColumn> ordered_columns,
|
||||
IDictionary<VolSurfaceDisplayGridExpiration, IDictionary<VolSurfaceDisplayGridColumn, object>> data)
|
||||
: this(ordered_expirations, ordered_columns, data.ToDictionary(
|
||||
kv => kv.Key, kv => kv.Value.ToDictionary(_kv => _kv.Key.unique_col_name, _kv => _kv.Value).as_idictionary())) { }
|
||||
|
||||
public VolSurfaceDisplayGrid(IEnumerable<VolSurfaceDisplayGridExpiration> ordered_expirations,
|
||||
IEnumerable<VolSurfaceDisplayGridColumn> ordered_columns,
|
||||
IDictionary<VolSurfaceDisplayGridExpiration, IDictionary<string, object>> data) {
|
||||
_ordered_expirations = ordered_expirations;
|
||||
_ordered_columns = ordered_columns;
|
||||
_data_map = data;
|
||||
_column_map = ordered_columns.ToDictionary(k => k.unique_col_name, k => k);
|
||||
}
|
||||
|
||||
public object get_grid_data(VolSurfaceDisplayGridExpiration exp, VolSurfaceDisplayGridColumn col, object default_value) =>
|
||||
get_grid_data(exp, col.unique_col_name, out var res) ? res : default_value;
|
||||
|
||||
public object get_grid_data(VolSurfaceDisplayGridExpiration exp, string col_name, object default_value) =>
|
||||
get_grid_data(exp, col_name, out var res) ? res : default_value;
|
||||
|
||||
public bool get_grid_data(VolSurfaceDisplayGridExpiration exp, string col_name, out object data) {
|
||||
if (_data_map.TryGetValue(exp, out var exp_data) && exp_data.TryGetValue(col_name, out data)) {
|
||||
return true;
|
||||
}
|
||||
data = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool get_grid_data<T>(VolSurfaceDisplayGridExpiration exp, string col_name, out T result) {
|
||||
if (get_grid_data(exp, col_name, out var res) && res is T res_t) {
|
||||
result = res_t;
|
||||
return true;
|
||||
}
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool has_grid_data(VolSurfaceDisplayGridExpiration exp, VolSurfaceDisplayGridColumn col) =>
|
||||
_data_map.TryGetValue(exp, out var exp_data) && exp_data.ContainsKey(col.unique_col_name);
|
||||
|
||||
public bool copy(
|
||||
VolSurfaceDisplayGridExpiration source_exp,
|
||||
VolSurfaceDisplayGridColumn source_col,
|
||||
VolSurfaceDisplayGridExpiration target_exp,
|
||||
VolSurfaceDisplayGridColumn target_col) =>
|
||||
copy(source_exp, source_col?.unique_col_name, target_exp, target_col?.unique_col_name);
|
||||
|
||||
public bool copy(
|
||||
VolSurfaceDisplayGridExpiration source_exp,
|
||||
string source_col_name,
|
||||
VolSurfaceDisplayGridExpiration target_exp,
|
||||
string target_col_name) =>
|
||||
get_grid_data(source_exp, source_col_name, out var data) &&
|
||||
set_grid_data(target_exp, target_col_name, data);
|
||||
|
||||
/// Returns the expiration differences
|
||||
public static void compare_exps(
|
||||
VolSurfaceDisplayGrid new_grid,
|
||||
VolSurfaceDisplayGrid old_grid,
|
||||
out IEnumerable<VolSurfaceDisplayGridExpiration> deleted,
|
||||
out IEnumerable<VolSurfaceDisplayGridExpiration> added) {
|
||||
var new_grid_map = HashSet.create(new_grid.get_ordered_expirations());
|
||||
var old_grid_map = HashSet.create(old_grid.get_ordered_expirations());
|
||||
CollectionHelper.compare_hashsets(new_grid_map, old_grid_map, out var del, out var add);
|
||||
deleted = del;
|
||||
added = add;
|
||||
}
|
||||
|
||||
public static bool cols_changed(VolSurfaceDisplayGrid d1, VolSurfaceDisplayGrid d2) {
|
||||
compare_cols(d1, d2, out var d1_extra, out var d2_extra);
|
||||
return d1_extra.Any() || d2_extra.Any();
|
||||
}
|
||||
|
||||
/// Returns the col name differences (it will generally be very rare, but for instance when a point gets added
|
||||
/// to a polynomial or the spline model, d1 or d2 wont be empty)
|
||||
public static void compare_cols(
|
||||
VolSurfaceDisplayGrid d1,
|
||||
VolSurfaceDisplayGrid d2,
|
||||
out IEnumerable<VolSurfaceDisplayGridColumn> d1_extra,
|
||||
out IEnumerable<VolSurfaceDisplayGridColumn> d2_extra) {
|
||||
var d1_exp_map = HashSet.create(d1.get_ordered_columns());
|
||||
var d2_exp_map = HashSet.create(d2.get_ordered_columns());
|
||||
CollectionHelper.compare_hashsets(d1_exp_map, d2_exp_map, out var del, out var add);
|
||||
d1_extra = add;
|
||||
d2_extra = del;
|
||||
}
|
||||
|
||||
/// Returns the differernce between two VolSurfaceDisplay's.
|
||||
/// It only returns the elements that are present in both
|
||||
/// and are different.
|
||||
public static IEnumerable<Tuple<VolSurfaceDisplayGridExpiration, VolSurfaceDisplayGridColumn>> compare_data(
|
||||
VolSurfaceDisplayGrid d1, VolSurfaceDisplayGrid d2) {
|
||||
if (d1 == d2) {
|
||||
return Enumerable.Empty<Tuple<VolSurfaceDisplayGridExpiration, VolSurfaceDisplayGridColumn>>();
|
||||
}
|
||||
var exps = d1.get_ordered_expirations().Concat(d2.get_ordered_expirations());
|
||||
var cols = d1.get_ordered_columns().Concat(d2.get_ordered_columns());
|
||||
return exps.SelectMany(exp => cols
|
||||
.Where(col => d1.has_grid_data(exp, col) && d2.has_grid_data(exp, col))
|
||||
.Select(col => Tuple.Create(exp, col)));
|
||||
}
|
||||
|
||||
public VolSurfaceDisplayGrid Clone() => new(
|
||||
_ordered_expirations.ToList(),
|
||||
_ordered_columns.ToList(),
|
||||
_data_map.ToDictionary(kv => kv.Key, kv => kv.Value.ToDictionary().as_idictionary()));
|
||||
|
||||
object ICloneable.Clone() =>
|
||||
Clone();
|
||||
|
||||
public IEnumerable<VolSurfaceDisplayGridExpiration> get_rows() =>
|
||||
get_ordered_expirations();
|
||||
|
||||
public ICellDataStore<VolSurfaceDisplayGridExpiration, VolSurfaceDisplayGridColumn, object> get_cell_data_store() => this;
|
||||
|
||||
public bool read(VolSurfaceDisplayGridExpiration row, VolSurfaceDisplayGridColumn col, out object value) =>
|
||||
read(row, col?.unique_col_name, out value);
|
||||
|
||||
public bool read(VolSurfaceDisplayGridExpiration row, string col_name, out object value) =>
|
||||
get_grid_data(row, col_name, out value);
|
||||
|
||||
public object read(VolSurfaceDisplayGridExpiration row, VolSurfaceDisplayGridColumn col) =>
|
||||
read(row, col?.unique_col_name);
|
||||
|
||||
public object read(VolSurfaceDisplayGridExpiration row, string col_name) =>
|
||||
get_grid_data(row, col_name, out var value) ? value : null;
|
||||
|
||||
public bool write(VolSurfaceDisplayGridExpiration row, VolSurfaceDisplayGridColumn col, object value) =>
|
||||
write(row, col?.unique_col_name, value);
|
||||
|
||||
public bool write(VolSurfaceDisplayGridExpiration row, string col_name, object value) =>
|
||||
set_grid_data(row, col_name, value);
|
||||
|
||||
internal bool set_grid_data(VolSurfaceDisplayGridExpiration exp, string col_name, object data) {
|
||||
if (_data_map.TryGetValue(exp, out var exp_data) && exp_data.ContainsKey(col_name)) {
|
||||
exp_data[col_name] = data;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void set_grid_data_text(VolSurfaceDisplayGridExpiration exp, string col_name, string formatted_data) {
|
||||
if (_column_map.TryGetValue(col_name, out var grid_col)) {
|
||||
write(exp, grid_col.unique_col_name, formatted_data);
|
||||
}
|
||||
}
|
||||
|
||||
// internal string log_string {
|
||||
// get {
|
||||
// Func<string, string> trim_leading_comma = (s) => {
|
||||
// if (!s.IsNullOrEmpty() && s.EndsWith(",")) {
|
||||
// return s.Remove(s.Length - 1, 1);
|
||||
// }
|
||||
// return s;
|
||||
// };
|
||||
// Func<IDictionary<VolSurfaceDisplayGridColumn, object>, string> log_exp = (map) => {
|
||||
// string rv = String.Empty;
|
||||
// foreach (var kv in map) {
|
||||
// string val_string = kv.Value == null ? "Null" : kv.Value.ToString();
|
||||
// rv += $"{kv.Key.display_name}:{val_string},";
|
||||
// }
|
||||
// return trim_leading_comma(rv);
|
||||
// };
|
||||
// string rv = String.Empty;
|
||||
// foreach (var kv in _data_map) {
|
||||
// rv += $"Exp:{kv.Key.expiration.ToShortDateString()} Data:{log_exp(kv.Value)},";
|
||||
// }
|
||||
// return trim_leading_comma(rv);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
using bts.api;
|
||||
using bts.utils;
|
||||
|
||||
using System;
|
||||
|
||||
public class VolSurfaceDisplayGridExpiration : IComparable<VolSurfaceDisplayGridExpiration>, IEquatable<VolSurfaceDisplayGridExpiration> {
|
||||
public VolSurfaceDisplayGridExpiration(string symbol, DateTime expiration, analytics.VolSurfaceEnums.VolSurfaceExpirationCalculationMethod calc_mode) {
|
||||
this.symbol = symbol;
|
||||
this.expiration = expiration;
|
||||
this.calc_mode = calc_mode;
|
||||
}
|
||||
|
||||
public string symbol { get; }
|
||||
public DateTime expiration { get; }
|
||||
public analytics.VolSurfaceEnums.VolSurfaceExpirationCalculationMethod calc_mode { get; }
|
||||
|
||||
/// Slave exps are drawn differently and selecting them does not activate
|
||||
/// the controls
|
||||
public bool is_slave =>
|
||||
calc_mode == analytics.VolSurfaceEnums.VolSurfaceExpirationCalculationMethod.Slave;
|
||||
|
||||
public bool Equals(VolSurfaceDisplayGridExpiration other) =>
|
||||
other != null &&
|
||||
expiration == other.expiration &&
|
||||
symbol == other.symbol &&
|
||||
calc_mode == other.calc_mode;
|
||||
|
||||
public override int GetHashCode() =>
|
||||
EqualityComparer.auto_phase(symbol.GetHashCode(), expiration.GetHashCode());
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
Equals(obj as VolSurfaceDisplayGridExpiration);
|
||||
|
||||
public override string ToString() =>
|
||||
SecurityFormatter.format_future(symbol, expiration);
|
||||
|
||||
public static bool operator ==(VolSurfaceDisplayGridExpiration x, VolSurfaceDisplayGridExpiration y) =>
|
||||
x is null ? y is null : x.Equals(y);
|
||||
|
||||
public static bool operator !=(VolSurfaceDisplayGridExpiration left, VolSurfaceDisplayGridExpiration right) =>
|
||||
!(left == right);
|
||||
|
||||
public int CompareTo(VolSurfaceDisplayGridExpiration other) {
|
||||
if (other is null) {
|
||||
return 1;
|
||||
}
|
||||
int rv = expiration.CompareTo(other.expiration);
|
||||
if (rv == 0) {
|
||||
rv = string.Compare(symbol, other.symbol);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
namespace mbts.ui.controls {
|
||||
using bts;
|
||||
using bts.utils;
|
||||
|
||||
using mbts.spark;
|
||||
using mbts.spark.VolSurface;
|
||||
using mbts.user.settings;
|
||||
|
||||
using System;
|
||||
|
||||
class VolSurfaceDisplayUtilities {
|
||||
public static TickDisplaySettings default_tick_display =>
|
||||
TickDisplaySettings.Default.with(
|
||||
show_commas: false,
|
||||
nan_text: string.Empty);
|
||||
|
||||
public static TickDisplaySettings percent_tick_display =>
|
||||
default_tick_display.with(display_multiplier: 100);
|
||||
|
||||
public static double parse_double(object obj) {
|
||||
Log.assert(obj is double);
|
||||
obj = obj ?? Double.NaN;
|
||||
double rv = obj is Double ? (double)obj : (Double.TryParse(obj.ToString(), out rv) ? rv : Double.NaN);
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static bool parse_boolean(object obj, bool def_value) {
|
||||
Log.assert(obj is bool);
|
||||
bool rv;
|
||||
rv = Boolean.TryParse(obj == null ? String.Empty : obj.ToString(), out rv) ? rv : def_value;
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static Func<string, object> get_parse_double(TickFactors tick_factors, TickDisplaySettings tick_display) =>
|
||||
tick_factors is null ?
|
||||
text => double.TryParse(text, out var res) ? res : double.NaN :
|
||||
text => tick_factors.parse(text, tick_display);
|
||||
|
||||
public static Func<object, string> get_double_tostring(TickFactors tick_factors, TickDisplaySettings tick_display) {
|
||||
if (tick_factors is null) {
|
||||
return data => data is double d_data && !d_data.is_nan() ? d_data.ToString() : string.Empty;
|
||||
}
|
||||
return data => {
|
||||
if (data is not double d_data) {
|
||||
return string.Empty;
|
||||
}
|
||||
return tick_factors.format(d_data, tick_display);
|
||||
};
|
||||
}
|
||||
|
||||
public static Func<object, bool, object> get_double_tickmove(TickFactors tick_factors, int tick_move) =>
|
||||
(data, is_up) => data is double d_data ?
|
||||
tick_factors.tick(d_data, is_up ? tick_move : -tick_move) :
|
||||
data;
|
||||
|
||||
public static VolSurfaceDisplayGridColumn get_double_output_col(
|
||||
string group,
|
||||
string name,
|
||||
string display_name,
|
||||
VolSurfaceMacroGridSettings grid_settings,
|
||||
TickFactors tick_factors,
|
||||
TickDisplaySettings tick_display = null) =>
|
||||
get_double_col(true, group, name, display_name, grid_settings, tick_factors, tick_display);
|
||||
|
||||
public static VolSurfaceDisplayGridColumn get_double_input_col(
|
||||
string group,
|
||||
string name,
|
||||
string display_name,
|
||||
VolSurfaceMacroGridSettings grid_settings,
|
||||
TickFactors tick_factors,
|
||||
TickDisplaySettings tick_display = null) =>
|
||||
get_double_col(false, group, name, display_name, grid_settings, tick_factors, tick_display);
|
||||
|
||||
public static VolSurfaceDisplayGridColumn get_double_col(
|
||||
bool is_readonly,
|
||||
string group,
|
||||
string name,
|
||||
string display_name,
|
||||
VolSurfaceMacroGridSettings grid_settings,
|
||||
TickFactors tick_factors,
|
||||
TickDisplaySettings tick_display = null) => get_double_col(
|
||||
is_readonly, group, name, display_name, grid_settings?.get_column(name), tick_factors, tick_display);
|
||||
|
||||
public static VolSurfaceDisplayGridColumn get_double_col(
|
||||
bool is_readonly,
|
||||
string group,
|
||||
string name,
|
||||
string display_name,
|
||||
VolSurfaceColumnSettings col_config,
|
||||
TickFactors tick_factors,
|
||||
TickDisplaySettings tick_display = null) {
|
||||
if (col_config is null) {
|
||||
col_config = VolSurfaceColumnSettings.Default(new(name, display_name));
|
||||
if (tick_factors?.is_valid() ?? false) {
|
||||
col_config.tick_factors = tick_factors;
|
||||
}
|
||||
if (tick_display is not null) {
|
||||
col_config.tick_display = tick_display;
|
||||
}
|
||||
} else {
|
||||
if (!(col_config.tick_factors?.is_valid() ?? false) && (tick_factors?.is_valid() ?? false)) {
|
||||
col_config.tick_factors = tick_factors;
|
||||
}
|
||||
if (col_config.tick_display is null) {
|
||||
col_config.tick_display = tick_display;
|
||||
}
|
||||
}
|
||||
|
||||
col_config.core.group = group;
|
||||
col_config.type = is_readonly ? VolSurfaceColumnType.ReadOnly : VolSurfaceColumnType.ReadWriteTick;
|
||||
|
||||
return new VolSurfaceDisplayGridColumn(
|
||||
col_config,
|
||||
format: get_double_tostring(col_config.tick_factors, col_config.tick_display),
|
||||
parse: get_parse_double(col_config.tick_factors, col_config.tick_display),
|
||||
tick_move: get_double_tickmove(col_config.tick_factors, col_config.tick_move));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
namespace mbts.ui.controls {
|
||||
using bts;
|
||||
using bts.utils;
|
||||
|
||||
using mbts.spark;
|
||||
|
||||
using ProtoBuf;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
[ProtoContract]
|
||||
class VolSurfaceMacroGridSettings : ICloneable<VolSurfaceMacroGridSettings> {
|
||||
[ProtoMember(1)]
|
||||
readonly List<VolSurfaceColumnSettings> _column_settings = new();
|
||||
|
||||
public static VolSurfaceMacroGridSettings Default =>
|
||||
new();
|
||||
|
||||
public IReadOnlyList<VolSurfaceColumnSettings> column_settings => _column_settings;
|
||||
|
||||
public void set_column(VolSurfaceColumnSettings column_settings) {
|
||||
var idx = _column_settings.FindIndex(c => c.core?.id == column_settings?.core?.id);
|
||||
if (idx >= 0) {
|
||||
_column_settings[idx] = column_settings;
|
||||
return;
|
||||
}
|
||||
_column_settings.Add(column_settings);
|
||||
}
|
||||
|
||||
public void set_columns(IEnumerable<VolSurfaceColumnSettings> column_settings) {
|
||||
foreach (var c in column_settings) {
|
||||
set_column(c);
|
||||
}
|
||||
}
|
||||
|
||||
public VolSurfaceColumnSettings get_column(string col_name) {
|
||||
if (col_name is null) {
|
||||
throw new ArgumentNullException(nameof(col_name));
|
||||
}
|
||||
|
||||
var lcol_name = col_name.ToLower();
|
||||
return _column_settings.FirstOrDefault(c => c.core?.id?.ToLower() == lcol_name);
|
||||
}
|
||||
|
||||
public VolSurfaceMacroGridSettings Clone() {
|
||||
var rv = new VolSurfaceMacroGridSettings();
|
||||
rv._column_settings.AddRange(_column_settings.clone_all());
|
||||
return rv;
|
||||
}
|
||||
|
||||
object ICloneable.Clone() =>
|
||||
Clone();
|
||||
}
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using mbts.analytics;
|
||||
using bts.api;
|
||||
using mbts.ui;
|
||||
|
||||
namespace mbts.spark {
|
||||
// Publishes theos for all options (on the side, also publishes the theos for TC2)
|
||||
public class LiveTheoPublisher : IDisposable {
|
||||
private ThreadedBlackboard _bb;
|
||||
private readonly ITag<IReadOnlyDictionary<string, OptionTheoInterpolationData>>
|
||||
_greeks_tag = SparkTags.AllInterpGreeks;
|
||||
private readonly ITag<IReadOnlyDictionary<string, OptionDriverPriceMap>>
|
||||
_drivers_tag = SparkTags.AllOptionDriverBBOTag;
|
||||
private readonly HighPerformanceTimer _timer = new HighPerformanceTimer();
|
||||
private readonly PerfStatsLogger _logger = new PerfStatsLogger(50, 100);
|
||||
private readonly string _log_id = "LiveTheoPublisher";
|
||||
|
||||
public LiveTheoPublisher(ThreadedBlackboard bb) {
|
||||
_bb = bb;
|
||||
_bb.subscribe(_greeks_tag);
|
||||
_bb.subscribe(_drivers_tag);
|
||||
_bb.data_callback += _on_data;
|
||||
_interp_and_publish();
|
||||
}
|
||||
|
||||
private void _on_data(object tag, object data) {
|
||||
if (tag.Equals(_drivers_tag) ||
|
||||
tag.Equals(_greeks_tag)) {
|
||||
_interp_and_publish();
|
||||
}
|
||||
}
|
||||
|
||||
private void _log_interpgreeks(
|
||||
IReadOnlyDictionary<string, OptionTheoInterpolationData> interp_greeks) {
|
||||
string log_msg = String.Empty;
|
||||
foreach (var kv in interp_greeks) {
|
||||
string symbol = kv.Key;
|
||||
var symbol_ig = kv.Value;
|
||||
if (symbol_ig == null) {
|
||||
continue;
|
||||
}
|
||||
var exps = symbol_ig.get_expirations();
|
||||
foreach (DateTime e in exps) {
|
||||
var e_data = symbol_ig.get_expiration_data(e);
|
||||
foreach (var e_kv in e_data) {
|
||||
double driver = e_kv.Key;
|
||||
foreach (var k_kv in e_kv.Value) {
|
||||
double k = k_kv.Key;
|
||||
TheoPoint tp = k_kv.Value;
|
||||
log_msg += "\n" + $"s: {symbol} e: {e} k: {k} d: {driver} " +
|
||||
$"c: {tp.call} p: {tp.put}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!String.IsNullOrEmpty(log_msg))
|
||||
bts.Log.Gen.info($"LiveTheoPublisher state: {log_msg}");
|
||||
}
|
||||
|
||||
private void _log_theos(SystemContractData sc_data,
|
||||
IReadOnlyDictionary<uint, GreeksTuple> greeks_map,
|
||||
DateTime? exp_filt = null) {
|
||||
string rv = "LiveTheosPublisher data: ";
|
||||
foreach (var kv in greeks_map) {
|
||||
var id = kv.Key;
|
||||
var g_tup = kv.Value;
|
||||
if (sc_data.sec_md_map.TryGetValue(id, out var smd)) {
|
||||
if (exp_filt == null ||
|
||||
(smd.security.security_type() == SecurityType.Option &&
|
||||
smd.security.Option.expiration_date().Equals(exp_filt.Value))) {
|
||||
string sec_str = smd.ToString();
|
||||
rv += "\n" + $"id: {id} sec: {sec_str} greeks: {g_tup}";
|
||||
}
|
||||
}
|
||||
}
|
||||
bts.Log.Gen.info(rv);
|
||||
}
|
||||
|
||||
private static DriverMD _get_option_driver(
|
||||
IReadOnlyDictionary<string, OptionDriverPriceMap> driver_map,
|
||||
SecurityStrike k) {
|
||||
if (driver_map.TryGetValue(k.expiration.symbol, out var exp_map) &&
|
||||
exp_map != null)
|
||||
return exp_map.get_driver_md(k.expiration);
|
||||
return DriverMD.empty;
|
||||
}
|
||||
private static TheoPoint _interp_theo(
|
||||
IReadOnlyDictionary<string, OptionTheoInterpolationData> interp_greeks_map,
|
||||
SecurityStrike k, double driver_price) {
|
||||
if (interp_greeks_map.TryGetValue(k.expiration.symbol, out var interp_greeks) &&
|
||||
interp_greeks != null)
|
||||
return interp_greeks.interpolate_theos(k.expiration.expiration, k.strike,
|
||||
driver_price);
|
||||
return TheoPoint.getNulledObject();
|
||||
}
|
||||
|
||||
private void _publish_tc2_theos(IDictionary<SecurityStrike, TheoPoint> theos) {
|
||||
var rv = new Dictionary<string, ExpStrikeKeyedData<TheoPoint>>();
|
||||
foreach (var kv in theos) {
|
||||
SecurityStrike k = kv.Key;
|
||||
TheoPoint tp = kv.Value;
|
||||
ExpStrikeKeyedData<TheoPoint> sym_theos = null;
|
||||
if (!rv.TryGetValue(k.expiration.symbol, out sym_theos)) {
|
||||
sym_theos = new ExpStrikeKeyedData<TheoPoint>();
|
||||
rv.Add(k.expiration.symbol, sym_theos);
|
||||
}
|
||||
sym_theos.set_data(k, tp);
|
||||
}
|
||||
foreach (var kv in rv) {
|
||||
_bb.post(SparkTags.TC2Tags.LiveTheosTag(kv.Key), kv.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void _interp_and_publish() {
|
||||
_timer.start();
|
||||
var res = new Dictionary<uint, GreeksTuple>();
|
||||
IReadOnlyDictionary<string, OptionDriverPriceMap> driver_map =
|
||||
_bb.read_state(_drivers_tag);
|
||||
IReadOnlyDictionary<string, OptionTheoInterpolationData> interp_greeks =
|
||||
_bb.read_state(SparkTags.AllInterpGreeks);
|
||||
SystemContractData sc_data = _bb.read_state(SparkTags.SystemContractsTag);
|
||||
if (driver_map == null || interp_greeks == null || sc_data == null) {
|
||||
return;
|
||||
}
|
||||
var k_theos = new Dictionary<SecurityStrike, TheoPoint>();
|
||||
foreach (var kv in sc_data.strike_map) {
|
||||
foreach (SecurityStrike k in kv.Value) {
|
||||
var cp_id = k.call_put_id;
|
||||
var driver = _get_option_driver(driver_map, k);
|
||||
var tp = _interp_theo(interp_greeks, k, driver.get_driver());
|
||||
k_theos[k] = tp;
|
||||
// put it in the output map
|
||||
if (cp_id.Item1.HasValue) {
|
||||
res.Add(cp_id.Item1.Value,
|
||||
new GreeksTuple(tp.vol, tp.driver, tp.call, tp.cdelta, tp.cgamma,
|
||||
tp.cvega, tp.c_theta, Double.NaN));
|
||||
}
|
||||
if (cp_id.Item2.HasValue) {
|
||||
res.Add(cp_id.Item2.Value,
|
||||
new GreeksTuple(tp.vol, tp.driver, tp.put, tp.pdelta, tp.pgamma,
|
||||
tp.pvega, tp.p_theta, Double.NaN));
|
||||
}
|
||||
}
|
||||
}
|
||||
IReadOnlyDictionary<uint, GreeksTuple> res_ro = res;
|
||||
bts.Log.Gen.info($"LiveTheoPublisher._interp_and_publish posting " +
|
||||
$"count: {res_ro.Count}");
|
||||
_timer.stop();
|
||||
_logger.log(_log_id, _log_id, _timer.lastIntervalTime);
|
||||
_bb.post(SparkTags.Greeks, res_ro);
|
||||
_publish_tc2_theos(k_theos);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
_bb.data_callback -= _on_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using bts.api;
|
||||
|
||||
using mbts.analytics;
|
||||
|
||||
|
||||
namespace mbts.spark {
|
||||
// Conveniant wrapper with some functions added
|
||||
// around map of AnalyticsExpirationParameters
|
||||
public class AnalyticsExpirationParametersMap {
|
||||
public readonly
|
||||
IReadOnlyDictionary<mbts.SecurityExpiration, AnalyticsExpirationParameters> exp_map;
|
||||
public AnalyticsExpirationParametersMap(
|
||||
IDictionary<SecurityExpiration, AnalyticsExpirationParameters> exp_map_arg,
|
||||
SystemContractData sc_data) {
|
||||
var empty = SecurityExpiration.empty;
|
||||
var temp = new Dictionary<SecurityExpiration,
|
||||
AnalyticsExpirationParameters>(exp_map_arg);
|
||||
foreach (var kv in sc_data.exp_map) {
|
||||
var exp = kv.Key;
|
||||
if (!temp.ContainsKey(kv.Key)) {
|
||||
temp.Add(kv.Key,
|
||||
new AnalyticsExpirationParameters(exp, empty, empty, empty, 0, 0, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
exp_map = temp;
|
||||
}
|
||||
|
||||
public IEnumerable<mbts.SecurityExpiration> get_sorted_exps() {
|
||||
List<SecurityExpiration> sorted_exps = new List<SecurityExpiration>(exp_map.Keys);
|
||||
sorted_exps.Sort((e1, e2) => {
|
||||
int rv = e1.expiration.CompareTo(e2.expiration);
|
||||
if (rv == 0)
|
||||
rv = e1.symbol.CompareTo(e2.symbol);
|
||||
if (rv == 0)
|
||||
rv = e1.security_type.ToString().CompareTo(e2.security_type.ToString());
|
||||
return rv;
|
||||
});
|
||||
return sorted_exps;
|
||||
}
|
||||
|
||||
public AnalyticsExpirationParameters get_parameter(mbts.SecurityExpiration sec_expiration) {
|
||||
mbts.analytics.AnalyticsExpirationParameters rv = null;
|
||||
return exp_map.TryGetValue(sec_expiration, out rv) ? rv : null;
|
||||
}
|
||||
|
||||
/// Ignores the exchange and gets the first match
|
||||
public AnalyticsExpirationParameters get_option_parameter(string symbol, DateTime exp) {
|
||||
var rv = exp_map.Where(i => i.Key.security_type == SecurityType.Option &&
|
||||
i.Key.symbol == symbol && i.Key.expiration == exp);
|
||||
return rv != null && rv.Count() == 1 ?
|
||||
rv.ElementAt(0).Value : mbts.analytics.AnalyticsExpirationParameters.empty;
|
||||
}
|
||||
|
||||
public IEnumerable<mbts.SecurityExpiration> get_futures() {
|
||||
return exp_map.Keys.Where(i => i.security_type == SecurityType.Future);
|
||||
}
|
||||
|
||||
/// Ignores the exchange
|
||||
// public IDictionary<DateTime, AnalyticsExpirationParameters> get_future_map(string future_name) {
|
||||
// return exp_map.ToList().Where(
|
||||
// kv => kv.Key.security_type == SecurityType.Future &&
|
||||
// kv.Key.symbol == future_name).ToDictionary(kv => kv.Key.expiration, kv => kv.Value);
|
||||
// }
|
||||
|
||||
/// Ignores the exchange
|
||||
// public IDictionary<mbts.SecurityExpiration, AnalyticsExpirationParameters>
|
||||
// get_symbol_params(SecurityType sec_type, string symbol) {
|
||||
// return exp_map.ToList().Where(kv => kv.Key.security_type == sec_type &&
|
||||
// kv.Key.symbol == symbol).ToDictionaryDupes(kv => kv.Key, kv => kv.Value);
|
||||
// }
|
||||
|
||||
// public IEnumerable<mbts.SecurityExpiration> get_stocks() {
|
||||
// return exp_map.Keys.Where(i => i.security_type == SecurityType.Stock);
|
||||
// }
|
||||
|
||||
// public IDictionary<DateTime, double> get_option_rolls(string option_name) {
|
||||
// IDictionary<DateTime, double> rv = new Dictionary<DateTime, double>();
|
||||
// var list = exp_map.Where(kv => kv.Key.security_type == SecurityType.Option &&
|
||||
// kv.Key.symbol == option_name);
|
||||
// foreach (var kv in list)
|
||||
// rv[kv.Key.expiration] = kv.Value.roll_target;
|
||||
// return rv;
|
||||
// }
|
||||
|
||||
// Returns a driver to expiration it drives
|
||||
public IDictionary<mbts.SecurityExpiration, IEnumerable<mbts.SecurityExpiration>>
|
||||
get_option_driver_map() {
|
||||
var rv = new Dictionary<mbts.SecurityExpiration, HashSet<mbts.SecurityExpiration>>();
|
||||
foreach (var kv in exp_map.Where(kv_arg => kv_arg.Key.security_type == SecurityType.Option)) {
|
||||
mbts.SecurityExpiration sec = kv.Key, driver_sec = kv.Value.driver_security;
|
||||
HashSet<mbts.SecurityExpiration> driven_by_this_driver;
|
||||
if (!rv.TryGetValue(driver_sec, out driven_by_this_driver))
|
||||
rv[driver_sec] = driven_by_this_driver = new HashSet<mbts.SecurityExpiration>();
|
||||
driven_by_this_driver.Add(sec);
|
||||
}
|
||||
return rv.ToDictionary(kv => kv.Key, kv => kv.Value as IEnumerable<mbts.SecurityExpiration>);
|
||||
}
|
||||
|
||||
public IDictionary<mbts.SecurityExpiration, mbts.SecurityExpiration>
|
||||
get_option_to_driver_map(string option_name) {
|
||||
var filt = exp_map.Where(kv => kv.Key.security_type == SecurityType.Option &&
|
||||
kv.Key.symbol == option_name);
|
||||
return filt.ToDictionary(kv => kv.Key, kv => kv.Value.driver_security);
|
||||
}
|
||||
|
||||
// public IList<Tuple<mbts.SecurityExpiration, mbts.SecurityExpiration, double>>
|
||||
// get_expiring_expirations(DateTime expiration_date) {
|
||||
// var rv = new List<Tuple<mbts.SecurityExpiration, mbts.SecurityExpiration, double>>();
|
||||
// foreach (var kv in exp_map.Where(kv_arg => kv_arg.Key.expiration == expiration_date.Date &&
|
||||
// kv_arg.Value.deliverable_security != mbts.SecurityExpiration.empty)) {
|
||||
// mbts.SecurityExpiration sec = kv.Key;
|
||||
// mbts.SecurityExpiration deliverable = kv.Value.deliverable_security;
|
||||
// rv.Add(Tuple.Create(sec, deliverable, kv.Value.settlement_price));
|
||||
// }
|
||||
// return rv;
|
||||
// }
|
||||
|
||||
// public IList<Tuple<mbts.SecurityExpiration, mbts.SecurityExpiration, double>>
|
||||
// get_expiring_expirations() {
|
||||
// return get_expiring_expirations(DateTime.Now);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using mbts.spark;
|
||||
|
||||
namespace mbts.ui {
|
||||
/// <summary>
|
||||
/// just a conveniant way to store exp,K based data
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class ExpStrikeKeyedData<T> {
|
||||
public delegate T CreateT(DateTime exp, double strike);
|
||||
|
||||
private IDictionary<DateTime, IDictionary<double, T>> _map = new Dictionary<DateTime, IDictionary<double, T>>();
|
||||
|
||||
public ExpStrikeKeyedData() { }
|
||||
|
||||
public ExpStrikeKeyedData(ExpStrikeKeyedData<T> data) {
|
||||
foreach (KeyValuePair<DateTime, IDictionary<double, T>> p in data._map)
|
||||
_map[p.Key] = new Dictionary<double, T>(p.Value);
|
||||
}
|
||||
|
||||
public ExpStrikeKeyedData(ICollection<Pair<DateTime, double>> exp_strikes, CreateT del) {
|
||||
foreach (Pair<DateTime, double> p in exp_strikes)
|
||||
set_data(p.first, p.second, del(p.first, p.second));
|
||||
}
|
||||
|
||||
#region Mutators
|
||||
public void set_data(SecurityStrike k, T t) {
|
||||
set_data(k.expiration.expiration, k.strike, t);
|
||||
}
|
||||
public void set_data(DateTime exp, double strike, T t) {
|
||||
IDictionary<double, T> strike_vs_t_map = null;
|
||||
if (!_map.TryGetValue(exp, out strike_vs_t_map)) {
|
||||
strike_vs_t_map = new Dictionary<double, T>();
|
||||
_map.Add(exp, strike_vs_t_map);
|
||||
}
|
||||
strike_vs_t_map[strike] = t;
|
||||
}
|
||||
|
||||
public void set_data_for_expiration(DateTime expiration, IDictionary<double, T> strike_data) {
|
||||
_map[expiration] = strike_data;
|
||||
}
|
||||
|
||||
public void clear() { _map.Clear(); }
|
||||
|
||||
public bool delete_data(DateTime exp, double strike) {
|
||||
IDictionary<double, T> strike_vs_t_map = null;
|
||||
if (_map.TryGetValue(exp, out strike_vs_t_map))
|
||||
return strike_vs_t_map.Remove(strike);
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
public T get_data(DateTime exp, double strike) {
|
||||
IDictionary<double, T> strike_vs_t_map = null;
|
||||
if (_map.TryGetValue(exp, out strike_vs_t_map)) {
|
||||
T rv;
|
||||
if (strike_vs_t_map.TryGetValue(strike, out rv))
|
||||
return rv;
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public bool contains(DateTime exp, double strike) {
|
||||
IDictionary<double, T> strike_vs_t_map = null;
|
||||
return _map.TryGetValue(exp, out strike_vs_t_map) && strike_vs_t_map.ContainsKey(strike);
|
||||
}
|
||||
|
||||
public List<double> get_strike_list_for_expiration(DateTime expiration) {
|
||||
List<double> rv = new List<double>();
|
||||
IDictionary<double, T> exp_map = null;
|
||||
if (_map.TryGetValue(expiration, out exp_map))
|
||||
rv = new List<double>(exp_map.Keys);
|
||||
return rv;
|
||||
}
|
||||
|
||||
public T get_random_data_for_exp(DateTime option_expiration) {
|
||||
IDictionary<double, T> exp_data = null;
|
||||
if (_map.TryGetValue(option_expiration, out exp_data))
|
||||
foreach (T t in exp_data.Values)
|
||||
return t;
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public DateTime[] get_expirations() {
|
||||
return new List<DateTime>(_map.Keys).ToArray();
|
||||
}
|
||||
|
||||
public double[] get_strikes() {
|
||||
Dictionary<double, bool> strikes = new Dictionary<double, bool>();
|
||||
foreach (Pair<DateTime, double> p in get_expstrike_pairs())
|
||||
if (!strikes.ContainsKey(p.second))
|
||||
strikes.Add(p.second, true);
|
||||
double[] rv = new double[strikes.Count];
|
||||
strikes.Keys.CopyTo(rv, 0);
|
||||
return rv;
|
||||
}
|
||||
|
||||
public ICollection<Pair<DateTime, double>> get_expstrike_pairs() {
|
||||
List<Pair<DateTime, double>> rv = new List<Pair<DateTime, double>>();
|
||||
foreach (KeyValuePair<DateTime, IDictionary<double, T>> kv1 in _map) {
|
||||
DateTime exp = kv1.Key;
|
||||
foreach (KeyValuePair<double, T> kv2 in kv1.Value)
|
||||
rv.Add(new Pair<DateTime, double>(exp, kv2.Key));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
private ICollection<Tuple<DateTime, double, T>> _get_data_linearly() {
|
||||
List<Tuple<DateTime, double, T>> rv = new List<Tuple<DateTime, double, T>>();
|
||||
foreach (KeyValuePair<DateTime, IDictionary<double, T>> kv1 in _map) {
|
||||
DateTime exp = kv1.Key;
|
||||
foreach (KeyValuePair<double, T> kv2 in kv1.Value)
|
||||
rv.Add(new Tuple<DateTime, double, T>(exp, kv2.Key, kv2.Value));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
public ICollection<Triplet<DateTime, double, T>> get_data_linearly() {
|
||||
var rv = _get_data_linearly();
|
||||
return rv.Select(i => new Triplet<DateTime, double, T>(i)).ToList();
|
||||
}
|
||||
|
||||
public ExpStrikeKeyedData<T> clone_filtered_set(HashSet<DateTime> filtered_expirations, bool is_exp_inclusive,
|
||||
HashSet<double> filtered_strikes, bool is_strike_inclusive) {
|
||||
ExpStrikeKeyedData<T> rv = new ExpStrikeKeyedData<T>();
|
||||
foreach (KeyValuePair<DateTime, IDictionary<double, T>> ep in _map)
|
||||
if ((is_exp_inclusive && filtered_expirations.Contains(ep.Key)) || (!is_exp_inclusive && !filtered_expirations.Contains(ep.Key)))
|
||||
foreach (KeyValuePair<double, T> kp in ep.Value)
|
||||
if ((is_strike_inclusive && filtered_strikes.Contains(kp.Key)) || (!is_strike_inclusive && !filtered_strikes.Contains(kp.Key)))
|
||||
rv.set_data(ep.Key, kp.Key, kp.Value);
|
||||
return rv;
|
||||
}
|
||||
|
||||
public IDictionary<double, T> get_data_for_single_exp(DateTime exp) {
|
||||
IDictionary<double, T> rv = null;
|
||||
_map.TryGetValue(exp, out rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<DateTime, IReadOnlyDictionary<double, T>> get_full_data() {
|
||||
IDictionary<DateTime, IReadOnlyDictionary<double, T>> rv = _map.ToDictionary(kv => kv.Key, kv => (IReadOnlyDictionary<double, T>)kv.Value);
|
||||
return (IReadOnlyDictionary<DateTime, IReadOnlyDictionary<double, T>>)rv;
|
||||
}
|
||||
|
||||
public int count {
|
||||
get {
|
||||
int count = 0;
|
||||
foreach (Dictionary<double, T> exp_map in _map.Values)
|
||||
count += exp_map.Count;
|
||||
return count;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace mbts.spark
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a timer, much more accurate than using timers based on System.DateTime. It does not accumulate time, as the
|
||||
/// stress was on small time intervals.
|
||||
/// </summary>
|
||||
public class HighPerformanceTimer
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
public extern static short QueryPerformanceCounter(ref long x);
|
||||
[DllImport("kernel32.dll")]
|
||||
public extern static short QueryPerformanceFrequency(ref long x);
|
||||
|
||||
private long myStartCount = 0, myEndCount = 0, myFreq = 0, myTotalCount = 0;
|
||||
private long myZeroTime;
|
||||
/// <summary>
|
||||
/// This a static instance that can be shared across a running process.
|
||||
/// The only member function that is thread-safe right now
|
||||
/// is 'runningMilliseconds'
|
||||
/// </summary>
|
||||
public readonly static HighPerformanceTimer sharedTimer = new HighPerformanceTimer ();
|
||||
|
||||
|
||||
public HighPerformanceTimer()
|
||||
{
|
||||
QueryPerformanceFrequency(ref myFreq);
|
||||
if (myFreq == 0)
|
||||
throw new ApplicationException ("High resolution timers not supported by this machine's hardware");
|
||||
QueryPerformanceCounter(ref myZeroTime);
|
||||
}
|
||||
/// <summary>
|
||||
/// starts measuring the time
|
||||
/// </summary>
|
||||
public void start()
|
||||
{
|
||||
QueryPerformanceCounter (ref myStartCount);
|
||||
}
|
||||
|
||||
public double runningMilliseconds()
|
||||
{
|
||||
double rv = 0;
|
||||
lock (this)
|
||||
{
|
||||
long t = 0;
|
||||
QueryPerformanceCounter (ref t);
|
||||
rv = (t - myZeroTime) * 1000.0 / myFreq;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
public double toMilliseconds(long count)
|
||||
{
|
||||
lock (this)
|
||||
return count * 1000.0 / myFreq;
|
||||
}
|
||||
public double getRunningMilliseconds (long count)
|
||||
{
|
||||
double rv = 0;
|
||||
lock (this)
|
||||
{
|
||||
rv = (count - myZeroTime) * 1000.0 / myFreq;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
public long nowCount
|
||||
{
|
||||
get
|
||||
{
|
||||
long t = 0;
|
||||
QueryPerformanceCounter (ref t);
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stops recording time
|
||||
/// </summary>
|
||||
public void stop()
|
||||
{
|
||||
QueryPerformanceCounter (ref myEndCount);
|
||||
myTotalCount += myEndCount - myStartCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// total milliseconds, ie aggregated time of all intervals
|
||||
/// </summary>
|
||||
public double totalMilliseconds {get{return myTotalCount * 1000.0 / myFreq ; }}
|
||||
|
||||
public double getMilliseconds (long count)
|
||||
{
|
||||
return count * 1000.0 / myFreq;
|
||||
}
|
||||
|
||||
public long ticks {get{return myEndCount - myStartCount;}}
|
||||
|
||||
/// <summary>
|
||||
/// time between the last start-stop
|
||||
/// </summary>
|
||||
public double lastIntervalTime {get{return (myEndCount - myStartCount) * 1000.0 / myFreq ; }}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the running time
|
||||
/// </summary>
|
||||
public void reset ()
|
||||
{
|
||||
QueryPerformanceCounter(ref myZeroTime);
|
||||
myTotalCount = 0;
|
||||
}
|
||||
|
||||
public long freq
|
||||
{
|
||||
get { return myFreq; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using mbts.analytics;
|
||||
|
||||
namespace mbts.spark
|
||||
{
|
||||
public interface IVolSurfaceBroker
|
||||
{
|
||||
int get_new_volsurface_id();
|
||||
void save_volsurface(int volsurface_id, string volsurface_name, byte[] data, string save_marker = null);
|
||||
void delete_volsurface(int volsurface_id);
|
||||
/// Cleans up all the vol surfaces, leeping the
|
||||
/// last active_list_size around
|
||||
void clean_up(int active_list_size);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
namespace mbts.spark {
|
||||
public enum MessageDisplayType { Info, Warn, Error }
|
||||
|
||||
public class MessageDisplayData {
|
||||
public MessageDisplayData(string caption, string message)
|
||||
: this(caption, message, true) { }
|
||||
|
||||
public MessageDisplayData(string caption, string message, bool move_to_mouse)
|
||||
: this(caption, message, MessageDisplayType.Info, move_to_mouse) { }
|
||||
|
||||
public MessageDisplayData(string caption, string message, MessageDisplayType type, bool move_to_mouse) {
|
||||
this.caption = caption;
|
||||
this.message = message;
|
||||
this.type = type;
|
||||
this.move_to_mouse = move_to_mouse;
|
||||
}
|
||||
public readonly string message, caption;
|
||||
public readonly MessageDisplayType type;
|
||||
public readonly bool move_to_mouse;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using mbts.analytics;
|
||||
using bts.api;
|
||||
using bts.api.persistence;
|
||||
using System.Linq;
|
||||
|
||||
namespace mbts.spark {
|
||||
// All driver prices (along with some more info) for an option symbol
|
||||
public class OptionDriverPriceMap {
|
||||
public readonly String option_symbol = null;
|
||||
public readonly IDictionary<SecurityExpiration, DriverMD> exp_price_map = null;
|
||||
public OptionDriverPriceMap(
|
||||
string option_symbol_a,
|
||||
IDictionary<SecurityExpiration, DriverMD> exp_price_map_a) {
|
||||
option_symbol = option_symbol_a;
|
||||
exp_price_map = exp_price_map_a;
|
||||
}
|
||||
public IDictionary<SecurityExpiration, DriverMD> unexpired_exp_price_map {
|
||||
get {
|
||||
return exp_price_map.Where(
|
||||
kv => kv.Key.expiration >= DateTime.Now.Date).ToDictionary(
|
||||
kv => kv.Key, kv => kv.Value);
|
||||
}
|
||||
}
|
||||
// this is the BS needed because of ignoring exchange
|
||||
public DriverMD get_driver_md(DateTime exp) {
|
||||
foreach (var kv in exp_price_map) {
|
||||
if (kv.Key.expiration == exp) {
|
||||
return kv.Value;
|
||||
}
|
||||
}
|
||||
return DriverMD.empty;
|
||||
}
|
||||
public DriverMD get_driver_md(SecurityExpiration exp) {
|
||||
if (exp_price_map.TryGetValue(exp, out var d))
|
||||
return d;
|
||||
return DriverMD.empty;
|
||||
}
|
||||
|
||||
public static IDictionary<VolSurfaceExpiration, DriverMD> get_vs_price_map(
|
||||
IReadOnlyDictionary<string, OptionDriverPriceMap> all_sym_map,
|
||||
Func<string, bool> sym_filter = null) {
|
||||
var rv = new Dictionary<VolSurfaceExpiration, DriverMD>();
|
||||
if (all_sym_map != null)
|
||||
foreach (var kv in all_sym_map) {
|
||||
string sym = kv.Key;
|
||||
OptionDriverPriceMap sym_map = kv.Value;
|
||||
if (sym_filter == null || sym_filter(sym)) {
|
||||
foreach (var kv_int in sym_map.exp_price_map) {
|
||||
rv[new VolSurfaceExpiration(kv_int.Key)] = kv_int.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace mbts.spark {
|
||||
|
||||
// A conveniant way to hold precomputed theo values
|
||||
// indexed by option_expiration->driver_price->option_strike->TheoPoint
|
||||
public class OptionTheoInterpolationData {
|
||||
public readonly string symbol;
|
||||
private IDictionary<DateTime, Dictionary<double, Dictionary<double, TheoPoint>>> _map =
|
||||
new Dictionary<DateTime, Dictionary<double, Dictionary<double, TheoPoint>>>();
|
||||
private IDictionary<DateTime, double> _zero_move_driver_map = new Dictionary<DateTime, double>();
|
||||
|
||||
public OptionTheoInterpolationData(string symbol) { this.symbol = symbol; }
|
||||
|
||||
public void set_data(DateTime option_expiration, double driver_price,
|
||||
double move, double option_strike, TheoPoint theo_point) {
|
||||
Dictionary<double, Dictionary<double, TheoPoint>> driver_map = null;
|
||||
if (!_map.TryGetValue(option_expiration, out driver_map))
|
||||
_map.Add(option_expiration, driver_map = new Dictionary<double, Dictionary<double, TheoPoint>>());
|
||||
Dictionary<double, TheoPoint> strike_map = null;
|
||||
if (!driver_map.TryGetValue(driver_price, out strike_map))
|
||||
driver_map.Add(driver_price, strike_map = new Dictionary<double, TheoPoint>());
|
||||
strike_map[option_strike] = theo_point;
|
||||
if (move == 0)
|
||||
_zero_move_driver_map[option_expiration] = driver_price;
|
||||
}
|
||||
|
||||
/// Returns NULL if data is not present (should it return a nulled out TheoPoint ?)
|
||||
public TheoPoint get_data(DateTime option_expiration, double driver_price, double option_strike) {
|
||||
Dictionary<double, Dictionary<double, TheoPoint>> driver_map = null;
|
||||
Dictionary<double, TheoPoint> strike_map = null;
|
||||
TheoPoint rv = null;
|
||||
if (_map.TryGetValue(option_expiration, out driver_map))
|
||||
if (driver_map.TryGetValue(driver_price, out strike_map))
|
||||
if (strike_map.TryGetValue(option_strike, out rv))
|
||||
return rv;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Dictionary<double, Dictionary<double, TheoPoint>> get_expiration_data(
|
||||
DateTime option_expiration) {
|
||||
Dictionary<double, Dictionary<double, TheoPoint>> rv = null;
|
||||
_map.TryGetValue(option_expiration, out rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
public List<double> get_sorted_driverprices_for_expiration(DateTime option_expiration) {
|
||||
List<double> rv = new List<double>();
|
||||
Dictionary<double, Dictionary<double, TheoPoint>> driver_map = null;
|
||||
if (_map.TryGetValue(option_expiration, out driver_map)) {
|
||||
rv = new List<double>(driver_map.Keys);
|
||||
rv.Sort();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
public IEnumerable<DateTime> get_expirations() { return _map.Keys; }
|
||||
|
||||
public bool contains_expiration(DateTime exp) {
|
||||
Dictionary<double, Dictionary<double, TheoPoint>> price_map = null;
|
||||
return _map.TryGetValue(exp, out price_map) && price_map != null && price_map.Count > 0;
|
||||
}
|
||||
|
||||
public IDictionary<DateTime, HashSet<double>> get_contracts() {
|
||||
Dictionary<DateTime, HashSet<double>> rv = new Dictionary<DateTime, HashSet<double>>();
|
||||
foreach (KeyValuePair<DateTime, Dictionary<double, Dictionary<double, TheoPoint>>> exp_p in _map) {
|
||||
HashSet<double> strike_map = new HashSet<double>();
|
||||
foreach (KeyValuePair<double, Dictionary<double, TheoPoint>> driver_p in exp_p.Value)
|
||||
strike_map.AddRange(driver_p.Value.Keys);
|
||||
rv.Add(exp_p.Key, strike_map);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
public int get_n_exps() { return _map.Count; }
|
||||
|
||||
public double get_zero_move_driver(DateTime option_exp) {
|
||||
double rv = _zero_move_driver_map.TryGetValue(option_exp, out rv) ? rv : Double.NaN;
|
||||
return rv;
|
||||
}
|
||||
|
||||
#region Interpoaltion
|
||||
|
||||
public TheoPoint interpolate_theos(DateTime option_expiration,
|
||||
double option_strike,
|
||||
double driver_price) {
|
||||
Tuple<double, double> neighbor_driver_points =
|
||||
_find_neighboring_drivers(this, option_expiration, driver_price);
|
||||
return _interpolate_theos(this, driver_price,
|
||||
neighbor_driver_points, option_expiration, option_strike);
|
||||
}
|
||||
|
||||
private static Tuple<double, double> _find_neighboring_drivers(
|
||||
OptionTheoInterpolationData interp_data, DateTime option_expiration, double driver_price) {
|
||||
if (interp_data != null) {
|
||||
List<double> sorted_drivers =
|
||||
interp_data.get_sorted_driverprices_for_expiration(option_expiration);
|
||||
for (int i = 0; i < sorted_drivers.Count - 1; i++)
|
||||
if (driver_price >= sorted_drivers[i] && driver_price <= sorted_drivers[i + 1])
|
||||
return new Tuple<double, double>(sorted_drivers[i], sorted_drivers[i + 1]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static TheoPoint _interpolate_theos(OptionTheoInterpolationData interp_data,
|
||||
double driver_price, Tuple<double, double> neighbors,
|
||||
DateTime option_expiration,
|
||||
double option_strike) {
|
||||
TheoPoint rv = TheoPoint.getNulledObject();
|
||||
rv.driver = driver_price;
|
||||
if (interp_data != null && neighbors != null) {
|
||||
TheoPoint p1 = interp_data.get_data(option_expiration, neighbors.Item1, option_strike),
|
||||
p2 = interp_data.get_data(option_expiration, neighbors.Item2, option_strike);
|
||||
|
||||
if (p1 != null && p2 != null)
|
||||
TheoPoint.interp(TheoPoint.InterpolationMethod.TAYLOR,
|
||||
p1, p2, driver_price, rv, option_expiration, option_strike);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
using ProtoBuf;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mbts.spark {
|
||||
// TODO move it out or replace it with Tuple
|
||||
[Serializable]
|
||||
public class Pair<F, S> {
|
||||
public F first;
|
||||
public S second;
|
||||
|
||||
public Pair() { }
|
||||
public Pair(F f, S s) {
|
||||
first = f;
|
||||
second = s;
|
||||
}
|
||||
|
||||
public Pair(KeyValuePair<F, S> kvp)
|
||||
: this(kvp.Key, kvp.Value) { }
|
||||
|
||||
public override string ToString() {
|
||||
return String.Format("{0},{1}", first != null ? first.ToString() : "NULL",
|
||||
second != null ? second.ToString() : "NULL");
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
return ToString().GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj) {
|
||||
return obj != null && obj is Pair<F, S> && ToString() == obj.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class Triplet<F, S, T> {
|
||||
public F first;
|
||||
public S second;
|
||||
public T third;
|
||||
|
||||
public Triplet() { }
|
||||
|
||||
public Triplet(Tuple<F, S, T> tp) {
|
||||
first = tp.Item1;
|
||||
second = tp.Item2;
|
||||
third = tp.Item3;
|
||||
}
|
||||
|
||||
public Triplet(F f, S s, T t) {
|
||||
first = f;
|
||||
second = s;
|
||||
third = t;
|
||||
}
|
||||
|
||||
public static Triplet<F, S, T> from_tuple(Tuple<F, S, T> t) { return new Triplet<F, S, T>(t.Item1, t.Item2, t.Item3); }
|
||||
|
||||
public override string ToString() {
|
||||
return String.Format("{0},{1},{2}", first != null ? first.ToString() : "NULL",
|
||||
second != null ? second.ToString() : "NULL",
|
||||
third != null ? third.ToString() : "NULL");
|
||||
}
|
||||
|
||||
public override bool Equals(object obj) {
|
||||
return obj != null && obj is Triplet<F, S, T> && ToString() == obj.ToString();
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
return ToString().GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Text;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using bts;
|
||||
|
||||
namespace mbts.spark {
|
||||
public class PerfStatsLogger {
|
||||
private class Entry {
|
||||
public uint tot_count = 0;
|
||||
public List<double> logs = new List<double>();
|
||||
}
|
||||
private Dictionary<string, Entry> _entry_map =
|
||||
new Dictionary<string, Entry>();
|
||||
private readonly int _log_period_updates, _max_size;
|
||||
private DateTime _last_write_time = DateTime.Now;
|
||||
private readonly string _default_id = String.Empty;
|
||||
private readonly HighPerformanceTimer _defaut_timer = new HighPerformanceTimer();
|
||||
|
||||
|
||||
public PerfStatsLogger() : this(100, 200) { }
|
||||
|
||||
/// <summary>
|
||||
/// log_period_updates tells how often are the stats logged
|
||||
/// max_size is the max size of the sample before it is cleaned out
|
||||
/// </summary>
|
||||
/// <param name="log_period_updates"></param>
|
||||
/// <param name="max_size"></param>
|
||||
public PerfStatsLogger(int log_period_updates, int max_size, string default_id = "") {
|
||||
_log_period_updates = log_period_updates;
|
||||
_max_size = max_size;
|
||||
_default_id = default_id;
|
||||
}
|
||||
|
||||
public void start_default_timer() {
|
||||
_defaut_timer.start();
|
||||
}
|
||||
|
||||
public void stop_default_timer() {
|
||||
if (String.IsNullOrEmpty(_default_id))
|
||||
return;
|
||||
_defaut_timer.stop();
|
||||
log(_default_id, _default_id, _defaut_timer.lastIntervalTime);
|
||||
}
|
||||
|
||||
public void log_default(double time) {
|
||||
log(_default_id, _default_id, time);
|
||||
}
|
||||
|
||||
public void log(string id, string msg, double time) {
|
||||
Entry entry = null;
|
||||
if (!_entry_map.TryGetValue(id, out entry))
|
||||
_entry_map.Add(id, entry = new Entry());
|
||||
List<double> logs = entry.logs;
|
||||
logs.Add(time);
|
||||
entry.tot_count++;
|
||||
if (logs.Count > 0 && logs.Count % _log_period_updates == 0) {
|
||||
TimeSpan period = DateTime.Now - _last_write_time;
|
||||
_last_write_time = DateTime.Now;
|
||||
logs.Sort();
|
||||
double sum = 0;
|
||||
logs.ForEach(d => sum += d);
|
||||
Log.Gen.info(String.Format("Perf: {0} sample_size: {1} min: {2:0.00} max: {3:0.00} " +
|
||||
"mean: {4:0.00} median: {5:0.00} upate_period: {6:0.00} " +
|
||||
"updates_per_sec: {7:0.00} tot_count: {8}", msg, logs.Count,
|
||||
logs[0], logs[logs.Count - 1], sum / logs.Count,
|
||||
logs[logs.Count / 2],
|
||||
period.TotalMilliseconds,
|
||||
1000.0 * logs.Count / period.TotalMilliseconds,
|
||||
entry.tot_count));
|
||||
logs.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace mbts.spark
|
||||
{
|
||||
public class SymbolResourceAllocationUnit
|
||||
{
|
||||
public readonly IEnumerable<mbts.SecurityTuple> sectups;
|
||||
public readonly object user_id;
|
||||
public readonly bool is_activate;
|
||||
|
||||
public SymbolResourceAllocationUnit(IEnumerable<mbts.SecurityTuple> this_sectups,
|
||||
object this_user_id,
|
||||
bool this_is_activate)
|
||||
{
|
||||
sectups = this_sectups;
|
||||
user_id = this_user_id;
|
||||
is_activate = this_is_activate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,247 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using bts.api;
|
||||
using bts.utils;
|
||||
|
||||
using mbts.analytics;
|
||||
using mbts.co2;
|
||||
|
||||
namespace mbts.spark {
|
||||
// Data structure for securities stored in the system
|
||||
// (These dont have to be exchange securities).
|
||||
public class SystemContractData {
|
||||
internal readonly IReadOnlyDictionary<UInt32, SecurityMD> sec_md_map;
|
||||
public readonly HashSet<SecurityTuple> sectup_map = new HashSet<SecurityTuple>();
|
||||
// for expirations that are contracts themselves (ie non options)
|
||||
public readonly IReadOnlyDictionary<SecurityExpiration, UInt32> exp_map =
|
||||
new Dictionary<SecurityExpiration, UInt32>();
|
||||
public readonly IReadOnlyDictionary<SecurityExpiration, HashSet<SecurityStrike>>
|
||||
strike_map = new Dictionary<SecurityExpiration, HashSet<SecurityStrike>>();
|
||||
|
||||
private SystemContractData() { }
|
||||
public static readonly SystemContractData empty = new SystemContractData();
|
||||
|
||||
class CPKey {
|
||||
public Nullable<UInt32> ckey = null, pkey = null;
|
||||
}
|
||||
|
||||
static void _add_strike(
|
||||
ref Dictionary<SecurityExpiration, Dictionary<double, CPKey>> exp_k_map,
|
||||
SecurityImmutable sec) {
|
||||
bts.Log.assert(sec.HasOption);
|
||||
SecurityExpiration sec_exp = new SecurityExpiration(sec.Exchange,
|
||||
SecurityType.Option, sec.Symbol, sec.Option.expiration_date());
|
||||
Dictionary<double, CPKey> k_map = null;
|
||||
if (!exp_k_map.TryGetValue(sec_exp, out k_map)) {
|
||||
k_map = new Dictionary<double, CPKey>();
|
||||
exp_k_map.Add(sec_exp, k_map);
|
||||
}
|
||||
CPKey cp_key = null;
|
||||
if (!k_map.TryGetValue(sec.Option.Strike, out cp_key)) {
|
||||
cp_key = new CPKey();
|
||||
k_map.Add(sec.Option.Strike, cp_key);
|
||||
}
|
||||
if (sec.Option.CallPut == PutOrCall.Put) {
|
||||
cp_key.pkey = sec.Id;
|
||||
} else {
|
||||
cp_key.ckey = sec.Id;
|
||||
}
|
||||
}
|
||||
|
||||
internal SystemContractData(IReadOnlyDictionary<uint, SecurityMD> sec_map_arg) {
|
||||
sec_md_map = sec_map_arg;
|
||||
HashSet<SecurityTuple> sectup_map_aux = new HashSet<SecurityTuple>();
|
||||
Dictionary<SecurityExpiration, UInt32> exp_map_aux =
|
||||
new Dictionary<SecurityExpiration, uint>();
|
||||
Dictionary<SecurityExpiration, Dictionary<double, CPKey>> strike_map_temp =
|
||||
new Dictionary<SecurityExpiration, Dictionary<double, CPKey>>();
|
||||
foreach (var kv in sec_md_map) {
|
||||
SecurityImmutable sec = kv.Value.security;
|
||||
SecurityTuple sec_tup =
|
||||
new SecurityTuple(sec.security_type(), sec.Symbol, sec.Exchange);
|
||||
sectup_map_aux.Add(sec_tup);
|
||||
SecurityExpiration sec_exp =
|
||||
new SecurityExpiration(sec_tup, sec.security_expiration() ?? default, sec.Id);
|
||||
exp_map_aux[sec_exp] = sec.Id;
|
||||
if (sec.HasOption) {
|
||||
_add_strike(ref strike_map_temp, sec);
|
||||
}
|
||||
}
|
||||
Dictionary<SecurityExpiration, HashSet<SecurityStrike>> strike_map_aux =
|
||||
new Dictionary<SecurityExpiration, HashSet<SecurityStrike>>();
|
||||
foreach (var kv in strike_map_temp) {
|
||||
SecurityExpiration exp = kv.Key;
|
||||
HashSet<SecurityStrike> k_map = new HashSet<SecurityStrike>();
|
||||
foreach (var kv_i in kv.Value) {
|
||||
double k = kv_i.Key;
|
||||
CPKey cp_key = kv_i.Value;
|
||||
SecurityStrike sec_k =
|
||||
new SecurityStrike(exp, k, new Tuple<uint?, uint?>(cp_key.ckey, cp_key.pkey));
|
||||
k_map.Add(sec_k);
|
||||
}
|
||||
strike_map_aux.Add(exp, k_map);
|
||||
}
|
||||
sectup_map = sectup_map_aux;
|
||||
exp_map = exp_map_aux;
|
||||
strike_map = strike_map_aux;
|
||||
_log_data();
|
||||
}
|
||||
|
||||
private void _log_data() {
|
||||
bts.Log.Gen.info(
|
||||
String.Format(
|
||||
"SystemContractData constructed, sec_tups:{0} total_exps:{1} option_exps:{2}",
|
||||
sectup_map.Count, exp_map.Count, strike_map.Count));
|
||||
sectup_map.ForEach(st => bts.Log.Gen.info(
|
||||
String.Format("SystemContractData loaded sectup:{0}", st.ToString())));
|
||||
foreach (var kv in exp_map) {
|
||||
var log_txt = String.Format("SystemContractData loaded exp:{0} id:{1}",
|
||||
kv.Key.ToString(), kv.Value);
|
||||
if (kv.Key.security_type == SecurityType.Option) {
|
||||
strike_map.TryGetValue(kv.Key, out var k_map);
|
||||
log_txt += " n_strikes:" + ((k_map == null) ? 0 : k_map.Count);
|
||||
}
|
||||
bts.Log.Gen.info(log_txt);
|
||||
}
|
||||
}
|
||||
|
||||
public Tuple<uint?, uint?> get_option_sec_id(
|
||||
Venue venue, string symbol, DateTime exp, double strike) {
|
||||
var s_exp = new SecurityExpiration(venue, SecurityType.Option, symbol, exp);
|
||||
if (strike_map.TryGetValue(s_exp, out var exp_strikes)) {
|
||||
foreach (var k in exp_strikes) {
|
||||
if (k.strike == strike) {
|
||||
return k.call_put_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public SystemContractData Default { get { return empty; } }
|
||||
|
||||
public IEnumerable<string> get_symbols(SecurityType sec_type) {
|
||||
return new HashSet<string>(
|
||||
sectup_map.Where(s => s.security_type == sec_type).Select(s => s.security_name));
|
||||
}
|
||||
|
||||
public HashSet<SecurityStrike> get_strikes_for_exp(SecurityExpiration sec_exp) {
|
||||
HashSet<SecurityStrike> rv = null;
|
||||
if (strike_map.TryGetValue(sec_exp, out rv)) {
|
||||
return rv;
|
||||
}
|
||||
return new HashSet<SecurityStrike>();
|
||||
}
|
||||
|
||||
public Tuple<SecurityImmutable, VolSurfaceMDUnit> get_sec_md(UInt32? id) {
|
||||
if (!id.HasValue) {
|
||||
return null;
|
||||
}
|
||||
SecurityMD sec_md;
|
||||
if (!sec_md_map.TryGetValue(id.Value, out sec_md)) {
|
||||
return null;
|
||||
}
|
||||
NativePriceSize bid, ask;
|
||||
ulong time = 0;
|
||||
sec_md.md.get_bbo(ref time, out bid, out ask);
|
||||
return Tuple.Create(sec_md.security,
|
||||
new VolSurfaceMDUnit(bid, ask, sec_md.md.fixing_price));
|
||||
}
|
||||
|
||||
public Tuple<SecurityImmutable, VolSurfaceMDUnit>
|
||||
get_exp_md(SecurityExpiration sec_exp) {
|
||||
uint sec_id = 0;
|
||||
if (!exp_map.TryGetValue(sec_exp, out sec_id)) {
|
||||
return null;
|
||||
}
|
||||
return get_sec_md(sec_id);
|
||||
}
|
||||
|
||||
internal Tuple<SecurityExpiration,
|
||||
IDictionary<double, Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit>>>
|
||||
get_option_bbo_vsexp(VolSurfaceExpiration exp) {
|
||||
// this is a workaround for VSExp not having an exchange
|
||||
foreach (Venue v in System.Enum.GetValues(typeof(Venue))) {
|
||||
var sec_exp =
|
||||
new SecurityExpiration(v, SecurityType.Option, exp.symbol, exp.expiration);
|
||||
var rv = get_option_bbo(sec_exp);
|
||||
if (rv != null && rv.Count > 0) {
|
||||
return Tuple.Create(sec_exp, rv);
|
||||
}
|
||||
}
|
||||
IDictionary<double, Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit>> rv_data =
|
||||
new Dictionary<double, Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit>>();
|
||||
return Tuple.Create(exp.to_security_expiration(), rv_data);
|
||||
}
|
||||
|
||||
internal IDictionary<double, Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit>> get_option_bbo(
|
||||
SecurityExpiration option_exp) {
|
||||
HashSet<SecurityStrike> strikes = get_strikes_for_exp(option_exp);
|
||||
Dictionary<double, Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit>> rv =
|
||||
new Dictionary<double, Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit>>();
|
||||
foreach (SecurityStrike k in strikes) {
|
||||
// call
|
||||
uint? call_id = k.call_put_id.Item1;
|
||||
var call_sec_md = get_sec_md(call_id);
|
||||
VolSurfaceMDUnit call_bbo = call_sec_md == null ? VolSurfaceMDUnit.empty : call_sec_md.Item2;
|
||||
// put
|
||||
uint? put_id = k.call_put_id.Item2;
|
||||
var put_sec_md = get_sec_md(put_id);
|
||||
VolSurfaceMDUnit put_bbo = put_sec_md == null ? VolSurfaceMDUnit.empty : put_sec_md.Item2;
|
||||
rv.Add(k.strike, new Tuple<VolSurfaceMDUnit, VolSurfaceMDUnit>(call_bbo, put_bbo));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
public IDictionary<DateTime, IEnumerable<double>> get_option_strikes(string option_name) {
|
||||
return strike_map.Where(kv => kv.Key.symbol == option_name)
|
||||
.ToDictionary(kv => kv.Key.expiration, kv => kv.Value.Select(k => k.strike));
|
||||
}
|
||||
|
||||
public IDictionary<SecurityExpiration, IEnumerable<double>>
|
||||
get_option_strikes(HashSet<string> option_names) {
|
||||
return strike_map.Where(kv => option_names.Contains(kv.Key.symbol))
|
||||
.ToDictionary(kv => kv.Key, kv => kv.Value.Select(k => k.strike));
|
||||
}
|
||||
|
||||
public Nullable<UInt32> get_exp_sec_id(SecurityExpiration sec_exp) {
|
||||
UInt32 rv;
|
||||
if (exp_map.TryGetValue(sec_exp, out rv)) {
|
||||
return rv;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IEnumerable<DateTime> get_option_expirations(string option_name,
|
||||
bool is_display_expiration = false) {
|
||||
return exp_map.Keys.Where(e => e.security_type == SecurityType.Option &&
|
||||
e.symbol == option_name).Select(e => e.expiration);
|
||||
}
|
||||
|
||||
public IDictionary<string, IEnumerable<DateTime>> get_option_expirations(
|
||||
IEnumerable<string> option_names, bool is_display_expiration) {
|
||||
return option_names.ToDictionaryDupes(kv => kv, kv => get_option_expirations(kv));
|
||||
}
|
||||
|
||||
public IEnumerable<SecurityTuple> get_options() {
|
||||
return sectup_map.Where(st => st.security_type == SecurityType.Option);
|
||||
}
|
||||
|
||||
public IEnumerable<double> get_all_option_strikes(string option_name) {
|
||||
HashSet<double> rv = new HashSet<double>();
|
||||
foreach (var kv in strike_map.Where(kv => kv.Key.symbol == option_name))
|
||||
foreach (var k in kv.Value)
|
||||
rv.Add(k.strike);
|
||||
return rv;
|
||||
}
|
||||
|
||||
public IEnumerable<DateTime> get_option_expirations_with_strikes(string option_name,
|
||||
bool is_display_expiration) {
|
||||
return strike_map.Where(kv => kv.Key.symbol == option_name &&
|
||||
kv.Value.Count > 0).Select(kv => kv.Key.expiration);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,285 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace mbts.spark {
|
||||
public class TheoPoint : ICloneable {
|
||||
//if true, SPX mode -- assumes you hedge the whole thing with combos at the tie price
|
||||
//false, Merc mode -- assumes you get what you get
|
||||
private static bool assume_tied_spreads_fully_hedged = true;
|
||||
static TheoPoint() {
|
||||
// assume_tied_spreads_fully_hedged = mbts.config.Configuration.get<bts.config.toggles.
|
||||
// Assume_tied_spreads_hedged_gamma_price>().enabled;
|
||||
}
|
||||
//Rationale
|
||||
//If the market is at live_driver, and I pay for a spread tied to locked_driver that is not the current futures price
|
||||
//and perfectly hedge it, I will receive gamma for that spread that, if in the event the market moves
|
||||
//to the locked price, I will be able sell additional hedge units against that new delta.
|
||||
//Thus, here we compute the value of those extra hedge units and incorporate them into the theo.
|
||||
//Delta's and gammas here are as a percent, like 45 instead of .45
|
||||
|
||||
//9 Jan 2015
|
||||
//Randy / Kev conversation (spurred on by questions from Lorry)
|
||||
//Let's say we consider a spread buying 2 35 delta options worth 10 bucks a piece at und == 1000
|
||||
//Now I do the spread tied to 1010, wherein those options are now worth 14 (delta gets us to 13.5, add .5 for gamma, approx)
|
||||
//and the delta is now 50 (because of gamma).
|
||||
//Hedging the delta up at 1010 (the essence of the locked trade), I sell 1 future at 1010 (because 2*50 delta = 1 future)
|
||||
//BUT I get to sell that future 10 dollars higher than the current market of 1000.
|
||||
|
||||
//I could now turn around and buy that future back at 1000 and yield a profit of 10 bucks on that 1 future, and then
|
||||
//sell the spread back out at a price of 10 bucks per option (it's current theo at the live market),
|
||||
//so I'd lose 4 bucks per option (bought at 14 sld at 10), or 8 bucks total on the options, but I made 10 on the future,
|
||||
//netting me a 2 dollar profit for simply unwinding the trade I just did.
|
||||
|
||||
//Therefore I can choose to reflect this windfall in what we call the gamma-adjusted theoretical value by
|
||||
//adding that 2 bucks of profit back into the theoretical value of the package.
|
||||
public static void compute_enhanced_spread(double live_driver, double locked_driver,
|
||||
double spread_locked_price, double spread_locked_delta_no_futs, double spread_locked_gamma,
|
||||
double spread_live_price, double spread_live_delta_no_futs, double spread_live_gamma,
|
||||
double initial_hedge,
|
||||
|
||||
ref double new_spread_price,
|
||||
ref double spread_delta_difference, ref double unused) {
|
||||
//travel from locked to live with the option
|
||||
double spread_change = spread_live_price - spread_locked_price;
|
||||
|
||||
//NEW 10/28/2015 KD travel from locked to live with initial hedge (if it's an exchange-listed covered)
|
||||
double initial_hedge_change = (assume_tied_spreads_fully_hedged) ? 0.0
|
||||
: (initial_hedge * (live_driver - locked_driver));
|
||||
|
||||
//travel from locked to live with the sold hedge (note it's locked-live here to negate for hedge)
|
||||
//NEW 11/24/2015 -- only hedge this spread if it's not a covered, hedging it twice doesn't make sense
|
||||
double hedge_change = 0.0;
|
||||
if (initial_hedge == 0.0 || assume_tied_spreads_fully_hedged)
|
||||
hedge_change = (spread_locked_delta_no_futs + initial_hedge) * (locked_driver - live_driver);
|
||||
|
||||
new_spread_price = spread_locked_price + spread_change + initial_hedge_change + hedge_change;
|
||||
spread_delta_difference = 100.0 * (spread_locked_delta_no_futs - spread_live_delta_no_futs);
|
||||
unused = 0.0;
|
||||
}
|
||||
|
||||
public enum InterpolationMethod {
|
||||
TAYLOR = 0, LINEAR = 1, POLY = 2
|
||||
}
|
||||
|
||||
public double call = Double.NaN, put = Double.NaN,
|
||||
cdelta = Double.NaN, pdelta = Double.NaN,
|
||||
c_interp_delta = Double.NaN, p_interp_delta = Double.NaN,
|
||||
cgamma = Double.NaN, pgamma = Double.NaN,
|
||||
c_interp_gamma = Double.NaN, p_interp_gamma = Double.NaN,
|
||||
cvega = Double.NaN, pvega = Double.NaN, driver = Double.NaN,
|
||||
vol = Double.NaN,
|
||||
/// added 02/18/2014
|
||||
c_oev = Double.NaN, p_oev = Double.NaN,
|
||||
c_slope_vega = Double.NaN, p_slope_vega = Double.NaN,
|
||||
c_vanna = Double.NaN, p_vanna = Double.NaN,
|
||||
veganovr = double.NaN,
|
||||
c_adj_vega = Double.NaN, p_adj_vega = Double.NaN,
|
||||
c_theta = Double.NaN, p_theta = Double.NaN, fwd = double.NaN, standard_strike = double.NaN, theo_time = Double.NaN,
|
||||
/// added 7/30/2016
|
||||
driver_bid, driver_ask;
|
||||
|
||||
private TheoPoint() { }
|
||||
|
||||
public readonly static TheoPoint shared_null_tp = getNulledObject();
|
||||
|
||||
public static TheoPoint getNulledObject() {
|
||||
return new TheoPoint();
|
||||
}
|
||||
|
||||
public TheoPoint(double theCall, double thePut, double theCDelta, double thePDelta, double theCVega, double thePVega, double theDriver) {
|
||||
call = theCall;
|
||||
put = thePut;
|
||||
cdelta = theCDelta;
|
||||
pdelta = thePDelta;
|
||||
cvega = theCVega;
|
||||
pvega = thePVega;
|
||||
driver = theDriver;
|
||||
}
|
||||
|
||||
public double fwd_normalized_call {
|
||||
get => (fwd == 0 ? Double.NaN : call / fwd);
|
||||
}
|
||||
|
||||
public double fwd_normalized_put {
|
||||
get => (fwd == 0 ? Double.NaN : put / fwd);
|
||||
}
|
||||
|
||||
public TheoPoint(double theCall, double thePut, double theCDelta, double thePDelta, double theCGamma, double thePGamma, double theCVega, double thePVega, double theVol, double theDriver)
|
||||
: this(theCall, thePut, theCDelta, thePDelta, theCVega, thePVega, theDriver) {
|
||||
cgamma = theCGamma;
|
||||
pgamma = thePGamma;
|
||||
vol = theVol;
|
||||
}
|
||||
|
||||
public void copy_from(TheoPoint other) {
|
||||
call = other.call;
|
||||
put = other.put;
|
||||
cdelta = other.cdelta;
|
||||
pdelta = other.pdelta;
|
||||
cvega = other.cvega;
|
||||
pvega = other.pvega;
|
||||
driver = other.driver;
|
||||
cgamma = other.cgamma;
|
||||
pgamma = other.pgamma;
|
||||
vol = other.vol;
|
||||
c_oev = other.c_oev;
|
||||
p_oev = other.p_oev;
|
||||
c_slope_vega = other.c_slope_vega;
|
||||
p_slope_vega = other.p_slope_vega;
|
||||
c_vanna = other.c_vanna;
|
||||
p_vanna = other.p_vanna;
|
||||
veganovr = other.veganovr;
|
||||
c_adj_vega = other.c_adj_vega;
|
||||
p_adj_vega = other.p_adj_vega;
|
||||
c_theta = other.c_theta;
|
||||
p_theta = other.p_theta;
|
||||
fwd = other.fwd;
|
||||
standard_strike = other.standard_strike;
|
||||
theo_time = other.theo_time;
|
||||
}
|
||||
|
||||
public void copy_view_delta_gamma_to_interp() {
|
||||
c_interp_delta = cdelta;
|
||||
p_interp_delta = pdelta;
|
||||
c_interp_gamma = cgamma;
|
||||
p_interp_gamma = pgamma;
|
||||
}
|
||||
|
||||
public void mult_interp_delta_gamma(double delta_mult, double gamma_mult) {
|
||||
c_interp_delta *= delta_mult;
|
||||
p_interp_delta *= delta_mult;
|
||||
c_interp_gamma *= gamma_mult;
|
||||
p_interp_gamma *= gamma_mult;
|
||||
}
|
||||
|
||||
public object Clone() {
|
||||
return new TheoPoint(call, put, cdelta, pdelta, cgamma, pgamma, cvega, pvega, vol, driver) { c_interp_delta = this.c_interp_delta, p_interp_delta = this.p_interp_delta, c_interp_gamma = this.c_interp_gamma, p_interp_gamma = this.p_interp_gamma, standard_strike = this.standard_strike, theo_time = this.theo_time };
|
||||
}
|
||||
|
||||
public static double _weighted_mean_taylor_interp(double x1, double f1, double df1, double d2f1,
|
||||
double x2, double f2, double df2, double d2f2, double x) {
|
||||
double t_f_x1 = _taylor_interp(x1, f1, df1, d2f1, x),
|
||||
t_f_x2 = _taylor_interp(x2, f2, df2, d2f2, x);
|
||||
return (t_f_x1 * Math.Abs(x2 - x) + t_f_x2 * Math.Abs(x1 - x)) / (Math.Abs(x2 - x1));
|
||||
}
|
||||
|
||||
public static double _taylor_interp(double x1, double f1, double df1, double d2f1, double x) {
|
||||
return f1 + df1 * (x - x1) + d2f1 * Math.Pow(x - x1, 2) * 0.5;
|
||||
}
|
||||
|
||||
private class point_info {
|
||||
public double x, f, df, d2f;
|
||||
};
|
||||
|
||||
public static double _poly_interp(double x1, double f1, double df1, double d2f1,
|
||||
double x2, double f2, double df2, double d2f2, double x) {
|
||||
if (x1 == x2)
|
||||
return f1;
|
||||
else {
|
||||
point_info p1 = new point_info() { x = x1, f = f1, df = df1, d2f = d2f1 },
|
||||
p2 = new point_info() { x = x2, f = f2, df = df2, d2f = d2f2 };
|
||||
double dx = p2.x - p1.x;
|
||||
double p1mult = (p2.d2f - p1.d2f) * dx * dx;
|
||||
double p2mult = (p2.df - p1.df - p1.d2f * dx) * dx;
|
||||
double p3mult = p2.f - p1.f - (p1.df + 0.5 * p1.d2f * dx) * dx;
|
||||
x = (x - p1.x) / dx;
|
||||
return p1.f + x * (p1.df * dx + x * (0.5 * p1.d2f * dx * dx + x * (0.5 * p1mult - 4.0 * p2mult + 10.0 * p3mult + x * (-p1mult + 7.0 * p2mult - 15.0 * p3mult + x * (0.5 * p1mult - 3.0 * p2mult + 6.0 * p3mult)))));
|
||||
}
|
||||
}
|
||||
|
||||
public static double _linear_interp(double x1, double y1, double x2, double y2, double x) {
|
||||
/// return SplineCalcsCLR.linear_interp(x, new double[] { x1, x2 }, new double[] { y1, y2 }, 2);
|
||||
return ((y2 - y1) / (x2 - x1)) * (x - x1) + y1;
|
||||
}
|
||||
|
||||
//This is a copy of _interp in UIFramework d:/home/darby/bts/blue2-hotfix-akuna/blue2/UIFramework/tc2/Calculator2/InterpolationCalculation/XFEDInterpolationCalculator.cs
|
||||
//I since removed it from there
|
||||
public static void interp(InterpolationMethod interp_method, TheoPoint p1, TheoPoint p2, double driver, TheoPoint result,
|
||||
DateTime exp, double strike) {
|
||||
if (interp_method == InterpolationMethod.LINEAR) {
|
||||
result.driver = driver;
|
||||
result.call = _linear_interp(p1.driver, p1.call, p2.driver, p2.call, driver);
|
||||
result.put = _linear_interp(p1.driver, p1.put, p2.driver, p2.put, driver);
|
||||
result.cdelta = _linear_interp(p1.driver, p1.cdelta, p2.driver, p2.cdelta, driver);
|
||||
result.pdelta = _linear_interp(p1.driver, p1.pdelta, p2.driver, p2.pdelta, driver);
|
||||
} else if (interp_method == InterpolationMethod.TAYLOR) {
|
||||
result.driver = driver;
|
||||
double parity_roll = strike + p1.call - p1.put - p1.driver;
|
||||
double fwd = driver + parity_roll;
|
||||
if ((p1.c_interp_gamma == 0.0 || p2.c_interp_gamma == 0.0) && (DateTime.Now.Date >= exp)) {
|
||||
result.call = Math.Max(fwd - strike, 0.0);
|
||||
result.cdelta = (strike < fwd) ? 1.0 : 0.0;
|
||||
//BCG.Utilities.BlueEventLog.logEvent(String.Format("Parity : {0} {1} {2} {3} {4} {5}", p1.driver, p2.driver, driver, exp, strike, true), BCG.Utilities.BlueEventLevel.Information);
|
||||
} else {
|
||||
result.call = _weighted_mean_taylor_interp(p1.driver, p1.call, p1.c_interp_delta, p1.c_interp_gamma,
|
||||
p2.driver, p2.call, p2.c_interp_delta, p2.c_interp_gamma, driver);
|
||||
result.cdelta = _linear_interp(p1.driver, p1.cdelta, p2.driver, p2.cdelta, driver);
|
||||
}
|
||||
|
||||
if ((p1.p_interp_gamma == 0.0 || p2.p_interp_gamma == 0.0) && (DateTime.Now.Date >= exp)) {
|
||||
result.put = Math.Max(strike - fwd, 0.0);
|
||||
result.pdelta = (strike > fwd) ? -1.0 : 0.0;
|
||||
//BCG.Utilities.BlueEventLog.logEvent (String.Format ("Parity : {0} {1} {2} {3} {4} {5}", p1.driver, p2.driver, driver, exp, strike, false), BCG.Utilities.BlueEventLevel.Information);
|
||||
} else {
|
||||
result.put = _weighted_mean_taylor_interp(p1.driver, p1.put, p1.p_interp_delta, p1.p_interp_gamma,
|
||||
p2.driver, p2.put, p2.p_interp_delta, p2.p_interp_gamma, driver);
|
||||
result.pdelta = _linear_interp(p1.driver, p1.pdelta, p2.driver, p2.pdelta, driver);
|
||||
}
|
||||
} else if (interp_method == InterpolationMethod.POLY) {
|
||||
result.driver = driver;
|
||||
double parity_roll = strike + p1.call - p1.put - p1.driver;
|
||||
double fwd = driver + parity_roll;
|
||||
if ((p1.c_interp_gamma == 0.0 || p2.c_interp_gamma == 0.0) && (DateTime.Now.Date >= exp)) {
|
||||
result.call = Math.Max(fwd - strike, 0.0);
|
||||
result.cdelta = (strike < fwd) ? 1.0 : 0.0;
|
||||
//BCG.Utilities.BlueEventLog.logEvent(String.Format("Parity : {0} {1} {2} {3} {4} {5}", p1.driver, p2.driver, driver, exp, strike, true), BCG.Utilities.BlueEventLevel.Information);
|
||||
} else {
|
||||
result.call = _poly_interp(p1.driver, p1.call, p1.c_interp_delta, p1.c_interp_gamma, p2.driver, p2.call, p2.c_interp_delta, p2.c_interp_gamma, driver);
|
||||
result.cdelta = _poly_interp(p1.driver, p1.cdelta, p1.c_interp_gamma, 0.0, p2.driver, p2.cdelta, p2.c_interp_gamma, 0.0, driver);
|
||||
}
|
||||
|
||||
if ((p1.p_interp_gamma == 0.0 || p2.p_interp_gamma == 0.0) && (DateTime.Now.Date >= exp)) {
|
||||
result.put = Math.Max(strike - fwd, 0.0);
|
||||
result.pdelta = (strike > fwd) ? -1.0 : 0.0;
|
||||
//BCG.Utilities.BlueEventLog.logEvent(String.Format("Parity : {0} {1} {2} {3} {4} {5}", p1.driver, p2.driver, driver, exp, strike, false), BCG.Utilities.BlueEventLevel.Information);
|
||||
} else {
|
||||
result.put = _poly_interp(p1.driver, p1.put, p1.p_interp_delta, p1.p_interp_gamma, p2.driver, p2.put, p2.p_interp_delta, p2.p_interp_gamma, driver);
|
||||
result.pdelta = _poly_interp(p1.driver, p1.pdelta, p1.p_interp_gamma, 0.0, p2.driver, p2.pdelta, p2.p_interp_gamma, 0.0, driver);
|
||||
}
|
||||
}
|
||||
/// the rest can only be linear, because we dont have the derivatives
|
||||
result.cgamma = _linear_interp(p1.driver, p1.cgamma, p2.driver, p2.cgamma, driver);
|
||||
result.pgamma = _linear_interp(p1.driver, p1.pgamma, p2.driver, p2.pgamma, driver);
|
||||
result.cvega = _linear_interp(p1.driver, p1.cvega, p2.driver, p2.cvega, driver);
|
||||
result.pvega = _linear_interp(p1.driver, p1.pvega, p2.driver, p2.pvega, driver);
|
||||
result.c_theta = _linear_interp(p1.driver, p1.c_theta, p2.driver, p2.c_theta, driver);
|
||||
result.p_theta = _linear_interp(p1.driver, p1.p_theta, p2.driver, p2.p_theta, driver);
|
||||
result.vol = _linear_interp(p1.driver, p1.vol, p2.driver, p2.vol, driver);
|
||||
result.fwd = _linear_interp(p1.driver, p1.fwd, p2.driver, p2.fwd, driver);
|
||||
result.standard_strike = _linear_interp(p1.driver, p1.standard_strike, p2.driver, p2.standard_strike, driver);
|
||||
result.c_adj_vega = _linear_interp(p1.driver, p1.c_adj_vega, p2.driver, p2.c_adj_vega, driver);
|
||||
result.p_adj_vega = _linear_interp(p1.driver, p1.p_adj_vega, p2.driver, p2.p_adj_vega, driver);
|
||||
result.c_oev = _linear_interp(p1.driver, p1.c_oev, p2.driver, p2.c_oev, driver);
|
||||
result.p_oev = _linear_interp(p1.driver, p1.p_oev, p2.driver, p2.p_oev, driver);
|
||||
result.c_slope_vega = _linear_interp(p1.driver, p1.c_slope_vega, p2.driver, p2.c_slope_vega, driver);
|
||||
result.p_slope_vega = _linear_interp(p1.driver, p1.p_slope_vega, p2.driver, p2.p_slope_vega, driver);
|
||||
result.c_vanna = _linear_interp(p1.driver, p1.c_vanna, p2.driver, p2.c_vanna, driver);
|
||||
result.p_vanna = _linear_interp(p1.driver, p1.p_vanna, p2.driver, p2.p_vanna, driver);
|
||||
result.veganovr = _linear_interp(p1.driver, p1.veganovr, p2.driver, p2.veganovr, driver);
|
||||
result.standard_strike = _linear_interp(p1.driver, p1.standard_strike, p2.driver, p2.standard_strike, driver);
|
||||
result.theo_time = p1.theo_time;
|
||||
}
|
||||
|
||||
/// Computes theos at a given driver price (extrapolating using taylors)
|
||||
public static double get_theo_at_driver(TheoPoint tp, double driver, bool is_call) {
|
||||
tp = tp ?? TheoPoint.shared_null_tp;
|
||||
double driver_diff = driver - tp.driver;
|
||||
if (is_call)
|
||||
return tp.call + (tp.cdelta * driver_diff) + (0.5 * tp.cgamma * driver_diff * driver_diff);
|
||||
else
|
||||
return tp.put + (tp.pdelta * driver_diff) + (0.5 * tp.pgamma * driver_diff * driver_diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Security.AccessControl;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using BCG;
|
||||
|
||||
using bts.api;
|
||||
|
||||
namespace mbts.spark {
|
||||
/// <summary>
|
||||
/// For classes, that are constructed and run on their
|
||||
/// own thread, this class provides a threaded wrapper
|
||||
/// around the main blackboard.
|
||||
/// The assumption here is that this class will
|
||||
/// be constructed in the secondary thread, and
|
||||
/// all functions prefixed with 'sec_thread' will be called
|
||||
/// from the same secondary thread.
|
||||
/// </summary>
|
||||
public class ThreadedBlackboard {
|
||||
private IBus _bus;
|
||||
private List<IDisposable> _subs = new List<IDisposable>();
|
||||
private HashSet<object> _tag_map = new HashSet<object>();
|
||||
public event Action<object, object> data_callback = (t, v) => { };
|
||||
public event Action timer_callback = () => { };
|
||||
|
||||
private IDictionary<object, object> _cache = new
|
||||
Dictionary<object, object>();
|
||||
private static int _tid() { return VolSurfaceTroubleshootingFunctions.tid(); }
|
||||
public ThreadedBlackboard(IBus bus) {
|
||||
bts.Log.Ui.info($"ThreadedBlackBoard.cons tid:{ _tid()}");
|
||||
_bus = bus;
|
||||
subscribe(SparkTags.SparkTimer);
|
||||
System.Threading.Thread timer_thread = new System.Threading.Thread(() => {
|
||||
DateTime start_time = DateTime.Now;
|
||||
while (true) {
|
||||
System.Threading.Thread.Sleep(100);
|
||||
_bus.post(SparkTags.SparkTimer, DateTime.Now - start_time);
|
||||
}
|
||||
});
|
||||
timer_thread.IsBackground = true;
|
||||
timer_thread.Start();
|
||||
}
|
||||
|
||||
#region Public API
|
||||
|
||||
public T read_state<T>(ITag<T> tag, T not_found_default = default(T)) {
|
||||
var rv = _retrieve_from_cache(tag);
|
||||
if (rv is null) {
|
||||
return not_found_default;
|
||||
}
|
||||
return (T)rv;
|
||||
}
|
||||
|
||||
public void subscribe<T>(ITag<T> tag) {
|
||||
if (_tag_map.Contains(tag)) {
|
||||
return;
|
||||
}
|
||||
_tag_map.Add(tag);
|
||||
bts.Log.Ui.info($"ThreadedBlackBoard.subscribe tag:{tag} tid:{ _tid()}");
|
||||
var observable = _bus.subscribe(tag).OnDispatcher().Subscribe(
|
||||
data => _on_bus_data(tag, data));
|
||||
_subs.Add(observable);
|
||||
}
|
||||
|
||||
public void post<T>(ITag<T> tag, T data, bool block_until_written = false) {
|
||||
bts.Log.Ui.diag($"ThreadedBlackBoard.post tag:{tag} data:{_data_string(data)} " +
|
||||
$"tid:{_tid()}");
|
||||
_cache[tag] = data;
|
||||
_bus.post(tag, data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private static string _data_string<T>(T data) {
|
||||
string rv = "Null";
|
||||
try {
|
||||
rv = data.ToString();
|
||||
} catch (Exception ex) {
|
||||
bts.Log.Ui.error($"ThreadedBlackBoard data:Null ex:{ex.Message}");
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
private void _on_bus_data<T>(ITag<T> tag, T data) {
|
||||
_cache[tag] = data;
|
||||
if (tag == SparkTags.SparkTimer) {
|
||||
timer_callback();
|
||||
return;
|
||||
}
|
||||
bts.Log.Ui.diag($"ThreadedBlackBoard._on_bus_data tag:{tag} data:{_data_string(data)} " +
|
||||
$"tid:{_tid()}");
|
||||
data_callback(tag, data);
|
||||
}
|
||||
|
||||
private object _retrieve_from_cache(object tag) {
|
||||
object rv = null;
|
||||
if (_cache.TryGetValue(tag, out rv))
|
||||
return rv;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using mbts;
|
||||
using mbts.analytics;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.shell;
|
||||
using mbts.spark;
|
||||
using bts.utils;
|
||||
using bts.api;
|
||||
using bts.collections;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace mbts.spark {
|
||||
/// This contains the list of global values for the vol
|
||||
/// surface (whereas VolSurfaceDisplayGrid has exp keyed
|
||||
/// values)
|
||||
public static class VolSurfaceTroubleshootingFunctions {
|
||||
public static string log_string(this VolSurfaceInput vs_inp) {
|
||||
string rv = "Null";
|
||||
if (vs_inp.surface_parameters != null && vs_inp.surface_parameters.curve_parameters_map != null) {
|
||||
rv = String.Empty;
|
||||
foreach (var kv in vs_inp.surface_parameters.curve_parameters_map) {
|
||||
var exp = kv.Item1;
|
||||
var exp_data = kv.Item2;
|
||||
double atm_vol = VolSurfaceDataFunctions.get_atm_vol(vs_inp.surface_settings, exp_data);
|
||||
rv += $"exp:{exp.expiration.ToShortDateString()} atm_vol:{atm_vol} \n";
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static string log_string(this VolSurfaceOutput vs_out,
|
||||
DateTime? exp_filter = null) {
|
||||
if (vs_out == null) {
|
||||
return "Null";
|
||||
}
|
||||
var vs_inp = vs_out.volsurface_input;
|
||||
string rv = "vs_inp:" + vs_inp == null ? "Null" : vs_inp.log_string() + "\n";
|
||||
rv += "vs_output:" + "\n";
|
||||
if (vs_out.exp_output_map != null) {
|
||||
foreach (var exp_kv in vs_out.exp_output_map) {
|
||||
var exp = exp_kv.Key;
|
||||
var exp_output = exp_kv.Value;
|
||||
rv += $"exp: {exp} fwd: {exp_output.fwd} c_fwd: {exp_output.conversion_fwd} " +
|
||||
$"atm_vol: {exp_output.atm_vol}" + "\n";
|
||||
var sorted_k_map = exp_output.strike_vol_map.ToImmutableSortedDictionary();
|
||||
foreach (var k_kv in sorted_k_map) {
|
||||
rv += $"exp: {exp} k: {k_kv.Key} vol: {k_kv.Value}" + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
private static string _trim_leading_char(string s, char c) {
|
||||
if (!s.is_null_or_empty() && s.EndsWith(c)) {
|
||||
return s.Remove(s.Length - 1, 1);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
internal static string log_string(this VolSurfaceDisplayModel.DisplayModelData dm_data) {
|
||||
string rv = String.Empty;
|
||||
string global_grid_str = dm_data.global_grid == null ? "Null" : dm_data.global_grid.log_string();
|
||||
rv += $"global_grid: {global_grid_str} \n";
|
||||
string exp_grid_str = dm_data.exp_grid == null ? "Null" : dm_data.exp_grid.log_string();
|
||||
rv += $"exp_grid: {exp_grid_str} \n";
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static string log_string(this VolSurfaceDisplayGlobalGrid ggrid) {
|
||||
string rv = String.Empty;
|
||||
foreach (var col in ggrid.get_ordered_columns()) {
|
||||
object col_data = null;
|
||||
ggrid.get_grid_data(col, out col_data);
|
||||
string col_data_str = col_data == null ? "Null" : col_data.ToString();
|
||||
rv += $"{col.display_name}:{col_data_str} ";
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
internal static string log_string(this VolSurfaceDisplayGrid dgrid) {
|
||||
Func<IDictionary<string, object>, string> log_exp = (map) => {
|
||||
string rv = String.Empty;
|
||||
foreach (var kv in map) {
|
||||
string val_string = kv.Value == null ? "Null" : kv.Value.ToString();
|
||||
rv += $"{kv.Key}:{val_string},";
|
||||
}
|
||||
return _trim_leading_char(rv, ',');
|
||||
};
|
||||
string rv = String.Empty;
|
||||
foreach (var kv in dgrid.data_map) {
|
||||
rv += $"Exp:{kv.Key.expiration.ToShortDateString()} Data:{log_exp(kv.Value)},";
|
||||
}
|
||||
return _trim_leading_char(rv, ',');
|
||||
}
|
||||
|
||||
internal static string log_string(this OptionDriverPriceMap map) {
|
||||
string rv = String.Empty;
|
||||
foreach (var kv in map.exp_price_map) {
|
||||
DriverMD dmd = kv.Value;
|
||||
var dmd_pr = dmd.get_driver();
|
||||
var dmd_sec = !dmd.driver_security.HasValue ? "NULL" :
|
||||
dmd.driver_security.Value.security_desc();
|
||||
rv += $"{kv.Key.ToString()}:{dmd_sec},{dmd_pr}\n";
|
||||
}
|
||||
return _trim_leading_char(rv, ',');
|
||||
}
|
||||
|
||||
internal static string log_string(this VolCurveMarketImpliedVolData d,
|
||||
bool log_all_vols = false) {
|
||||
string rv = $"atm_strike: {d.atm_strike} atm_vol: {d.atm_vol}";
|
||||
if (log_all_vols) {
|
||||
var pk_vols = new SortedDictionary<double, double>(d.put_rawk_vols);
|
||||
var ck_vols = new SortedDictionary<double, double>(d.call_rawk_vols);
|
||||
foreach (var kv in pk_vols) {
|
||||
rv += "\n" + $"pk: {kv.Key} vol: {kv.Value}";
|
||||
}
|
||||
foreach (var kv in ck_vols) {
|
||||
rv += "\n" + $"ck: {kv.Key} vol: {kv.Value}";
|
||||
}
|
||||
} else {
|
||||
int n_vol_points = d.put_rawk_vols.Where(kv => !kv.Value.is_nan()).Count() +
|
||||
d.put_rawk_vols.Where(kv => !kv.Value.is_nan()).Count();
|
||||
rv += $" n_vol_points: {n_vol_points}";
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
internal static string log_string(this Theos t) {
|
||||
string rv = $"strike: {t.strike} fwd: {t.fwd} driver: {t.driver} " +
|
||||
$"move: { t.move} vol: {t.vol} c_theo: {t.call} " +
|
||||
$"p_theo: {t.put}";
|
||||
return rv;
|
||||
}
|
||||
|
||||
internal static string log_string(this VolMatrix v) {
|
||||
string rv = $"strike: {v.strike} fwd: {v.fwd} driver: {v.driver} " +
|
||||
$"vol: {v.vol}";
|
||||
return rv;
|
||||
}
|
||||
|
||||
internal static string log_string(this SystemContractData sc_data) {
|
||||
Func<uint?, string> k_id = (id) => {
|
||||
return !id.HasValue ? "NULL" : id.Value.ToString();
|
||||
};
|
||||
string rv = "SystemContractData data:" + "\n";
|
||||
foreach (var kv in sc_data.strike_map) {
|
||||
var exp = kv.Key;
|
||||
foreach (var k in kv.Value) {
|
||||
rv += $"exp: {exp} k: {k} c_id: {k_id(k.call_put_id.Item1)} " +
|
||||
$"p_id: {k.call_put_id.Item2}" + "\n";
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
internal static string log_string(this VolCurveDisplayGraph g) {
|
||||
Func<string, IEnumerable<Tuple<double, double>>, string> points_txt =
|
||||
(t, points) => {
|
||||
string rv = t + "\n";
|
||||
if (points != null)
|
||||
foreach (var kv in points) {
|
||||
rv += $"{kv.Item1},{kv.Item2}" + "\n";
|
||||
}
|
||||
return rv;
|
||||
};
|
||||
string rv = "VolCurveDisplayGraph:" + "\n";
|
||||
rv += points_txt("all_points", g.all_points);
|
||||
rv += points_txt("special_call_points", g.special_call_points);
|
||||
rv += points_txt("special_put_points", g.special_put_points);
|
||||
rv += points_txt("atm_point", new Tuple<double, double>[] { g.atm_point });
|
||||
rv += $"call_wing_start: {g.call_wing_start}" + "\n";
|
||||
rv += $"put_wing_start: {g.put_wing_start}";
|
||||
return rv;
|
||||
}
|
||||
|
||||
internal static int tid() {
|
||||
return System.Threading.Thread.CurrentThread.ManagedThreadId;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 3639 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user