diff --git a/src/client/spark/view/Spark/PAndL/PnLCalculator.cs b/src/client/spark/view/Spark/PAndL/PnLCalculator.cs index 1d0d2a08e..d8fa4f2af 100644 --- a/src/client/spark/view/Spark/PAndL/PnLCalculator.cs +++ b/src/client/spark/view/Spark/PAndL/PnLCalculator.cs @@ -86,7 +86,11 @@ namespace mbts.spark { // Note that this isn't the acutal start of the trading day // but it's close enough for pnl purposes. // In reality, instruments have different schedules - _start_of_trading_day_utc = DateTime.Now.Date.Add(start_of_day_ts).AddDays(-1).ToUniversalTime(); + var _start_of_trading_day_local = DateTime.Now.Date.Add(start_of_day_ts); + if (_start_of_trading_day_local >= DateTime.Now) { + _start_of_trading_day_local = _start_of_trading_day_local.AddDays(-1); + } + _start_of_trading_day_utc = _start_of_trading_day_local.ToUniversalTime(); } public IEnumerable get_summary_position() { @@ -191,7 +195,7 @@ namespace mbts.spark { if (pnl_request.HasFlag(pnl_calc_type.last)) { driver_price = last.price; return true; } // note that bid_or_ask is not considered here since this method only // supports returning a single driver price; see update_pnl - if (pnl_request.HasFlag(pnl_calc_type.midpoint)) { driver_price = TickUtils.mid_tick(sec_md.security.ContractSpec, bid.price, ask.price); return true; } + if (pnl_request.HasFlag(pnl_calc_type.midpoint)) { driver_price = (bid.price + ask.price) / 2.0; return true; } if (pnl_request.HasFlag(pnl_calc_type.open)) { driver_price = sec_md.md.open_price; return true; } if (pnl_request.HasFlag(pnl_calc_type.close)) { driver_price = sec_md.md.close_price; return true; } if (pnl_request.HasFlag(pnl_calc_type.settle)) { driver_price = sec_md.md.settlement_price; return true; }