More of Spark-328
This commit is contained in:
1 parent
e7ecf32423
commit
0d5bf06587
7 files changed
+63
-25
No files matched your search
@@ -74,6 +74,7 @@ namespace mbts.ui
|
||||
public static ImageSource Beaker { get { return (DrawingImage)_resources["Beaker"]; } }
|
||||
public static ImageSource Book { get { return (DrawingImage)_resources["Book"]; } }
|
||||
public static ImageSource CancelOrders { get { return (DrawingImage)_resources["CancelOrders"]; } }
|
||||
public static ImageSource ModifyOrder { get { return (DrawingImage)_resources["Pencil"]; } }
|
||||
public static ImageSource Clock { get { return (DrawingImage)_resources["Clock"]; } }
|
||||
public static ImageSource Defrag { get { return (DrawingImage)_resources["Defrag"]; } }
|
||||
public static ImageSource Display { get { return (DrawingImage)_resources["Display"]; } }
|
||||
|
||||
@@ -450,7 +450,18 @@ M0,0L63.999001,0 63.999001,48.792999 0,48.792999z">
|
||||
</DrawingGroup.Children>
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</DrawingImage>
|
||||
|
||||
<DrawingImage x:Key="Pencil">
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup>
|
||||
<DrawingGroup.Children>
|
||||
<GeometryDrawing Brush="Black" Geometry="M397.736,78.378c6.824,0,12.358-5.533,12.358-12.358V27.027C410.094,12.125,397.977,0,383.08,0H121.641c-3.277,0-6.42,1.303-8.739,3.62L10.527,105.995c-2.317,2.317-3.62,5.461-3.62,8.738v370.239C6.908,499.875,19.032,512,33.935,512h349.144c14.897,0,27.014-12.125,27.014-27.027V296.289c0.001-6.824-5.532-12.358-12.357-12.358c-6.824,0-12.358,5.533-12.358,12.358v188.684c0,1.274-1.031,2.311-2.297,2.311H33.936c-1.274,0-2.311-1.037-2.311-2.311v-357.88h75.36c14.898,0,27.016-12.12,27.016-27.017V24.716H383.08c1.267,0,2.297,1.037,2.297,2.311V66.02C385.377,72.845,390.911,78.378,397.736,78.378z M109.285,100.075c0,1.269-1.032,2.301-2.3,2.301H49.107l60.178-60.18V100.075z"/>
|
||||
<GeometryDrawing Brush="Black" Geometry="M492.865,100.396l-14.541-14.539c-16.304-16.304-42.832-16.302-59.138,0L303.763,201.28H103.559c-6.825,0-12.358,5.533-12.358,12.358c0,6.825,5.533,12.358,12.358,12.358h175.488l-74.379,74.379H103.559c-6.825,0-12.358,5.533-12.358,12.358s5.533,12.358,12.358,12.358h76.392l-0.199,0.199c-1.508,1.508-2.598,3.379-3.169,5.433l-19.088,68.747h-53.936c-6.825,0-12.358,5.533-12.358,12.358s5.533,12.358,12.358,12.358h63.332c0.001,0,2.709-0.306,3.107-0.41c0.065-0.017,77.997-21.642,77.997-21.642c2.054-0.57,3.926-1.662,5.433-3.169l239.438-239.435C509.168,143.228,509.168,116.7,492.865,100.396z M184.644,394.073l10.087-36.326l26.24,26.24L184.644,394.073z M244.69,372.752l-38.721-38.721l197.648-197.648l38.722,38.721L244.69,372.752z M475.387,142.054l-15.571,15.571l-38.722-38.722l15.571-15.571c6.669-6.668,17.517-6.667,24.181,0l14.541,14.541C482.054,124.54,482.054,135.388,475.387,142.054z"/>
|
||||
</DrawingGroup.Children>
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
|
||||
<DrawingImage x:Key="PauseIcon">
|
||||
<DrawingImage.Drawing>
|
||||
|
||||
@@ -83,6 +83,8 @@ namespace bts.spark
|
||||
SparkCommand.create("Cancel Buys", Icons.CancelOrders, SparkTags.NotImplemented);
|
||||
public static SparkCommand CancelSellOrders =>
|
||||
SparkCommand.create("Cancel Sells", Icons.CancelOrders, SparkTags.NotImplemented);
|
||||
|
||||
}
|
||||
public static SparkCommand ModifyOrder =>
|
||||
SparkCommand.create("Modify Order", Icons.ModifyOrder, SparkTags.NotImplemented);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ using System.Windows.Input;
|
||||
|
||||
namespace mbts.spark
|
||||
{
|
||||
class OrderBookRowVM : ViewModelBase {
|
||||
class OrderBookRowVM : ViewModelBase, IEquatable<OrderBookRowVM> {
|
||||
// implement Equals to be sync_with -friendly; Equals will defer to the OrderRecordImmutable
|
||||
readonly OrderBookVM _parent;
|
||||
readonly OrdersModel _model;
|
||||
@@ -38,6 +38,10 @@ namespace mbts.spark
|
||||
|
||||
void ignore() {/*These setters are just for WPF databinding :(*/ throw new NotImplementedException(); }
|
||||
|
||||
public bool Equals(OrderBookRowVM other) {
|
||||
return this._order.Equals(other._order);
|
||||
}
|
||||
|
||||
// the grid view uses this for sorting, it was just a bts.api.Security once upon a time, but that class no longer implements IComparable
|
||||
// this SelectableViewModeBase is essentially a wrapper class, which implements ISelecatble and IComparable
|
||||
public SecurityImmutable security { get; }
|
||||
@@ -129,7 +133,12 @@ namespace mbts.spark
|
||||
}
|
||||
|
||||
public DateTime last_change {
|
||||
get => _order.State.LastChange.ToDateTime();
|
||||
get {
|
||||
if (_order.State !=null && _order.State.LastChange != null) {
|
||||
return _order.State.LastChange.ToDateTime();
|
||||
}
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
set => ignore();
|
||||
}
|
||||
|
||||
@@ -174,7 +183,7 @@ namespace mbts.spark
|
||||
|
||||
public bool is_paused { get; set; }
|
||||
|
||||
public bool is_parent => _order.ParentKey == 0;
|
||||
public bool is_parent => _parent.order_has_children(_order.Key);
|
||||
public bool is_child => _order.ParentKey != 0;
|
||||
|
||||
Property<bool> _expanded;
|
||||
@@ -192,6 +201,8 @@ namespace mbts.spark
|
||||
public ICommand details_command { get; }
|
||||
|
||||
public ICommand toggle_command { get; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,16 +26,18 @@ namespace mbts.spark {
|
||||
|
||||
ObservableCollection<OrderRecordImmutable> _order_records;
|
||||
OrderBookRowVM wrap(OrderRecordImmutable record, SecurityImmutable s) => new OrderBookRowVM(this, _model, record, s);
|
||||
//IReadOnlyDictionary<uint, OrderRecordImmutable> _complete_order_state;
|
||||
|
||||
//Task<OrderKey?> t;
|
||||
Task<OrderKey?> t;
|
||||
|
||||
private async Task<OrderKey?> send_an_order() {
|
||||
var result = await _model.send_order(
|
||||
new OrderDefinition() {
|
||||
Login = "W.O.P.R.",
|
||||
Account = "BTS",
|
||||
Side = Side.Buy,
|
||||
SecurityKey = 1,
|
||||
Market = new MarketOrderDefinition() { }
|
||||
SecurityKey = 176868,
|
||||
Market = new MarketOrderDefinition() { },
|
||||
TimeInForce = TimeInForce.Day
|
||||
},
|
||||
6.66,
|
||||
6
|
||||
@@ -49,7 +51,7 @@ namespace mbts.spark {
|
||||
_bus = bus;
|
||||
_model = model;
|
||||
|
||||
//t = send_an_order();
|
||||
t = send_an_order();
|
||||
_order_records = new ObservableCollection<OrderRecordImmutable>();
|
||||
|
||||
var orders_sequence = _model.on_orders;
|
||||
@@ -101,17 +103,7 @@ namespace mbts.spark {
|
||||
//_dispose = _context_menu = new ContextMenuVM(_context_menu_item_factory);
|
||||
}
|
||||
|
||||
//private void _update_with_new_orders() {
|
||||
// System.Windows.MessageBox.Show($"We have {_complete_order_state.Count} orders");
|
||||
// List<OrderBookRowVM> all_updated = new List<OrderBookRowVM>();
|
||||
// foreach( var x in _complete_order_state.Values) {
|
||||
// all_updated.Add(wrap(x));
|
||||
// }
|
||||
// orders.sync_with(all_updated);
|
||||
//}
|
||||
|
||||
private readonly IBus _bus;
|
||||
OrderIDComparer _order_cmp = new OrderIDComparer();
|
||||
//void orders_updated(IOrderBook order_book) {
|
||||
// var all = order_book.get_all_orders();
|
||||
// _order_books.sync_with(all, _order_cmp);
|
||||
@@ -120,14 +112,18 @@ namespace mbts.spark {
|
||||
// }
|
||||
//}
|
||||
|
||||
internal void set_expanded(bool visible, uint target_parent) {
|
||||
internal void set_expanded(bool visible, uint target_parent_key) {
|
||||
foreach (var order in orders) {
|
||||
if (order.parent_order_key == target_parent) {
|
||||
if (order.parent_order_key == target_parent_key) {
|
||||
order.is_visible = visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal bool order_has_children(uint order_key) {
|
||||
return orders.Any(row_vm => row_vm.parent_order_key == order_key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -210,7 +206,8 @@ namespace mbts.spark {
|
||||
//private ContextMenuVM _context_menu;
|
||||
//public ContextMenuVM context_menu => _context_menu;
|
||||
private ObservableCollection<OrderBookRowVM> _orders = new ObservableCollection<OrderBookRowVM>();
|
||||
public ObservableCollection<OrderBookRowVM> orders { get { return _orders; }
|
||||
public ObservableCollection<OrderBookRowVM> orders {
|
||||
get { return _orders; }
|
||||
}
|
||||
|
||||
// Bind column visibility
|
||||
|
||||
@@ -129,6 +129,7 @@
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Header="Order Key" CellStyle="{StaticResource RowHeaderCell}" Binding="{Binding order_key}" />
|
||||
<DataGridTextColumn Header="Time" CellStyle="{StaticResource RowHeaderCell}" Binding="{Binding last_change, StringFormat='M/d H:mm:ss'}" />
|
||||
<DataGridTextColumn Header="User" CellStyle="{StaticResource RowHeaderCell}" Binding="{Binding login}" />
|
||||
<DataGridTextColumn Header="Account" CellStyle="{StaticResource RowHeaderCell}" Binding="{Binding account}" />
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using bts.api.orderman2;
|
||||
|
||||
namespace mbts.spark {
|
||||
internal class OrderBookWindow : SparkWindow<OrderBookStartupData> {
|
||||
@@ -30,10 +31,24 @@ namespace mbts.spark {
|
||||
_view.DataContext = _vm;
|
||||
|
||||
Commands = new SparkCommand[] {
|
||||
SparkCommands.ModifyOrder,
|
||||
SparkCommands.CancelBuyOrders,
|
||||
SparkCommands.CancelSellOrders,
|
||||
SparkCommands.CancelOrders,
|
||||
new SparkCommandCommand("Create a random order", ui.Icons.Beaker, new ui.DelegateCommand(() => model.send_order(new bts.api.orderman2.OrderDefinition() { SecurityKey = 1, Side = Side.Buy, TimeInForce = bts.api.orderman2.TimeInForce.Day }, 6.9, 42).ignore()))
|
||||
new SparkCommandCommand("Create a random order", ui.Icons.Beaker, new ui.DelegateCommand(
|
||||
() =>
|
||||
model.send_order(new OrderDefinition() {
|
||||
Login = "W.O.P.R.",
|
||||
Account = "BTS",
|
||||
Side = Side.Buy,
|
||||
SecurityKey = 176868,
|
||||
Market = new MarketOrderDefinition() { },
|
||||
TimeInForce = TimeInForce.Day
|
||||
},
|
||||
6.9, 42)
|
||||
.ignore()
|
||||
)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user