From 5214a206205bb3cbcf216c801d7a863739aa530a Mon Sep 17 00:00:00 2001 From: Paul Squires Date: Fri, 22 Mar 2024 18:41:39 -0230 Subject: [PATCH] Fixed closed trades that have shares/futures not honoring the "Exclude Non-Stock" setting when producing the Closed Trades output. --- .../src/ClosedTrades/ClosedTrades.cpp | 27 ++++++++++++------- TradeTracker/src/Config/Config.h | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/TradeTracker/src/ClosedTrades/ClosedTrades.cpp b/TradeTracker/src/ClosedTrades/ClosedTrades.cpp index 774cd116..e9653130 100644 --- a/TradeTracker/src/ClosedTrades/ClosedTrades.cpp +++ b/TradeTracker/src/ClosedTrades/ClosedTrades.cpp @@ -148,6 +148,8 @@ void CClosedTrades::ShowClosedTrades() { if (latest_closed_date > end_date) continue; // If this Trade has Shares/Futures transactions show the costing + bool exclude_acb_non_shares = true; + for (const auto& share : trade->shares_history) { if (share.leg_action == Action::STC || share.leg_action == Action::BTC) { @@ -182,19 +184,26 @@ void CClosedTrades::ShowClosedTrades() { L" (" + diff_describe + L")"; vectorClosed.push_back(data); + + // If this closed Trade had shares/futures and average cost with options included then + // we set the flag here to bypass outputting the acb_non_shares amount because that amount + // would have been factored into the average cost of the shares. + exclude_acb_non_shares = config.GetExcludeNonStockCosts(); } } - if (!trade->is_open && trade->acb_non_shares) { - ClosedData data; - data.trade = trade; - data.trans = nullptr; - data.closed_date = latest_closed_date; - data.close_amount = trade->acb_non_shares; - data.description = trade->ticker_name; - if (config.IsFuturesTicker(trade->ticker_symbol)) data.description += L" (" + AfxFormatFuturesDate(trade->future_expiry) + L")"; - vectorClosed.push_back(data); + if (trade->is_open == false && exclude_acb_non_shares == true) { + if (trade->acb_non_shares) { + ClosedData data; + data.trade = trade; + data.trans = nullptr; + data.closed_date = latest_closed_date; + data.close_amount = trade->acb_non_shares; + data.description = trade->ticker_name; + if (config.IsFuturesTicker(trade->ticker_symbol)) data.description += L" (" + AfxFormatFuturesDate(trade->future_expiry) + L")"; + vectorClosed.push_back(data); + } } } diff --git a/TradeTracker/src/Config/Config.h b/TradeTracker/src/Config/Config.h index 4977e896..1f332680 100644 --- a/TradeTracker/src/Config/Config.h +++ b/TradeTracker/src/Config/Config.h @@ -30,7 +30,7 @@ SOFTWARE. #include "Utilities/AfxWin.h" -constexpr std::wstring version = L"4.1.0"; +constexpr std::wstring version = L"4.2.0"; enum class NumberFormatType { American,