diff --git a/src/client/spark/Modules/Trading/Fills/FillsVM.cs b/src/client/spark/Modules/Trading/Fills/FillsVM.cs index e370685ea..70e5d1977 100644 --- a/src/client/spark/Modules/Trading/Fills/FillsVM.cs +++ b/src/client/spark/Modules/Trading/Fills/FillsVM.cs @@ -5,6 +5,7 @@ using bts.collections; using bts.shell.fills; using bts.spark; using bts.utils; +using bts.utils.csv; using mbts.collections; using mbts.persist; using mbts.spark.filters; @@ -23,6 +24,7 @@ using System.Linq; using System.Reactive.Disposables; using System.Reactive.Linq; using System.Windows.Data; +using System.Windows.Input; using System.Windows.Media; using static bts.api.orderman.Fill.Types; using static bts.shell.FillsWindowFactory; @@ -145,6 +147,7 @@ namespace mbts.spark { _unfiltered_fills_changed += o.OnNext; return Disposable.Create(() => _unfiltered_fills_changed -= o.OnNext); }); + export_to_csv_command = FileDialogCommand.export_csv(() => rows.ToCsv(Row.csv_properties), "Fills"); _dispose = new CompositeDisposable( ObservableAutoWrapper.connect(col_tups, columns, ct => ct.col), ObservableAutoWrapper.connect_item_hooks(col_tups, ct => ct.filter as IDisposable), @@ -210,6 +213,8 @@ namespace mbts.spark { public void on_sorting(object sender, DIYGridSortingEventArgs e) => _rows_manager.on_sorting(e); + public ICommand export_to_csv_command { get; } + static Columns _col_key(ColumnBase column) => ((IKeyedColumn)column).key; @@ -309,6 +314,27 @@ namespace mbts.spark { public override bool Equals(object obj) => Equals(obj as Row); public override int GetHashCode() => _fill.FillKey.GetHashCode() ^ _order.Key.GetHashCode(); + static HashSet _properties_for_csv_export = new HashSet(new string[] { + nameof(fill_time), + nameof(time_in_force), + nameof(order_type), + nameof(display_name), + nameof(account), + nameof(user), + nameof(exchange), + nameof(side), + nameof(price), + nameof(size), + nameof(fill_kind), + nameof(fill_status), + nameof(fill_key), + nameof(order_key), + nameof(root_algo_order_type), + nameof(root_algo_display_name) + }); + public static IEnumerable csv_properties => typeof(Row).GetProperties() + .Where(x => _properties_for_csv_export.Contains(x.Name)); + public event Action invalidated; void IRowVM.raise_invalidated() => invalidated?.Invoke(); }