FillsVM - making it safer in case of nulls

This commit is contained in:
Jake Norbut committed 2018-08-22 18:11:14 -05:00
1 parent 102a6d8269
commit 4fdea219b6
2 files changed
+12 -4

No files matched your search

@@ -157,11 +157,11 @@ namespace mbts.spark {
}
public DateTime fill_time => _fill.Timestamp.ToDateTimeOffset().LocalDateTime;
public TimeInForce time_in_force => _order.Def.TimeInForce;
public OrderType order_type => _order.Def.CustomDef.CustomCase;
public TimeInForce time_in_force => _order.time_in_force();
public OrderType order_type => _order.order_type();
public OrderMetadata order_metadata => _model.factory.get_metadata(_order.Def.CustomDef.CustomCase);
public string account { get; private set; }
public string user => _order.Def.User;
public string user => _order.user();
public Venue exchange => security.Exchange;
public Side side => _fill.Side;
public double price => _fill.LastPrice;
+9 -1
View File
@@ -2,6 +2,7 @@
using bts.api.orderman;
using mbts.utils;
using System;
using static bts.api.orderman.Fill.Types;
namespace mbts.spark {
@@ -20,7 +21,14 @@ namespace mbts.spark {
// the TrimEnd is very important b/c the server currently does not trim,
// but the account is part of the group, so this is necessary
public string account => (fill.FillKind != FillKind.Sod ? order?.Def.Account : fill.Account).TrimEnd();
public string account {
get {
var trimmed_account_string = string.Empty;
if (fill.FillKind != FillKind.Sod && order.HasValue && order.Value.HasDef) trimmed_account_string = order.Value.Def.Account;
else trimmed_account_string = fill.Account;
return trimmed_account_string == null ? string.Empty : trimmed_account_string.Trim();
}
}
public bool Equals(FillTuple other) => other != null
&& other.order.HasValue == order.HasValue