Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Improve SecurityHolding.TotalCloseProfit for Outside Market Hours

Open AlexCatarino opened this issue 6 months ago • 0 comments

Expected Behavior

TotalCloseProfit takes into account market hours. For example, if the market is closed for Equity and Options, it cannot use the bid/ask to calculate the holdings value.

Actual Behavior

Outside market hours, the portfolio value can be all over the place. Realistically, these positions couldn't be closed: Image

Potential Solution

TotalCloseProfit uses the Price instead of AskPrice and BidPrice outside regular hours, except for Futures when market hours can be filled.

Checklist

  • [x] I have completely filled out this template
  • [x] I have confirmed that this issue exists on the current master branch
  • [x] I have confirmed that this is not a duplicate issue by searching issues

AlexCatarino avatar Jul 17 '25 16:07 AlexCatarino