diff --git a/doc/user/CMakeDeps.cmake b/doc/user/CMakeDeps.cmake index 00bd7e37b..5f3811807 100644 --- a/doc/user/CMakeDeps.cmake +++ b/doc/user/CMakeDeps.cmake @@ -1 +1 @@ -set(sources /home/ppinto/Dropbox/bts/spark/doc/user/build.sh;/home/ppinto/Dropbox/bts/spark/doc/user/mkdocs.yml;bts-help-theme/404.html;bts-help-theme/base.html;bts-help-theme/content.html;bts-help-theme/css/base.css;bts-help-theme/css/bts.css;bts-help-theme/css/font-awesome.min.css;bts-help-theme/css/highlight.css;bts-help-theme/css/local.css;bts-help-theme/fonts/fontawesome-webfont.eot;bts-help-theme/fonts/glyphicons-halflings-regular.eot;bts-help-theme/img/favicon.ico;bts-help-theme/js/base.js;bts-help-theme/js/bootstrap-3.0.3.min.js;bts-help-theme/js/highlight.pack.js;bts-help-theme/js/jquery-1.10.2.min.js;bts-help-theme/keyboard-modal.html;bts-help-theme/main.html;bts-help-theme/nav-sub.html;bts-help-theme/nav.html;bts-help-theme/search-modal.html;bts-help-theme/toc.html;docs/Help.md;docs/Launcher.md;docs/Logging-In-to-the-System.md;docs/Market.md;docs/My-Windows.md;docs/Settings.md;docs/Spreader.md;docs/Trading.md;docs/images/image1.png;docs/images/image10.png;docs/images/image11.png;docs/images/image12.png;docs/images/image13.png;docs/images/image14.png;docs/images/image15.png;docs/images/image16.png;docs/images/image17.png;docs/images/image18.png;docs/images/image19.png;docs/images/image2.png;docs/images/image20.png;docs/images/image21.png;docs/images/image22.png;docs/images/image23.png;docs/images/image24.png;docs/images/image25.png;docs/images/image26.png;docs/images/image27.png;docs/images/image28.png;docs/images/image29.png;docs/images/image3.png;docs/images/image30.png;docs/images/image31.png;docs/images/image32.png;docs/images/image33.png;docs/images/image34.png;docs/images/image35.png;docs/images/image36.png;docs/images/image37.png;docs/images/image38.png;docs/images/image39.png;docs/images/image4.png;docs/images/image40.png;docs/images/image41.png;docs/images/image42.png;docs/images/image43.png;docs/images/image44.png;docs/images/image45.png;docs/images/image46.png;docs/images/image47.png;docs/images/image48.png;docs/images/image49.png;docs/images/image5.png;docs/images/image50.png;docs/images/image51.png;docs/images/image52.png;docs/images/image53.png;docs/images/image54.png;docs/images/image55.png;docs/images/image56.png;docs/images/image57.png;docs/images/image58.png;docs/images/image59.png;docs/images/image6.png;docs/images/image60.png;docs/images/image61.png;docs/images/image62.png;docs/images/image63.png;docs/images/image64.png;docs/images/image65.png;docs/images/image66.png;docs/images/image67.png;docs/images/image68.png;docs/images/image69.png;docs/images/image7.png;docs/images/image70.png;docs/images/image71.png;docs/images/image72.png;docs/images/image73.png;docs/images/image74.png;docs/images/image76.png;docs/images/image8.png;docs/images/image9.png;docs/index.md;docs/release_notes.md) \ No newline at end of file +set(sources /home/ppinto/Dropbox/bts/spark/doc/user/build.sh;content/_index.md;content/bts_spark/Glossary/index.md;content/bts_spark/Help/about_spark.png;content/bts_spark/Help/image39.png;content/bts_spark/Help/image58.png;content/bts_spark/Help/index.md;content/bts_spark/Launcher/image38.png;content/bts_spark/Launcher/image68.png;content/bts_spark/Launcher/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/Logging-In-to-the-System/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/index.md;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/image15.png;content/bts_spark/My-Windows/image16.png;content/bts_spark/My-Windows/image37.png;content/bts_spark/My-Windows/index.md;content/bts_spark/Settings/image51.png;content/bts_spark/Settings/image9.png;content/bts_spark/Settings/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/Spreader/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/index.md;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/bts_spark_sdk/Client/Overview.md;content/bts_spark_sdk/Client/Threading.md;content/bts_spark_sdk/Client/_index.md;content/bts_spark_sdk/Server/_index.md;content/bts_spark_sdk/_index.md;content/release_notes/_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) \ No newline at end of file diff --git a/doc/user/CMakeLists.txt b/doc/user/CMakeLists.txt index 2cf38258b..432156777 100644 --- a/doc/user/CMakeLists.txt +++ b/doc/user/CMakeLists.txt @@ -22,7 +22,7 @@ update_deps_file("${All_Deps}") add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/web/docs/index.html COMMAND /bin/bash ${CMAKE_CURRENT_SOURCE_DIR}/build.sh - ARGS ${CMAKE_BINARY_DIR}/web/docs/ + ARGS ${CMAKE_BINARY_DIR}/web/docs/ ${CMAKE_BINARY_DIR} COMMENT "Building Manual UI" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${All_Deps}) diff --git a/doc/user/build.sh b/doc/user/build.sh index 1c1da418b..5bf4d5ae3 100644 --- a/doc/user/build.sh +++ b/doc/user/build.sh @@ -1,8 +1,20 @@ #!/bin/bash tmpfile=$(mktemp /tmp/quiet_build_log.XXXX) -cp -r ../../src/sdk/doc/* ./content/bts_spark_sdk/Server/ -./run_zola.sh build -u '/docs/' -o $1 >$tmpfile 2>&1 -rm ./content/bts_spark_sdk/Server/algos.md + +cur_dir=$(pwd) +temp_path="$2/web_temp" +zola_path=$(readlink -f "../../externals/linux/bin/zola/zola") + +mkdir -p $temp_path +cp -r ./* $temp_path +cp -r ../../src/sdk/doc/* $temp_path/content/bts_spark_sdk/Server/ + +cd $temp_path +$zola_path build -u '/docs/' -o $1 >$tmpfile 2>&1 + +cd $cur_dir +rm -r $temp_path + if [ $? -eq 0 ] then rm $tmpfile diff --git a/doc/user/config.toml b/doc/user/config.toml index 79c720fb0..b32f4ddce 100644 --- a/doc/user/config.toml +++ b/doc/user/config.toml @@ -1,5 +1,5 @@ # The URL the site will be built for -base_url = "https://www.bluetradingsystems.com/docs" +base_url = "https://www.bluetradingsystems.com/documentation" title = "BTS Spark Documentation" @@ -15,4 +15,4 @@ build_search_index = true [extra] # Put all your custom variables here -book_numbered_chapters = false \ No newline at end of file +book_numbered_chapters = false diff --git a/doc/user/content/bts_spark/Help/about_spark.png b/doc/user/content/bts_spark/Help/about_spark.png new file mode 100644 index 000000000..67080a103 Binary files /dev/null and b/doc/user/content/bts_spark/Help/about_spark.png differ diff --git a/doc/user/content/bts_spark/Help/image32.png b/doc/user/content/bts_spark/Help/image32.png deleted file mode 100644 index e7bab380a..000000000 Binary files a/doc/user/content/bts_spark/Help/image32.png and /dev/null differ diff --git a/doc/user/content/bts_spark/Help/index.md b/doc/user/content/bts_spark/Help/index.md index edb73415f..4ad320962 100644 --- a/doc/user/content/bts_spark/Help/index.md +++ b/doc/user/content/bts_spark/Help/index.md @@ -25,7 +25,7 @@ insert_anchor_links = "right" which will list what version you are running as well as who is currently logged in. -![](image32.png) +![](about_spark.png) ## Activity log This is an overall log viewer which will show diff --git a/doc/user/content/bts_spark/Market/change_securities.png b/doc/user/content/bts_spark/Market/change_securities.png new file mode 100644 index 000000000..ca313da6f Binary files /dev/null and b/doc/user/content/bts_spark/Market/change_securities.png differ diff --git a/doc/user/content/bts_spark/Market/image12.png b/doc/user/content/bts_spark/Market/image12.png deleted file mode 100644 index 90c372bdd..000000000 Binary files a/doc/user/content/bts_spark/Market/image12.png and /dev/null differ diff --git a/doc/user/content/bts_spark/Market/image30.png b/doc/user/content/bts_spark/Market/image30.png deleted file mode 100644 index c403cce86..000000000 Binary files a/doc/user/content/bts_spark/Market/image30.png and /dev/null differ diff --git a/doc/user/content/bts_spark/Market/image63.png b/doc/user/content/bts_spark/Market/image63.png deleted file mode 100644 index 4debed349..000000000 Binary files a/doc/user/content/bts_spark/Market/image63.png and /dev/null differ diff --git a/doc/user/content/bts_spark/Market/index.md b/doc/user/content/bts_spark/Market/index.md index 5baf9f04c..0098a3b57 100644 --- a/doc/user/content/bts_spark/Market/index.md +++ b/doc/user/content/bts_spark/Market/index.md @@ -51,7 +51,7 @@ insert_anchor_links = "right" securities you have chosen, in this example, it appears like the following: -![](image63.png) +![](market_view.png) - Once a market view is launched and you are viewing data, you can customize the view further by the following: @@ -88,31 +88,34 @@ insert_anchor_links = "right" - Change securities - - Click on the settings icon ![](image12.png)which will launch the market view security selection.  You can add or remove Securities you have already selected and are shown in the market view. + - Click on the settings icon ![](change_securities.png) which will launch the market view security selection.  You can add or remove Securities you have already selected and are shown in the market view. - Launch an order ticket - - - This is done 1 of 2 ways: - + - This is done 1 of 3 ways: - Single left clicking on either the Bid Qty, Bid Price, Ask Price, or Ask Qty which will bring up an order ticket pre-populated with either the Bid or Ask price and volume. - Highlighting a single security and clicking on the order ticket ![](image23.png) icon on the left-hand browser window of the market view + - Highlighting a single security and right clicking bringing up the + menu options to launch an order ticket. - Launch a ladder for 1 security - - You can double-click on any security in the market view, besides - the Bid Qty, Bid Price, Ask Price, or Ask Qty columns to launch a - ladder for that Security. + - This is done 1 of 2 ways: + - You can double-click on any security in the market view, besides + the Bid Qty, Bid Price, Ask Price, or Ask Qty columns to launch a + ladder for that Security. + - Highlighting a single security and right clicking bringing up the + menu options to launch a ladder. - Launching multiple ladders - - - If you hold down the Ctrl key and select multiple securities, you - can then click on the ladder icon - ![](image69.png) on - the left-hand side to bring up the selected ladders all at - once. + - This is done 1 of 2 ways: + - If you hold down the Ctrl key and select multiple securities, you + can then click on the ladder icon on the left hand side to bring + up the selected ladders all at once. + - Highlighting multiple securities and right clicking to bring up + the menu options to launch a ladder. - Launching a Fills window for 1 or many securities @@ -158,8 +161,9 @@ insert_anchor_links = "right" - On launching a security browser will appear, allowing you to choose the products you would like to view. -![](image30.png) +![](time_and_sales.png) - From time and sales, you can launch the same items as the market view with the exception of a launching the synthetic window to - create a synthetic product \ No newline at end of file + create a synthetic product +- From the settings icon ![](settings_icon.png) you can customize the time and sales modifying grid; the colors of the aggressor, status of trades coming in, as well as font sizes and which columns to see. \ No newline at end of file diff --git a/doc/user/content/bts_spark/Market/market_view.png b/doc/user/content/bts_spark/Market/market_view.png new file mode 100644 index 000000000..fe2e2913d Binary files /dev/null and b/doc/user/content/bts_spark/Market/market_view.png differ diff --git a/doc/user/content/bts_spark/Market/settings_icon.png b/doc/user/content/bts_spark/Market/settings_icon.png new file mode 100644 index 000000000..dcb67378c Binary files /dev/null and b/doc/user/content/bts_spark/Market/settings_icon.png differ diff --git a/doc/user/content/bts_spark/Market/time_and_sales.png b/doc/user/content/bts_spark/Market/time_and_sales.png new file mode 100644 index 000000000..a694e13b8 Binary files /dev/null and b/doc/user/content/bts_spark/Market/time_and_sales.png differ diff --git a/doc/user/content/bts_spark/Trading/algo_studio.png b/doc/user/content/bts_spark/Trading/algo_studio.png new file mode 100644 index 000000000..d0a3cec77 Binary files /dev/null and b/doc/user/content/bts_spark/Trading/algo_studio.png differ diff --git a/doc/user/content/bts_spark/Trading/collapse_all_icon.png b/doc/user/content/bts_spark/Trading/collapse_all_icon.png new file mode 100644 index 000000000..99822a59a Binary files /dev/null and b/doc/user/content/bts_spark/Trading/collapse_all_icon.png differ diff --git a/doc/user/content/bts_spark/Trading/cover_algo_control.png b/doc/user/content/bts_spark/Trading/cover_algo_control.png new file mode 100644 index 000000000..0dbd56a2a Binary files /dev/null and b/doc/user/content/bts_spark/Trading/cover_algo_control.png differ diff --git a/doc/user/content/bts_spark/Trading/expand_all_icon.png b/doc/user/content/bts_spark/Trading/expand_all_icon.png new file mode 100644 index 000000000..e6f78b364 Binary files /dev/null and b/doc/user/content/bts_spark/Trading/expand_all_icon.png differ diff --git a/doc/user/content/bts_spark/Trading/image22.png b/doc/user/content/bts_spark/Trading/image22.png deleted file mode 100644 index 2bedca75b..000000000 Binary files a/doc/user/content/bts_spark/Trading/image22.png and /dev/null differ diff --git a/doc/user/content/bts_spark/Trading/image26.png b/doc/user/content/bts_spark/Trading/image26.png deleted file mode 100644 index cab2ea751..000000000 Binary files a/doc/user/content/bts_spark/Trading/image26.png and /dev/null differ diff --git a/doc/user/content/bts_spark/Trading/image36.png b/doc/user/content/bts_spark/Trading/image36.png deleted file mode 100644 index 9df552211..000000000 Binary files a/doc/user/content/bts_spark/Trading/image36.png and /dev/null differ diff --git a/doc/user/content/bts_spark/Trading/image4.png b/doc/user/content/bts_spark/Trading/image4.png deleted file mode 100644 index 2f271a2c3..000000000 Binary files a/doc/user/content/bts_spark/Trading/image4.png and /dev/null differ diff --git a/doc/user/content/bts_spark/Trading/image41.png b/doc/user/content/bts_spark/Trading/image41.png deleted file mode 100644 index d61b84d3b..000000000 Binary files a/doc/user/content/bts_spark/Trading/image41.png and /dev/null differ diff --git a/doc/user/content/bts_spark/Trading/image46.png b/doc/user/content/bts_spark/Trading/image46.png deleted file mode 100644 index 1c4c3631c..000000000 Binary files a/doc/user/content/bts_spark/Trading/image46.png and /dev/null differ diff --git a/doc/user/content/bts_spark/Trading/image65.png b/doc/user/content/bts_spark/Trading/image65.png deleted file mode 100644 index 115c29682..000000000 Binary files a/doc/user/content/bts_spark/Trading/image65.png and /dev/null differ diff --git a/doc/user/content/bts_spark/Trading/image67.png b/doc/user/content/bts_spark/Trading/image67.png deleted file mode 100644 index 82e9c8d3b..000000000 Binary files a/doc/user/content/bts_spark/Trading/image67.png and /dev/null differ diff --git a/doc/user/content/bts_spark/Trading/image71.png b/doc/user/content/bts_spark/Trading/image71.png deleted file mode 100644 index b8ee988bd..000000000 Binary files a/doc/user/content/bts_spark/Trading/image71.png and /dev/null differ diff --git a/doc/user/content/bts_spark/Trading/index.md b/doc/user/content/bts_spark/Trading/index.md index ff4a81081..bdca5dc4b 100644 --- a/doc/user/content/bts_spark/Trading/index.md +++ b/doc/user/content/bts_spark/Trading/index.md @@ -59,7 +59,7 @@ insert_anchor_links = "right" functionality to quickly perform various tasks with live orders as well as launch other modules.  It appears like the below: -- ![](image4.png) + ![](spark_menu_order_book.png) - ![](image48.png)Fills - clicking on this will launch a fills window @@ -79,6 +79,18 @@ insert_anchor_links = "right" - ![](image2.png)Cancel all - clicking on this will cancel all working orders you have the order book + - ![](recreate_icon.png) Recreate - clicking this will recreate already cancelled orders, sending them back to market with the same price and quantity as they were previously at before being cancelled. + - ![](collapse_all_icon.png) Collapse all - This will collapse all trees inside the order book to show only the top level of the order. + - ![](expand_all_icon.png) Expand all - This will expand to show everything inside the order book. + - ![](settings_icon.png) Settings - This launches the settings for the orderbook. + - Furthermore, there is a “floating” or “mini orderbook” feature as well + integrated within the ladder itself. + - To access this, you need to center click with your mouse wheel over + working orders on the ladder. + - From here, you can change the price and quantity of any working order + within the mini orderbook straight from the window + - This looks like below: + ![](mini_orderbook.png) ## Fills @@ -89,6 +101,8 @@ insert_anchor_links = "right" like - All fill windows are brought up as tabs and can be combined with all other windows within BTS +- There is also a settings button in the left hand tab which can be + launched to customize the fills window ## P&L @@ -104,10 +118,20 @@ insert_anchor_links = "right" other windows within BTS - All columns are sortable and either searchable or can be further filtered by entering in min and max values. -- Below is an example P&L window showing a user’s multiple accounts - and various positions in each: +- There is also a settings button in the left hand tab which can be + launched to customize the P&L window +- In regards to the PnL specifically, you can choose how you want the + PnL calculated based on Last, MidPoint, or Settle price. +- This is accomplished on the top bar, which when clicked on, displays + the choices for calculation, this appears like below: -![](image67.png) + ![](pnl_calculation.png) + + +- Below is an example P&L window showing a user’s multiple accounts and + various positions in each: + +![](pnl_window.png) ## Ladder @@ -125,7 +149,7 @@ insert_anchor_links = "right" market with a single click - Below is an example ladder: -![](image36.png) +![](ladder.png) - The ladder consists of 2 major parts, the Ladder itself and the information and control section on the left-hand side @@ -213,37 +237,59 @@ insert_anchor_links = "right"           ![](image50.png) - - Lean - - - This is a specialized algo order which allows the user to + - Lean + - This is a specialized algo order which allows the user to essentially watch the opposite-inside market size and cross when that size goes below the threshold defined. - - “Crossing” means to take an order working on the bid and 'cross' by - buying into the asks.  This is often referred to as “paying up” as - well + - “Cross” means to take an order working on the bid and 'cross' by + buying into the asks.  This is often referred to as “paying up” as well - ![](image22.png?v2) + ![](lean_algo_control.png) - - Join - - - This is a specialized algo order which allows the user to enter an + - Join + - This is a specialized algo order which allows the user to enter an order which will watch the opposite-inside market and join when the market flips and has at least threshold size as defined. - - “Flip” refers to the event where the best offer becomes the best - bid or the market trades away from you, i.e. the line moves up in - the GUI.  The reverse is true if selling. - ![](image41.png) + ![](join_algo_control.png) - - Top - - - This is a specialized algo order which allows the user to + - Top + - This is a specialized algo order which allows the user to essentially not trade by themselves - - If the order is on the market (current bid price) and the quantity + - If the order is on the market (current bid price) and the quantity on that bid price is below the top threshold defined the order will cancel and do nothing else + ![](top_algo_control.png) -![](image26.png) + - Offset + + - The goal of the offset order is to send your order X amount of ticks + from where you actually place it on the ladder. This is sometimes + known as a "fat finger" safety. + ![](offset_algo_control.png) + + - OCO + + - An OCO order creates a relationship between a child order and a 'stop' + or 'other' order such that when one of these is cancelled, both cancel, + or when one is filled, the other order's size is debited in the amount + of the fill. Composing this order with Cover simulates scalping + functionality. + + ![](oco_algo_control.png) + + - Cover + + - A Cover order’s purpose is to fire a hedge order (of any algo-type) in response to fills from it’s child order on the opposite side of the market N ticks away. + + ![](cover_algo_control.png) + + - Trigger + + - The Trigger order is exactly as it sounds, where it will trigger an order based on conditions defined. + - This order also has exit strategy built in where a user can define when the trigger order can auto-cancel based on time as well as price conditional. + + ![](trigger_algo_control.png) - The middle of the control section is where you can click on predefined values to quickly populate the volume at which you wish @@ -264,20 +310,36 @@ insert_anchor_links = "right" -  The bottom section of the control area of a ladder has 4 aspects to it - - Cancel Buys, which will cancel all buys currently working on the - ladder - - Cancel Sells, which will cancel all sells currently working on the - ladder - - Cancel All, which will cancel all orders on the ladder - - Settings, which will launch the ladder settings window which - appears like below + - Cancel Buys, which will cancel all buys currently working on the + ladder + - Cancel Sells, which will cancel all sells currently working on the + ladder + - Cancel All, which will cancel all orders on the ladder + - Settings, which will launch the ladder settings window which + appears like below + ![](ladder_settings.png) + - Fonts and Colors - This is where you can customize the overall main + aspects of the ladder. + - Market Break Lines - These are where can control the viewing of what + has been traded through various shading. + - Market Size Display - This is where you can define if you wish + to see implieds or not and how exactly you would like to see them. + - Volume Display - Where you can choose to show the volume traded at price + graph and what details you would like to see. + - Size Presets - Here you can define what volume of predefined quick buttons + you would like to see or any at all. You can remove these by clicking on the “X” next to the volume number to remove one or many. + - Algo Favorites - Here you can set up which “quick button” or user defined + algos to see. You can customize the amount of columns to be + displayed as well. + - Left Panel - This is where you can remove predefined information on the + left panel to save room and get rid of data that you might not require + to see. -![](image71.png) - The other, main part of the ladder, is the ladder itself as displayed below -![](image65.png) +![](ladder_main_part.png) - There are 5 main columns @@ -291,14 +353,10 @@ insert_anchor_links = "right" where the last trade occurred - Functionality of the ladder + - To enter an order directly by clicking in the ladder, left click on either the bid or ask volume with a volume greater than 0 on the predefined value box on the left-hand section + - A badge will be displayed within the orders column of the value you have chosen and the quantity filled as displayed below - - To enter an order directly by clicking in the ladder, left click on - either the bid or ask volume with a volume greater than 0 on the - predefined value box on the left-hand section - - A badge will be displayed within the orders column of the value you - have chosen and the quantity filled as displayed below - -![](image46.png) + ![](ladder_badges.png) - To change the price level you wish to work the order, you can right-click and hold on the badge to move it up or down the ladder for the desired price @@ -344,3 +402,42 @@ insert_anchor_links = "right" - Please note you can also launch the required parameters for algo or synthetic orders by clicking on the right arrow next to the algo or synthetic + + +## Algo Studio + +- The BTS Algo Studio was built for users to experience algo composability + never seen before in a professional futures trading system. + +- There is no limit for putting both “canned algos” already present in the + system as well as user defined algos fed into the system via the API. + +- This is all in place in a very user friendly GUI as shown below: + +![](algo_studio.png) + + +- There are 3 main areas of the Algo Studio: + - Left Pane (from top to bottom) + - Add Algo + - Clone Algo + - Save Algo + - Remove Algo + - Middle Pane + - This is where your customized algo will be displayed in a running list + - Right Pane + - This is where your complete customization happens of combining various + algos together and saving them to fit your exact needs + - On the very top are the name and abbreviation boxes + - For the name you can simply name the algo whatever you would like + - For the abbreviation section (which is optional), you can put in an + abbreviated name for the algo which will be displayed on the Algo + buttons on the ladder. (Example - Algo name = PROFIT_OCO_LEAN, + Abbrev. = POL) + + + + + + + diff --git a/doc/user/content/bts_spark/Trading/join_algo_control.png b/doc/user/content/bts_spark/Trading/join_algo_control.png new file mode 100644 index 000000000..dff01f9f3 Binary files /dev/null and b/doc/user/content/bts_spark/Trading/join_algo_control.png differ diff --git a/doc/user/content/bts_spark/Trading/ladder.png b/doc/user/content/bts_spark/Trading/ladder.png new file mode 100644 index 000000000..db8dc3c71 Binary files /dev/null and b/doc/user/content/bts_spark/Trading/ladder.png differ diff --git a/doc/user/content/bts_spark/Trading/ladder_badges.png b/doc/user/content/bts_spark/Trading/ladder_badges.png new file mode 100644 index 000000000..6d80819dd Binary files /dev/null and b/doc/user/content/bts_spark/Trading/ladder_badges.png differ diff --git a/doc/user/content/bts_spark/Trading/ladder_main_part.png b/doc/user/content/bts_spark/Trading/ladder_main_part.png new file mode 100644 index 000000000..3df3f9d04 Binary files /dev/null and b/doc/user/content/bts_spark/Trading/ladder_main_part.png differ diff --git a/doc/user/content/bts_spark/Trading/ladder_settings.PNG b/doc/user/content/bts_spark/Trading/ladder_settings.PNG new file mode 100644 index 000000000..bb15cc7d9 Binary files /dev/null and b/doc/user/content/bts_spark/Trading/ladder_settings.PNG differ diff --git a/doc/user/content/bts_spark/Trading/lean_algo_control.png b/doc/user/content/bts_spark/Trading/lean_algo_control.png new file mode 100644 index 000000000..0fea03d47 Binary files /dev/null and b/doc/user/content/bts_spark/Trading/lean_algo_control.png differ diff --git a/doc/user/content/bts_spark/Trading/mini_orderbook.png b/doc/user/content/bts_spark/Trading/mini_orderbook.png new file mode 100644 index 000000000..da865c5a0 Binary files /dev/null and b/doc/user/content/bts_spark/Trading/mini_orderbook.png differ diff --git a/doc/user/content/bts_spark/Trading/oco_algo_control.png b/doc/user/content/bts_spark/Trading/oco_algo_control.png new file mode 100644 index 000000000..0513f729a Binary files /dev/null and b/doc/user/content/bts_spark/Trading/oco_algo_control.png differ diff --git a/doc/user/content/bts_spark/Trading/offset_algo_control.png b/doc/user/content/bts_spark/Trading/offset_algo_control.png new file mode 100644 index 000000000..f1ff7ab7f Binary files /dev/null and b/doc/user/content/bts_spark/Trading/offset_algo_control.png differ diff --git a/doc/user/content/bts_spark/Trading/pnl_calculation.png b/doc/user/content/bts_spark/Trading/pnl_calculation.png new file mode 100644 index 000000000..2be46e4f8 Binary files /dev/null and b/doc/user/content/bts_spark/Trading/pnl_calculation.png differ diff --git a/doc/user/content/bts_spark/Trading/pnl_window.png b/doc/user/content/bts_spark/Trading/pnl_window.png new file mode 100644 index 000000000..2eef9a6f5 Binary files /dev/null and b/doc/user/content/bts_spark/Trading/pnl_window.png differ diff --git a/doc/user/content/bts_spark/Trading/recreate_icon.png b/doc/user/content/bts_spark/Trading/recreate_icon.png new file mode 100644 index 000000000..f39aa4729 Binary files /dev/null and b/doc/user/content/bts_spark/Trading/recreate_icon.png differ diff --git a/doc/user/content/bts_spark/Trading/settings_icon.png b/doc/user/content/bts_spark/Trading/settings_icon.png new file mode 100644 index 000000000..dcb67378c Binary files /dev/null and b/doc/user/content/bts_spark/Trading/settings_icon.png differ diff --git a/doc/user/content/bts_spark/Trading/spark_menu_order_book.png b/doc/user/content/bts_spark/Trading/spark_menu_order_book.png new file mode 100644 index 000000000..d8f425044 Binary files /dev/null and b/doc/user/content/bts_spark/Trading/spark_menu_order_book.png differ diff --git a/doc/user/content/bts_spark/Trading/top_algo_control.png b/doc/user/content/bts_spark/Trading/top_algo_control.png new file mode 100644 index 000000000..4fb10d1e1 Binary files /dev/null and b/doc/user/content/bts_spark/Trading/top_algo_control.png differ diff --git a/doc/user/content/bts_spark/Trading/trigger_algo_control.png b/doc/user/content/bts_spark/Trading/trigger_algo_control.png new file mode 100644 index 000000000..5e9da4f94 Binary files /dev/null and b/doc/user/content/bts_spark/Trading/trigger_algo_control.png differ diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 45c69c4ce..d8d3199cd 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -4,6 +4,31 @@ weight = 3 sort_by = "weight" insert_anchor_links = "right" +++ +## 1.5.6 +### User Visible Changes + - Fixed a bug that could cause limits to be erroneously enforced + - Improved algo documentation + - Changed how the spreader uses net change + - Simplified trigger algo user interface +### Internal changes + - Defaulted to not recording sim market data + - Improved documentation build + - Added additional performance tracing + +## 1.5.5 + - Fixed Market View 'stale working orders' bug + +## 1.5.4 + - Avoided logging when warming up cache + +## 1.5.3 + - Fixed sounds startup issue + +## 1.5.2 + - Added better logging to AlgoDefinitionService + +## 1.5.1 + - Fixed missing securities in the Fills and P&L windows. ## 1.5.0 ### User Visible Changes diff --git a/doc/user/static/book.js b/doc/user/static/book.js index 8e4fc100e..59345ada8 100644 --- a/doc/user/static/book.js +++ b/doc/user/static/book.js @@ -1,223 +1,197 @@ -function initToggleMenu() { - var $menu = document.querySelector(".menu"); - var $menuIcon = document.querySelector(".menu-icon"); - var $page = document.querySelector(".page"); - $menuIcon.addEventListener("click", function() { - $menu.classList.toggle("menu-hidden"); - $page.classList.toggle("page-without-menu"); - }); -} - -function debounce(func, wait) { - var timeout; - - return function () { - var context = this; - var args = arguments; - clearTimeout(timeout); - - timeout = setTimeout(function () { - timeout = null; - func.apply(context, args); - }, wait); - }; -} - -// Taken from mdbook -// The strategy is as follows: -// First, assign a value to each word in the document: -// Words that correspond to search terms (stemmer aware): 40 -// Normal words: 2 -// First word in a sentence: 8 -// Then use a sliding window with a constant number of words and count the -// sum of the values of the words within the window. Then use the window that got the -// maximum sum. If there are multiple maximas, then get the last one. -// Enclose the terms in . -function makeTeaser(body, terms) { - var TERM_WEIGHT = 40; - var NORMAL_WORD_WEIGHT = 2; - var FIRST_WORD_WEIGHT = 8; - var TEASER_MAX_WORDS = 30; - - var stemmedTerms = terms.map(function (w) { - return elasticlunr.stemmer(w.toLowerCase()); - }); - var termFound = false; - var index = 0; - var weighted = []; // contains elements of ["word", weight, index_in_document] - - // split in sentences, then words - var sentences = body.toLowerCase().split(". "); - - for (var i in sentences) { - var words = sentences[i].split(" "); - var value = FIRST_WORD_WEIGHT; - - for (var j in words) { - var word = words[j]; - - if (word.length > 0) { - for (var k in stemmedTerms) { - if (elasticlunr.stemmer(word).startsWith(stemmedTerms[k])) { - value = TERM_WEIGHT; - termFound = true; - } - } - weighted.push([word, value, index]); - value = NORMAL_WORD_WEIGHT; - } - - index += word.length; - index += 1; // ' ' or '.' if last word in sentence - } - - index += 1; // because we split at a two-char boundary '. ' - } - - if (weighted.length === 0) { - return body; - } - - var windowWeights = []; - var windowSize = Math.min(weighted.length, TEASER_MAX_WORDS); - // We add a window with all the weights first - var curSum = 0; - for (var i = 0; i < windowSize; i++) { - curSum += weighted[i][1]; - } - windowWeights.push(curSum); - - for (var i = 0; i < weighted.length - windowSize; i++) { - curSum -= weighted[i][1]; - curSum += weighted[i + windowSize][1]; - windowWeights.push(curSum); - } - - // If we didn't find the term, just pick the first window - var maxSumIndex = 0; - if (termFound) { - var maxFound = 0; - // backwards - for (var i = windowWeights.length - 1; i >= 0; i--) { - if (windowWeights[i] > maxFound) { - maxFound = windowWeights[i]; - maxSumIndex = i; - } - } - } - - var teaser = []; - var startIndex = weighted[maxSumIndex][2]; - for (var i = maxSumIndex; i < maxSumIndex + windowSize; i++) { - var word = weighted[i]; - if (startIndex < word[2]) { - // missing text from index to start of `word` - teaser.push(body.substring(startIndex, word[2])); - startIndex = word[2]; - } - - // add around search terms - if (word[1] === TERM_WEIGHT) { - teaser.push(""); - } - startIndex = word[2] + word[0].length; - teaser.push(body.substring(word[2], startIndex)); - - if (word[1] === TERM_WEIGHT) { - teaser.push(""); - } - } - teaser.push("…"); - return teaser.join(""); -} - -function formatSearchResultItem(item, terms) { - var li = document.createElement("li"); - li.classList.add("search-results__item"); - li.innerHTML = `${item.doc.title}`; - li.innerHTML += `
${makeTeaser(item.doc.body, terms)}
`; - return li; -} - -// Go from the book view to the search view -function toggleSearchMode() { - var $bookContent = document.querySelector(".book-content"); - var $searchContainer = document.querySelector(".search-container"); - if ($searchContainer.classList.contains("search-container--is-visible")) { - $searchContainer.classList.remove("search-container--is-visible"); - document.body.classList.remove("search-mode"); - $bookContent.style.display = "block"; - } else { - $searchContainer.classList.add("search-container--is-visible"); - document.body.classList.add("search-mode"); - $bookContent.style.display = "none"; - document.getElementById("search").focus(); - } -} - -function initSearch() { - var $searchInput = document.getElementById("search"); - if (!$searchInput) { - return; - } - var $searchIcon = document.querySelector(".search-icon"); - $searchIcon.addEventListener("click", toggleSearchMode); - - var $searchResults = document.querySelector(".search-results"); - var $searchResultsHeader = document.querySelector(".search-results__header"); - var $searchResultsItems = document.querySelector(".search-results__items"); - var MAX_ITEMS = 10; - - var options = { - bool: "AND", - fields: { - title: {boost: 2}, - body: {boost: 1}, - } - }; - var currentTerm = ""; - var index = elasticlunr.Index.load(window.searchIndex); - - $searchInput.addEventListener("keyup", debounce(function() { - var term = $searchInput.value.trim(); - if (term === currentTerm || !index) { - return; - } - $searchResults.style.display = term === "" ? "none" : "block"; - $searchResultsItems.innerHTML = ""; - if (term === "") { - return; - } - - var results = index.search(term, options).filter(function (r) { - return r.doc.body !== ""; - }); - if (results.length === 0) { - $searchResultsHeader.innerText = `No search results for '${term}'.`; - return; - } - - currentTerm = term; - $searchResultsHeader.innerText = `${results.length} search results for '${term}':`; - for (var i = 0; i < Math.min(results.length, MAX_ITEMS); i++) { - if (!results[i].doc.body) { - continue; - } - // var item = document.createElement("li"); - // item.innerHTML = formatSearchResultItem(results[i], term.split(" ")); - console.log(results[i]); - $searchResultsItems.appendChild(formatSearchResultItem(results[i], term.split(" "))); - } - }, 150)); -} - -if (document.readyState === "complete" || - (document.readyState !== "loading" && !document.documentElement.doScroll) -) { - initToggleMenu(); -} else { - document.addEventListener("DOMContentLoaded", function () { - initToggleMenu(); - initSearch(); - }); -} +function initToggleMenu() { + var $menu = document.querySelector(".menu"); + var $menuIcon = document.querySelector(".menu-icon"); + var $page = document.querySelector(".page"); + $menuIcon.addEventListener("click", function () { + $menu.classList.toggle("menu-hidden"); + $page.classList.toggle("page-without-menu"); + }); +} +function debounce(func, wait) { + var timeout; + return function () { + var context = this; + var args = arguments; + clearTimeout(timeout); + timeout = setTimeout(function () { + timeout = null; + func.apply(context, args); + }, wait); + }; +} +// Taken from mdbook +// The strategy is as follows: +// First, assign a value to each word in the document: +// Words that correspond to search terms (stemmer aware): 40 +// Normal words: 2 +// First word in a sentence: 8 +// Then use a sliding window with a constant number of words and count the +// sum of the values of the words within the window. Then use the window that got the +// maximum sum. If there are multiple maximas, then get the last one. +// Enclose the terms in . +function makeTeaser(body, terms) { + var TERM_WEIGHT = 40; + var NORMAL_WORD_WEIGHT = 2; + var FIRST_WORD_WEIGHT = 8; + var TEASER_MAX_WORDS = 30; + var stemmedTerms = terms.map(function (w) { + return elasticlunr.stemmer(w.toLowerCase()); + }); + var termFound = false; + var index = 0; + var weighted = []; // contains elements of ["word", weight, index_in_document] + // split in sentences, then words + var sentences = body.toLowerCase().split(". "); + for (var i in sentences) { + var words = sentences[i].split(" "); + var value = FIRST_WORD_WEIGHT; + for (var j in words) { + var word = words[j]; + if (word.length > 0) { + for (var k in stemmedTerms) { + if (elasticlunr.stemmer(word).startsWith(stemmedTerms[k])) { + value = TERM_WEIGHT; + termFound = true; + } + } + weighted.push([word, value, index]); + value = NORMAL_WORD_WEIGHT; + } + index += word.length; + index += 1; // ' ' or '.' if last word in sentence + } + index += 1; // because we split at a two-char boundary '. ' + } + if (weighted.length === 0) { + return body; + } + var windowWeights = []; + var windowSize = Math.min(weighted.length, TEASER_MAX_WORDS); + // We add a window with all the weights first + var curSum = 0; + for (var i = 0; i < windowSize; i++) { + curSum += weighted[i][1]; + } + windowWeights.push(curSum); + for (var i = 0; i < weighted.length - windowSize; i++) { + curSum -= weighted[i][1]; + curSum += weighted[i + windowSize][1]; + windowWeights.push(curSum); + } + // If we didn't find the term, just pick the first window + var maxSumIndex = 0; + if (termFound) { + var maxFound = 0; + // backwards + for (var i = windowWeights.length - 1; i >= 0; i--) { + if (windowWeights[i] > maxFound) { + maxFound = windowWeights[i]; + maxSumIndex = i; + } + } + } + var teaser = []; + var startIndex = weighted[maxSumIndex][2]; + for (var i = maxSumIndex; i < maxSumIndex + windowSize; i++) { + var word = weighted[i]; + if (startIndex < word[2]) { + // missing text from index to start of `word` + teaser.push(body.substring(startIndex, word[2])); + startIndex = word[2]; + } + // add around search terms + if (word[1] === TERM_WEIGHT) { + teaser.push(""); + } + startIndex = word[2] + word[0].length; + teaser.push(body.substring(word[2], startIndex)); + if (word[1] === TERM_WEIGHT) { + teaser.push(""); + } + } + teaser.push("…"); + return teaser.join(""); +} +function formatSearchResultItem(item, terms) { + var li = document.createElement("li"); + li.classList.add("search-results__item"); + li.innerHTML = "" + item.doc.title + ""; + li.innerHTML += "
" + makeTeaser(item.doc.body, terms) + "
"; + return li; +} +// Go from the book view to the search view +function toggleSearchMode() { + var $bookContent = document.querySelector(".book-content"); + var $searchContainer = document.querySelector(".search-container"); + if ($searchContainer.classList.contains("search-container--is-visible")) { + $searchContainer.classList.remove("search-container--is-visible"); + document.body.classList.remove("search-mode"); + $bookContent.style.display = "block"; + } + else { + $searchContainer.classList.add("search-container--is-visible"); + document.body.classList.add("search-mode"); + $bookContent.style.display = "none"; + document.getElementById("search").focus(); + } +} +function initSearch() { + var $searchInput = document.getElementById("search"); + if (!$searchInput) { + return; + } + var $searchIcon = document.querySelector(".search-icon"); + $searchIcon.addEventListener("click", toggleSearchMode); + var $searchResults = document.querySelector(".search-results"); + var $searchResultsHeader = document.querySelector(".search-results__header"); + var $searchResultsItems = document.querySelector(".search-results__items"); + var MAX_ITEMS = 10; + var options = { + bool: "AND", + fields: { + title: { boost: 2 }, + body: { boost: 1 } + } + }; + var currentTerm = ""; + var index = elasticlunr.Index.load(window.searchIndex); + $searchInput.addEventListener("keyup", debounce(function () { + var term = $searchInput.value.trim(); + if (term === currentTerm || !index) { + return; + } + $searchResults.style.display = term === "" ? "none" : "block"; + $searchResultsItems.innerHTML = ""; + if (term === "") { + return; + } + var results = index.search(term, options).filter(function (r) { + return r.doc.body !== ""; + }); + if (results.length === 0) { + $searchResultsHeader.innerText = "No search results for '" + term + "'."; + return; + } + currentTerm = term; + $searchResultsHeader.innerText = results.length + " search results for '" + term + "':"; + for (var i = 0; i < Math.min(results.length, MAX_ITEMS); i++) { + if (!results[i].doc.body) { + continue; + } + // var item = document.createElement("li"); + // item.innerHTML = formatSearchResultItem(results[i], term.split(" ")); + console.log(results[i]); + $searchResultsItems.appendChild(formatSearchResultItem(results[i], term.split(" "))); + } + }, 150)); +} +if (document.readyState === "complete" || + (document.readyState !== "loading" && !document.documentElement.doScroll)) { + initToggleMenu(); +} +else { + document.addEventListener("DOMContentLoaded", function () { + initToggleMenu(); + initSearch(); + }); +} diff --git a/doc/user/static/image.js b/doc/user/static/image.js index db3e85f52..ab70803eb 100644 --- a/doc/user/static/image.js +++ b/doc/user/static/image.js @@ -8,5 +8,10 @@ $(document).ready(function() { $(".back-button") .html("Go Back") - .click(_ => window.history.back()); + .click(function(_) { window.history.back()}); + + if(navigator.userAgent.indexOf("Trident") > -1) { + console.log(navigator.userAgent); + $(".search-icon").css("display", "none"); + } }); diff --git a/docker/linux b/docker/linux index 8d82558f9..ce08a5129 160000 --- a/docker/linux +++ b/docker/linux @@ -1 +1 @@ -Subproject commit 8d82558f9015a699c3baf88e2490b4ac6efcb83e +Subproject commit ce08a5129f14af0d1bb9fa569d1e721b694964fe diff --git a/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml index d846f422e..fc8977181 100644 --- a/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml +++ b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml @@ -20,6 +20,8 @@ 16 -16 15 + 6 + - + @@ -369,16 +371,21 @@ - + + + - - Name @@ -390,18 +397,22 @@ - Pricing + Pricing @@ -409,7 +420,7 @@ - + (SyntheticContract.Types.PriceCalc)GetValue(PriceCalcProperty); set => SetValue(PriceCalcProperty, value); } public static readonly IEnumerable PriceCalcItems = EnumHelper.get_values(); @@ -315,7 +315,6 @@ namespace mbts.ui.spark { else if (t == typeof(uint)) return UIntTemplate; else if (t == typeof(QuantityMeasure)) return QuantityMeasureTemplate; else if (t == typeof(LegSpreaderParams.Types.MarketDataType)) return MarketDataTypeTemplate; - else if (t == typeof(LegSpreaderParams.Types.LegMarketDataCalculation)) return MarketDataCalculationTemplate; else if (t == typeof(ConditionalQuoting.Types.PriceType)) return ConditionalPriceTypeTemplate; else return null; } diff --git a/src/client/spark/Modules/Spreader/VM/ParameterRows/Leg/MarketDataCalculationModel.cs b/src/client/spark/Modules/Spreader/VM/ParameterRows/Leg/MarketDataCalculationModel.cs deleted file mode 100644 index f526589a3..000000000 --- a/src/client/spark/Modules/Spreader/VM/ParameterRows/Leg/MarketDataCalculationModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -using mbts.ui.spark; -using LegMarketDataCalculation = bts.spark.LegSpreaderParams.Types.LegMarketDataCalculation; - -namespace mbts.spark { - partial class SyntheticEditorVM { - class MarketDataCalculationModel : RowModelBase { - public override string display_name { get; } = "Market Data Calculation"; - public override string help_text { get; } - public override string man_page { get; } = string.Empty; - - public override LegMarketDataCalculation get_value(LegSpreaderParamsTuple leg_tup) => - leg_tup.leg_params.LegMdCalc; - - public override void set_value(LegSpreaderParamsTuple leg_tup, LegMarketDataCalculation value) => - leg_tup.leg_params.LegMdCalc = value; - } - } -} \ No newline at end of file diff --git a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs index 35af6e260..8e0449b8f 100644 --- a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs +++ b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs @@ -26,6 +26,7 @@ namespace mbts.spark { readonly PriceMultiplierModel _price_mult_model; readonly List _resources = new List(); readonly Property _has_working_orders, _can_add_leg; + Security _synthetic; bool _set_name_automatically, _set_ticks_automatically, _set_quantities_automatically, _set_price_mults_automatically, _is_setting_quantities, _is_setting_price_mults; TickFactors _tick_factors; @@ -207,7 +208,6 @@ namespace mbts.spark { //new MinLeanQtyModel(), //TAHA_SPREADER //new QuoteHiddenModel(), new MarketDataTypeModel(), - new MarketDataCalculationModel(), new QuoteThrottleEnabledModel(quote_throttle_inside_ticks, quote_throttle_outside_ticks), quote_throttle_inside_ticks, quote_throttle_outside_ticks, @@ -291,7 +291,9 @@ namespace mbts.spark { public ExecutionStrategyImmutable get_strategy() { var mutable_strategy = _strategy.CloneToMutable(); mutable_strategy.LegParamsMap.Clear(); - foreach (var lt in leg_tuples) mutable_strategy.LegParamsMap.Add(lt.leg.Security.Id, lt.leg_params); + foreach (var lt in leg_tuples) { + mutable_strategy.LegParamsMap.Add(lt.leg.Security.Id, lt.leg_params); + } return new ExecutionStrategyImmutable(mutable_strategy); } diff --git a/src/client/spark/Modules/Trading/AlgoStudio/Model/AlgoData.cs b/src/client/spark/Modules/Trading/AlgoStudio/Model/AlgoData.cs index 50ad47fe2..58f92670c 100644 --- a/src/client/spark/Modules/Trading/AlgoStudio/Model/AlgoData.cs +++ b/src/client/spark/Modules/Trading/AlgoStudio/Model/AlgoData.cs @@ -10,7 +10,7 @@ namespace mbts.spark { public readonly AlgoKey key; public AlgoData(CustomOrderDefinitionImmutable value) - : this(value, value.CustomCase.display_name(), new AlgoKey(value.CustomCase)) { } + : this(value, value.display_name(), OrderDataHelper.get_shallow_factory_key(value)) { } public AlgoData(CustomOrderDefinitionImmutable value, string name, AlgoKey key) { this.value = value; diff --git a/src/client/spark/Modules/Trading/AlgoStudio/Model/AlgoStructureKey.cs b/src/client/spark/Modules/Trading/AlgoStudio/Model/AlgoStructureKey.cs index fff917a91..fb2c0666e 100644 --- a/src/client/spark/Modules/Trading/AlgoStudio/Model/AlgoStructureKey.cs +++ b/src/client/spark/Modules/Trading/AlgoStudio/Model/AlgoStructureKey.cs @@ -72,7 +72,7 @@ namespace mbts.spark { _build_structure(definition.CloneToMutable(), ref structure, pos); static void _build_structure(CustomOrderDefinition algo, ref int[] structure, int pos) { - var cad = OrderDataHelper.get_child_algo_data(algo.CustomCase); + var cad = OrderDataHelper.get_child_algo_data(algo); for (int di = 0; di < cad.Count; di++) { if (cad[di].get_child(algo) is CustomOrderDefinition child_algo) { ArrayHelper.ensure_capacity(ref structure, pos + 1); @@ -87,7 +87,7 @@ namespace mbts.spark { static void _build_def(int[] structure, ref int pos, ref CustomOrderDefinition algo) { for (int i = pos; i < structure.Length; i++) { - var cad = OrderDataHelper.get_child_algo_data(algo.CustomCase); + var cad = OrderDataHelper.get_child_algo_data(algo); for (int di = 0; di < cad.Count; di++) { int mask = 1 << (31 - di); if ((structure[i] & mask) == mask) { @@ -95,10 +95,10 @@ namespace mbts.spark { var child_algo = OrderDataHelper.Defaults.CustomOrderDefinition(type); pos++; _build_def(structure, ref pos, ref child_algo); - cad[di].set_child(algo, child_algo); + cad[di].assign_child(algo, child_algo); } } } } } -} \ No newline at end of file +} diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs index 193e66887..d7e964708 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs @@ -105,19 +105,23 @@ namespace mbts.spark { } public void row_selection_changed(SelectionChangedEventArgs e) { - if (e.RemovedItems != null) { - foreach (var row_vm in e.RemovedItems.Cast()) { - row_vm.is_selected = false; + try { + if (e.RemovedItems != null) { + foreach (var row_vm in e.RemovedItems.Cast()) { + row_vm.is_selected = false; + } } - } - if (e.AddedItems != null) { - foreach (var row_vm in e.AddedItems.Cast()) { - row_vm.is_selected = true; + if (e.AddedItems != null) { + foreach (var row_vm in e.AddedItems.Cast()) { + row_vm.is_selected = true; + } } + RowSelectionHelper.apply_changes(_selected_rows, e); + selected_order_changed?.Invoke(current_order); + } catch (Exception ex) { + // [John]I observed a strange null-reference exception in this callback when the launcher was shutting down (see https://bluetradesys.atlassian.net/browse/SPARK-2089) + Log.Ui.error($"[{nameof(OrderBookVM)}] Error handling selection change: {ex}"); } - - RowSelectionHelper.apply_changes(_selected_rows, e); - selected_order_changed?.Invoke(current_order); } public OrderBookStartupData create() { diff --git a/src/client/spark/Notifications/INotificationService.cs b/src/client/spark/Notifications/INotificationService.cs index eb3823cc7..282fcd3ca 100644 --- a/src/client/spark/Notifications/INotificationService.cs +++ b/src/client/spark/Notifications/INotificationService.cs @@ -25,20 +25,28 @@ namespace bts.shell { } static class NotificationServiceExtensions { + /// TODO: remove this extension and force callers to use the appropriate 'link' method in (it is smelly, and is NOT ACTUALLY STRONGLY TYPED) public static IDisposable link(this INotificationService notification_service, IPredicate predicate, SoundNotification sound) { if (predicate is IPredicate orp) return notification_service.link_to_order(orp, sound); + if (predicate is IPredicate osp) { + // Note: watch out for implicit types as generic type arguments (although OrderSecurity can be implicitly cast to OrderTuple, IPredicate CANNOT be implicitly cast to IPredicate) + return notification_service.link_to_order(PredicateBuilder.create(ot => osp.trigger(new OrderSecurity(ot.Item1, ot.Item2))), sound); + } if (predicate is IPredicate ap) return notification_service.link_to_activity(ap, sound); - throw new ArgumentException(nameof(predicate)); + Log.Ui.error($"Unable to activate sound-trigger (unrecognized predicate type '{typeof(T)}')."); + return Disposable.empty; } + /// TODO: remove this extension and force callers to use the appropriate 'link' method in (it is smelly, and is NOT ACTUALLY STRONGLY TYPED) public static IDisposable link(this INotificationService notification_service, INotificationPredicate toast_notification_predicate) { if (toast_notification_predicate is INotificationPredicate orp) return notification_service.link_to_order(orp); if (toast_notification_predicate is INotificationPredicate ap) return notification_service.link_to_activity(ap); - throw new ArgumentException(nameof(toast_notification_predicate)); + Log.Ui.error($"Unable to activate toast-notification-trigger (unrecognized predicate type '{typeof(T)}')."); + return Disposable.empty; } } diff --git a/src/client/spark/Orders/FillTuple.cs b/src/client/spark/Orders/FillTuple.cs index a97d7ba05..7796eb586 100644 --- a/src/client/spark/Orders/FillTuple.cs +++ b/src/client/spark/Orders/FillTuple.cs @@ -13,11 +13,11 @@ namespace mbts.spark { public readonly AlgoData? algo; public readonly AlgoDefinitionMetadata? algo_meta; - public FillTuple(FillImmutable fill, OrderSecurityAlgoMeta? order_tuple) { - this.fill = fill; + public FillTuple((SecurityImmutable? sec, FillImmutable val) fill, OrderSecurityAlgoMeta? order_tuple) { + this.fill = fill.val; + this.security = fill.sec; if (order_tuple is OrderSecurityAlgoMeta osam) { order = osam.order; - security = osam.security; algo = osam.algo; algo_meta = osam.meta; } diff --git a/src/client/spark/Orders/OrderPropertiesEditorVM.cs b/src/client/spark/Orders/OrderPropertiesEditorVM.cs index 3aa4ab8a9..1848ad93c 100644 --- a/src/client/spark/Orders/OrderPropertiesEditorVM.cs +++ b/src/client/spark/Orders/OrderPropertiesEditorVM.cs @@ -346,7 +346,9 @@ namespace mbts.spark { _time_in_force.observe_current(start_immediately); public IObservable observe_order_type(bool start_immediately = false) => - _selected_algo_template.observe_current(start_immediately).Select(t => t.algo_root); + _model.algo_model.templates_enabled() ? + _selected_algo_template.observe_current(start_immediately).Select(t => t?.algo_root) : + _selected_algo_definition.observe_selected_item(start_immediately).Select(d => d?.algo_root); public OrderDefinition create(Side side) { if (HasErrors) diff --git a/src/client/spark/Orders/OrderTypeVMs/DynamicOrderHelper.cs b/src/client/spark/Orders/OrderTypeVMs/DynamicOrderHelper.cs index 298ccb345..308a29fbc 100644 --- a/src/client/spark/Orders/OrderTypeVMs/DynamicOrderHelper.cs +++ b/src/client/spark/Orders/OrderTypeVMs/DynamicOrderHelper.cs @@ -1,5 +1,8 @@ using bts.api; using bts.api.orderman; +using bts.utils; +using Google.Protobuf.Reflection; +using mbts.utils; using System; using System.Collections.Generic; using System.ComponentModel.Composition; @@ -10,6 +13,9 @@ namespace mbts.spark { [Export] public class DynamicOrderHelper { + static readonly IReadOnlyDictionary _descriptor_case_index = + ProtoHelper.get_oneof_descriptor_index(nameof(DynamicOrderParam.ValueCase)); + readonly RegisteredDynamicOrderTypes _dynamic_types; [ImportingConstructor] private DynamicOrderHelper(OrderService order_service) @@ -28,11 +34,47 @@ namespace mbts.spark { foreach(var p in d.ParamDesc) dorder.Dynamic.OrderParams.Add( p.ParamName, new DynamicOrderParam() ); defs.Add(new CustomOrderDefinitionImmutable(dorder)); - var de = get_descriptor(""); } } internal DynamicOrderDescriptor get_descriptor(string dynamic_type) => - _dynamic_types.DynamicOrderDesc.FirstOrDefault(d => d.DynamicOrderType == dynamic_type); + _dynamic_types.DynamicOrderDesc.FirstOrDefault(d => d.DynamicOrderType == dynamic_type) ?? new DynamicOrderDescriptor(); + + internal DynamicOrderDefinition create_def(string dynamic_type) { + var desc = get_descriptor(dynamic_type); + var def = new DynamicOrderDefinition(); + foreach (var p in desc.ParamDesc) { + if (_is_child_algo_desc(p)) { + def.OrderParams[p.ParamName] = new DynamicOrderParam { AsOrderDef = new CustomOrderDefinition() }; + } else if (_is_value_param_desc(p)) { + var value_case = _get_value_case(p.ParamType.Primitive); + if (_descriptor_case_index.TryGetValue(value_case, out (FieldDescriptor fd, Type type) tup)) { + var dop = new DynamicOrderParam(); + tup.fd.Accessor.SetValue(dop, ConvertUtils.get_default(tup.type)); + def.OrderParams[p.ParamName] = dop; + } + } + } + return def; + } + + static DynamicOrderParam.ValueOneofCase _get_value_case(DynamicOrderPrimitiveDescriptor primitive_descriptor_case) { + switch (primitive_descriptor_case) { + case DynamicOrderPrimitiveDescriptor.DynamicOrderPrimitiveBool: return DynamicOrderParam.ValueOneofCase.AsBool; + case DynamicOrderPrimitiveDescriptor.DynamicOrderPrimitiveDouble: return DynamicOrderParam.ValueOneofCase.AsBool; + case DynamicOrderPrimitiveDescriptor.DynamicOrderPrimitiveInt: return DynamicOrderParam.ValueOneofCase.AsInt32; + case DynamicOrderPrimitiveDescriptor.DynamicOrderPrimitiveUint: return DynamicOrderParam.ValueOneofCase.AsUint32; + case DynamicOrderPrimitiveDescriptor.DynamicOrderPrimitiveString: return DynamicOrderParam.ValueOneofCase.AsString; + default: throw ExceptionBuilder.Argument.unexpected_case(primitive_descriptor_case, nameof(primitive_descriptor_case)); + } + } + + static bool _is_child_algo_desc(DynamicOrderParamDescriptor desc) => + desc.ParamType.DescriptorCase == DynamicOrderTypeDescriptor.DescriptorOneofCase.Primitive && + desc.ParamType.Primitive == DynamicOrderPrimitiveDescriptor.DynamicOrderPrimitiveOrderDef; + + static bool _is_value_param_desc(DynamicOrderParamDescriptor desc) => + desc.ParamType.DescriptorCase == DynamicOrderTypeDescriptor.DescriptorOneofCase.Enumerated || + (desc.ParamType.DescriptorCase == DynamicOrderTypeDescriptor.DescriptorOneofCase.Primitive && desc.ParamType.Primitive != DynamicOrderPrimitiveDescriptor.DynamicOrderPrimitiveOrderDef); } -} \ No newline at end of file +} diff --git a/src/client/spark/Orders/OrderTypeVMs/DynamicOrderVM.cs b/src/client/spark/Orders/OrderTypeVMs/DynamicOrderVM.cs index 62cf4c644..f436e7906 100644 --- a/src/client/spark/Orders/OrderTypeVMs/DynamicOrderVM.cs +++ b/src/client/spark/Orders/OrderTypeVMs/DynamicOrderVM.cs @@ -1,28 +1,36 @@ using bts.api.orderman; using mbts.collections; -using mbts.ui; -using mbts.ui.shell; +using mbts.spark.utilities; using mbts.ui.utility; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; -using System.Threading.Tasks; +using System.Linq; +using System.Reactive.Linq; namespace mbts.spark { static partial class OrderTypeVMFactory { class DynamicOrderVM : OrderTypeVMBase { readonly ObservableKeyedCollection _parameters = new ObservableKeyedCollection(vm => vm.descriptor.ParamName); readonly Property _dyn_type; - OrdersModel _model; - bool _active; public DynamicOrderVM(AlgoKey key, string dyn_type, string display_name, AlgoEditingPermissions editing_permissions) : base(key, display_name, editing_permissions) { _dyn_type = add_property(nameof(this.dyn_type), DynamicOrderDefinition.DynamicOrderTypeFieldNumber, dyn_type); _parameters = new ObservableKeyedCollection(vm => vm.descriptor.ParamName); _resources.AddRange( - _dyn_type.Subscribe(_ => _reset_dynamic_types()), + _dyn_type.Subscribe(_ => { + _sync_dynamic_params(); + sync_selectors(); + }), + ObservableAutoWrapper.connect_item_hooks(_parameters.AsCollection(), pvm => { + add_property(pvm.descriptor.ParamName, mdef => mdef.OrderParams[pvm.descriptor.ParamName] = pvm.param, mdef => { + if (mdef.OrderParams.TryGetValue(pvm.descriptor.ParamName, out DynamicOrderParam p)) + pvm.param = p; + }); + return Disposable.Create(() => remove_property(pvm.descriptor.ParamName)); + }), ObservableAutoWrapper.connect_item_hooks(_parameters, p => { p.PropertyChanged += on_param_prop_changed; return Disposable.Create(() => p.PropertyChanged -= on_param_prop_changed); @@ -31,103 +39,26 @@ namespace mbts.spark { } public string dyn_type => _dyn_type.Value; - public ObservableCollection parameters { - get { - _ensure_init(); - return _parameters; + public ObservableCollection parameters => _parameters; + + protected override void on_model_internal() => + _sync_dynamic_params(); + + protected override IEnumerable get_selector_datum() => + OrderDataHelper.get_child_algo_data(new CustomOrderDefinition { + Dynamic = model?.dynamic_helper?.create_def(dyn_type) ?? new DynamicOrderDefinition() + }); + + void _sync_dynamic_params() { + if (model != null) { + var desc = model.dynamic_helper.get_descriptor(dyn_type); + _parameters.SyncWithDictionary(desc.ParamDesc.Where(_is_value_param_desc).ToDictionary(p => p.ParamName), DynamicOrderParamVM.create); } } - protected override void assign_to_internal(DynamicOrderDefinition dynamic_def) { - foreach (var vm in _parameters.Values) - dynamic_def.OrderParams[vm.descriptor.ParamName] = vm.param; - } - - protected override void load_from_internal(DynamicOrderDefinitionImmutable dyn_defi) { - foreach (var p in _parameters) { - if (dyn_defi.OrderParams.TryGetValue(p.descriptor.ParamName, out DynamicOrderParam dop)) { - p.param = dop; - } else { - p.param.ClearValue(); - } - } - } - - protected override async Task on_load_from_async(CustomOrderDefinitionImmutable defi) { - await Wait.until_true(() => _model != null, TimeSpan.FromSeconds(60)); - _ensure_init(); - } - - void _ensure_init() { - if (!_active) { - _active = true; - // lazy initialization is required to avoid a stack overflow (otherwise, the algo-hierarchy would grow recursively without stopping). - _reset_dynamic_types(); - } - } - protected override void on_model_internal(OrdersModel model) { - _model = model; - _reset_dynamic_types(); - } - - void _reset_dynamic_types() { - if (!_active) - return; - var value_descs = new Dictionary(); - var child_descs = new Dictionary(); - if (_model != null) { - var desc = _model.dynamic_helper.get_descriptor(dyn_type); - if (desc != null) { - foreach (var p in desc.ParamDesc) { - if (_is_value_param_desc(p)) { - value_descs[p.ParamName] = p; - } else if (_is_child_algo_desc(p)) { - child_descs[p.ParamName] = p; - } - } - } - } - _parameters.SyncWithDictionary(value_descs, DynamicOrderParamVM.create); - using (reset_selectors()) { - foreach (var kv in child_descs) { - add_selector(kv.Key, get_child, set_child); - // local methods - CustomOrderDefinitionImmutable? get_child(DynamicOrderDefinitionImmutable dyn_defi) { - if (dyn_defi.OrderParams.TryGetValue(kv.Key, out DynamicOrderParam p) && p.ValueCase == DynamicOrderParam.ValueOneofCase.AsOrderDef) - return new CustomOrderDefinitionImmutable(p.AsOrderDef); - return null; - } - void set_child(DynamicOrderDefinition dyn_def, CustomOrderDefinition child) => - dyn_def.OrderParams[kv.Key] = new DynamicOrderParam { AsOrderDef = child }; - } - } - } - - static bool _is_child_algo_desc(DynamicOrderParamDescriptor desc) => - desc.ParamType.DescriptorCase == DynamicOrderTypeDescriptor.DescriptorOneofCase.Primitive && - desc.ParamType.Primitive == DynamicOrderPrimitiveDescriptor.DynamicOrderPrimitiveOrderDef; - static bool _is_value_param_desc(DynamicOrderParamDescriptor desc) => desc.ParamType.DescriptorCase == DynamicOrderTypeDescriptor.DescriptorOneofCase.Enumerated || (desc.ParamType.DescriptorCase == DynamicOrderTypeDescriptor.DescriptorOneofCase.Primitive && desc.ParamType.Primitive != DynamicOrderPrimitiveDescriptor.DynamicOrderPrimitiveOrderDef); - - public class SelectorVM : ViewModelBase { - readonly IAlgoSelector _selector; - - public SelectorVM(IAlgoSelector selector) { - _selector = selector; - _selector.selected_algo_changed += _on_selected_algo_changed; - } - - public IAlgoVM selected_algo { get => _selector.selected_algo; set => _selector.selected_algo = value; } - public ObservableCollection algos => _selector.algos; - - public void Dispose() => - _selector.selected_algo_changed -= _on_selected_algo_changed; - - void _on_selected_algo_changed(IAlgoVM oldval, IAlgoVM newval) => - RaisePropertyChanged(nameof(selected_algo)); - } } } } diff --git a/src/client/spark/Orders/OrderTypeVMs/OrderTypeVMFactory.cs b/src/client/spark/Orders/OrderTypeVMs/OrderTypeVMFactory.cs index dd404cc99..3dfaea3de 100644 --- a/src/client/spark/Orders/OrderTypeVMs/OrderTypeVMFactory.cs +++ b/src/client/spark/Orders/OrderTypeVMs/OrderTypeVMFactory.cs @@ -113,11 +113,12 @@ namespace mbts.spark { readonly IDictionary _children_vm = new ExpandoObject(); protected CompositeDisposable _resources = new CompositeDisposable(); - readonly List<(Action assign, Action load)> _auto_props = new List<(Action assign, Action load)>(); + readonly ObservableKeyedCollection<(string name, Action assign, Action load), string> _auto_props = new ObservableKeyedCollection<(string name, Action assign, Action load), string>(t => t.name); readonly ObservableKeyedCollection _child_algo_selector_data = new ObservableKeyedCollection(sd => sd.prop_name); readonly ObservableAutoWrapper _child_algo_selectors; readonly Property _is_expanded, _can_save_values, _can_save_structure; readonly DeferrableActionWrapper _def_change_notifier; + IDisposable _pending_load; protected OrderTypeVMBase(AlgoKey id, string display_name, AlgoEditingPermissions editing_permissions) { this.id = id; @@ -127,9 +128,7 @@ namespace mbts.spark { _can_save_values = backing(nameof(can_save_values), true); _can_save_structure = backing(nameof(can_save_structure), true); _is_expanded = backing(nameof(is_expanded)); - foreach (var c in OrderDataHelper.get_child_algo_data(order_type)) { - _children_vm[c.name] = add_selector(c.name, c.descriptor); - } + meta = OrderDataHelper.get_metadata(order_type); _def_change_notifier = new DeferrableActionWrapper(() => definition_changed?.Invoke()); PropertyChanged += (s, e) => { switch (e.PropertyName) { @@ -170,39 +169,41 @@ namespace mbts.spark { }, true)); } - public AlgoEditingPermissions editing_permissions { get; private set; } public event Action definition_changed; + // core public AlgoDefi definition => new AlgoDefi(this.created_assigned()); public AlgoType order_type => OrderDataHelper.get_order_type(new TMutable()); - public bool is_bts_type => display_name.StartsWith("BTS"); public AlgoKey id { get; } + // display + public bool is_bts_type => display_name.StartsWith("BTS"); public string display_name { get; private set; } - public OrderMetadata meta => OrderDataHelper.get_metadata(order_type); - public virtual bool can_expand => !meta.NoProps; - public virtual bool is_expanded { - get => _is_expanded.Value; - set => _is_expanded.Value = value; - } + public OrderMetadata meta { get; } + // child algos public dynamic children_vm => _children_vm; public ObservableCollection child_algo_selectors => _child_algo_selectors; + // editing permissions + public AlgoEditingPermissions editing_permissions { get; private set; } public bool can_edit_values => EnumHelper.includes_flag(editing_permissions, AlgoEditingPermissions.AllowEditValues); public bool can_edit_structure => EnumHelper.includes_flag(editing_permissions, AlgoEditingPermissions.AllowEditStructure); public bool can_save_values => _can_save_values.Value; public bool can_save_structure => _can_save_structure.Value; + // misc + public virtual bool can_expand => !meta.NoProps; + public virtual bool is_expanded { get => _is_expanded.Value; set => _is_expanded.Value = value; } + // protected (observed props) protected OrdersModel model { get; private set; } protected SecurityMD? security_md { get; private set; } protected SecurityImmutable? security => security_md?.security; public void assign_to(AlgoDef value) { var algo = new TMutable(); - foreach (var (assign, load) in _auto_props) + foreach (var (name, assign, load) in _auto_props) assign(algo); _descriptor.Accessor.SetValue(value, algo); foreach (var sd in _child_algo_selector_data) { if (sd.selector.selected_algo != null) sd.set_order(value, sd.selector.selected_algo.created_assigned()); } - assign_to_internal(algo); } public void set_permissions(AlgoEditingPermissions editing_permissions) { @@ -217,26 +218,23 @@ namespace mbts.spark { public void load_from(AlgoDefi value) { if (value.CustomCase != order_type) return; - using (_def_change_notifier.defer_execution()) { - foreach (var sd in _child_algo_selector_data) { - var inner_def = sd.get_order(value); - if (inner_def.HasValue) { - if (security.HasValue) { - inner_def = OrderDataHelper.fit_to_type(inner_def.Value, security.Value.ContractCase); - if (!inner_def.HasValue) - continue; + var algom = _descriptor.Accessor.GetValue(value.CloneToMutable()) as TMutable ?? new TMutable(); + Disposable.replace(ref _pending_load, + new CompositeDisposable( + ObservableAutoWrapper.connect_item_actions(_child_algo_selector_data.AsCollection(), sd => { + var inner_def = sd.get_order(value); + if (inner_def.HasValue) { + if (security.HasValue) { + inner_def = OrderDataHelper.fit_to_type(inner_def.Value, security.Value.ContractCase); + if (!inner_def.HasValue) + return; + } + var vm = sd.selector.algos.GetOrAdd(OrderDataHelper.get_shallow_factory_key(inner_def.Value), k => create(k, inner_def.Value.display_name(), inner_def.Value.CustomCase)); + vm.load_from(inner_def.Value); + sd.selector.selected_algo = vm; } - var vm = sd.selector.algos.GetOrAdd(OrderDataHelper.get_shallow_factory_key(inner_def.Value), k => create(k, inner_def.Value.display_name(), inner_def.Value.CustomCase)); - vm.load_from(inner_def.Value); - sd.selector.selected_algo = vm; - } - } - var algom = _descriptor.Accessor.GetValue(value.CloneToMutable()) as TMutable ?? new TMutable(); - var algoi = _create_immutable(algom); - foreach (var (assign, load) in _auto_props) - load(algom); - load_from_internal(algoi); - } + }), + ObservableAutoWrapper.connect_item_actions(_auto_props.AsCollection(), p => p.load(algom)))); } public virtual async Task load_from_async(AlgoDefi defi) { @@ -254,92 +252,72 @@ namespace mbts.spark { } } var algom = _descriptor.Accessor.GetValue(defi.CloneToMutable()) as TMutable ?? new TMutable(); - var algoi = _create_immutable(algom); - foreach (var (assign, load) in _auto_props) + foreach (var (name, assign, load) in _auto_props) load(algom); - load_from_internal(algoi); return defi; } } protected virtual Task on_load_from_async(AlgoDefi defi) => Task.CompletedTask; - protected virtual void assign_to_internal(TMutable value) { } - protected virtual void load_from_internal(TImmutable value) { } - - protected void raise_definition_changed() => - _def_change_notifier.execute(); - - protected virtual void validate() { } protected virtual void on_permissions_changed() { foreach (var vm in child_algo_selectors.SelectMany(s => s.algos.AsCollection())) vm.set_permissions(editing_permissions); } + protected void raise_definition_changed() => + _def_change_notifier.execute(); + + protected virtual void validate() { } + protected override void Dispose(bool disposing) => Disposable.dispose(ref _resources); - #region Chidl Algo Selectors (add/remove/reset) - protected IAlgoSelector add_selector(string vm_prop_name, FieldDescriptor inner_desc) { - return add_selector(vm_prop_name, def => { - if (_descriptor.Accessor.GetValue(def.CloneToMutable()) is TMutable mval) { - if (inner_desc.Accessor.GetValue(mval) is AlgoDef inner_def) - return new AlgoDefi(inner_def); - } - return null; - }, (mdef, inner_def) => { - if (_descriptor.Accessor.GetValue(mdef) is TMutable mval) - inner_desc.Accessor.SetValue(mval, inner_def); - }); - } - - protected IAlgoSelector add_selector(string prop_name, Func get_order, Action set_order) => - add_selector(prop_name, get_order, set_order, (s, e) => validate()); - - protected IAlgoSelector add_selector(string prop_name, Func get_order, Action set_order, EventHandler on_errors_changed) { - var rv = new AlgoSelector(); - _child_algo_selector_data[prop_name] = new AlgoSelectorData(prop_name, rv, get_order, set_order); - return rv; - } - - protected IAlgoSelector add_selector(string prop_name, Func get_algo, Action set_algo) { - var rv = new AlgoSelector(); - _child_algo_selector_data[prop_name] = new AlgoSelectorData(prop_name, rv, def => _descriptor.Accessor.GetValue(def.CloneToMutable()) is TMutable mval ? get_algo(_create_immutable(mval)) : null, - (def, child_def) => { - if (_descriptor.Accessor.GetValue(def) is TMutable mval) - set_algo(mval, child_def); - }); - return rv; - } - - protected bool remove_selector(string prop_name) => - _child_algo_selector_data.Remove(prop_name); - - /// TODO: maybe should just be a protected field? - /// Conversely, it is nice to hide these sort of implementation-specific details from inheriting classes. - /// Fwiw, as of 2/12/2019, the only class that needs the ability to add/remove selectors dynamically is . - /// The other implementations simply add a whatever selectors they need in their constructor. - protected IDisposable reset_selectors() { - var to_remove = _child_algo_selector_data.Keys.ToList(); - _child_algo_selector_data.CollectionChanged += on_change; - void on_change(object sender, NotifyCollectionChangedEventArgs e) { - switch (e.Action) { - case NotifyCollectionChangedAction.Reset: - throw new InvalidOperationException($"{nameof(_child_algo_selector_data)} was reset; unable to continue processing incremental changes."); - default: - // catches Replace/Remove/Add ops (Add ops account for cases where the item was effectively replaced by a remove/re-add) - if (e.NewItems != null) { - foreach (AlgoSelectorData sd in e.NewItems) - to_remove.Remove(sd.prop_name); - } - break; + #region Child Algo Selectors + protected virtual IEnumerable get_selector_datum() => + OrderDataHelper.get_child_algo_data(order_type); + + protected void sync_selectors() { + using (reset()) { + foreach (var c in get_selector_datum()) { + _children_vm[c.name] = mk_selector(c.name, new Func(defi => { + var mchild = c.get_child(defi.CloneToMutable()); + if (mchild != null) + return new AlgoDefi(mchild); + return null; + }), + c.assign_child); } + _populate_selectors(); + } + // local methods + IDisposable reset() { + var to_remove = _child_algo_selector_data.Keys.ToList(); + _child_algo_selector_data.CollectionChanged += on_change; + void on_change(object sender, NotifyCollectionChangedEventArgs e) { + switch (e.Action) { + case NotifyCollectionChangedAction.Reset: + throw new InvalidOperationException($"{nameof(_child_algo_selector_data)} was reset; unable to continue processing incremental changes."); + default: + // catches Replace/Remove/Add ops (Add ops account for cases where the item was effectively replaced by a remove/re-add) + if (e.NewItems != null) { + foreach (AlgoSelectorData sd in e.NewItems) + to_remove.Remove(sd.prop_name); + } + break; + } + } + return Disposable.Create(() => { + _child_algo_selector_data.CollectionChanged -= on_change; + foreach (var id in to_remove) + _child_algo_selector_data.Remove(id); + }); + } + IAlgoSelector mk_selector(string prop_name, Func get_order, Action set_order) { + var rv = new AlgoSelector(); + _child_algo_selector_data[prop_name] = new AlgoSelectorData(prop_name, rv, get_order, set_order); + return rv; } - return Disposable.Create(() => { - _child_algo_selector_data.CollectionChanged -= on_change; - foreach (var id in to_remove) - _child_algo_selector_data.Remove(id); - }); } #endregion @@ -347,7 +325,7 @@ namespace mbts.spark { protected Property add_property(string prop_name, int target_field_number, T init_value = default) { var prop = backing(prop_name, init_value); var field_desc = new TMutable().Descriptor.FindFieldByNumber(target_field_number); - _auto_props.Add((mval => { + _auto_props.Add((prop_name, mval => { if (mval != null) field_desc.Accessor.SetValue(mval, prop.Value); }, mval => { @@ -356,22 +334,12 @@ namespace mbts.spark { return prop; } - protected UserProperty add_user_property(string prop_name, int target_field_number, T init_value = default) { - var prop = user_backing(prop_name, init_value); - var field_desc = new TMutable().Descriptor.FindFieldByNumber(target_field_number); - add_property( - mdef => ConvertUtils.try_convert(field_desc.Accessor.GetValue(mdef)), - (mdef, val) => field_desc.Accessor.SetValue(mdef, val), - val => prop.bypass_setter(val), - () => prop.Value); - return prop; - } - protected Property add_property(string prop_name, int target_field_number, TImmutableValue init_value = default) where TMutableValue : class, IMessage, new() where TImmutableValue : IImmutableMessage { var prop = backing(prop_name, init_value); var field_desc = new TMutable().Descriptor.FindFieldByNumber(target_field_number); var immutable_factory = OrderTypeVMUtils.immutable_factory(); add_property( + prop_name, mdef => field_desc.Accessor.GetValue(mdef) as TMutableValue, (mdef, mval) => field_desc.Accessor.SetValue(mdef, mval), mval => prop.set(immutable_factory(mval ?? new TMutableValue())), @@ -383,15 +351,36 @@ namespace mbts.spark { return prop; } - protected void add_property(Func get_from_def, Action assign_to_def, Action set_local, Func get_local) => - _auto_props.Add((def => { + protected void add_property(string prop_name, Func get_from_def, Action assign_to_def, Action set_local, Func get_local) => + _auto_props.Add(( + prop_name, + def => { assign_to_def(def, get_local()); }, def => { set_local(get_from_def(def)); })); - protected virtual void on_model_internal(OrdersModel model) { } - protected virtual void on_security_md_internal(SecurityMD? security_md) { } + protected void add_property(string prop_name, Action assign, Action load) => + _auto_props[prop_name] = (prop_name, assign, load); + + protected UserProperty add_user_property(string prop_name, int target_field_number, T init_value = default) { + var prop = user_backing(prop_name, init_value); + var field_desc = new TMutable().Descriptor.FindFieldByNumber(target_field_number); + add_property( + prop_name, + mdef => ConvertUtils.try_convert(field_desc.Accessor.GetValue(mdef)), + (mdef, val) => field_desc.Accessor.SetValue(mdef, val), + val => prop.bypass_setter(val), + () => prop.Value); + return prop; + } + + protected void remove_property(string prop_name) => + _auto_props.Remove(prop_name); + #endregion + + protected virtual void on_model_internal() { } + protected virtual void on_security_md_internal() { } // model void IObserver.OnNext(OrdersModel model) { @@ -402,36 +391,39 @@ namespace mbts.spark { return; } this.model = model; - on_model_internal(model); - _reset(); + using (_def_change_notifier.defer_execution()) { + on_model_internal(); + sync_selectors(); + } } void IObserver.OnError(Exception error) { } void IObserver.OnCompleted() { } // security md void IObserver.OnNext(SecurityMD? security_md) { this.security_md = security_md; - on_security_md_internal(security_md); - _reset(); + using (_def_change_notifier.defer_execution()) { + on_security_md_internal(); + _populate_selectors(); + } } void IObserver.OnError(Exception error) { } void IObserver.OnCompleted() { } - IDisposable _hook; - void _reset() { + IDisposable _selector_data_hooks; + void _populate_selectors() { if (model != null && security.HasValue) { var algo_data = model.factory.default_algos(security.Value); var default_algo = new AlgoKey(OrderDataHelper.get_default_algo(OrderDataHelper.get_algo_format(security.Value.ContractCase))); foreach (var sd in _child_algo_selectors) sd.load_algo_data_recursive(algo_data, default_algo); - Disposable.replace(ref _hook, ObservableAutoWrapper.connect_item_hooks(child_algo_selectors, s => { - s.load_algo_data_recursive(algo_data, default_algo); - return Disposable.empty; - })); + Disposable.replace( + ref _selector_data_hooks, + ObservableAutoWrapper.connect_item_hooks(child_algo_selectors, s => { + s.load_algo_data_recursive(algo_data, default_algo); + return Disposable.empty; + })); } } - - public IDisposable Subscribe(IObserver observer) => throw new NotImplementedException(); - #endregion } struct AlgoSelectorData { @@ -521,4 +513,4 @@ namespace mbts.spark { } #endregion } -} +} \ No newline at end of file diff --git a/src/client/spark/Orders/OrderTypeVMs/SpreaderOrderVM.cs b/src/client/spark/Orders/OrderTypeVMs/SpreaderOrderVM.cs index 194aa952b..ad61e47cc 100644 --- a/src/client/spark/Orders/OrderTypeVMs/SpreaderOrderVM.cs +++ b/src/client/spark/Orders/OrderTypeVMs/SpreaderOrderVM.cs @@ -23,7 +23,38 @@ namespace mbts.spark { _template = backing(nameof(template)); /// depends on (i.e. initialize the latter first). _strategy_editor_wrapper = new StrategyEditorWrapper(this); - concat_disposable(_strategy_editor_wrapper, _template.Subscribe(vals => validate())); + _resources.AddRange(_strategy_editor_wrapper, _template.Subscribe(vals => validate())); + // strategy + add_property( + nameof(SpreaderDef.ExecutionStrategy), + mdef => mdef.ExecutionStrategy, + (mdef, val) => mdef.ExecutionStrategy = val, + val => { + if (template.HasValue) { + template = template.Value.with(execution_strategy: val); + } else { + var mdef = new SpreaderDef { + Security = security?.CloneToMutable(), + ExecutionStrategy = val + }; + template = new SpreaderDefi(mdef); + } + }, + () => strategy_editor?.get_strategy().CloneToMutable()); + // security + add_property( + nameof(SpreaderDef.Security), + mdef => mdef.Security, + (mdef, val) => mdef.Security = val, + val => { + if (template.HasValue) { + template = template.Value.with(security: val); + } else { + var mdef = new SpreaderDef { Security = val }; + template = new SpreaderDefi(mdef); + } + }, + () => security?.CloneToMutable()); validate(); } @@ -43,12 +74,6 @@ namespace mbts.spark { } public bool is_loaded { get; private set; } - protected override void assign_to_internal(SpreaderDef value) => - value.MergeFrom(template.HasValue ? template.Value.CloneToMutable() : new SpreaderDef()); - - protected override void load_from_internal(SpreaderDefi value) => - _template.set(value); - protected override void validate() { base.validate(); if (!template.HasValue) diff --git a/src/client/spark/Orders/OrderTypeVMs/StopLimitOrderVM.cs b/src/client/spark/Orders/OrderTypeVMs/StopLimitOrderVM.cs index 63378127d..854628a38 100644 --- a/src/client/spark/Orders/OrderTypeVMs/StopLimitOrderVM.cs +++ b/src/client/spark/Orders/OrderTypeVMs/StopLimitOrderVM.cs @@ -31,11 +31,6 @@ namespace mbts.spark { public ContractSpecificationImmutable? spec => _security_md.spec_or_default(); - protected override void load_from_internal(StopLimitDefi value) { - // TODO: the StopLimitOrderDefinition, StopLimitOrderDefinitionImmutable needs relative vs absolute prices to function as a useful template (talk to Pedro) - _stop_price.bypass_setter(value.StopPrice); - } - // no need to constantly poll the md, just check the inline props when the popup opens, and right before sending an order // (if the user never looks at the popup, assume that the bid_price will be used) // TODO: add settings so the trigger-price can default to something relative to the md, e.g "bid-price" or "ask-price - nticks" or "best-bid-price with a minimum size of 10" diff --git a/src/client/spark/Orders/OrderTypeVMs/TimeBoxOrderVM.cs b/src/client/spark/Orders/OrderTypeVMs/TimeBoxOrderVM.cs index f12b3e9c9..3b4cbb713 100644 --- a/src/client/spark/Orders/OrderTypeVMs/TimeBoxOrderVM.cs +++ b/src/client/spark/Orders/OrderTypeVMs/TimeBoxOrderVM.cs @@ -16,14 +16,26 @@ namespace mbts.spark { public TimeBoxOrderVM(AlgoKey key, string display_name, AlgoEditingPermissions editing_permissions) : base(key, display_name, editing_permissions) { - add_property(def => def.Start, (def, val) => def.Start = val, val => absolute_start = TimeTextTuple.FromDateTime(val.ToDateTime()), () => { - _validate(out DateTime? start_time, out DateTime? _); - return start_time.GetValueOrDefault().ToUniversalTime().ToGoogleTime(); - }); - add_property(def => def.Stop, (def, val) => def.Stop = val, val => absolute_stop = TimeTextTuple.FromDateTime(val.ToDateTime()), () => { - _validate(out DateTime? _, out DateTime? stop_time); - return stop_time.GetValueOrDefault().ToUniversalTime().ToGoogleTime(); - }); + // start + add_property( + nameof(TimeBoxOrderDefinition.Start), + def => def.Start, + (def, val) => def.Start = val, + val => absolute_start = TimeTextTuple.FromDateTime(val.ToDateTime()), + () => { + _validate(out DateTime? start_time, out DateTime? _); + return start_time.GetValueOrDefault().ToUniversalTime().ToGoogleTime(); + }); + // stop + add_property( + nameof(TimeBoxOrderDefinition.Stop), + def => def.Stop, + (def, val) => def.Stop = val, + val => absolute_stop = TimeTextTuple.FromDateTime(val.ToDateTime()), + () => { + _validate(out DateTime? _, out DateTime? stop_time); + return stop_time.GetValueOrDefault().ToUniversalTime().ToGoogleTime(); + }); validate(); } diff --git a/src/client/spark/Orders/OrderTypeVMs/TriggerOrderVM.cs b/src/client/spark/Orders/OrderTypeVMs/TriggerOrderVM.cs index f1cff6c37..69149dfd5 100644 --- a/src/client/spark/Orders/OrderTypeVMs/TriggerOrderVM.cs +++ b/src/client/spark/Orders/OrderTypeVMs/TriggerOrderVM.cs @@ -1,5 +1,4 @@ -using bts.api; -using bts.api.orderman; +using bts.api.orderman; using mbts.ui.utility; using mbts.utils; using System; @@ -31,13 +30,59 @@ namespace mbts.spark { _is_priceout_checked = create_user_prop(nameof(is_priceout_checked), false); _is_timeout_checked = create_user_prop(nameof(is_timeout_checked), false); _timeout_secs = create_user_prop(nameof(timeout_secs), 10); + add_property(nameof(TriggerDef), assign, load); validate(); - // + // local methods UserProperty create_user_prop(string name, T default_value = default) { var rv = user_backing(name, default_value); rv.Changed += validation_callback; return rv; } + void assign(TriggerDef trigger_def) { + trigger_def.TriggerAction = new TriggerAction(); + if (security.HasValue) + trigger_def.TriggerAction.SecurityId = security.Value.Id; + trigger_def.TriggerCondition = new TriggerCondition() { + PriceType = trigger_price_type, + AbsolutePriceTrigger = new AbsolutePriceTrigger() { TriggerQuantity = new TriggerQuantity() }, + }; + trigger_def.ExitCondition = new TriggerExitCondition { + ConditionalCancel = is_priceout_checked, + TimeoutEnabled = is_timeout_checked, + TimeoutSeconds = (uint)(timeout_secs) + }; + switch (order_price_case) { + case OrderpriceOneofCase.Price: + // 'fixed price' is no longer supported (ca. 03/04/2019) + goto case OrderpriceOneofCase.Payup; + case OrderpriceOneofCase.Payup: + trigger_def.TriggerAction.Price = double.NaN; + trigger_def.TriggerAction.Payup = new TriggerPayupPrice { + PayupTicks = payup_ticks, + PayupPriceType = payup_price_type + }; + break; + } + } + void load(TriggerDef trigger_defi) { + if (trigger_defi.TriggerCondition is TriggerCondition c) { + trigger_price_type = c.PriceType; + } + if (trigger_defi.ExitCondition is TriggerExitCondition ec) { + is_priceout_checked = ec.ConditionalCancel; + is_timeout_checked = ec.TimeoutEnabled; + if (ec.TimeoutSeconds < int.MaxValue) + timeout_secs = (int)ec.TimeoutSeconds; + } + if (trigger_defi.TriggerAction is TriggerAction a) { + if (a.Payup is TriggerPayupPrice pp) { + order_price_case = OrderpriceOneofCase.Payup; + fixed_price = double.NaN; + payup_ticks = pp.PayupTicks; + payup_price_type = pp.PayupPriceType; + } + } + } void validation_callback(T oldval, T newval) => validate(); } @@ -56,68 +101,20 @@ namespace mbts.spark { public bool is_timeout_checked { get => _is_timeout_checked.Value; set => _is_timeout_checked.Value = value; } public int timeout_secs { get => _timeout_secs.Value; set => _timeout_secs.Value = value; } - protected override void assign_to_internal(TriggerDef trigger_def) { - trigger_def.TriggerAction = new TriggerAction(); - if (security.HasValue) - trigger_def.TriggerAction.SecurityId = security.Value.Id; - trigger_def.TriggerCondition = new TriggerCondition() { - PriceType = trigger_price_type, - AbsolutePriceTrigger = new AbsolutePriceTrigger() { TriggerQuantity = new TriggerQuantity() }, - }; - trigger_def.ExitCondition = new TriggerExitCondition { - ConditionalCancel = is_priceout_checked, - TimeoutEnabled = is_timeout_checked, - TimeoutSeconds = (uint)(timeout_secs) - }; - switch (order_price_case) { - case OrderpriceOneofCase.Price: - // should already be null, setting it here for clarity - trigger_def.TriggerAction.Payup = null; - trigger_def.TriggerAction.Price = fixed_price; - break; - case OrderpriceOneofCase.Payup: - trigger_def.TriggerAction.Price = double.NaN; - trigger_def.TriggerAction.Payup = new TriggerPayupPrice { - PayupTicks = payup_ticks, - PayupPriceType = payup_price_type - }; - break; - } - } - - protected override void load_from_internal(TriggerDefi trigger_defi) { - if (trigger_defi.HasTriggerCondition) { - trigger_price_type = trigger_defi.TriggerCondition.PriceType; - } - if (trigger_defi.HasExitCondition) { - var exit_condition = trigger_defi.ExitCondition; - is_priceout_checked = exit_condition.ConditionalCancel; - is_timeout_checked = exit_condition.TimeoutEnabled; - if (exit_condition.TimeoutSeconds < int.MaxValue) - timeout_secs = (int)exit_condition.TimeoutSeconds; - } - if (trigger_defi.HasTriggerAction) { - var trigger_action = trigger_defi.TriggerAction; - if (trigger_action.HasPayup) { - order_price_case = OrderpriceOneofCase.Payup; - fixed_price = double.NaN; - var payup = trigger_action.Payup; - payup_ticks = payup.PayupTicks; - payup_price_type = payup.PayupPriceType; - } else { - order_price_case = OrderpriceOneofCase.Price; - fixed_price = trigger_action.Price; - } - } - } - - void _refresh_md() { + protected override void on_security_md_internal() { if (security.HasValue) { security_md.Value.md.get_bbo(ref _bbo_ref, out co2.NativePriceSize bid, out co2.NativePriceSize ask); _best_bid = bid.price; _best_ask = ask.price; security_md.Value.md.get_last_trade(ref _last_trade_ref, out co2.NativePriceSize ps, out DateTime ts, out ulong v); } + if (double.IsNaN(fixed_price) || !_fixed_price.setter_called) { + switch (trigger_price_type) { + case TriggerPriceType.Bid: _fixed_price.bypass_setter(_best_bid); break; + case TriggerPriceType.Ask: _fixed_price.bypass_setter(_best_ask); break; + case TriggerPriceType.LastTradePrice: _fixed_price.bypass_setter(_last_trade_price); break; + } + } } protected override void validate() { @@ -131,17 +128,6 @@ namespace mbts.spark { } assert(!is_timeout_checked || timeout_secs > 0, nameof(timeout_secs), "Please specify valid Timeout(secs)."); } - - protected override void on_security_md_internal(SecurityMD? security_md) { - _refresh_md(); - if (double.IsNaN(fixed_price) || !_fixed_price.setter_called) { - switch (trigger_price_type) { - case TriggerPriceType.Bid: _fixed_price.bypass_setter(_best_bid); break; - case TriggerPriceType.Ask: _fixed_price.bypass_setter(_best_ask); break; - case TriggerPriceType.LastTradePrice: _fixed_price.bypass_setter(_last_trade_price); break; - } - } - } } } } \ No newline at end of file diff --git a/src/client/spark/Orders/OrdersModel.cs b/src/client/spark/Orders/OrdersModel.cs index 05e1a9699..f8a4cca8c 100644 --- a/src/client/spark/Orders/OrdersModel.cs +++ b/src/client/spark/Orders/OrdersModel.cs @@ -91,12 +91,13 @@ namespace mbts.spark { _service.subscribei_fills() .Naggle(interval, scheduler) .PermissionFilter(admin_model.on_admin_data) + .join(sstore, f => f.SecurityKey) .Table().Cache(); var fill_order_tuples_join = on_fills.LeftJoin( on_order_tuples, - f => f.FillKey, + f => f.val.FillKey, o => o.order.Key, - f => f.OrderKey, + f => f.val.OrderKey, (f, fk, o, ok) => new FillTuple(f, o), (f, fk, ok) => new FillTuple(f, null), f => f.fill.FillKey); @@ -284,7 +285,7 @@ namespace mbts.spark { // DO NOT REMOVE (END) public static IObservable> on_security_root_orders(this OrdersModel orders_model, uint security_key) => - orders_model.on_security_orders(security_key).Scan(new RootOrderData(), (rod, table) => { + orders_model.on_security_orders(security_key).AddRemoveOnly().Scan(new RootOrderData(), (rod, table) => { // ** using HashSet/List pairs, rather than a Dictionary, because TableUpdateTransform calls for IReadOnlyLists, while Dictionary.Values only implements IReadOnlyCollection. // (this way, we avoid copying both added/removed Dictionary.Values to new Lists at the end, see comment at bottom of method if this is unclear) ** var added_root_keys = new HashSet(); diff --git a/src/client/spark/core/Collections/ObservableAutoWrapper.cs b/src/client/spark/core/Collections/ObservableAutoWrapper.cs index 3836876d8..94f20049f 100644 --- a/src/client/spark/core/Collections/ObservableAutoWrapper.cs +++ b/src/client/spark/core/Collections/ObservableAutoWrapper.cs @@ -1,4 +1,3 @@ -using bts.collections; using bts.utils; using mbts.utils; using NUnit.Framework; @@ -11,11 +10,6 @@ using System.Linq; using System.Reactive.Disposables; namespace mbts.ui.utility { - /// - /// The sole purpose of this class is to offer a less verbose alternative to - /// "new ObservableAutoWrapper(doodi, poodi)" - /// when the generic types are implicit - /// static class ObservableAutoWrapper { public static ObservableAutoWrapper Create(ObservableCollection models, Func converter) { return new ObservableAutoWrapper(models, converter); @@ -198,6 +192,18 @@ namespace mbts.ui.utility { } } + public static IDisposable connect_item_actions(IReadOnlyObservableCollection source, Action action) { + foreach (T v in source) + action(v); + return source.Subscribe((s, e) => CollectionHelper.process_new_items(source, action, e)); + } + + public static IDisposable connect_item_actions(ObservableCollection source, Action action) { + foreach (T v in source) + action(v); + return source.Subscribe((s, e) => CollectionHelper.process_new_items(source, action, e)); + } + public static IDisposable connect_item_hooks(IReadOnlyObservableCollection source, Func get_item_hook) { var item_hooks = source.Select(get_item_hook).ToList(); return new CompositeDisposable( @@ -298,7 +304,7 @@ namespace mbts.ui.utility { void _remove_and_notify(T value) { int pos = _assert_remove(value); - CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, value, pos)); + CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, value, pos)); } int _add(T value) { diff --git a/src/client/spark/core/GlobalExtensions/TickExtensions.cs b/src/client/spark/core/GlobalExtensions/TickExtensions.cs index 2ed66ffbc..467cb394c 100644 --- a/src/client/spark/core/GlobalExtensions/TickExtensions.cs +++ b/src/client/spark/core/GlobalExtensions/TickExtensions.cs @@ -10,7 +10,8 @@ namespace mbts { #region Public Extensions (is_valid, format, parse, tick_up, tick_down) public static bool is_valid(this TickFactors tick) => - tick.tick_unit > 0 && tick.tick_unit <= (tick.tick_base * 0.5); + (tick.tick_unit > 0 && tick.tick_unit <= (tick.tick_base * 0.5)) || + tick.tick_unit == tick.tick_base; public static bool is_valid(this RegionalTickFactors regional_tick) => regional_tick.low_tick.is_valid() && regional_tick.high_tick.is_valid(); @@ -20,6 +21,9 @@ namespace mbts { public static double reduced_base(this TickFactors tick) => factor_out(tick.tick_base, 10); + public static string format_without_decimal_part(this TickFactors tick, double value) => + format(tick, value, double.NaN, false, _nan_text, true); + public static string format(this TickFactors tick, double value) => format(tick, value, double.NaN, false, _nan_text); @@ -32,13 +36,16 @@ namespace mbts { public static string format(this TickFactors tick, double value, double display_multiplier, bool show_commas) => format(tick, value, display_multiplier, show_commas, _nan_text); - public static string format(this TickFactors tick, double value, double display_multiplier, bool show_commas, string nan_text) { + public static string format(this TickFactors tick, double value, double display_multiplier, bool show_commas, string nan_text, bool hide_decimal_part = false) { if (double.IsNaN(value)) return nan_text; if (double.IsInfinity(value)) return value.ToString(); if (!tick.is_valid()) return _format_no_tick(value, display_multiplier, show_commas); - return _format_tick(tick, double.IsNaN(display_multiplier) ? value : value * display_multiplier, show_commas); + return _format_tick(tick, double.IsNaN(display_multiplier) ? value : value * display_multiplier, show_commas, hide_decimal_part); } + public static string format_without_decimal_part(this RegionalTickFactors regional_tick, double value) => + format_without_decimal_part(value <= regional_tick.low_tick_inclusive_end ? regional_tick.low_tick : regional_tick.high_tick, value); + public static string format(this RegionalTickFactors regional_tick, double value) => format(value <= regional_tick.low_tick_inclusive_end ? regional_tick.low_tick : regional_tick.high_tick, value); @@ -193,7 +200,12 @@ namespace mbts { if (DoubleHelper.IsNaNOrInfinity(input)) return input; return input <= regional_tick.low_tick_inclusive_end ? regional_tick.low_tick.round(input) : regional_tick.high_tick.round(input); } - public static int display_digits(this TickFactors tick) => display_digits(tick.tick_base); + public static int display_digits(this TickFactors tick) { + if (tick.tick_unit == tick.tick_base) { + return (int)Math.Floor(Math.Log10(tick.tick_base)); + } + return display_digits(tick.tick_base); + } #endregion public static int display_digits(double tick_base) { @@ -265,15 +277,21 @@ namespace mbts { return integer_part + numerator_part / tick.tick_base; } - private static string _format_tick(TickFactors tick, double value, bool show_commas) { - if (value < 0) return "-" + _format_tick(tick, Math.Abs(value), show_commas); + private static string _format_tick(TickFactors tick, double value, bool show_commas, bool hide_decimal_part) { + if (value < 0) return "-" + _format_tick(tick, Math.Abs(value), show_commas, hide_decimal_part); try { checked { int integer_part = (int)Math.Floor(value); double numerator_dec = value - integer_part; double unit_frac = tick.tick_unit / tick.tick_base; int n_units = (int)Math.Round(numerator_dec / unit_frac); - if (n_units == tick.tick_base) return (integer_part + 1).ToString() + tick.separator() + new string('0', display_digits(tick.tick_base)); + if (n_units == tick.tick_base) { + if (hide_decimal_part) { + return integer_part.ToString(); + } else { + return (integer_part + 1).ToString() + tick.separator() + new string('0', display_digits(tick.tick_base)); + } + } double decimal_part = n_units * tick.tick_unit; if (decimal_part == tick.tick_base) { ++integer_part; @@ -284,7 +302,11 @@ namespace mbts { decimal_part = Math.Floor(decimal_part); } string integer_part_text = show_commas ? integer_part.ToString("#,0") : integer_part.ToString(); - return integer_part_text + tick.separator() + decimal_part.ToString(new string('0', display_digits(tick.tick_base))); + if (hide_decimal_part) { + return integer_part_text; + } else { + return integer_part_text + tick.separator() + decimal_part.ToString(new string('0', display_digits(tick.tick_base))); + } } } catch (OverflowException ex) { diff --git a/src/client/spark/core/Utility/CollectionHelper.cs b/src/client/spark/core/Utility/CollectionHelper.cs index d74e91393..65d7252bf 100644 --- a/src/client/spark/core/Utility/CollectionHelper.cs +++ b/src/client/spark/core/Utility/CollectionHelper.cs @@ -75,6 +75,20 @@ namespace mbts.utils { } } + public static void process_new_items(IEnumerable source, Action on_new_item, NotifyCollectionChangedEventArgs e) { + switch (e.Action) { + case NotifyCollectionChangedAction.Add: + case NotifyCollectionChangedAction.Replace: + foreach (T v in e.NewItems) + on_new_item(v); + break; + case NotifyCollectionChangedAction.Reset: + foreach (T v in source) + on_new_item(v); + break; + } + } + // Note: this is not optimized, be wary of use with large collections public static void sync_with_never_duplicate(ObservableCollection dest, IEnumerable src) => sync_with_never_duplicate(dest, src, EqualityComparer.Default); diff --git a/src/client/spark/core/Utility/ProtoHelper.cs b/src/client/spark/core/Utility/ProtoHelper.cs new file mode 100644 index 000000000..987c6d041 --- /dev/null +++ b/src/client/spark/core/Utility/ProtoHelper.cs @@ -0,0 +1,91 @@ +using mbts; +using Google.Protobuf; +using Google.Protobuf.Reflection; +using mbts.ui.utility; +using System; +using System.Collections.Generic; +using System.Linq; +using mbts.utils; + +namespace bts.utils { + static class ProtoHelper { + const string + _case_suffix = "Case", + _oneof_case_suffix = "OneofCase"; + + public static MessageDescriptor Descriptor() where T : IMessage, new() => + _DescriptorImpl.value; + + public static OneofDescriptor get_oneof_descriptor(string prop_name) where T : IMessage, new() { + prop_name = prop_name.iremove_suffix(_case_suffix); + return Descriptor().Oneofs.FirstOrDefault(d => d.Name.iequals(prop_name)); + } + + public static IReadOnlyDictionary get_oneof_descriptor_index(string prop_name) + where T : IMessage, new() + where TOneofCase : struct => + _DescriptorImpl.OneofImpl.get_descriptor_case_index(prop_name); + + public static FieldDescriptor get_oneof_field_descriptor(TOneofCase oneof_case) where T : IMessage, new() where TOneofCase : struct { + string oneof_name = oneof_case.ToString(); + return Descriptor().Fields.InFieldNumberOrder().FirstOrDefault(fd => fd.Name.Replace("_", "").iequals(oneof_name)); + } + + public static Type get_field_type(FieldDescriptor field_descriptor) { + switch (field_descriptor.FieldType) { + case FieldType.Bool: return typeof(bool); + case FieldType.Bytes: return typeof(ByteString); + case FieldType.Double: return typeof(double); + case FieldType.Float: return typeof(float); + case FieldType.UInt32: return typeof(uint); + case FieldType.UInt64: return typeof(ulong); + // int + case FieldType.SFixed32: + case FieldType.Fixed32: + case FieldType.SInt32: + case FieldType.Int32: return typeof(int); + // long + case FieldType.SFixed64: + case FieldType.Fixed64: + case FieldType.SInt64: + case FieldType.Int64: return typeof(long); + // + case FieldType.String: return typeof(string); + case FieldType.Enum: return field_descriptor.EnumType.ClrType; + case FieldType.Message: return field_descriptor.MessageType.ClrType; + default: throw ExceptionBuilder.Argument.unexpected_case(field_descriptor.FieldType, nameof(field_descriptor)); + } + } + + public static IReadOnlyDictionary get_oneof_descriptor_index(OneofDescriptor descriptor) where TOneofCase : struct => + descriptor.Fields.ToDictionary(fd => EnumHelper.parse(fd.Name.Replace("_", ""))); + + static class _DescriptorImpl where T : IMessage, new() { + public static readonly MessageDescriptor value = new T().Descriptor; + + public static class OneofImpl where TOneofCase : struct { + static Dictionary> _descriptor_case_indices = + new Dictionary>(); + + public static IReadOnlyDictionary get_descriptor_case_index(string prop_name) { + /// Use local copy because is updated atomically. + var dci = _descriptor_case_indices; + if (!dci.TryGetValue(prop_name, out IReadOnlyDictionary rv)) { + /// Update atomically (lock-free). + /// 1) clone the local copy. + /// 2) add the new KeyValue to the clone. + /// 3) assign the clone back to . + rv = get_oneof_descriptor_index(get_oneof_descriptor(prop_name)) + .ToDictionary(kv => kv.Key, kv => (kv.Value, get_field_type(kv.Value))); + dci = dci.ToDictionary(); + dci.Add(prop_name, rv); + /// It is possible for add ops to be overwritten. + /// This is perfectly safe, just means that the 'clone-add-assign' will be repeated the next time a caller requests this key. + _descriptor_case_indices = dci; + } + return rv; + } + } + } + } +} \ No newline at end of file diff --git a/src/client/spark/view/Controls/Order/AlgoContentTemplateSelector.xaml b/src/client/spark/view/Controls/Order/AlgoContentTemplateSelector.xaml index cbb666f21..154ab1e64 100644 --- a/src/client/spark/view/Controls/Order/AlgoContentTemplateSelector.xaml +++ b/src/client/spark/view/Controls/Order/AlgoContentTemplateSelector.xaml @@ -461,117 +461,43 @@ /> - - - Trigger Action - + + + + + + + - - + + - - - - Price - - - - - - - - - - - - - - - - - - - Fixed - - - - - - - - - - - Payup - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Payup\less + + > + + + + + + + + + + + - + Trigger Exit diff --git a/src/client/spark/view/Controls/TickFactorsPicker/TickFactorsPicker.xaml.cs b/src/client/spark/view/Controls/TickFactorsPicker/TickFactorsPicker.xaml.cs index 7d14d8064..161e87df7 100644 --- a/src/client/spark/view/Controls/TickFactorsPicker/TickFactorsPicker.xaml.cs +++ b/src/client/spark/view/Controls/TickFactorsPicker/TickFactorsPicker.xaml.cs @@ -82,7 +82,7 @@ namespace mbts.ui.controls { })); static IEnumerable _get_dbased_tick_unit_presets(int log10) => - Enumerable.Range(0, log10).SelectMany(_coins); + Enumerable.Range(0, log10).SelectMany(_coins).Concat(new[] { Math.Pow(10, log10) }); static IEnumerable _coins(int pow10) { double d = Math.Pow(10, pow10); diff --git a/src/client/spark/view/Converters/EnumConverters/SyntheticPriceCalcDisplayTextConverter.cs b/src/client/spark/view/Converters/EnumConverters/SyntheticPriceCalcDisplayTextConverter.cs index 386076cde..9adc0770a 100644 --- a/src/client/spark/view/Converters/EnumConverters/SyntheticPriceCalcDisplayTextConverter.cs +++ b/src/client/spark/view/Converters/EnumConverters/SyntheticPriceCalcDisplayTextConverter.cs @@ -9,10 +9,7 @@ namespace mbts.ui.converters { class SyntheticPriceCalcDisplayTextConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is SyntheticContract.Types.PriceCalc price_calc) { - switch (price_calc) { - case SyntheticContract.Types.PriceCalc.Diff: return "Standard"; - default: return DisplayNameHelper.camel_to_title_case(value.ToString()); - } + return DisplayNameHelper.camel_to_title_case(value.ToString()); } else return value != null ? value.ToString() : string.Empty; } diff --git a/src/client/spark/view/Spark/Core/OrderUtils.cs b/src/client/spark/view/Spark/Core/OrderUtils.cs index 15ba5770c..8324e92e7 100644 --- a/src/client/spark/view/Spark/Core/OrderUtils.cs +++ b/src/client/spark/view/Spark/Core/OrderUtils.cs @@ -213,7 +213,7 @@ namespace mbts.spark { // local methods void impl(StringBuilder sb, CustomOrderDefinition mdef) { sb.Append(abbreviate(mdef.CustomCase)); - foreach (var cad in OrderDataHelper.get_child_algo_data(def.CustomCase)) { + foreach (var cad in OrderDataHelper.get_child_algo_data(def.CloneToMutable())) { var child = cad.get_child(mdef); sb.Append(".["); impl(sb, child); diff --git a/src/client/spark/view/Spark/Core/TickUtils.cs b/src/client/spark/view/Spark/Core/TickUtils.cs index 8a624540e..166af2942 100644 --- a/src/client/spark/view/Spark/Core/TickUtils.cs +++ b/src/client/spark/view/Spark/Core/TickUtils.cs @@ -24,6 +24,13 @@ namespace mbts.spark { public static double ticksize(this ContractSpecificationImmutable spec, double price) => Math.Abs(price) > spec.PriceBreak ? spec.HighTick : spec.LowTick; + public static string format(this ContractSpecificationImmutable spec, double price, double with_regard_to_price, bool in_tick_terms) { + double net_change = price - with_regard_to_price; + return (in_tick_terms) ? + TickStore.get(spec).format_without_decimal_part((net_change) / spec.ticksize(net_change)) : + TickStore.get(spec).format(net_change); + } + public static string format(this ContractSpecificationImmutable spec, double price) => TickStore.get(spec).format(price); @@ -289,7 +296,7 @@ namespace mbts.spark { } static bool _check_tick_size(double tick_size) => - tick_size > 0 && tick_size <= 0.5; + (tick_size > 0 && tick_size <= 0.5) || tick_size == 1; struct SpecKey : IEquatable { public readonly uint denominator, display_digits; diff --git a/src/client/spark/view/Spark/Ladder/LadderGridHost.cs b/src/client/spark/view/Spark/Ladder/LadderGridHost.cs index 14e2748fe..2f91999d2 100644 --- a/src/client/spark/view/Spark/Ladder/LadderGridHost.cs +++ b/src/client/spark/view/Spark/Ladder/LadderGridHost.cs @@ -6,6 +6,7 @@ using mbts.co2; using mbts.ui; using mbts.ui.controls; using mbts.ui.spark; +using mbts.ui.utility; using mbts.ui.utility.text; using mbts.utils; using System; @@ -355,14 +356,27 @@ namespace mbts.spark { case ColumnType.Order: _ordershost.set_col_width(column.settings.width); break; case ColumnType.Bid: render_market_col(_bids); break; case ColumnType.Price: - LadderRender.render_prices( - column.visual_tup.visual, - column.visual_tup.glyph_context, - _row_count, - _settings.row_height, - _price_list, - column.settings, - security.ContractSpec); + if (_settings.net_change != LadderSettings.NetChangeTerms.None) { + LadderRender.render_prices( + column.visual_tup.visual, + column.visual_tup.glyph_context, + _row_count, + _settings.row_height, + _price_list, + _vm.md.settlement_price, + _settings.net_change == LadderSettings.NetChangeTerms.Ticks, + column.settings, + security.ContractSpec); + } else { + LadderRender.render_prices( + column.visual_tup.visual, + column.visual_tup.glyph_context, + _row_count, + _settings.row_height, + _price_list, + column.settings, + security.ContractSpec); + } break; case ColumnType.Ask: render_market_col(_asks); break; case ColumnType.Volume: @@ -556,7 +570,9 @@ namespace mbts.spark { void _refresh_prices() { var prev_price_list = _price_list; - _price_list = LadderRender.render_prices(_price_vis_tup.visual, _price_vis_tup.glyph_context, _mkt_break_lines.origin, _row_count, _settings.row_height, _settings.price_column, security.ContractSpec); + _price_list = (!(_settings.net_change == LadderSettings.NetChangeTerms.None)) ? + LadderRender.render_prices(_price_vis_tup.visual, _price_vis_tup.glyph_context, _mkt_break_lines.origin, _vm.md.settlement_price, _settings.net_change == LadderSettings.NetChangeTerms.Ticks, _row_count, _settings.row_height, _settings.price_column, security.ContractSpec) : + LadderRender.render_prices(_price_vis_tup.visual, _price_vis_tup.glyph_context, _mkt_break_lines.origin, _row_count, _settings.row_height, _settings.price_column, security.ContractSpec); _ordershost.update_settings(_price_list, _price_comparer, _settings.row_height, _settings.orders_column); if (prev_price_list != null) { // maintain previous visible price range if possible diff --git a/src/client/spark/view/Spark/Ladder/LadderSettings.cs b/src/client/spark/view/Spark/Ladder/LadderSettings.cs index 25ebc2435..6d1784488 100644 --- a/src/client/spark/view/Spark/Ladder/LadderSettings.cs +++ b/src/client/spark/view/Spark/Ladder/LadderSettings.cs @@ -299,12 +299,15 @@ namespace mbts.spark { order_entry_panel_initial_width = _default_order_entry_panel_width, zoom_slider_visible = false, zoom_factor = _default_zoom_factor, + net_change = NetChangeTerms.None, }; } } public enum BadgeStyle { Normal, Alternate } + public enum NetChangeTerms { None, Dollars, Ticks } + [ProtoMember(1)] public double row_height { get; set; } [ProtoMember(2)] @@ -411,6 +414,9 @@ namespace mbts.spark { [ProtoMember(47)] public LadderFavoriteAlgosSettings favorite_algos { get; set; } + [ProtoMember(48)] + public NetChangeTerms net_change { get; set; } + public bool Equals(LadderSettings other) => other != null && row_height == other.row_height && @@ -456,7 +462,8 @@ namespace mbts.spark { zoom_slider_visible == other.zoom_slider_visible && zoom_factor == other.zoom_factor && use_defaults == other.use_defaults && - favorite_algos == other.favorite_algos; + favorite_algos == other.favorite_algos && + net_change == other.net_change; public override bool Equals(object obj) => Equals(obj as LadderSettings); @@ -505,7 +512,8 @@ namespace mbts.spark { zoom_slider_visible.GetHashCode(), zoom_factor.GetHashCode(), use_defaults.GetHashCode(), - favorite_algos.GetHashCode()); + favorite_algos.GetHashCode(), + net_change.GetHashCode()); public struct WindowSpecifics { public readonly double order_entry_panel_width, zoom_factor; diff --git a/src/client/spark/view/Spark/Ladder/LadderSettingsVM.cs b/src/client/spark/view/Spark/Ladder/LadderSettingsVM.cs index 3f14f68ca..b3f9bed8b 100644 --- a/src/client/spark/view/Spark/Ladder/LadderSettingsVM.cs +++ b/src/client/spark/view/Spark/Ladder/LadderSettingsVM.cs @@ -56,6 +56,10 @@ namespace mbts.spark { _cancel_buys_visibility = new OrderEntryPanelItemVisibilityVM("Cancel Buys"), _cancel_sells_visibility = new OrderEntryPanelItemVisibilityVM("Cancel Sells"), _cancel_all_visibility = new OrderEntryPanelItemVisibilityVM("Cancel All"); + readonly Property + _show_in_net_change, + _show_in_net_change_dollars, + _show_in_net_change_ticks; public LadderSettingsVM(OrdersModel model, bool is_synthetic, Func get_left_panel_width, Func get_zoom_factor) { this.is_synthetic = is_synthetic; @@ -67,6 +71,10 @@ namespace mbts.spark { _alternate_order_size = backing(nameof(alternate_order_size)); _get_order_entry_panel_width = get_left_panel_width; _get_zoom_factor = get_zoom_factor; + _show_in_net_change = backing(nameof(show_in_net_change)); + _show_in_net_change_dollars = backing(nameof(show_in_net_change_dollars)); + _show_in_net_change_ticks = backing(nameof(show_in_net_change_ticks)); + // be sure to initialize backings before this measure_row_height call _row_height = backing(nameof(row_height), () => LadderRender.measure_row_height(get_result())); _orders.font_size_changed += on_font_size_changed; @@ -74,6 +82,7 @@ namespace mbts.spark { _price.font_size_changed += on_font_size_changed; _ask.font_size_changed += on_font_size_changed; _last.font_size_changed += on_font_size_changed; + void on_font_size_changed(double oldval, double newval) => _row_height.refresh(); } @@ -159,6 +168,32 @@ namespace mbts.spark { } } + public bool show_in_net_change { + get => _show_in_net_change.Value; + set { + // when unchecking, clear out dollars and ticks + if (!value) { + show_in_net_change_dollars = false; + show_in_net_change_ticks = false; + } + // when checking, by defalt check dollars + if (value) { + show_in_net_change_dollars = true; + } + _show_in_net_change.Value = value; + } + } + public bool show_in_net_change_dollars { + get => _show_in_net_change_dollars.Value; + set => _show_in_net_change_dollars.Value = value; + } + + public bool show_in_net_change_ticks { + get => _show_in_net_change_ticks.Value; + set => _show_in_net_change_ticks.Value = value; + } + + public string key => GridOrLadderSettingsSelectorKeys.Ladder; public void load(LadderSettings settings) { @@ -201,6 +236,9 @@ namespace mbts.spark { // because it could have changed from the UI // there might be a better way of doing this, like how // does the widths of the ladder grid column pull this off? + show_in_net_change = settings.net_change != LadderSettings.NetChangeTerms.None; + show_in_net_change_dollars = settings.net_change == LadderSettings.NetChangeTerms.Dollars; + show_in_net_change_ticks = settings.net_change == LadderSettings.NetChangeTerms.Ticks; } public LadderSettings get_result() { @@ -242,7 +280,19 @@ namespace mbts.spark { clone.order_entry_panel_initial_width = _get_order_entry_panel_width(); clone.zoom_slider_visible = _zoom_slider_visbility.show; clone.zoom_factor = _get_zoom_factor(); + clone.net_change = _create_net_change_terms(show_in_net_change_dollars, show_in_net_change_ticks); return clone; + + LadderSettings.NetChangeTerms _create_net_change_terms(bool dollars, bool ticks) { + if (dollars) { + return LadderSettings.NetChangeTerms.Dollars; + } + if (ticks) { + return LadderSettings.NetChangeTerms.Ticks; + } + return LadderSettings.NetChangeTerms.None; + } + } public void Dispose() => favorite_algos_vm.Dispose(); diff --git a/src/client/spark/view/Spark/Ladder/LadderSettingsView.xaml b/src/client/spark/view/Spark/Ladder/LadderSettingsView.xaml index 52b822f55..c51572218 100644 --- a/src/client/spark/view/Spark/Ladder/LadderSettingsView.xaml +++ b/src/client/spark/view/Spark/Ladder/LadderSettingsView.xaml @@ -134,7 +134,7 @@ Alternate Order Qty - +