remove avg price delta columns from new pnl
This commit is contained in:
1 parent
ae4e6c2221
commit
d2bfcf7603
2 files changed
+111
-12
No files matched your search
@@ -20,6 +20,7 @@ using System.Collections.Specialized;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
@@ -277,5 +278,103 @@ namespace bts.shell {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class RemoveAvgPriceDeltaColumns {
|
||||
static IEnumerable<PNLView.Columns> _price_delta_cols =>
|
||||
EnumHelper.get_values<PNLView.Columns>()
|
||||
.Where(c => Regex.IsMatch(c.ToString(), ".*pricedelta.*", RegexOptions.IgnoreCase));
|
||||
|
||||
[Export]
|
||||
public IPNLSettingsMigrationRule remove_columns => new RemoveColumnsMigrationRule(_price_delta_cols);
|
||||
|
||||
[Export]
|
||||
public IPNLSettingsMigrationRule remove_triggers => new RemoveColumnAnimationsMigrationRule(_price_delta_cols);
|
||||
|
||||
class RemoveColumnsMigrationRule : IPNLSettingsMigrationRule {
|
||||
readonly HashSet<PNLView.Columns> _cols_to_remove;
|
||||
|
||||
public RemoveColumnsMigrationRule(IEnumerable<PNLView.Columns> cols_to_remove) =>
|
||||
_cols_to_remove = new HashSet<PNLView.Columns>(cols_to_remove);
|
||||
|
||||
public bool apply(PNLSettings settings, out PNLSettings new_settings) {
|
||||
if (settings != null) {
|
||||
if (_apply(ref settings, settings.grid.columns, (s, cols) => s.with(grid: s.grid.with(cols))) |
|
||||
_apply(ref settings, settings.group_columns, (s, cols) => s.with(group_columns: cols)) |
|
||||
_apply(ref settings, settings.header_columns, (s, cols) => s.with(header_columns: cols))) {
|
||||
new_settings = settings;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_settings = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _apply(ref PNLSettings settings, IEnumerable<GridColumnSettings> columns, Func<PNLSettings, IEnumerable<GridColumnSettings>, PNLSettings> set_columns) {
|
||||
if (_apply(columns, out var new_cols)) {
|
||||
settings = set_columns(settings, new_cols);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _apply(IEnumerable<GridColumnSettings> columns, out IEnumerable<GridColumnSettings> result) {
|
||||
var col_list = columns.ToList();
|
||||
int orig_count = col_list.Count;
|
||||
col_list.RemoveWhere(c => _cols_to_remove.Contains(EnumHelper.parse<PNLView.Columns>(c.id)));
|
||||
if (col_list.Count < orig_count) {
|
||||
result = col_list;
|
||||
return true;
|
||||
}
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class RemoveColumnAnimationsMigrationRule : IPNLSettingsMigrationRule {
|
||||
readonly HashSet<PNLView.Columns> _cols_to_remove;
|
||||
|
||||
public RemoveColumnAnimationsMigrationRule(IEnumerable<PNLView.Columns> cols_to_remove) =>
|
||||
_cols_to_remove = new HashSet<PNLView.Columns>(cols_to_remove);
|
||||
|
||||
public bool apply(PNLSettings settings, out PNLSettings new_settings) {
|
||||
if (settings != null) {
|
||||
if (_apply(ref settings, settings.animations, (s, t) => s.with(animations: t)) |
|
||||
_apply(ref settings, settings.group_header_animations, (s, t) => s.with(group_header_animations: t)) |
|
||||
_apply(ref settings, settings.header_row_animations, (s, t) => s.with(header_row_animations: t))) {
|
||||
new_settings = settings;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_settings = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _apply(ref PNLSettings settings, IEnumerable<PNLAnimationTriggerData> triggers, Func<PNLSettings, IEnumerable<PNLAnimationTriggerData>, PNLSettings> set_triggers) {
|
||||
if (_apply(triggers, out var new_triggers)) {
|
||||
settings = set_triggers(settings, new_triggers);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _apply(IEnumerable<PNLAnimationTriggerData> triggers, out IEnumerable<PNLAnimationTriggerData> result) {
|
||||
var trigger_map = triggers.ToImmutableDictionary(t => t.expression);
|
||||
var snapshot = trigger_map;
|
||||
foreach (var t in trigger_map.Values) {
|
||||
var anims = t.animations.ToList();
|
||||
int orig_count = anims.Count;
|
||||
anims.RemoveWhere(a => _cols_to_remove.Contains(a.column));
|
||||
if (anims.Count < orig_count)
|
||||
trigger_map = trigger_map.SetItem(t.expression, t.with(animations: anims.ToArray()));
|
||||
}
|
||||
if (trigger_map != snapshot) {
|
||||
result = trigger_map.Values;
|
||||
return true;
|
||||
}
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -382,37 +382,37 @@ namespace bts.shell.pnl {
|
||||
yield return day_pnl;
|
||||
/// total
|
||||
yield return total_net_pos;
|
||||
yield return total_net_avg_price_delta; // hidden
|
||||
//yield return total_net_avg_price_delta; // hidden
|
||||
// total long
|
||||
yield return total_long_pos; // hidden
|
||||
yield return total_long_avg_price; // hidden
|
||||
yield return total_long_avg_price_delta; // hidden
|
||||
//yield return total_long_avg_price_delta; // hidden
|
||||
// total short
|
||||
yield return total_short_pos; // hidden
|
||||
yield return total_short_avg_price; // hidden
|
||||
yield return total_short_avg_price_delta; // hidden
|
||||
//yield return total_short_avg_price_delta; // hidden
|
||||
/// sod
|
||||
yield return sod_net_pos;
|
||||
yield return sod_net_avg_price_delta; // hidden
|
||||
//yield return sod_net_avg_price_delta; // hidden
|
||||
// sod long
|
||||
yield return sod_long_pos; // hidden
|
||||
yield return sod_long_avg_price; // hidden
|
||||
yield return sod_long_avg_price_delta; // hidden
|
||||
//yield return sod_long_avg_price_delta; // hidden
|
||||
// sod short
|
||||
yield return sod_short_pos; // hidden
|
||||
yield return sod_short_avg_price; // hidden
|
||||
yield return sod_short_avg_price_delta; // hidden
|
||||
//yield return sod_short_avg_price_delta; // hidden
|
||||
/// day
|
||||
yield return day_net_pos;
|
||||
yield return day_net_avg_price_delta; // hidden
|
||||
//yield return day_net_avg_price_delta; // hidden
|
||||
// day long
|
||||
yield return day_long_pos; // hidden
|
||||
yield return day_long_avg_price; // hidden
|
||||
yield return day_long_avg_price_delta; // hidden
|
||||
//yield return day_long_avg_price_delta; // hidden
|
||||
// day short
|
||||
yield return day_short_pos; // hidden
|
||||
yield return day_short_avg_price; // hidden
|
||||
yield return day_short_avg_price_delta; // hidden
|
||||
//yield return day_short_avg_price_delta; // hidden
|
||||
/// raw day
|
||||
yield return raw_day_long_pos; // hidden
|
||||
yield return raw_day_short_pos; // hidden
|
||||
@@ -422,15 +422,15 @@ namespace bts.shell.pnl {
|
||||
/// working
|
||||
// working net
|
||||
yield return working_net_pos;
|
||||
yield return working_net_avg_price_delta;
|
||||
//yield return working_net_avg_price_delta;
|
||||
// working long
|
||||
yield return working_long_pos;
|
||||
yield return working_long_avg_price;
|
||||
yield return working_long_avg_price_delta;
|
||||
//yield return working_long_avg_price_delta;
|
||||
// working short
|
||||
yield return working_short_pos;
|
||||
yield return working_short_avg_price;
|
||||
yield return working_short_avg_price_delta;
|
||||
//yield return working_short_avg_price_delta;
|
||||
/// market
|
||||
yield return bid_price;
|
||||
yield return ask_price;
|
||||
|
||||
Reference in new issue
Block a user