diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs index dc595bb3d..086c97ae7 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs @@ -101,8 +101,49 @@ namespace mbts.spark public double working_best_bid => _working_best_bid.Value; public double working_best_ask => _working_best_ask.Value; public IEnumerable animations => _animation.get_animations(); - public ICommand show_ladder => new DelegateCommand(() => _bus.post(SparkTags.ShowLadderTag, md)); - public ICommand show_order_ticket => new DelegateCommand(col => { + public ICommand show_ladder => new DelegateCommand(_show_ladder); + public ICommand show_order_book => new DelegateCommand(_show_order_book); + public ICommand show_order_ticket => new DelegateCommand(_show_order_ticket); + #endregion + + public void refresh() { + if (md.md.get_bbo(ref _bbo_ref, out NativePriceSize b, out NativePriceSize a)) { + _bid_price.set(b.price); + _bid_size.set(b.size); + _ask_price.set(a.price); + _ask_size.set(a.size); + } + if (md.md.get_last_trade(ref _last_ref, out NativePriceSize ps, out DateTime ts, out ulong v)) { + _last_price.set(ps.price); + _last_size.set(ps.size); + _volume.set(v); + } + _settlement.set(md.md.settlement_price); + _session_low.set(md.md.session_low); + _session_high.set(md.md.session_high); + _day_change.set(last_price - session_high); + } + + #region Show Windows + void _show_ladder() => _bus.post(SparkTags.ShowLadderTag, md); + + void _show_order_book(MarketViewView.Columns col) { + switch(col) { + case MarketViewView.Columns.WorkingBids: _show_order_book(Side.Buy); break; + case MarketViewView.Columns.WorkingAsks: _show_order_book(Side.Sell); break; + } + } + + void _show_order_book(Side side) => + _bus.post(SparkTags.ShowOrderBookTag, new bts.shell.OrderBookWindowFactory.OrderBookStartupData( + new List(), + new bts.shell.OrderBookWindowFactory.FilterStates { + statuses = new[] { OrderUtils.order_state_display_name(OrderStatus.Working) }, + sides = new[] { Side.Sell }, + security_criteria = new SecurityCriteria(security) + })); + + void _show_order_ticket(MarketViewView.Columns col) { var order = OrderDataHelper.Defaults.OrderDefinition(security); switch (col) { case MarketViewView.Columns.Bid: @@ -128,27 +169,10 @@ namespace mbts.spark _bus.post(SparkTags.ShowOrderTicketTag, (order, last_price, last_size)); break; } - }); + } #endregion - public void refresh() { - if (md.md.get_bbo(ref _bbo_ref, out NativePriceSize b, out NativePriceSize a)) { - _bid_price.set(b.price); - _bid_size.set(b.size); - _ask_price.set(a.price); - _ask_size.set(a.size); - } - if (md.md.get_last_trade(ref _last_ref, out NativePriceSize ps, out DateTime ts, out ulong v)) { - _last_price.set(ps.price); - _last_size.set(ps.size); - _volume.set(v); - } - _settlement.set(md.md.settlement_price); - _session_low.set(md.md.session_low); - _session_high.set(md.md.session_high); - _day_change.set(last_price - session_high); - } - + #region Callbacks void _on_orders(TableUpdate orders) { uint removed_buys = 0, removed_sells = 0, added_buys = 0, added_sells = 0; foreach (var o in orders.removed) { @@ -183,6 +207,7 @@ namespace mbts.spark } void _animation_AnimationsChanged() => RaisePropertyChanged(nameof(animations)); + #endregion } } } \ No newline at end of file diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml b/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml index ad6b6e61e..97ab90f23 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml +++ b/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml @@ -46,11 +46,44 @@ - - + + @@ -96,11 +129,21 @@ c:DataGridFilterProperties.Filter="{Binding DataContext.position_filter, Source={u:DirectReference grid}}" c:DataGridFilterProperties.FilterActive="{Binding DataContext.position_filter.active, Source={u:DirectReference grid}}" c:DataGridFilterProperties.FilterTemplate="{StaticResource IntMinMaxTemplate}"/> - + + + + + + + + + + + - - - - + @@ -138,21 +167,7 @@ - - - - + @@ -174,21 +189,7 @@ - - - - + @@ -210,32 +211,28 @@ - - - - + - + + + + + + + + + + + show()) - ); + _dispose = bus.subscribe(SparkTags.ShowOrderBookTag).ObserveOnDispatcher().Subscribe(show); } public override Task load(OrderBookStartupData state) { @@ -28,8 +26,8 @@ namespace bts.shell { return Task.FromResult(w); } - public async void show() { - var w = await load(new OrderBookStartupData()); + async void show(OrderBookStartupData startup_data) { + var w = await load(startup_data); _bus.post(SparkTags.ShowWindow, w); } diff --git a/src/client/spark/Modules/Trading/TradingShellModule.cs b/src/client/spark/Modules/Trading/TradingShellModule.cs index 14441e2fa..c4a857ab7 100644 --- a/src/client/spark/Modules/Trading/TradingShellModule.cs +++ b/src/client/spark/Modules/Trading/TradingShellModule.cs @@ -37,7 +37,7 @@ namespace bts.shell public int priority => 20; public IEnumerable actions => new [] { - SparkCommands.ShowOrders, + SparkCommands.ShowOrders.complete(() => new OrderBookWindowFactory.OrderBookStartupData()), SparkCommands.ShowFills, //SparkCommands.ShowPAndL, SparkCommands.PickLadder, diff --git a/src/client/spark/core/Bus/SparkCommands.cs b/src/client/spark/core/Bus/SparkCommands.cs index dc9ea3cbb..519426f10 100644 --- a/src/client/spark/core/Bus/SparkCommands.cs +++ b/src/client/spark/core/Bus/SparkCommands.cs @@ -1,5 +1,6 @@ using bts.api; using bts.api.orderman2; +using bts.shell; using mbts.spark; using mbts.ui; using System; @@ -21,7 +22,7 @@ namespace bts.spark SparkCommand.create("Time and Sales", Icons.Clock, SparkTags.ShowPickMultiple, ShowTimeAndSales); // Trading - public static SparkCommand ShowOrders => + public static PartialCommand ShowOrders => SparkCommand.create("Order Book", Icons.Book, SparkTags.ShowOrderBookTag); public static SparkCommand ShowFills => diff --git a/src/client/spark/core/Bus/SparkTags.cs b/src/client/spark/core/Bus/SparkTags.cs index ee52717a1..60b550f16 100644 --- a/src/client/spark/core/Bus/SparkTags.cs +++ b/src/client/spark/core/Bus/SparkTags.cs @@ -1,5 +1,6 @@ using bts.api; using bts.api.orderman2; +using bts.shell; using bts.spark; using mbts.ui; using System; @@ -35,7 +36,7 @@ namespace mbts.spark public static ITag ShowLadderTag { get; } = new SparkTag("Show Ladder"); public static ITag> ShowLinkedLadder { get; } = new SparkTag>("Linked Ladder"); public static ITag ShowMarketViewTag { get; } = new SparkTag("Show MarketView"); - public static ITag ShowOrderBookTag { get; } = new SparkTag(nameof(ShowOrderBookTag)); + public static ITag ShowOrderBookTag { get; } = new SparkTag(nameof(ShowOrderBookTag)); public static ITag ShowModifyOrderTag { get; } = new SparkTag(nameof(ShowModifyOrderTag)); public static ITag ShowOrderDetailsTag { get; } = new SparkTag(nameof(ShowOrderDetailsTag)); public static ITag ShowOrderModifyTag { get; } = new SparkTag(nameof(ShowOrderModifyTag));