Skip to content

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.

feat: add optional adanos market sentiment research tab

Alex Schneider4a56328bdc11
diff --git a/README.md b/README.md
index cc93d212e..0619999c5 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@ State-of-the-art financial intelligence platform with CFA-level analytics, AI au
|-------------|-----------------|
| 📊 **CFA-Level Analytics** | DCF models, portfolio optimization, risk metrics (VaR, Sharpe), derivatives pricing via embedded Python |
| 🤖 **AI Agents** | 20+ investor personas (Buffett, Dalio, Graham), hedge fund strategies, local LLM support, multi-provider (OpenAI, Anthropic, Gemini, Groq, DeepSeek, MiniMax, OpenRouter, Ollama) |
-| 🌐 **100+ Data Connectors** | DBnomics, Polygon, Kraken, Yahoo Finance, FRED, IMF, World Bank, AkShare, government APIs |
+| 🌐 **100+ Data Connectors** | DBnomics, Polygon, Kraken, Yahoo Finance, FRED, IMF, World Bank, AkShare, government APIs, plus optional alternative-data overlays such as Adanos market sentiment for equity research |
| 📈 **Real-Time Trading** | Crypto (Kraken/HyperLiquid WebSocket), equity, algo trading, paper trading engine |
| 🔬 **QuantLib Suite** | 18 quantitative analysis modules — pricing, risk, stochastic, volatility, fixed income |
| 🚢 **Global Intelligence** | Maritime tracking, geopolitical analysis, relationship mapping, satellite data |
@@ -166,6 +166,8 @@ cmake --build build --config Release --parallel
**Fincept Terminal** is an open-source financial platform built for those who refuse to be limited by traditional software. We compete on **analytics depth** and **data accessibility** — not on insider info or exclusive feeds.
+Recent builds also support optional **Adanos Market Sentiment** connectivity in **Data Sources → Alternative Data**. When configured, Equity Research can surface cross-source retail sentiment snapshots across Reddit, X, finance news, and Polymarket. Without an active Adanos connection, the feature remains dormant and the rest of the app behaves exactly as before.
+
- **Native performance** — C++20 with Qt6, no Electron/web overhead
- **Single binary** — no Node.js, no browser runtime, no JavaScript bundler
- **CFA-level analytics** — complete curriculum coverage via Python modules
diff --git a/fincept-qt/CMakeLists.txt b/fincept-qt/CMakeLists.txt
index 7e490f0c5..8815e96a5 100644
--- a/fincept-qt/CMakeLists.txt
+++ b/fincept-qt/CMakeLists.txt
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.20)
project(FinceptTerminal VERSION 4.0.0 LANGUAGES CXX)
+enable_testing()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -423,6 +424,8 @@ set(SERVICE_SOURCES
src/services/dbnomics/DBnomicsService.cpp
src/services/gov_data/GovDataService.cpp
src/services/equity/EquityResearchService.cpp
+ src/services/equity/MarketSentimentService.cpp
+ src/services/equity/MarketSentimentSupport.cpp
src/services/ma_analytics/MAAnalyticsService.cpp
src/services/geopolitics/GeopoliticsService.cpp
src/services/maritime/MaritimeService.cpp
@@ -775,6 +778,7 @@ set(SCREEN_SOURCES
src/screens/equity_research/EquityTalippTab.cpp
src/screens/equity_research/EquityPeersTab.cpp
src/screens/equity_research/EquityNewsTab.cpp
+ src/screens/equity_research/EquitySentimentTab.cpp
# Portfolio
src/screens/portfolio/PortfolioScreen.cpp
@@ -943,6 +947,7 @@ set_source_files_properties(
src/screens/equity_research/EquityOverviewTab.cpp
src/screens/equity_research/EquityPeersTab.cpp
src/screens/equity_research/EquityResearchScreen.cpp
+ src/screens/equity_research/EquitySentimentTab.cpp
src/screens/equity_research/EquityTalippTab.cpp
src/screens/equity_research/EquityTechnicalsTab.cpp
src/screens/excel/ExcelScreen.cpp
@@ -1479,6 +1484,14 @@ target_link_libraries(FinceptTerminal PRIVATE
OpenSSL::Crypto
)
+add_executable(fincept_market_sentiment_support_test
+ tests/MarketSentimentSupportTest.cpp
+ src/services/equity/MarketSentimentSupport.cpp
+)
+target_include_directories(fincept_market_sentiment_support_test PRIVATE src)
+target_link_libraries(fincept_market_sentiment_support_test PRIVATE Qt6::Core)
+add_test(NAME fincept_market_sentiment_support_test COMMAND fincept_market_sentiment_support_test)
+
# macOS: also link Security.framework for Keychain in SecureStorage
if(APPLE)
target_link_libraries(FinceptTerminal PRIVATE "-framework Security")
diff --git a/fincept-qt/src/screens/data_sources/DataSourcesScreen.cpp b/fincept-qt/src/screens/data_sources/DataSourcesScreen.cpp
index 0cc35c400..9fb0c14ef 100644
--- a/fincept-qt/src/screens/data_sources/DataSourcesScreen.cpp
+++ b/fincept-qt/src/screens/data_sources/DataSourcesScreen.cpp
@@ -2098,6 +2098,8 @@ static QString provider_probe_url(const QString& provider_id, const QJsonObject&
return "https://data.thinknum.com/";
if (provider_id == "revelio-labs")
return "https://api.reveliolabs.com/";
+ if (provider_id == "adanos-market-sentiment")
+ return "https://api.adanos.org/news/stocks/v1/health";
// ── Open banking ─────────────────────────────────────────────────────────
if (provider_id == "plaid")
diff --git a/fincept-qt/src/screens/data_sources/connectors/AlternativeData.cpp b/fincept-qt/src/screens/data_sources/connectors/AlternativeData.cpp
index a0e23de28..44e2f7e7d 100644
--- a/fincept-qt/src/screens/data_sources/connectors/AlternativeData.cpp
+++ b/fincept-qt/src/screens/data_sources/connectors/AlternativeData.cpp
@@ -1,5 +1,5 @@
-// Alternative Data connectors (8): RavenPack, Bloomberg Second Measure, SafeGraph, Orbital Insight,
-// Refinitiv Tick History, Earnest Research, Thinknum, Revelio Labs
+// Alternative Data connectors (9): RavenPack, Bloomberg Second Measure, SafeGraph, Orbital Insight,
+// Refinitiv Tick History, Earnest Research, Thinknum, Revelio Labs, Adanos Market Sentiment
#include "screens/data_sources/ConnectorRegistry.h"
namespace fincept::screens::datasources {
@@ -139,6 +139,18 @@ static QVector<ConnectorConfig> alt_data_configs() {
false,
"headcount",
{{"Headcount", "headcount"}, {"Hiring Rate", "hiring"}, {"Attrition Rate", "attrition"}, {"Skill Demand", "skills"}}}}},
+
+ {"adanos-market-sentiment",
+ "Adanos Market Sentiment",
+ "adanos-market-sentiment",
+ Category::AlternativeData,
+ "A",
+ "#C06524",
+ "Cross-source US equity market sentiment across Reddit, X, finance news, and Polymarket. Exposed as an optional overlay in Equity Research.",
+ true,
+ true,
+ {{"apiKey", "API Key", FieldType::Password, "sk_live_...", true, "", {}},
+ {"defaultUniverse", "Default Universe (optional)", FieldType::Text, "AAPL,MSFT,NVDA", false, "", {}}}},
};
}
diff --git a/fincept-qt/src/screens/equity_research/EquityResearchScreen.cpp b/fincept-qt/src/screens/equity_research/EquityResearchScreen.cpp
index 5c1aa196f..b5b33d6e6 100644
--- a/fincept-qt/src/screens/equity_research/EquityResearchScreen.cpp
+++ b/fincept-qt/src/screens/equity_research/EquityResearchScreen.cpp
@@ -6,6 +6,7 @@
#include "screens/equity_research/EquityNewsTab.h"
#include "screens/equity_research/EquityOverviewTab.h"
#include "screens/equity_research/EquityPeersTab.h"
+#include "screens/equity_research/EquitySentimentTab.h"
#include "screens/equity_research/EquityTalippTab.h"
#include "screens/equity_research/EquityTechnicalsTab.h"
#include "core/events/EventBus.h"
@@ -91,6 +92,7 @@ void EquityResearchScreen::build_ui() {
talipp_tab_ = new EquityTalippTab;
peers_tab_ = new EquityPeersTab;
news_tab_ = new EquityNewsTab;
+ sentiment_tab_ = new EquitySentimentTab;
tab_widget_->addTab(overview_tab_, "Overview");
tab_widget_->addTab(financials_tab_, "Financials");
@@ -99,6 +101,7 @@ void EquityResearchScreen::build_ui() {
tab_widget_->addTab(talipp_tab_, "TALIpp");
tab_widget_->addTab(peers_tab_, "Peers");
tab_widget_->addTab(news_tab_, "News");
+ tab_widget_->addTab(sentiment_tab_, "Sentiment");
connect(tab_widget_, &QTabWidget::currentChanged, this, &EquityResearchScreen::on_tab_changed);
@@ -211,6 +214,9 @@ void EquityResearchScreen::on_tab_changed(int index) {
news_tab_->set_symbol(current_symbol_);
svc.fetch_news(current_symbol_);
break;
+ case 7:
+ sentiment_tab_->set_symbol(current_symbol_);
+ break;
default:
break;
}
diff --git a/fincept-qt/src/screens/equity_research/EquityResearchScreen.h b/fincept-qt/src/screens/equity_research/EquityResearchScreen.h
index 36b2380cf..6e87f29da 100644
--- a/fincept-qt/src/screens/equity_research/EquityResearchScreen.h
+++ b/fincept-qt/src/screens/equity_research/EquityResearchScreen.h
@@ -19,6 +19,7 @@ class EquityTechnicalsTab;
class EquityTalippTab;
class EquityPeersTab;
class EquityNewsTab;
+class EquitySentimentTab;
class EquityResearchScreen : public QWidget, public IStatefulScreen {
Q_OBJECT
@@ -66,6 +67,7 @@ class EquityResearchScreen : public QWidget, public IStatefulScreen {
EquityTalippTab* talipp_tab_ = nullptr;
EquityPeersTab* peers_tab_ = nullptr;
EquityNewsTab* news_tab_ = nullptr;
+ EquitySentimentTab* sentiment_tab_ = nullptr;
QTimer* refresh_timer_ = nullptr;
QString current_symbol_;
diff --git a/fincept-qt/src/screens/equity_research/EquitySentimentTab.cpp b/fincept-qt/src/screens/equity_research/EquitySentimentTab.cpp
new file mode 100644
index 000000000..82ca9472d
--- /dev/null
+++ b/fincept-qt/src/screens/equity_research/EquitySentimentTab.cpp
@@ -0,0 +1,294 @@
+#include "screens/equity_research/EquitySentimentTab.h"
+
+#include "services/equity/MarketSentimentService.h"
+#include "ui/theme/Theme.h"
+
+#include <QFrame>
+#include <QHBoxLayout>
+#include <QPushButton>
+
+namespace fincept::screens {
+
+namespace {
+
+QFrame* make_panel(const QString& title) {
+ auto* frame = new QFrame;
+ frame->setStyleSheet(
+ QString("QFrame { background:%1; border:1px solid %2; border-radius:4px; }")
+ .arg(ui::colors::BG_SURFACE(), ui::colors::BORDER_DIM()));
+
+ auto* layout = new QVBoxLayout(frame);
+ layout->setContentsMargins(12, 10, 12, 10);
+ layout->setSpacing(6);
+
+ auto* label = new QLabel(title);
+ label->setStyleSheet(
+ QString("color:%1; font-size:11px; font-weight:700; letter-spacing:1px; background:transparent; border:0;")
+ .arg(ui::colors::AMBER()));
+ layout->addWidget(label);
+ return frame;
+}
+
+QWidget* make_stat_box(const QString& title, QLabel** value_label) {
+ auto* box = new QFrame;
+ box->setStyleSheet(
+ QString("QFrame { background:%1; border:1px solid %2; border-radius:4px; }")
+ .arg(ui::colors::BG_RAISED(), ui::colors::BORDER_DIM()));
+ auto* layout = new QVBoxLayout(box);
+ layout->setContentsMargins(10, 10, 10, 10);
+ layout->setSpacing(4);
+
+ auto* title_label = new QLabel(title);
+ title_label->setStyleSheet(
+ QString("color:%1; font-size:10px; font-weight:700; letter-spacing:1px; background:transparent; border:0;")
+ .arg(ui::colors::TEXT_TERTIARY()));
+ layout->addWidget(title_label);
+
+ auto* value = new QLabel("—");
+ value->setStyleSheet(
+ QString("color:%1; font-size:18px; font-weight:700; background:transparent; border:0;")
+ .arg(ui::colors::TEXT_PRIMARY()));
+ layout->addWidget(value);
+
+ *value_label = value;
+ return box;
+}
+
+QString alignment_label(const QString& alignment) {
+ if (alignment == "aligned") {
+ return "ALIGNED";
+ }
+ if (alignment == "mixed") {
+ return "MIXED";
+ }
+ if (alignment == "divergent") {
+ return "DIVERGENT";
+ }
+ if (alignment == "single_source") {
+ return "SINGLE SOURCE";
+ }
+ return "UNAVAILABLE";
+}
+
+QString alignment_color(const QString& alignment) {
+ if (alignment == "aligned") {
+ return ui::colors::POSITIVE();
+ }
+ if (alignment == "mixed" || alignment == "single_source") {
+ return ui::colors::WARNING();
+ }
+ if (alignment == "divergent") {
+ return ui::colors::NEGATIVE();
+ }
+ return ui::colors::TEXT_TERTIARY();
+}
+
+} // namespace
+
+EquitySentimentTab::EquitySentimentTab(QWidget* parent) : QWidget(parent) {
+ build_ui();
+ auto& service = services::equity::MarketSentimentService::instance();
+ connect(&service, &services::equity::MarketSentimentService::snapshot_loaded,
+ this, &EquitySentimentTab::on_snapshot_loaded);
+}
+
+void EquitySentimentTab::set_symbol(const QString& symbol) {
+ if (symbol.isEmpty()) {
+ return;
+ }
+ current_symbol_ = symbol;
+ company_label_->setText(symbol);
+ coverage_label_->setText("");
+ content_widget_->hide();
+ clear_sources();
+ status_label_->setText("Loading market sentiment…");
+ status_label_->show();
+ loading_overlay_->show_loading("LOADING SENTIMENT…");
+ services::equity::MarketSentimentService::instance().fetch_snapshot(symbol);
+}
+
+void EquitySentimentTab::build_ui() {
+ setStyleSheet(QString("background:%1;").arg(ui::colors::BG_BASE()));
+ loading_overlay_ = new ui::LoadingOverlay(this);
+
+ auto* root = new QVBoxLayout(this);
+ root->setContentsMargins(0, 0, 0, 0);
+ root->setSpacing(0);
+
+ auto* header = new QWidget;
+ header->setStyleSheet(
+ QString("background:%1; border-bottom:2px solid %2;").arg(ui::colors::BG_SURFACE(), ui::colors::AMBER()));
+ auto* header_layout = new QHBoxLayout(header);
+ header_layout->setContentsMargins(14, 8, 14, 8);
+ header_layout->setSpacing(12);
+
+ auto* title = new QLabel("MARKET SENTIMENT");
+ title->setStyleSheet(
+ QString("color:%1; font-size:11px; font-weight:700; letter-spacing:2px; background:transparent; border:0;")
+ .arg(ui::colors::AMBER()));
+ header_layout->addWidget(title);
+
+ coverage_label_ = new QLabel;
+ coverage_label_->setStyleSheet(
+ QString("color:%1; font-size:10px; background:transparent; border:0;")
+ .arg(ui::colors::TEXT_TERTIARY()));
+ header_layout->addWidget(coverage_label_);
+
+ company_label_ = new QLabel;
+ company_label_->setStyleSheet(
+ QString("color:%1; font-size:10px; background:transparent; border:0;").arg("#22d3ee"));
+ header_layout->addWidget(company_label_);
+
+ header_layout->addStretch();
+
+ auto* refresh_button = new QPushButton("REFRESH");
+ refresh_button->setStyleSheet(
+ QString("QPushButton { background:transparent; color:%1; border:1px solid %2; border-radius:3px; "
+ "padding:4px 12px; font-size:10px; font-weight:700; }"
+ "QPushButton:hover { border-color:%3; color:%3; }")
+ .arg(ui::colors::TEXT_SECONDARY(), ui::colors::BORDER_DIM(), ui::colors::AMBER()));
+ connect(refresh_button, &QPushButton::clicked, this, [this]() {
+ if (!current_symbol_.isEmpty()) {
+ content_widget_->hide();
+ clear_sources();
+ status_label_->setText("Refreshing market sentiment…");
+ status_label_->show();
+ loading_overlay_->show_loading("REFRESHING SENTIMENT…");
+ services::equity::MarketSentimentService::instance().fetch_snapshot(current_symbol_, 7, true);
+ }
+ });
+ header_layout->addWidget(refresh_button);
+ root->addWidget(header);
+
+ status_label_ = new QLabel("Open a symbol and enable Adanos Market Sentiment in Data Sources to load a snapshot.");
+ status_label_->setAlignment(Qt::AlignCenter);
+ status_label_->setStyleSheet(
+ QString("color:%1; font-size:12px; padding:20px; background:transparent;").arg(ui::colors::TEXT_SECONDARY()));
+ root->addWidget(status_label_);
+
+ auto* scroll = new QScrollArea;
+ scroll->setWidgetResizable(true);
+ scroll->setFrameShape(QFrame::NoFrame);
+ scroll->setStyleSheet("background:transparent; border:0;");
+
+ content_widget_ = new QWidget;
+ auto* content_layout = new QVBoxLayout(content_widget_);
+ content_layout->setContentsMargins(12, 12, 12, 12);
+ content_layout->setSpacing(12);
+ content_layout->addWidget(build_summary_panel());
+
+ auto* sources_panel = make_panel("SOURCE BREAKDOWN");
+ sources_widget_ = sources_panel;
+ sources_layout_ = new QGridLayout;
+ sources_layout_->setContentsMargins(0, 0, 0, 0);
+ sources_layout_->setSpacing(10);
+ static_cast<QVBoxLayout*>(sources_panel->layout())->addLayout(sources_layout_);
+ content_layout->addWidget(sources_panel);
+ content_layout->addStretch();
+
+ scroll->setWidget(content_widget_);
+ root->addWidget(scroll, 1);
+ content_widget_->hide();
+}
+
+QWidget* EquitySentimentTab::build_summary_panel() {
+ auto* panel = make_panel("SUMMARY");
+ auto* grid = new QGridLayout;
+ grid->setContentsMargins(0, 0, 0, 0);
+ grid->setSpacing(10);
+
+ grid->addWidget(make_stat_box("AVERAGE BUZZ", &avg_buzz_value_), 0, 0);
+ grid->addWidget(make_stat_box("BULLISH %", &avg_bullish_value_), 0, 1);
+ grid->addWidget(make_stat_box("COVERAGE", &coverage_value_), 1, 0);
+ grid->addWidget(make_stat_box("ALIGNMENT", &alignment_value_), 1, 1);
+
+ static_cast<QVBoxLayout*>(panel->layout())->addLayout(grid);
+ return panel;
+}
+
+void EquitySentimentTab::clear_sources() {
+ while (sources_layout_->count() > 0) {
+ auto* item = sources_layout_->takeAt(0);
+ if (item->widget()) {
+ item->widget()->deleteLater();
+ }
+ delete item;
+ }
+}
+
+void EquitySentimentTab::populate(const services::equity::MarketSentimentSnapshot& snapshot) {
+ avg_buzz_value_->setText(QString::number(snapshot.average_buzz, 'f', 1));
+ avg_bullish_value_->setText(QString("%1%").arg(QString::number(snapshot.average_bullish_pct, 'f', 1)));
+ coverage_value_->setText(QString("%1 / %2").arg(snapshot.coverage).arg(snapshot.sources.size()));
+ alignment_value_->setText(alignment_label(snapshot.source_alignment));
+ alignment_value_->setStyleSheet(
+ QString("color:%1; font-size:18px; font-weight:700; background:transparent; border:0;")
+ .arg(alignment_color(snapshot.source_alignment)));
+
+ clear_sources();
+ for (int i = 0; i < snapshot.sources.size(); ++i) {
+ const auto& source = snapshot.sources.at(i);
+ auto* card = make_panel(source.label);
+ auto* layout = static_cast<QVBoxLayout*>(card->layout());
+
+ auto add_row = [layout](const QString& key, const QString& value, const QString& color = QString()) {
+ auto* row = new QWidget;
+ auto* row_layout = new QHBoxLayout(row);
+ row_layout->setContentsMargins(0, 0, 0, 0);
+ row_layout->setSpacing(6);
+
+ auto* key_label = new QLabel(key);
+ key_label->setStyleSheet(
+ QString("color:%1; font-size:10px; background:transparent; border:0;").arg(ui::colors::TEXT_SECONDARY()));
+ row_layout->addWidget(key_label);
+
+ auto* value_label = new QLabel(value);
+ value_label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
+ value_label->setStyleSheet(
+ QString("color:%1; font-size:11px; font-weight:600; background:transparent; border:0;")
+ .arg(color.isEmpty() ? ui::colors::TEXT_PRIMARY() : color));
+ row_layout->addWidget(value_label, 1);
+ layout->addWidget(row);
+ };
+
+ if (source.available) {
+ add_row("Buzz", QString::number(source.buzz_score, 'f', 1));
+ add_row("Bullish", QString("%1%").arg(QString::number(source.bullish_pct, 'f', 1)));
+ add_row("Activity", QString::number(source.activity_count, 'f', 0));
+ add_row("Sentiment", QString::number(source.sentiment_score, 'f', 2),
+ source.sentiment_score >= 0.0 ? ui::colors::POSITIVE() : ui::colors::NEGATIVE());
+ } else {
+ auto* empty = new QLabel("No snapshot available.");
+ empty->setWordWrap(true);
+ empty->setStyleSheet(
+ QString("color:%1; font-size:11px; background:transparent; border:0;").arg(ui::colors::TEXT_TERTIARY()));
+ layout->addWidget(empty);
+ }
+
+ sources_layout_->addWidget(card, i / 2, i % 2);
+ }
+}
+
+void EquitySentimentTab::on_snapshot_loaded(QString symbol, fincept::services::equity::MarketSentimentSnapshot snapshot) {
+ if (symbol != current_symbol_) {
+ return;
+ }
+
+ loading_overlay_->hide_loading();
+ coverage_label_->setText(snapshot.coverage > 0
+ ? QString("%1 sources live").arg(snapshot.coverage)
+ : QString("Optional alternative data"));
+
+ if (!snapshot.configured || !snapshot.available) {
+ content_widget_->hide();
+ status_label_->setText(snapshot.message.isEmpty() ? "No market sentiment snapshot is available for this symbol." : snapshot.message);
+ status_label_->show();
+ return;
+ }
+
+ populate(snapshot);
+ status_label_->hide();
+ content_widget_->show();
+}
+
+} // namespace fincept::screens
diff --git a/fincept-qt/src/screens/equity_research/EquitySentimentTab.h b/fincept-qt/src/screens/equity_research/EquitySentimentTab.h
new file mode 100644
index 000000000..3563f0840
--- /dev/null
+++ b/fincept-qt/src/screens/equity_research/EquitySentimentTab.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#include "services/equity/EquityResearchModels.h"
+#include "ui/widgets/LoadingOverlay.h"
+
+#include <QGridLayout>
+#include <QLabel>
+#include <QScrollArea>
+#include <QVBoxLayout>
+#include <QWidget>
+
+namespace fincept::screens {
+
+class EquitySentimentTab : public QWidget {
+ Q_OBJECT
+ public:
+ explicit EquitySentimentTab(QWidget* parent = nullptr);
+ void set_symbol(const QString& symbol);
+
+ private slots:
+ void on_snapshot_loaded(QString symbol, fincept::services::equity::MarketSentimentSnapshot snapshot);
+
+ private:
+ void build_ui();
+ void populate(const fincept::services::equity::MarketSentimentSnapshot& snapshot);
+ void clear_sources();
+ QWidget* build_summary_panel();
+
+ QString current_symbol_;
+ QWidget* content_widget_ = nullptr;
+ QWidget* sources_widget_ = nullptr;
+ QGridLayout* sources_layout_ = nullptr;
+ QLabel* status_label_ = nullptr;
+ QLabel* company_label_ = nullptr;
+ QLabel* coverage_label_ = nullptr;
+ QLabel* avg_buzz_value_ = nullptr;
+ QLabel* avg_bullish_value_ = nullptr;
+ QLabel* coverage_value_ = nullptr;
+ QLabel* alignment_value_ = nullptr;
+ ui::LoadingOverlay* loading_overlay_ = nullptr;
+};
+
+} // namespace fincept::screens
diff --git a/fincept-qt/src/services/equity/EquityResearchModels.h b/fincept-qt/src/services/equity/EquityResearchModels.h
index cd9cebc90..ff62d6fd8 100644
--- a/fincept-qt/src/services/equity/EquityResearchModels.h
+++ b/fincept-qt/src/services/equity/EquityResearchModels.h
@@ -182,4 +182,29 @@ struct NewsArticle {
QString published_date;
};
+// ── Optional market sentiment snapshot ──────────────────────────────────────
+struct SentimentSourceSnapshot {
+ QString source_id;
+ QString label;
+ bool available = false;
+ double buzz_score = 0.0;
+ double bullish_pct = 0.0;
+ double sentiment_score = 0.0;
+ double activity_count = 0.0;
+};
+
+struct MarketSentimentSnapshot {
+ QString symbol;
+ bool configured = false;
+ bool available = false;
+ QString status;
+ QString message;
+ double average_buzz = 0.0;
+ double average_bullish_pct = 0.0;
+ int coverage = 0;
+ QString source_alignment;
+ QVector<SentimentSourceSnapshot> sources;
+ QString fetched_at;
+};
+
} // namespace fincept::services::equity
diff --git a/fincept-qt/src/services/equity/MarketSentimentService.cpp b/fincept-qt/src/services/equity/MarketSentimentService.cpp
new file mode 100644
index 000000000..4519b96b9
--- /dev/null
+++ b/fincept-qt/src/services/equity/MarketSentimentService.cpp
@@ -0,0 +1,216 @@
+#include "services/equity/MarketSentimentService.h"
+
+#include "core/logging/Logger.h"
+#include "services/equity/MarketSentimentSupport.h"
+#include "storage/cache/CacheManager.h"
+#include "storage/repositories/DataSourceRepository.h"
+
+#include <QDateTime>
+#include <QJsonDocument>
+#include <QMap>
+#include <QNetworkReply>
+#include <QUrlQuery>
+
+#include <memory>
+
+namespace fincept::services::equity {
+
+namespace {
+
+constexpr auto kApiBase = "https://api.adanos.org";
+
+struct PendingSnapshotRequest {
+ quint64 request_id = 0;
+ QString symbol;
+ int pending = 0;
+ MarketSentimentSnapshot snapshot;
+ QMap<QString, SentimentSourceSnapshot> sources;
+};
+
+QString cache_key_for_symbol(const QString& symbol) {
+ return "equity:adanos:sentiment:" + symbol.toUpper();
+}
+
+QByteArray variant_to_json_bytes(const QVariant& value) {
+ if (value.canConvert<QByteArray>()) {
+ return value.toByteArray();
+ }
+ return value.toString().toUtf8();
+}
+
+} // namespace
+
+MarketSentimentService& MarketSentimentService::instance() {
+ static MarketSentimentService service;
+ return service;
+}
+
+MarketSentimentService::MarketSentimentService(QObject* parent) : QObject(parent) {
+ nam_ = new QNetworkAccessManager(this);
+}
+
+bool MarketSentimentService::is_configured() const {
+ return load_connection().configured;
+}
+
+MarketSentimentService::ConnectionConfig MarketSentimentService::load_connection() const {
+ const auto result = DataSourceRepository::instance().list_all();
+ if (result.is_err()) {
+ return {};
+ }
+
+ for (const auto& source : result.value()) {
+ if (source.provider != sentiment::kProviderId || !source.enabled) {
+ continue;
+ }
+ const auto config = QJsonDocument::fromJson(source.config.toUtf8()).object();
+ const auto api_key = config.value("apiKey").toString().trimmed();
+ if (!api_key.isEmpty()) {
+ return {true, api_key};
+ }
+ }
+
+ return {};
+}
+
+QNetworkRequest MarketSentimentService::build_request(const QUrl& url, const QString& api_key) const {
+ QNetworkRequest request(url);
+ request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
+ request.setHeader(QNetworkRequest::UserAgentHeader, "FinceptTerminal/4.0");
+ request.setRawHeader("X-API-Key", api_key.toUtf8());
+ return request;
+}
+
+void MarketSentimentService::fetch_snapshot(const QString& symbol, int days, bool force) {
+ const QString normalized_symbol = symbol.trimmed().toUpper();
+ if (normalized_symbol.isEmpty()) {
+ return;
+ }
+
+ const auto connection = load_connection();
+ if (!connection.configured) {
+ MarketSentimentSnapshot snapshot;
+ snapshot.symbol = normalized_symbol;
+ snapshot.status = "not_configured";
+ snapshot.message = "Configure Adanos Market Sentiment in Data Sources → Alternative Data to enable this view.";
+ emit snapshot_loaded(normalized_symbol, snapshot);
+ return;
+ }
+
+ const QString key = cache_key_for_symbol(normalized_symbol);
+ if (!force && CacheManager::instance().has(key)) {
+ const auto cached = variant_to_json_bytes(CacheManager::instance().get(key));
+ const auto doc = QJsonDocument::fromJson(cached);
+ if (doc.isObject()) {
+ auto snapshot = sentiment::snapshot_from_json(doc.object());
+ snapshot.configured = true;
+ emit snapshot_loaded(normalized_symbol, snapshot);
+ return;
+ }
+ }
+
+ active_request_id_ += 1;
+ const auto request_id = active_request_id_;
+
+ auto pending = std::make_shared<PendingSnapshotRequest>();
+ pending->request_id = request_id;
+ pending->symbol = normalized_symbol;
+ pending->pending = sentiment::source_ids().size();
+ pending->snapshot.symbol = normalized_symbol;
+ pending->snapshot.configured = true;
+ pending->snapshot.status = "loading";
+
+ auto finalize = [this, pending, key]() {
+ if (pending->request_id != active_request_id_) {
+ return;
+ }
+
+ const auto ordered_sources = sentiment::source_ids();
+ pending->snapshot.sources.clear();
+ pending->snapshot.sources.reserve(ordered_sources.size());
+
+ double total_buzz = 0.0;
+ double total_bullish = 0.0;
+ int coverage = 0;
+
+ for (const auto& source_id : ordered_sources) {
+ const auto source = pending->sources.value(source_id, SentimentSourceSnapshot{source_id, sentiment::source_label(source_id)});
+ pending->snapshot.sources.append(source);
+ if (source.available) {
+ total_buzz += source.buzz_score;
+ total_bullish += source.bullish_pct;
+ coverage += 1;
+ }
+ }
+
+ pending->snapshot.coverage = coverage;
+ pending->snapshot.source_alignment = sentiment::compute_source_alignment(pending->snapshot.sources);
+ pending->snapshot.fetched_at = QDateTime::currentDateTimeUtc().toString(Qt::ISODate);
+
+ if (coverage > 0) {
+ pending->snapshot.available = true;
+ pending->snapshot.status = "ok";
+ pending->snapshot.average_buzz = total_buzz / coverage;
+ pending->snapshot.average_bullish_pct = total_bullish / coverage;
+ } else {
+ pending->snapshot.available = false;
+ pending->snapshot.status = "unavailable";
+ pending->snapshot.message = "No Adanos market sentiment snapshot is available for this symbol yet.";
+ }
+
+ CacheManager::instance().put(
+ key,
+ QVariant(QJsonDocument(sentiment::snapshot_to_json(pending->snapshot)).toJson(QJsonDocument::Compact)),
+ kCacheTtlSec,
+ "equity");
+
+ emit snapshot_loaded(pending->symbol, pending->snapshot);
+ };
+
+ for (const auto& source_id : sentiment::source_ids()) {
+ QUrl url(QString("%1/%2/stocks/v1/compare").arg(kApiBase, source_id));
+ QUrlQuery query;
+ query.addQueryItem("tickers", normalized_symbol);
+ query.addQueryItem("days", QString::number(days));
+ url.setQuery(query);
+
+ auto* reply = nam_->get(build_request(url, connection.api_key));
+ connect(reply, &QNetworkReply::finished, this, [this, reply, pending, source_id, finalize]() {
+ const QUrl request_url = reply->request().url();
+ const int status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ const QByteArray body = reply->readAll();
+ reply->deleteLater();
+
+ SentimentSourceSnapshot snapshot;
+ if (reply->error() == QNetworkReply::NoError) {
+ const auto doc = QJsonDocument::fromJson(body);
+ if (doc.isObject()) {
+ snapshot = sentiment::parse_compare_payload(source_id, doc.object());
+ }
+ } else {
+ LOG_WARN(
+ "MarketSentiment",
+ QString("Adanos request failed for %1 (%2): %3")
+ .arg(source_id, request_url.toString(QUrl::RemoveQuery), reply->errorString()));
+ if (pending->request_id == active_request_id_) {
+ emit error_occurred(
+ "market_sentiment",
+ QString("Adanos source %1 returned HTTP %2.").arg(source_id, QString::number(status_code)));
+ }
+ }
+
+ if (snapshot.source_id.isEmpty()) {
+ snapshot.source_id = source_id;
+ snapshot.label = sentiment::source_label(source_id);
+ }
+
+ pending->sources.insert(source_id, snapshot);
+ pending->pending -= 1;
+ if (pending->pending == 0) {
+ finalize();
+ }
+ });
+ }
+}
+
+} // namespace fincept::services::equity
diff --git a/fincept-qt/src/services/equity/MarketSentimentService.h b/fincept-qt/src/services/equity/MarketSentimentService.h
new file mode 100644
index 000000000..8a81cee60
--- /dev/null
+++ b/fincept-qt/src/services/equity/MarketSentimentService.h
@@ -0,0 +1,42 @@
+#pragma once
+
+#include "services/equity/EquityResearchModels.h"
+
+#include <QNetworkAccessManager>
+#include <QNetworkRequest>
+#include <QObject>
+
+namespace fincept::services::equity {
+
+class MarketSentimentService : public QObject {
+ Q_OBJECT
+ public:
+ static MarketSentimentService& instance();
+
+ void fetch_snapshot(const QString& symbol, int days = 7, bool force = false);
+ bool is_configured() const;
+
+ signals:
+ void snapshot_loaded(QString symbol, fincept::services::equity::MarketSentimentSnapshot snapshot);
+ void error_occurred(QString context, QString message);
+
+ private:
+ explicit MarketSentimentService(QObject* parent = nullptr);
+ Q_DISABLE_COPY(MarketSentimentService)
+
+ struct ConnectionConfig {
+ bool configured = false;
+ QString api_key;
+ };
+
+ ConnectionConfig load_connection() const;
+
+ QNetworkRequest build_request(const QUrl& url, const QString& api_key) const;
+
+ QNetworkAccessManager* nam_ = nullptr;
+ quint64 active_request_id_ = 0;
+
+ static constexpr int kCacheTtlSec = 600;
+};
+
+} // namespace fincept::services::equity
diff --git a/fincept-qt/src/services/equity/MarketSentimentSupport.cpp b/fincept-qt/src/services/equity/MarketSentimentSupport.cpp
new file mode 100644
index 000000000..e1c398092
--- /dev/null
+++ b/fincept-qt/src/services/equity/MarketSentimentSupport.cpp
@@ -0,0 +1,181 @@
+#include "services/equity/MarketSentimentSupport.h"
+
+#include <QJsonArray>
+
+#include <algorithm>
+
+namespace fincept::services::equity::sentiment {
+
+namespace {
+
+double first_numeric(const QJsonObject& object, const QStringList& keys) {
+ for (const auto& key : keys) {
+ if (!object.contains(key)) {
+ continue;
+ }
+ const auto value = object.value(key);
+ if (value.isDouble()) {
+ return value.toDouble();
+ }
+ if (value.isString()) {
+ bool ok = false;
+ const double parsed = value.toString().toDouble(&ok);
+ if (ok) {
+ return parsed;
+ }
+ }
+ }
+ return 0.0;
+}
+
+QJsonObject unwrap_payload(const QJsonObject& payload) {
+ if (payload.contains("data") && payload.value("data").isObject()) {
+ return payload.value("data").toObject();
+ }
+ return payload;
+}
+
+QJsonArray extract_stocks(const QJsonObject& payload) {
+ const auto root = unwrap_payload(payload);
+ if (root.contains("stocks") && root.value("stocks").isArray()) {
+ return root.value("stocks").toArray();
+ }
+ if (root.contains("results") && root.value("results").isArray()) {
+ return root.value("results").toArray();
+ }
+ return {};
+}
+
+} // namespace
+
+QStringList source_ids() {
+ return {"reddit", "x", "news", "polymarket"};
+}
+
+QString source_label(const QString& source_id) {
+ if (source_id == "reddit") {
+ return "Reddit";
+ }
+ if (source_id == "x") {
+ return "X";
+ }
+ if (source_id == "news") {
+ return "News";
+ }
+ if (source_id == "polymarket") {
+ return "Polymarket";
+ }
+ return source_id.toUpper();
+}
+
+SentimentSourceSnapshot parse_compare_payload(const QString& source_id, const QJsonObject& payload) {
+ SentimentSourceSnapshot snapshot;
+ snapshot.source_id = source_id;
+ snapshot.label = source_label(source_id);
+
+ const auto stocks = extract_stocks(payload);
+ if (stocks.isEmpty() || !stocks.first().isObject()) {
+ return snapshot;
+ }
+
+ const auto stock = stocks.first().toObject();
+ snapshot.available = !stock.isEmpty();
+ snapshot.buzz_score = first_numeric(stock, {"buzz_score"});
+ snapshot.bullish_pct = first_numeric(stock, {"bullish_pct"});
+ snapshot.sentiment_score = first_numeric(stock, {"sentiment_score", "sentiment"});
+ snapshot.activity_count = first_numeric(
+ stock,
+ {"mentions", "trade_count", "unique_posts", "source_count", "subreddit_count", "market_count", "unique_traders"});
+
+ return snapshot;
+}
+
+QString compute_source_alignment(const QVector<SentimentSourceSnapshot>& sources) {
+ QVector<double> bullish_values;
+ bullish_values.reserve(sources.size());
+ for (const auto& source : sources) {
+ if (source.available) {
+ bullish_values.append(source.bullish_pct);
+ }
+ }
+
+ if (bullish_values.isEmpty()) {
+ return "unavailable";
+ }
+ if (bullish_values.size() == 1) {
+ return "single_source";
+ }
+
+ auto [min_it, max_it] = std::minmax_element(bullish_values.begin(), bullish_values.end());
+ const double spread = *max_it - *min_it;
+
+ if (spread <= 12.0) {
+ return "aligned";
+ }
+ if (spread <= 25.0) {
+ return "mixed";
+ }
+ return "divergent";
+}
+
+QJsonObject snapshot_to_json(const MarketSentimentSnapshot& snapshot) {
+ QJsonArray sources;
+ for (const auto& source : snapshot.sources) {
+ QJsonObject object;
+ object["source_id"] = source.source_id;
+ object["label"] = source.label;
+ object["available"] = source.available;
+ object["buzz_score"] = source.buzz_score;
+ object["bullish_pct"] = source.bullish_pct;
+ object["sentiment_score"] = source.sentiment_score;
+ object["activity_count"] = source.activity_count;
+ sources.append(object);
+ }
+
+ QJsonObject object;
+ object["symbol"] = snapshot.symbol;
+ object["configured"] = snapshot.configured;
+ object["available"] = snapshot.available;
+ object["status"] = snapshot.status;
+ object["message"] = snapshot.message;
+ object["average_buzz"] = snapshot.average_buzz;
+ object["average_bullish_pct"] = snapshot.average_bullish_pct;
+ object["coverage"] = snapshot.coverage;
+ object["source_alignment"] = snapshot.source_alignment;
+ object["sources"] = sources;
+ object["fetched_at"] = snapshot.fetched_at;
+ return object;
+}
+
+MarketSentimentSnapshot snapshot_from_json(const QJsonObject& object) {
+ MarketSentimentSnapshot snapshot;
+ snapshot.symbol = object.value("symbol").toString();
+ snapshot.configured = object.value("configured").toBool();
+ snapshot.available = object.value("available").toBool();
+ snapshot.status = object.value("status").toString();
+ snapshot.message = object.value("message").toString();
+ snapshot.average_buzz = object.value("average_buzz").toDouble();
+ snapshot.average_bullish_pct = object.value("average_bullish_pct").toDouble();
+ snapshot.coverage = object.value("coverage").toInt();
+ snapshot.source_alignment = object.value("source_alignment").toString();
+ snapshot.fetched_at = object.value("fetched_at").toString();
+
+ const auto source_values = object.value("sources").toArray();
+ snapshot.sources.reserve(source_values.size());
+ for (const auto& value : source_values) {
+ const auto source_object = value.toObject();
+ SentimentSourceSnapshot source;
+ source.source_id = source_object.value("source_id").toString();
+ source.label = source_object.value("label").toString();
+ source.available = source_object.value("available").toBool();
+ source.buzz_score = source_object.value("buzz_score").toDouble();
+ source.bullish_pct = source_object.value("bullish_pct").toDouble();
+ source.sentiment_score = source_object.value("sentiment_score").toDouble();
+ source.activity_count = source_object.value("activity_count").toDouble();
+ snapshot.sources.append(source);
+ }
+
+ return snapshot;
+}
+
+} // namespace fincept::services::equity::sentiment
diff --git a/fincept-qt/src/services/equity/MarketSentimentSupport.h b/fincept-qt/src/services/equity/MarketSentimentSupport.h
new file mode 100644
index 000000000..c85a4fc35
--- /dev/null
+++ b/fincept-qt/src/services/equity/MarketSentimentSupport.h
@@ -0,0 +1,19 @@
+#pragma once
+
+#include "services/equity/EquityResearchModels.h"
+
+#include <QJsonObject>
+#include <QStringList>
+
+namespace fincept::services::equity::sentiment {
+
+inline constexpr const char* kProviderId = "adanos-market-sentiment";
+
+QStringList source_ids();
+QString source_label(const QString& source_id);
+SentimentSourceSnapshot parse_compare_payload(const QString& source_id, const QJsonObject& payload);
+QString compute_source_alignment(const QVector<SentimentSourceSnapshot>& sources);
+QJsonObject snapshot_to_json(const MarketSentimentSnapshot& snapshot);
+MarketSentimentSnapshot snapshot_from_json(const QJsonObject& object);
+
+} // namespace fincept::services::equity::sentiment
diff --git a/fincept-qt/tests/MarketSentimentSupportTest.cpp b/fincept-qt/tests/MarketSentimentSupportTest.cpp
new file mode 100644
index 000000000..333f9283f
--- /dev/null
+++ b/fincept-qt/tests/MarketSentimentSupportTest.cpp
@@ -0,0 +1,118 @@
+#include "services/equity/MarketSentimentSupport.h"
+
+#include <QJsonArray>
+#include <QJsonObject>
+
+#include <iostream>
+
+using fincept::services::equity::MarketSentimentSnapshot;
+using fincept::services::equity::SentimentSourceSnapshot;
+using fincept::services::equity::sentiment::compute_source_alignment;
+using fincept::services::equity::sentiment::parse_compare_payload;
+using fincept::services::equity::sentiment::snapshot_from_json;
+using fincept::services::equity::sentiment::snapshot_to_json;
+
+namespace {
+
+bool expect(bool condition, const char* message) {
+ if (!condition) {
+ std::cerr << "FAILED: " << message << '\n';
+ return false;
+ }
+ return true;
+}
+
+bool test_parse_compare_payload() {
+ QJsonObject stock;
+ stock["ticker"] = "AAPL";
+ stock["buzz_score"] = 63.5;
+ stock["bullish_pct"] = 68.0;
+ stock["sentiment_score"] = 0.42;
+ stock["mentions"] = 123;
+
+ QJsonObject payload;
+ payload["stocks"] = QJsonArray{stock};
+
+ const auto snapshot = parse_compare_payload("reddit", payload);
+ return expect(snapshot.available, "reddit source should be available") &&
+ expect(snapshot.source_id == "reddit", "reddit source id should round-trip") &&
+ expect(snapshot.label == "Reddit", "reddit label should be humanized") &&
+ expect(snapshot.buzz_score == 63.5, "buzz score should be parsed") &&
+ expect(snapshot.bullish_pct == 68.0, "bullish pct should be parsed") &&
+ expect(snapshot.sentiment_score == 0.42, "sentiment score should be parsed") &&
+ expect(snapshot.activity_count == 123.0, "mentions should backfill activity count");
+}
+
+bool test_polymarket_activity_fallback() {
+ QJsonObject stock;
+ stock["ticker"] = "TSLA";
+ stock["buzz_score"] = 58.0;
+ stock["bullish_pct"] = 55.0;
+ stock["trade_count"] = 87;
+
+ QJsonObject payload;
+ payload["stocks"] = QJsonArray{stock};
+
+ const auto snapshot = parse_compare_payload("polymarket", payload);
+ return expect(snapshot.available, "polymarket source should be available") &&
+ expect(snapshot.activity_count == 87.0, "trade_count should backfill activity count");
+}
+
+bool test_alignment_and_roundtrip() {
+ SentimentSourceSnapshot reddit;
+ reddit.source_id = "reddit";
+ reddit.label = "Reddit";
+ reddit.available = true;
+ reddit.bullish_pct = 70.0;
+
+ SentimentSourceSnapshot news;
+ news.source_id = "news";
+ news.label = "News";
+ news.available = true;
+ news.bullish_pct = 66.0;
+
+ SentimentSourceSnapshot x;
+ x.source_id = "x";
+ x.label = "X";
+ x.available = true;
+ x.bullish_pct = 48.0;
+
+ const auto alignment = compute_source_alignment({reddit, news, x});
+ if (!expect(alignment == "mixed", "alignment should detect moderate source dispersion")) {
+ return false;
+ }
+
+ MarketSentimentSnapshot snapshot;
+ snapshot.symbol = "AAPL";
+ snapshot.configured = true;
+ snapshot.available = true;
+ snapshot.status = "ok";
+ snapshot.message = "";
+ snapshot.average_buzz = 61.2;
+ snapshot.average_bullish_pct = 61.3;
+ snapshot.coverage = 3;
+ snapshot.source_alignment = alignment;
+ snapshot.sources = {reddit, news, x};
+ snapshot.fetched_at = "2026-04-09T12:00:00Z";
+
+ const auto restored = snapshot_from_json(snapshot_to_json(snapshot));
+ return expect(restored.symbol == "AAPL", "symbol should survive serialization") &&
+ expect(restored.coverage == 3, "coverage should survive serialization") &&
+ expect(restored.sources.size() == 3, "sources should survive serialization") &&
+ expect(restored.source_alignment == "mixed", "alignment should survive serialization");
+}
+
+} // namespace
+
+int main() {
+ if (!test_parse_compare_payload()) {
+ return 1;
+ }
+ if (!test_polymarket_activity_fallback()) {
+ return 1;
+ }
+ if (!test_alignment_and_roundtrip()) {
+ return 1;
+ }
+ return 0;
+}