From 4029ccf8e69c5d4299239ecbc397ed5a93dd7561 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Mon, 23 Jul 2018 16:06:49 -0500 Subject: [PATCH 1/2] pnl - using actual mid and not a tick-rounded one --- src/client/spark/view/Spark/PAndL/PnLCalculator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark/view/Spark/PAndL/PnLCalculator.cs b/src/client/spark/view/Spark/PAndL/PnLCalculator.cs index 1d0d2a08e..a6de90078 100644 --- a/src/client/spark/view/Spark/PAndL/PnLCalculator.cs +++ b/src/client/spark/view/Spark/PAndL/PnLCalculator.cs @@ -191,7 +191,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; } From 5e056dfff4103b222826fd9aa7232df362ec48c6 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Mon, 23 Jul 2018 17:18:22 -0500 Subject: [PATCH 2/2] pnl - account for current time in calculating start of day time --- src/client/spark/view/Spark/PAndL/PnLCalculator.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/spark/view/Spark/PAndL/PnLCalculator.cs b/src/client/spark/view/Spark/PAndL/PnLCalculator.cs index a6de90078..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() {