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
// src/screens/ai_quant_lab/QuantModulePanel.h
#pragma once
#include "services/ai_quant_lab/AIQuantLabTypes.h"
#include "storage/repositories/LlmProfileRepository.h"
#include <QComboBox>
#include <QDateEdit>
#include <QDoubleSpinBox>
#include <QEvent>
#include <QHash>
#include <QHideEvent>
#include <QJsonObject>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QShowEvent>
#include <QSpinBox>
#include <QTableWidget>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QWidget>
#include <functional>
namespace fincept::screens {
/// Dynamic panel for a single AI Quant Lab module.
/// Builds input forms and result display based on module type.
class QuantModulePanel : public QWidget {
Q_OBJECT
public:
explicit QuantModulePanel(const fincept::services::quant::QuantModule& mod, QWidget* parent = nullptr);
protected:
void changeEvent(QEvent* event) override;
// The loading spinner is a UI animation timer: run it only while the panel is on screen.
void showEvent(QShowEvent* event) override;
void hideEvent(QHideEvent* event) override;
private slots:
void on_result(const QString& module_id, const QString& command, const QJsonObject& data);
void on_error(const QString& module_id, const QString& message);
private:
void build_ui();
void connect_service();
/// Re-apply tr() lookups to persistent, member-stored widgets after a
/// QEvent::LanguageChange. Module header label/category are data-derived
/// (services::quant::QuantModule) and kept verbatim; dynamically-rebuilt
/// input forms and result cards re-render in the active language on their
/// next build/fetch.
void retranslateUi();
// Module-specific builders
QWidget* build_deep_agent_panel();
QWidget* build_rd_agent_tab(QComboBox* llm_combo);
QWidget* build_generic_panel();
QWidget* build_gs_quant_panel();
QWidget* build_functime_panel();
QWidget* build_statsmodels_panel();
QWidget* build_fortitudo_panel();
QWidget* build_gluonts_panel();
QWidget* build_cfa_quant_panel();
QWidget* build_backtesting_panel();
QWidget* build_rl_trading_panel();
QWidget* build_advanced_models_panel();
QWidget* build_factor_discovery_panel();
QWidget* build_model_library_panel();
QWidget* build_live_signals_panel();
QWidget* build_online_learning_panel();
QWidget* build_meta_learning_panel();
QWidget* build_hft_panel();
QWidget* build_rolling_retraining_panel();
QWidget* build_feature_engineering_panel();
QWidget* build_portfolio_opt_panel();
QWidget* build_factor_evaluation_panel();
QWidget* build_strategy_builder_panel();
QWidget* build_data_processors_panel();
QWidget* build_quant_reporting_panel();
// Helpers
QWidget* build_input_row(const QString& label, QWidget* input, QWidget* parent);
QDoubleSpinBox* make_double_spin(double min, double max, double val, int decimals, const QString& suffix,
QWidget* parent);
QPushButton* make_run_button(const QString& text, QWidget* parent);
/// "LOAD SYNTHETIC SAMPLE" button that fills `edit` with `generator()`.
/// The filled text is remembered on the edit, so a run whose visible inputs
/// still hold the synthetic sample is flagged SAMPLE INPUT on its results.
QPushButton* make_sample_button(QLineEdit* edit, QWidget* parent, const QString& tip,
std::function<QString()> generator);
/// True when a visible input of the panel still holds unedited sample text.
bool visible_inputs_are_sample() const;
QWidget* build_llm_picker(QWidget* parent, QComboBox** out_combo);
QJsonObject llm_config_from_combo(QComboBox* combo) const;
void display_result(const QJsonObject& data);
void display_backtest_result(const QJsonObject& data);
void display_cfa_result(const QString& command, const QJsonObject& data);
void display_gs_result(const QString& command, const QJsonObject& data);
void display_functime_result(const QString& command, const QJsonObject& data);
void display_statsmodels_result(const QString& command, const QJsonObject& data);
void display_fortitudo_result(const QString& command, const QJsonObject& data);
void display_quant_reporting_result(const QString& command, const QJsonObject& data);
void display_gluonts_result(const QString& command, const QJsonObject& data);
// ADVANCED-category panel renderers (card-based, mirror analytics pattern).
// hft and rolling_retraining have bespoke per-tab UI in on_result() (in-tab
// cards/tables, progress bar, schedule cards) — these display_*_result
// versions exist as fallbacks for direct invocation but are not dispatched
// by on_result() because the bespoke UI is the primary surface.
void display_hft_result(const QString& command, const QJsonObject& data);
void display_rolling_retraining_result(const QString& command, const QJsonObject& data);
void display_advanced_models_result(const QString& command, const QJsonObject& data);
void display_feature_engineering_result(const QString& command, const QJsonObject& data);
// AI/ML-category renderers (rl_trading, online_learning, meta_learning)
void display_rl_trading_result(const QString& command, const QJsonObject& data);
void display_online_learning_result(const QString& command, const QJsonObject& data);
void display_meta_learning_result(const QString& command, const QJsonObject& data);
// CORE-category renderers (factor_discovery, model_library, live_signals)
// backtesting kept on its existing display_backtest_result KPI grid.
void display_factor_discovery_result(const QString& command, const QJsonObject& data);
void display_model_library_result(const QString& command, const QJsonObject& data);
void display_live_signals_result(const QString& command, const QJsonObject& data);
void display_portfolio_opt_result(const QString& command, const QJsonObject& data);
void display_factor_evaluation_result(const QString& command, const QJsonObject& data);
void display_strategy_builder_result(const QString& command, const QJsonObject& data);
void display_data_processors_result(const QString& command, const QJsonObject& data);
void show_loading(const QString& message);
void display_error(const QString& msg);
void clear_results();
void refresh_theme();
fincept::services::quant::QuantModule module_;
QVBoxLayout* results_layout_ = nullptr;
QLabel* status_label_ = nullptr;
QWidget* panel_header_ = nullptr; // the fixed header bar inside build_ui()
QLabel* header_title_ = nullptr;
QLabel* header_cat_ = nullptr;
QTextEdit* agent_output_ = nullptr; // deep_agent LangGraph tab
QTextEdit* rd_agent_output_ = nullptr; // rd_agent tab output
QTableWidget* rd_task_table_ = nullptr; // rd_agent task monitor
// RL Trading subtab — live progress UI
class QProgressBar* rl_progress_bar_ = nullptr;
QLabel* rl_progress_stats_ = nullptr;
class QPlainTextEdit* rl_log_console_ = nullptr;
QPushButton* rl_train_button_ = nullptr;
/// Set by show_loading() when the run was fed LOAD SAMPLE data; on_result()
/// then puts a SAMPLE INPUT banner above the results.
bool sample_input_pending_ = false;
QHash<QString, QDoubleSpinBox*> double_inputs_;
QHash<QString, QLineEdit*> text_inputs_;
QHash<QString, QComboBox*> combo_inputs_;
QHash<QString, QSpinBox*> int_inputs_;
QHash<QString, QDateEdit*> date_inputs_;
};
} // namespace fincept::screens