fills window
This commit is contained in:
1 parent
ec7bd46cbb
commit
b26a2ef784
9 files changed
+71
-40
No files matched your search
@@ -19,10 +19,14 @@ namespace bts.spark
|
||||
|
||||
|
||||
// Trading
|
||||
public static SparkCommand ShowOrders { get; }
|
||||
public static SparkCommand ShowFills { get; }
|
||||
public static SparkCommand ShowOrders { get; } =
|
||||
SparkCommand.create("Order Book", Icons.Book, SparkTags.ShowOrderBookTag);
|
||||
|
||||
public static SparkCommand ShowFills { get; } =
|
||||
SparkCommand.create("Fills", Icons.Payment, SparkTags.ShowFillsTag);
|
||||
public static SparkCommand ShowPAndL { get; }
|
||||
public static SparkCommand ShowLadder { get; }
|
||||
//= SparkCommand.create("Ladder", Icons.Depth, SparkTags.ShowPickOne, SparkTags.ShowLadderTag);
|
||||
public static SparkCommand ShowOrderTicket { get; }
|
||||
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace mbts.spark {
|
||||
|
||||
#region Show Window
|
||||
public static ITag ShowAuditLogsTag { get; } = new SparkTag(nameof(ShowAuditLogsTag));
|
||||
public static ITag ShowFillsTag { get; } = new SparkTag(nameof(ShowFillsTag));
|
||||
public static ITag<SecurityList> ShowFillsTag { get; } = new SparkTag<SecurityList>(nameof(ShowFillsTag));
|
||||
public static ITag<uint> ShowLadderTag { get; } = new SparkTag<uint>("Show Ladder");
|
||||
public static ITag<IObservable<uint>> ShowLinkedLadder { get; } = new SparkTag<IObservable<uint>>("Linked Ladder");
|
||||
public static ITag<SecurityList> ShowMarketViewTag { get; } = new SparkTag<SecurityList>("Show MarketView");
|
||||
public static ITag ShowOrderBookTag { get; } = new SparkTag(nameof(ShowOrderBookTag));
|
||||
public static ITag<Nothing> ShowOrderBookTag { get; } = new SparkTag<Nothing>(nameof(ShowOrderBookTag));
|
||||
public static ITag ShowOrderDetailsTag = new SparkTag(nameof(ShowOrderDetailsTag));
|
||||
public static ITag ShowOrderModifyTag = new SparkTag(nameof(ShowOrderModifyTag));
|
||||
public static ITag ShowOrderTicketTag = new SparkTag(nameof(ShowOrderTicketTag));
|
||||
@@ -46,6 +46,9 @@ namespace mbts.spark {
|
||||
|
||||
public static ITag<IShellWindow> ShowWindow { get; } = new SparkTag<IShellWindow>("Show Window");
|
||||
|
||||
public static ITag<ITag<SecurityList>> ShowPickMultiple { get; } = new SparkTag<ITag<SecurityList>>("PickN");
|
||||
public static ITag<ITag<SecurityMD>> ShowPickOne { get; } = new SparkTag<ITag<SecurityMD>>("Pick1");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Action
|
||||
|
||||
@@ -5,6 +5,9 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using bts.api;
|
||||
using mbts.spark;
|
||||
using mbts.ui;
|
||||
using System.ComponentModel.Composition;
|
||||
using mbts;
|
||||
|
||||
namespace bts {
|
||||
static class SecurityPicker {
|
||||
@@ -17,4 +20,26 @@ namespace bts {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
class SecurityPickerDaemon : IInitializable, IDisposable {
|
||||
public int priority => 42;
|
||||
IDisposable _dispose;
|
||||
|
||||
[ImportingConstructor]
|
||||
public SecurityPickerDaemon(IBus bus) {
|
||||
|
||||
_dispose = Disposable.Create(
|
||||
bus.subscribe(SparkTags.ShowPickOne).Subscribe(show_pick_one)
|
||||
);
|
||||
}
|
||||
|
||||
void show_pick_one(ITag<SecurityMD> tag) {
|
||||
}
|
||||
|
||||
public void initialize() { }
|
||||
|
||||
public void Dispose() {
|
||||
Disposable.dispose(ref _dispose);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,14 +11,21 @@ using bts.spark;
|
||||
using mbts;
|
||||
using System.ComponentModel.Composition;
|
||||
using bts.api;
|
||||
using mbts.spark;
|
||||
|
||||
namespace bts.shell {
|
||||
class TradingShellModule : IShellModule {
|
||||
LadderWindowFactory _lf;
|
||||
LadderWindowFactory _lwf;
|
||||
OrderBookWindowFactory _obwf;
|
||||
FillsWindowFactory _fwf;
|
||||
PositionWindowFactory _plwf;
|
||||
|
||||
[ImportingConstructor]
|
||||
public TradingShellModule(IBus bus, IWindowManager wm) {
|
||||
_lf = new LadderWindowFactory(this, bus, wm);
|
||||
public TradingShellModule(IBus bus, IWindowManager wm, SecuritySource ssrc) {
|
||||
_lwf = new LadderWindowFactory(this, bus, wm);
|
||||
_obwf = new OrderBookWindowFactory(this, bus);
|
||||
_fwf = new FillsWindowFactory(this, bus, ssrc);
|
||||
_plwf = new PositionWindowFactory(this, bus);
|
||||
}
|
||||
|
||||
public ImageSource icon => Icons.Trades;
|
||||
@@ -35,15 +42,24 @@ namespace bts.shell {
|
||||
SparkCommands.ShowOrderTicket
|
||||
};
|
||||
|
||||
IEnumerable<IShellWindowFactory> window_factories() {
|
||||
yield return _lwf;
|
||||
yield return _obwf;
|
||||
yield return _fwf;
|
||||
yield return _plwf;
|
||||
}
|
||||
|
||||
public Task<IShellWindow> create(Stream load_stream) {
|
||||
if (try_deserialize(load_stream, out ShellSerializationHeader header)) {
|
||||
if (header.name == _lf.name) return _lf.load_window(load_stream, header.version);
|
||||
foreach (var wf in window_factories()) {
|
||||
if (header.name == wf.name) return wf.load_window(load_stream, header.version);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
Disposable.dispose(ref _lf);
|
||||
Disposable.dispose(ref _lwf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts.shell;
|
||||
using bts.spark;
|
||||
using Google.Protobuf;
|
||||
using mbts.spark.menu_items;
|
||||
@@ -21,12 +22,10 @@ namespace mbts.spark
|
||||
{
|
||||
internal class FillsVM : DisposableViewModelBase
|
||||
{
|
||||
public const int VERSION = 1;
|
||||
public const string SAVE_NAME = "Fills";
|
||||
|
||||
public FillsVM(IBus bus, DemoOrdersModel model, SecuritySource ssrc, IReadOnlyCollection<SecurityImmutable> securities, IReadOnlyCollection<SortingCriteria> sorting_criteria = null) {
|
||||
public FillsVM(FillsWindowFactory factory, IBus bus, DemoOrdersModel model, SecuritySource ssrc, IEnumerable<SecurityImmutable> securities, IEnumerable<SortingCriteria> sorting_criteria = null) {
|
||||
_bus = bus;
|
||||
_model = model;
|
||||
_factory = factory;
|
||||
_securities = new HashSet<SecurityImmutable>(securities ?? Enumerable.Empty<SecurityImmutable>());
|
||||
_rows = new ObservableAutoWrapper<Row, FillTuple>(_fills, f => new Row(f, _model));
|
||||
rows_view = CollectionViewSource.GetDefaultView(_rows);
|
||||
@@ -46,6 +45,7 @@ namespace mbts.spark
|
||||
}
|
||||
|
||||
private readonly IBus _bus;
|
||||
private readonly FillsWindowFactory _factory;
|
||||
private readonly DemoOrdersModel _model;
|
||||
private readonly ObservableCollection<FillTuple> _fills = new ObservableCollection<FillTuple>();
|
||||
private readonly ObservableAutoWrapper<Row, FillTuple> _rows;
|
||||
@@ -83,8 +83,7 @@ namespace mbts.spark
|
||||
public ContextMenuVM context_menu => _context_menu;
|
||||
|
||||
public void get_state(Stream save_here) {
|
||||
ProtoBufSerializationHelper.serialize(save_here, new ShellSerializationHeader { name = SAVE_NAME, version = VERSION });
|
||||
ProtoBufSerializationHelper.serialize(save_here, new StartupData(_securities, rows_view.SortDescriptions.Select(sd => new SortingCriteria(sd)).ToArray()));
|
||||
_factory.save(new StartupData(_securities, rows_view.SortDescriptions.Select(sd => new SortingCriteria(sd)).ToArray()), save_here);
|
||||
}
|
||||
|
||||
private class Row {
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace mbts.spark.menu_items
|
||||
public int priority => 1;
|
||||
public ImageSource icon => Icons.Payment;
|
||||
public string sectional_id => MenuItemSections.OrderPassiveWindow;
|
||||
public void execute() { _bus.post(SparkTags.ShowFillsTag, new SparkBusData.ShowFillsMessage()); }
|
||||
public void execute() { _bus.post(SparkTags.ShowFillsTag, null); }
|
||||
public bool can_execute() { return true; }
|
||||
public void raise_display_name_changed() { display_name_changed?.Invoke(); }
|
||||
public void raise_can_execute_changed() { can_execute_changed?.Invoke(); }
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace mbts.spark.menu_items
|
||||
{
|
||||
public OrderBookMenuItem(IBus bus) {
|
||||
items = new [] {
|
||||
Create("All Orders...", "a", Icons.Book, execute:() => bus.post(ShowOrderBookTag, new ShowOrderBookMessage())),
|
||||
Create("Active Orders...", "b", Icons.Book, execute:() => bus.post(ShowOrderBookTag, new ShowOrderBookMessage())),
|
||||
Create("Spreader Orders...", "b", Icons.Book, execute:() => bus.post(ShowOrderBookTag, new ShowOrderBookMessage()))
|
||||
Create("All Orders...", "a", Icons.Book, execute:() => bus.post(ShowOrderBookTag, nothing)),
|
||||
Create("Active Orders...", "b", Icons.Book, execute:() => bus.post(ShowOrderBookTag, nothing)),
|
||||
Create("Spreader Orders...", "b", Icons.Book, execute:() => bus.post(ShowOrderBookTag, nothing))
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts.shell;
|
||||
using bts.spark;
|
||||
using mbts.spark.menu_items;
|
||||
using mbts.spark.utilities;
|
||||
@@ -16,10 +17,11 @@ using System.Windows.Input;
|
||||
|
||||
namespace mbts.spark {
|
||||
class OrderBookVM : DisposableViewModelBase {
|
||||
public const string SAVE_NAME = "SparkOrderBookWindow";
|
||||
readonly OrderBookWindowFactory _creator;
|
||||
readonly DemoOrdersModel _model;
|
||||
|
||||
public OrderBookVM(IBus bus, DemoOrdersModel model, OrderBookState state, IObservable<OrderBookSettings> settings) {
|
||||
public OrderBookVM(OrderBookWindowFactory factory, IBus bus, DemoOrdersModel model, OrderBookState state, IObservable<OrderBookSettings> settings) {
|
||||
_creator = factory;
|
||||
_bus = bus;
|
||||
_model = model;
|
||||
|
||||
@@ -47,12 +49,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
public void get_state(System.IO.Stream output) {
|
||||
ShellSerializationHeader header = new ShellSerializationHeader() {
|
||||
version = 1,
|
||||
name = SAVE_NAME
|
||||
};
|
||||
ProtoBuf.Serializer.SerializeWithLengthPrefix(output, header, ProtoBuf.PrefixStyle.Fixed32);
|
||||
ProtoBuf.Serializer.SerializeWithLengthPrefix(output, new OrderBookState(), ProtoBuf.PrefixStyle.Fixed32);
|
||||
_creator.save(new OrderBookState(), output);
|
||||
}
|
||||
|
||||
private readonly IBus _bus;
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
// _ssrc = ssrc;
|
||||
// _wm = wm;
|
||||
// _dispose = Disposable.Create(
|
||||
// _bus.subscribe<ShowOrderBookMessage>(ShowOrderBookTag).ObserveOnDispatcher().Subscribe(show_order_book),
|
||||
// _bus.subscribe<ShowFillsMessage>(ShowFillsTag).ObserveOnDispatcher().Subscribe(show_fills),
|
||||
// _bus.subscribe<ShowAuditLogsMessage>(ShowAuditLogsTag).ObserveOnDispatcher().Subscribe(show_audit_log),
|
||||
// _bus.subscribe<ShowPositionsMessage>(ShowPositionsTag).ObserveOnDispatcher().Subscribe(show_positions),
|
||||
@@ -56,8 +55,6 @@
|
||||
// public Task<IShellWindow> create(Stream load_stream) {
|
||||
// var header = ProtoBuf.Serializer.DeserializeWithLengthPrefix<ShellSerializationHeader>(load_stream, ProtoBuf.PrefixStyle.Fixed32);
|
||||
// switch(header?.name) {
|
||||
// case OrderBookVM.SAVE_NAME: if (try_deserialize(load_stream, out OrderBookState orders_state)) return Task.FromResult(create_order_book_window(orders_state)); break;
|
||||
// case FillsVM.SAVE_NAME: { if (try_deserialize(load_stream, out FillsVM.StartupData state)) return Task.FromResult(create_fills_window(state)); break; }
|
||||
// case TimeAndSalesVM.SAVE_NAME: { if (try_deserialize(load_stream, out TimeAndSalesVM.StartupData state)) return Task.FromResult<IShellWindow>(new TimeAndSalesWindow(this, _bus, state, _ssrc)); break; }
|
||||
// }
|
||||
// return Task.FromResult<IShellWindow>(null);
|
||||
@@ -71,16 +68,6 @@
|
||||
// return ShellWindow.create(this, "Order Book", view, vm.get_state);
|
||||
// }
|
||||
|
||||
// private IShellWindow create_fills_window(FillsVM.StartupData startup_data) { return create_fills_window(startup_data.securities?.Select(x => (SecurityImmutable)deserialize<Security>(x)).ToList(), startup_data.sorting_criteria); }
|
||||
// private IShellWindow create_fills_window(IReadOnlyCollection<SecurityImmutable> securities) { return create_fills_window(securities, null); }
|
||||
// private IShellWindow create_fills_window(IReadOnlyCollection<SecurityImmutable> securities, IReadOnlyCollection<SortingCriteria> sorting_criteria) {
|
||||
// var vm = new FillsVM(_bus, new DemoOrdersModel(_bus), _ssrc, securities, sorting_criteria);
|
||||
// var view = new FillsView { DataContext = vm, Width = 1024, Height = 800 };
|
||||
// return ShellWindow.create(this, "Fills", view, vm.get_state, Icons.Ticket);
|
||||
// }
|
||||
|
||||
// private void show_order_book(ShowOrderBookMessage msg) { _wm.Windows.Add(create_order_book_window(new OrderBookState())); }
|
||||
// private void show_fills(ShowFillsMessage msg) { _wm.Windows.Add(create_fills_window(new List<SecurityImmutable>())); }
|
||||
// private void show_audit_log(ShowAuditLogsMessage msg) { }
|
||||
// private void show_positions(ShowPositionsMessage msg) { }
|
||||
// private void show_time_and_sales(ShowTimeAndSalesMessage msg) { _wm.Windows.Add(new TimeAndSalesWindow(this, _bus, msg.data, _ssrc)); }
|
||||
|
||||
Reference in new issue
Block a user