diff --git a/src/client/spark/Risk/Combo/ComboReportFutureRow.cs b/src/client/spark/Risk/Combo/ComboReportFutureRow.cs
index 80dad4171..5a588ff52 100644
--- a/src/client/spark/Risk/Combo/ComboReportFutureRow.cs
+++ b/src/client/spark/Risk/Combo/ComboReportFutureRow.cs
@@ -41,8 +41,7 @@ namespace mbts.analytics {
}
var exp_str = col_key is null ?
"(NULL)" :
- SecurityFormatter.format_expiration(
- Security.ContractOneofCase.Option, col_key.symbol, col_key.expiration);
+ SecurityFormatter.format_expiration(col_key.expiration, symbol: col_key.symbol);
Log.Ui.warn($"ComboFutureRow does not have data for the requested expiration: {exp_str}");
return null;
}
diff --git a/src/client/spark/Risk/Combo/ComboReportOptionRow.cs b/src/client/spark/Risk/Combo/ComboReportOptionRow.cs
index 197392766..743355eac 100644
--- a/src/client/spark/Risk/Combo/ComboReportOptionRow.cs
+++ b/src/client/spark/Risk/Combo/ComboReportOptionRow.cs
@@ -50,8 +50,7 @@ namespace mbts.analytics {
return cell;
}
var exp_str = col_key == null ?
- "(NULL)" : SecurityFormatter.format_expiration(
- Security.ContractOneofCase.Option, col_key.symbol, col_key.expiration);
+ "(NULL)" : SecurityFormatter.format_expiration(col_key.expiration, col_key.symbol);
Log.Ui.warn($"ComboOptionRow does not have data for the requested expiration: {exp_str}.");
return null;
}
diff --git a/src/client/spark/view/Converters/EnumerableStringConverters/SelectedItemsStringConverter.cs b/src/client/spark/view/Converters/EnumerableStringConverters/SelectedItemsStringConverter.cs
index be079aa55..a059cb0f5 100644
--- a/src/client/spark/view/Converters/EnumerableStringConverters/SelectedItemsStringConverter.cs
+++ b/src/client/spark/view/Converters/EnumerableStringConverters/SelectedItemsStringConverter.cs
@@ -29,8 +29,7 @@
if (item is not SecurityExpiration exp) {
return string.Empty;
}
- return SecurityFormatter.format_expiration(
- exp.security_type.contract_case(), exp.symbol, exp.expiration);
+ return SecurityFormatter.format_expiration(exp.expiration, exp.symbol);
}
}
}
diff --git a/src/client/spark_api/security/SecurityFormatter.cs b/src/client/spark_api/security/SecurityFormatter.cs
index ccb2a308d..d00cea05a 100644
--- a/src/client/spark_api/security/SecurityFormatter.cs
+++ b/src/client/spark_api/security/SecurityFormatter.cs
@@ -95,49 +95,23 @@
public static string format_call_put(PutOrCall call_put) =>
call_put.ToString()[..1];
- ///
- /// Returns a concise string representation of a security expiration appropriate for UIs (e.g.
- /// es March 22, 2019: es 22 Mar 19).
- ///
- public static string format_expiration(
- Security.ContractOneofCase sec_type, string symbol, DateTime exp_date) =>
- format_expiration(
- sec_type, symbol, exp_date, false, true, true, DateFormat.DayMonthAbvDiff2000);
-
- ///
- /// Returns a concise string representation of a security expiration (using symbol-mapped
- /// expiration dates, and single-letter month codes) appropriate for UIs (e.g. es March 22,
- /// 2019: [Opt] [es] 22 Mar 19).
- ///
- public static string format_expiration(
- Security.ContractOneofCase sec_type,
- string symbol,
- DateTime exp_date,
- bool show_type,
- bool show_symbol,
- bool use_mapped_exp) =>
- format_expiration(
- sec_type, symbol, exp_date, show_type, show_symbol, use_mapped_exp, DateFormat.DayMonthAbvDiff2000);
-
+#nullable enable
///
/// Returns a concise string representation of a security expiration (using symbol-mapped
/// expiration dates, and single-letter month codes) appropriate for UIs (e.g. es March 22,
/// 2019: [Opt] [es] 22 Mar 19, or [Opt] [es] 22 H19).
///
public static string format_expiration(
- Security.ContractOneofCase sec_type,
- string symbol,
DateTime exp_date,
- bool show_type,
- bool show_symbol,
- bool use_mapped_exp,
+ string? symbol = null,
+ Security.ContractOneofCase? type = null,
DateFormat date_format = DateFormat.DayMonthAbvDiff2000) {
- string result = DateFormatter.Format(exp_date, date_format);
- if (show_symbol) {
+ var result = DateFormatter.Format(exp_date, date_format);
+ if (symbol is not null) {
result = symbol + " " + result;
}
- if (show_type) {
- result = format_security_type(sec_type) + " " + result;
+ if (type.HasValue) {
+ result = format_security_type(type.Value) + " " + result;
}
return result;
}
@@ -145,11 +119,9 @@
///
/// Returns a concise string representation of a future trade appropriate for UIs.
///
-#nullable enable
public static string format_future_trade(
string symbol, DateTime exp_date, double size, double marginal_price) {
- var exp_str = format_expiration(
- Security.ContractOneofCase.Future, symbol, exp_date, false, true, true);
+ var exp_str = format_expiration(exp_date, symbol: symbol);
return $"{exp_str} {size} lots @ {marginal_price:C}";
}
#nullable disable
@@ -165,7 +137,7 @@
double size,
double marginal_price
) {
- var exp_str = format_expiration(Security.ContractOneofCase.Option, symbol, exp_date, false, true, true);
+ var exp_str = format_expiration(exp_date, symbol: symbol);
var cp_str = is_call ? "C" : "P";
return $"{exp_str} {strike} {cp_str} {size} lots @ {marginal_price:C}";
}