Skip to content

Commit

Permalink
Fixed closed trades that have shares/futures not honoring the "Exclud…
Browse files Browse the repository at this point in the history
…e Non-Stock" setting when producing the Closed Trades output.
  • Loading branch information
PaulSquires committed Mar 22, 2024
1 parent 0402c8d commit 5214a20
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
27 changes: 18 additions & 9 deletions TradeTracker/src/ClosedTrades/ClosedTrades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion TradeTracker/src/Config/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5214a20

Please sign in to comment.