From 960a618fe1a4ff17a5b98eef2cd4055ceb77588a Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 28 Jul 2022 10:26:11 -0400 Subject: [PATCH] fix: Bind pnl account col to AccountTuple Bugs (fixed): * The group-row pnl cell hyperlinks don't open anything when clicked Cause: An InvalidCastException is thrown when the code that creates the fills vm (for the popup) casts 'PNLRowCollectionViewGroup.Name' to an AccountTuple, as said 'Name' member is bound to the 'account_name' (of type string). --- src/client/spark/Modules/Trading/PNL/Data/PNLData.cs | 1 + src/client/spark/Modules/Trading/PNL/VM/PNLRowVM.cs | 4 ++-- src/client/spark/Modules/Trading/PNL/VM/PNLVM.cs | 4 +++- src/client/spark/Modules/Trading/PNL/View/PNLView.xaml | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/client/spark/Modules/Trading/PNL/Data/PNLData.cs b/src/client/spark/Modules/Trading/PNL/Data/PNLData.cs index 8812ce2db..4f44c1927 100644 --- a/src/client/spark/Modules/Trading/PNL/Data/PNLData.cs +++ b/src/client/spark/Modules/Trading/PNL/Data/PNLData.cs @@ -286,6 +286,7 @@ namespace bts.shell.pnl { AskLTESettle = Ask | Settle | 1 << 7 } + public AccountTuple account => new(account_id, account_name); public string symbol => security?.pnl_symbol() ?? string.Empty; public double effective_cpp => override_cpp ?? default_cpp; diff --git a/src/client/spark/Modules/Trading/PNL/VM/PNLRowVM.cs b/src/client/spark/Modules/Trading/PNL/VM/PNLRowVM.cs index ebfd07cdb..879e1e934 100644 --- a/src/client/spark/Modules/Trading/PNL/VM/PNLRowVM.cs +++ b/src/client/spark/Modules/Trading/PNL/VM/PNLRowVM.cs @@ -36,7 +36,7 @@ namespace bts.shell.pnl { _animator = new PNLCellEmbeddedAnimationModel(default_appearances, triggers); _animator.on_row(data); pnl_price = _cell_map.add_price_double(ColumnKeys.PNLPrice, d => d.pnl_price); - account_name_cell = _cell_map.add(ColumnKeys.Account, d => d.account_name); + account_cell = _cell_map.add(ColumnKeys.Account, d => d.account); security_type_cell = _cell_map.add(ColumnKeys.SecurityType, d => d.security?.ContractCase ?? Security.ContractOneofCase.None); exchange_cell = _cell_map.add(ColumnKeys.Exchange, d => d.security?.Exchange ?? Venue.Unset); symbol_cell = _cell_map.add(ColumnKeys.Symbol, d => d.symbol); @@ -159,7 +159,7 @@ namespace bts.shell.pnl { public Security.ContractOneofCase security_type => security?.ContractCase ?? Security.ContractOneofCase.None; public SecurityImmutable? security => data.security; // cells - public PNLCellVM account_name_cell { get; } + public PNLCellVM account_cell { get; } public PNLCellVM exchange_cell { get; } public PNLCellVM symbol_cell { get; } public PNLCellVM security_type_cell { get; } diff --git a/src/client/spark/Modules/Trading/PNL/VM/PNLVM.cs b/src/client/spark/Modules/Trading/PNL/VM/PNLVM.cs index 3f6b72486..d65b60327 100644 --- a/src/client/spark/Modules/Trading/PNL/VM/PNLVM.cs +++ b/src/client/spark/Modules/Trading/PNL/VM/PNLVM.cs @@ -656,7 +656,9 @@ namespace bts.shell.pnl { static void _append_fills_filter(fills.FillsFilterStates filter, PNLRowCollectionViewGroup group, ColumnKeys key) { switch (key) { - case ColumnKeys.Account: filter.account = new[] { ((AccountTuple)group.Name).id }; break; + case ColumnKeys.Account: + filter.account = new[] { ((PNLCellValue)group.Name).value.id }; + break; case ColumnKeys.Symbol: filter.symbol = new[] { group.Name.ToString() }; break; case ColumnKeys.Exchange: filter.exchange = new[] { (Venue)group.Name }; break; case ColumnKeys.Security: diff --git a/src/client/spark/Modules/Trading/PNL/View/PNLView.xaml b/src/client/spark/Modules/Trading/PNL/View/PNLView.xaml index 7242dea8d..1520a3522 100644 --- a/src/client/spark/Modules/Trading/PNL/View/PNLView.xaml +++ b/src/client/spark/Modules/Trading/PNL/View/PNLView.xaml @@ -643,7 +643,7 @@ c:DataGridFilterProperties.FilterActive="{Binding DataContext.account_filter.active, Source={u:DirectReference _grid}}" c:DataGridFilterProperties.FilterOpen="{Binding DataContext.account_filter.open, Source={u:DirectReference _grid}}" key="Account" - data_member_path="account_name_cell.cell_data" + data_member_path="account_cell.cell_data" sort_member_path="account_name" HeaderTemplate="{StaticResource AnchorableColumnHeaderTemplate}" /> @@ -1112,7 +1112,7 @@ - +