FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.
C++ ai-agentsalgorithmic-tradingbloomberg-terminalcppfinancefinancial-marketsfintechgood-first-issueinvestmentinvestment-researchmachine-learningopensourcepythonqtquantitative-financestock-markettrading
review: revert global sort, fix P&L% notional guard, add toLocalTime on Opened
Abhi Kakadiya0bf05d35fd73
diff --git a/fincept-qt/src/screens/equity_trading/EquityBottomPanel.cpp b/fincept-qt/src/screens/equity_trading/EquityBottomPanel.cppindex d80ecb9c8..bd49d3360 100644--- a/fincept-qt/src/screens/equity_trading/EquityBottomPanel.cpp+++ b/fincept-qt/src/screens/equity_trading/EquityBottomPanel.cpp@@ -233,9 +233,9 @@ void EquityBottomPanel::set_paper_positions(const QVector<trading::PtPosition>&const auto& p = positions[i];ensure_item(positions_table_, i, 0)->setText(p.symbol);- // Col 1 — "Opened": format ISO timestamp; fall back to raw string on parse failure+ // Col 1 — "Opened": parse ISO timestamp, convert to local time, fall back to raw string{- const QDateTime dt = QDateTime::fromString(p.opened_at, Qt::ISODate);+ const QDateTime dt = QDateTime::fromString(p.opened_at, Qt::ISODate).toLocalTime();ensure_item(positions_table_, i, 1)->setText(dt.isValid() ? dt.toString("yyyy-MM-dd HH:mm") : p.opened_at);}@@ -252,8 +252,11 @@ void EquityBottomPanel::set_paper_positions(const QVector<trading::PtPosition>&: QColor(fincept::ui::colors::NEGATIVE()));// Col 7 — P&L %- const double pct = p.entry_price > 0- ? (p.unrealized_pnl / (p.entry_price * p.quantity)) * 100.0+ // Use notional as the divisor so both entry_price == 0 and quantity == 0+ // are safely handled by a single guard (avoids divide-by-zero).+ const double notional = p.entry_price * p.quantity;+ const double pct = notional != 0.0+ ? (p.unrealized_pnl / notional) * 100.0: 0.0;auto* pct_item = ensure_item(positions_table_, i, 7);pct_item->setText(QString::number(pct, 'f', 2) + "%");diff --git a/fincept-qt/src/screens/watchlist/WatchlistScreen.cpp b/fincept-qt/src/screens/watchlist/WatchlistScreen.cppindex b733134aa..e571be3b7 100644--- a/fincept-qt/src/screens/watchlist/WatchlistScreen.cpp+++ b/fincept-qt/src/screens/watchlist/WatchlistScreen.cpp@@ -296,6 +296,7 @@ QWidget* WatchlistScreen::build_main_panel() {table_ = new ui::DataTable;table_->set_headers({"SYMBOL", "NAME", "PRICE", "CHANGE", "CHG %", "HIGH", "LOW", "VOLUME"});table_->set_column_widths({100, 160, 100, 90, 80, 90, 90, 110});+ table_->setSortingEnabled(true); // opt-in: WatchlistScreen stamps numeric EditRole valuestable_->setSelectionBehavior(QAbstractItemView::SelectRows);table_->setSelectionMode(QAbstractItemView::SingleSelection);