fix: Support multiple exchanges in exp params view/vm
This commit is contained in:
1 parent
10c0e4247d
commit
91042cb41e
3 files changed
+20
-5
No files matched your search
@@ -206,7 +206,16 @@ namespace mbts.spark {
|
||||
.Where(d => d.HasSecurity && d.Security.Symbol == r.security.symbol)
|
||||
.Where(d => is_unexpired(d))
|
||||
.TryGetMinElement(
|
||||
d => (r.security.expiration - d.Security.Expiration.date_time()).Ticks.abs(),
|
||||
d => {
|
||||
var expDiff = (r.security.expiration - d.Security.Expiration.date_time()).Ticks.abs();
|
||||
if (r.security.exchange != d.Security.Exchange.to_venue()) {
|
||||
// This is a hack to favor the security from the same venue as the row's
|
||||
// security in the event of a tie (for the nearest exp). As long as exp
|
||||
// dates are separated by more than 1 tick (100ns), the hack will work.
|
||||
expDiff += 1;
|
||||
}
|
||||
return expDiff;
|
||||
},
|
||||
out var nearest_exp)) {
|
||||
r.driver = nearest_exp;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ namespace mbts.ui.shell {
|
||||
new() {
|
||||
ShowSymbol = true,
|
||||
ShowType = true,
|
||||
MapExp = true
|
||||
MapExp = true,
|
||||
ShowVenue = true,
|
||||
};
|
||||
|
||||
public static IValueConverter driver_display_text_converter =>
|
||||
|
||||
@@ -4,10 +4,10 @@ namespace mbts.ui.converters {
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Windows.Data;
|
||||
|
||||
class ExpirationTextConverter : IValueConverter {
|
||||
public bool ShowVenue { get; set; }
|
||||
public bool ShowType { get; set; }
|
||||
public bool ShowSymbol { get; set; }
|
||||
public bool MapExp { get; set; }
|
||||
@@ -22,11 +22,16 @@ namespace mbts.ui.converters {
|
||||
object value, Type target_type, object parameter, CultureInfo culture) =>
|
||||
throw new NotImplementedException();
|
||||
|
||||
public string convert(SecurityExpiration exp) =>
|
||||
SecurityFormatter.format_expiration(
|
||||
public string convert(SecurityExpiration exp) {
|
||||
var rv = SecurityFormatter.format_expiration(
|
||||
exp.expiration,
|
||||
ShowSymbol ? exp.symbol : null,
|
||||
ShowType ? exp.security_type.contract_case() : null,
|
||||
DateFormat);
|
||||
if (ShowVenue) {
|
||||
rv = $"{rv} ({exp.exchange})";
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user