fix (ui): Format perp futs 'Perp' suffix (not bogus exp)
This commit is contained in:
1 parent
07fb9e8eb7
commit
357bc5ad44
9 files changed
+27
-32
No files matched your search
@@ -145,7 +145,7 @@ namespace mbts {
|
||||
!(x == y);
|
||||
|
||||
public override string ToString() =>
|
||||
$"{security_tuple} {expiration.ToShortDateString()}";
|
||||
$"{security_tuple} {SecurityFormatter.format_expiration(expiration)}";
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace mbts.analytics {
|
||||
IEnumerable<VolSurfaceExpiration> all_exps) {
|
||||
var exps = all_exps.Where(vse => vse.symbol.is_null_or_empty()).ToArray();
|
||||
var exp_header_cells = exps
|
||||
.Select(vse => DateFormatter.Format(vse.expiration, DateFormat.DayMonthAbvDiff2000))
|
||||
.Select(vse => SecurityFormatter.format_expiration(vse.expiration))
|
||||
.ToArray();
|
||||
return (exps, exp_header_cells);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ namespace mbts.analytics {
|
||||
IEnumerable<VolSurfaceExpiration> all_exps) {
|
||||
var exps = all_exps.ToArray();
|
||||
var exp_header_cells = exps.Select(vse => string.IsNullOrEmpty(vse.symbol) ?
|
||||
DateFormatter.Format(vse.expiration, DateFormat.DayMonthAbvDiff2000) : vse.symbol)
|
||||
SecurityFormatter.format_expiration(vse.expiration) : vse.symbol)
|
||||
.ToArray();
|
||||
return (exps, exp_header_cells);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#nullable enable
|
||||
namespace mbts.analytics {
|
||||
using bts.api;
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
@@ -17,13 +19,9 @@ namespace mbts.analytics {
|
||||
symbol = null;
|
||||
}
|
||||
|
||||
private static string _format_exp(DateTime exp) {
|
||||
return mbts.ui.utility.ExpirationFormatter.DateFormatter.format_day_month_year(exp);
|
||||
}
|
||||
|
||||
SlideGreekUnitKey(DateTime exp_date) {
|
||||
exp = exp_date;
|
||||
_unique_name = _format_exp(exp_date);
|
||||
_unique_name = SecurityFormatter.format_expiration(exp_date);
|
||||
type = GroupType.Exp;
|
||||
symbol = null;
|
||||
}
|
||||
@@ -31,7 +29,7 @@ namespace mbts.analytics {
|
||||
SlideGreekUnitKey(DateTime exp_date, string symbol) {
|
||||
exp = exp_date;
|
||||
this.symbol = symbol;
|
||||
_unique_name = $"{_format_exp(exp_date)}:{symbol}";
|
||||
_unique_name = $"{SecurityFormatter.format_expiration(exp_date)}:{symbol}";
|
||||
type = GroupType.SymExp;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ namespace BCG {
|
||||
foreach (string sym in temp.Keys) {
|
||||
SortedList<DateTime, string> temp2 = temp[sym];
|
||||
foreach (KeyValuePair<DateTime, string> kvp in temp2) {
|
||||
string datecode = bts.api.DateFormatter.Format(kvp.Key, bts.api.DateFormat.MonthCodeLastDigitYear);
|
||||
string datecode = bts.api.SecurityFormatter.format_expiration(
|
||||
kvp.Key, date_format: bts.api.DateFormat.MonthCodeLastDigitYear);
|
||||
|
||||
string explegs = (temp.Keys.Count > 1) ? string.Concat(sym, datecode, "_", kvp.Value) :
|
||||
string.Concat(datecode, "_", kvp.Value);
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace BCG {
|
||||
string rv = String.Empty;
|
||||
foreach (SingleSpreadLeg l in legs)
|
||||
rv += (rv == String.Empty ? "" : "/") + l.symbol + //BCG.Utilities.Dates.DateCode.getMonthSymbol(l.exp) + (l.exp.Year - 2000);
|
||||
bts.api.DateFormatter.Format(l.exp, bts.api.DateFormat.DayMonthAbvDiff2000);
|
||||
SecurityFormatter.format_expiration(l.exp);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,16 +22,11 @@ namespace mbts.ui.converters {
|
||||
object value, Type target_type, object parameter, CultureInfo culture) =>
|
||||
throw new NotImplementedException();
|
||||
|
||||
public string convert(SecurityExpiration exp) {
|
||||
var sb = new StringBuilder();
|
||||
if (ShowType) {
|
||||
sb.Append($"[{SecurityFormatter.format_security_type(exp.security_type)}] ");
|
||||
}
|
||||
if (ShowSymbol) {
|
||||
sb.Append(exp.symbol);
|
||||
}
|
||||
sb.Append(DateFormatter.Format(exp.expiration, DateFormat));
|
||||
return sb.ToString();
|
||||
}
|
||||
public string convert(SecurityExpiration exp) =>
|
||||
SecurityFormatter.format_expiration(
|
||||
exp.expiration,
|
||||
ShowSymbol ? exp.symbol : null,
|
||||
ShowType ? exp.security_type.contract_case() : null,
|
||||
DateFormat);
|
||||
}
|
||||
}
|
||||
@@ -33,13 +33,6 @@
|
||||
public static string Format(DateTime date, DateFormat format) =>
|
||||
Format(date.Year, date.Month, date.Day, format);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a concise string representation of a date (using single-letter month codes)
|
||||
/// appropriate for UIs (e.g. March 22, 2019: 22 Mar 19, or 22 H19).
|
||||
/// </summary>
|
||||
public static string Format(uint year, uint month, uint day, DateFormat format) =>
|
||||
Format((int)year, (int)month, (int)day, format);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a concise string representation of a date (using single-letter month codes)
|
||||
/// appropriate for UIs (e.g. March 22, 2019: 22 Mar 19, or 22 H19).
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace bts.api {
|
||||
public partial class Security {
|
||||
public static security_key key(Security s) { return s.Id; }
|
||||
|
||||
public static bool is_perpetual_exp(DateTime exp) =>
|
||||
exp.Year < 2000 || exp.Year > 2999;
|
||||
|
||||
public static class Defaults {
|
||||
public static ContractSpecification ContractSpecification =>
|
||||
new() {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
format_future(symbol, (uint)exp.Year, (uint)exp.Month, (uint)exp.Day);
|
||||
|
||||
public static string format_future(string symbol, uint exp_year, uint exp_month, uint exp_day) =>
|
||||
$"{symbol}{DateFormatter.Format(exp_year, exp_month, exp_day, DateFormat.DayMonthAbvDiff2000)}";
|
||||
$"{symbol}{format_expiration(new((int)exp_year, (int)exp_month, (int)exp_day))}";
|
||||
|
||||
public static string format_future(string symbol, FutureContractImmutable future) =>
|
||||
format_future(symbol, future.ExpirationYear, future.ExpirationMonth, future.ExpirationDay);
|
||||
@@ -108,12 +108,17 @@
|
||||
string? symbol = null,
|
||||
Security.ContractOneofCase? type = null,
|
||||
DateFormat date_format = DateFormat.DayMonthAbvDiff2000) {
|
||||
var result = DateFormatter.Format(exp_date, date_format);
|
||||
var result = Security.is_perpetual_exp(exp_date) ?
|
||||
"Perp" : DateFormatter.Format(exp_date, date_format);
|
||||
if (symbol is not null) {
|
||||
result = symbol + " " + result;
|
||||
}
|
||||
if (type.HasValue) {
|
||||
result = format_security_type(type.Value) + " " + result;
|
||||
if (result.Length == 0) {
|
||||
result = format_security_type(type.Value);
|
||||
} else {
|
||||
result = $"[{format_security_type(type.Value)}] {result}";
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user