# munquantsociety/mqsmaster architecture

> Architecture diagram of the GitHub repository munquantsociety/mqsmaster, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/munquantsociety/mqsmaster
- Repository: https://github.com/munquantsociety/mqsmaster

## Overview

MQSMaster combines live multi-portfolio trading, backtesting, market-data ingestion, risk controls, and separate NLP sentiment and relevance-based portfolio analysis. The live workflow starts at the application entry point, runs portfolio strategies through the trading engine, and sends executions through the executor and OMS. The README documents backtesting and NLP as major capabilities; source excerpts and the SOURCE INDEX support their principal internal stages. Some subsystems are represented at directory level because their implementation was not sampled, so their runtime links are left unasserted.

Main entry points: [`RBP/pipeline.py`](https://github.com/munquantsociety/mqsmaster/blob/main/RBP/pipeline.py) (RBP pipeline), [`src/main.py`](https://github.com/munquantsociety/mqsmaster/blob/main/src/main.py) (Live entry point), [`src/live_trading/engine.py`](https://github.com/munquantsociety/mqsmaster/blob/main/src/live_trading/engine.py) (Trading engine), [`src/live_trading/executor.py`](https://github.com/munquantsociety/mqsmaster/blob/main/src/live_trading/executor.py) (Trade executor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_live["Live Trading"]
  node_live_entry["Live entry point<br/>[main.py]"]
  node_engine["Trading engine<br/>[engine.py]"]
  node_executor["Trade executor<br/>[executor.py]"]
  node_oms_factory["OMS factory<br/>[factory.py]"]
  node_order_manager["Order manager<br/>[order_manager.py]"]
  node_scheduler["Order scheduler<br/>[scheduler.py]"]
  node_broker["Broker / trading API"]
  node_risk["Risk management"]
end

subgraph group_market["Market Data"]
  node_market_ingest["Realtime ingestion"]
  node_fmp["FMP market data<br/>[fmpMarketData.py]"]
  node_fmp_service["Financial Modeling Prep"]
end

subgraph group_research["Backtesting &amp; Portfolios"]
  node_strategies["Portfolio strategies<br/>[strategy.py]"]
  node_backtest["Backtest engine<br/>[backtest_engine.py]"]
  node_backtest_runtime["Backtest runtime"]
  node_indicators["Technical indicators"]
end

subgraph group_nlp["NLP Sentiment"]
  node_nlp_runner["Sentiment CLI"]
  node_sentiment_pipeline["Sentiment pipeline<br/>[pipeline.py]"]
  node_scorer["FinBERT scorer<br/>[scorer.py]"]
  node_repository["Sentiment repository<br/>[repository.py]"]
  node_article_collection["Article collection"]
  node_articles["Article files"]
end

subgraph group_rbp["RBP Analysis"]
  node_rbp_pipeline["RBP pipeline<br/>[pipeline.py]"]
  node_loader["Market-data loader<br/>[loader.py]"]
  node_feature_engineer["Feature engineering<br/>[engineer.py]"]
  node_predictor["RBP predictor<br/>[predictor.py]"]
  node_rbi["Relevance scoring<br/>[relevance.py]"]
end

subgraph group_shared["Shared Infrastructure"]
  node_database[("PostgreSQL")]
  node_db_connector["Database connector<br/>[MQSDBConnector.py]"]
end

node_operator(("Trading operator"))

node_operator -->|"starts"| node_live_entry
node_live_entry -->|"starts"| node_engine
node_live_entry -->|"constructs"| node_executor
node_engine -->|"runs"| node_strategies
node_engine -->|"executes children"| node_executor
node_engine -->|"uses"| node_oms_factory
node_oms_factory -->|"creates"| node_order_manager
node_order_manager -->|"releases due orders"| node_scheduler
node_executor -.->|"submits orders"| node_broker
node_live_entry -->|"configures overlay"| node_risk
node_market_ingest -->|"requests data"| node_fmp
node_fmp -->|"requests quotes"| node_fmp_service
node_fmp -.->|"stores market data"| node_database
node_db_connector -->|"queries"| node_database
node_executor -->|"uses market data"| node_fmp
node_backtest -->|"uses components"| node_backtest_runtime
node_backtest -->|"loads portfolio strategy"| node_strategies
node_backtest -->|"queries data"| node_database
node_strategies -->|"uses indicators"| node_indicators
node_operator -->|"runs"| node_nlp_runner
node_nlp_runner -->|"invokes"| node_sentiment_pipeline
node_sentiment_pipeline -->|"scores articles"| node_scorer
node_sentiment_pipeline -->|"persists scores"| node_repository
node_scorer -.->|"reads articles"| node_articles
node_article_collection -.->|"writes articles"| node_articles
node_repository -->|"queries"| node_db_connector
node_rbp_pipeline -->|"loads prices"| node_loader
node_rbp_pipeline -->|"engineers features"| node_feature_engineer
node_rbp_pipeline -->|"predicts outcomes"| node_predictor
node_rbp_pipeline -->|"calculates relevance"| node_rbi
node_loader -->|"reads market data"| node_db_connector
node_feature_engineer -->|"updates indicators"| node_indicators

click node_live_entry "https://github.com/munquantsociety/mqsmaster/blob/main/src/main.py"
click node_engine "https://github.com/munquantsociety/mqsmaster/blob/main/src/live_trading/engine.py"
click node_strategies "https://github.com/munquantsociety/mqsmaster/blob/main/src/portfolios/portfolio_3/strategy.py"
click node_executor "https://github.com/munquantsociety/mqsmaster/blob/main/src/live_trading/executor.py"
click node_oms_factory "https://github.com/munquantsociety/mqsmaster/blob/main/src/oms/factory.py"
click node_order_manager "https://github.com/munquantsociety/mqsmaster/blob/main/src/oms/order_manager.py"
click node_scheduler "https://github.com/munquantsociety/mqsmaster/blob/main/src/oms/scheduler.py"
click node_risk "https://github.com/munquantsociety/mqsmaster/tree/main/src/risk_manager"
click node_market_ingest "https://github.com/munquantsociety/mqsmaster/blob/main/src/orchestrator/realTime/realtimeDataIngestor.py"
click node_fmp "https://github.com/munquantsociety/mqsmaster/blob/main/src/orchestrator/marketData/fmpMarketData.py"
click node_db_connector "https://github.com/munquantsociety/mqsmaster/blob/main/src/common/database/MQSDBConnector.py"
click node_backtest "https://github.com/munquantsociety/mqsmaster/blob/main/src/backtest/backtest_engine.py"
click node_backtest_runtime "https://github.com/munquantsociety/mqsmaster/tree/main/src/backtest"
click node_indicators "https://github.com/munquantsociety/mqsmaster/tree/main/src/portfolios/indicators"
click node_nlp_runner "https://github.com/munquantsociety/mqsmaster/blob/main/NLP/process_sentiment_pipeline.py"
click node_sentiment_pipeline "https://github.com/munquantsociety/mqsmaster/blob/main/NLP/sentiment/pipeline.py"
click node_scorer "https://github.com/munquantsociety/mqsmaster/blob/main/NLP/sentiment/scorer.py"
click node_repository "https://github.com/munquantsociety/mqsmaster/blob/main/NLP/persistence/repository.py"
click node_article_collection "https://github.com/munquantsociety/mqsmaster/tree/main/NLP/scrapers"
click node_articles "https://github.com/munquantsociety/mqsmaster/tree/main/NLP"
click node_rbp_pipeline "https://github.com/munquantsociety/mqsmaster/blob/main/RBP/pipeline.py"
click node_loader "https://github.com/munquantsociety/mqsmaster/blob/main/RBP/database/loader.py"
click node_feature_engineer "https://github.com/munquantsociety/mqsmaster/blob/main/RBP/features/engineer.py"
click node_predictor "https://github.com/munquantsociety/mqsmaster/blob/main/RBP/models/predictor.py"
click node_rbi "https://github.com/munquantsociety/mqsmaster/blob/main/RBP/core/relevance.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_live_entry,node_engine,node_executor,node_oms_factory,node_order_manager,node_scheduler,node_broker,node_risk toneBlue
class node_market_ingest,node_fmp,node_fmp_service toneAmber
class node_strategies,node_backtest,node_backtest_runtime,node_indicators toneMint
class node_nlp_runner,node_sentiment_pipeline,node_scorer,node_repository,node_article_collection,node_articles toneRose
class node_rbp_pipeline,node_loader,node_feature_engineer,node_predictor,node_rbi,node_operator toneIndigo
class node_database,node_db_connector toneTeal
```

## Components

### Live Trading

- [Live entry point](https://github.com/munquantsociety/mqsmaster/blob/main/src/main.py): `src/main.py`
- [Trading engine](https://github.com/munquantsociety/mqsmaster/blob/main/src/live_trading/engine.py): `src/live_trading/engine.py`
- [Trade executor](https://github.com/munquantsociety/mqsmaster/blob/main/src/live_trading/executor.py): `src/live_trading/executor.py`
- [OMS factory](https://github.com/munquantsociety/mqsmaster/blob/main/src/oms/factory.py): `src/oms/factory.py`
- [Order manager](https://github.com/munquantsociety/mqsmaster/blob/main/src/oms/order_manager.py): `src/oms/order_manager.py`
- [Order scheduler](https://github.com/munquantsociety/mqsmaster/blob/main/src/oms/scheduler.py): `src/oms/scheduler.py`
- **Broker / trading API**
- [Risk management](https://github.com/munquantsociety/mqsmaster/tree/main/src/risk_manager): `src/risk_manager`

### Market Data

- [Realtime ingestion](https://github.com/munquantsociety/mqsmaster/blob/main/src/orchestrator/realTime/realtimeDataIngestor.py): `src/orchestrator/realTime/realtimeDataIngestor.py`
- [FMP market data](https://github.com/munquantsociety/mqsmaster/blob/main/src/orchestrator/marketData/fmpMarketData.py): `src/orchestrator/marketData/fmpMarketData.py`
- **Financial Modeling Prep**

### Backtesting & Portfolios

- [Portfolio strategies](https://github.com/munquantsociety/mqsmaster/blob/main/src/portfolios/portfolio_3/strategy.py): `src/portfolios/portfolio_3/strategy.py`
- [Backtest engine](https://github.com/munquantsociety/mqsmaster/blob/main/src/backtest/backtest_engine.py): `src/backtest/backtest_engine.py`
- [Backtest runtime](https://github.com/munquantsociety/mqsmaster/tree/main/src/backtest): `src/backtest`
- [Technical indicators](https://github.com/munquantsociety/mqsmaster/tree/main/src/portfolios/indicators): `src/portfolios/indicators`

### NLP Sentiment

- [Sentiment CLI](https://github.com/munquantsociety/mqsmaster/blob/main/NLP/process_sentiment_pipeline.py): `NLP/process_sentiment_pipeline.py`
- [Sentiment pipeline](https://github.com/munquantsociety/mqsmaster/blob/main/NLP/sentiment/pipeline.py): `NLP/sentiment/pipeline.py`
- [FinBERT scorer](https://github.com/munquantsociety/mqsmaster/blob/main/NLP/sentiment/scorer.py): `NLP/sentiment/scorer.py`
- [Sentiment repository](https://github.com/munquantsociety/mqsmaster/blob/main/NLP/persistence/repository.py): `NLP/persistence/repository.py`
- [Article collection](https://github.com/munquantsociety/mqsmaster/tree/main/NLP/scrapers): `NLP/scrapers`
- [Article files](https://github.com/munquantsociety/mqsmaster/tree/main/NLP): `NLP`

### RBP Analysis

- [RBP pipeline](https://github.com/munquantsociety/mqsmaster/blob/main/RBP/pipeline.py): `RBP/pipeline.py`
- [Market-data loader](https://github.com/munquantsociety/mqsmaster/blob/main/RBP/database/loader.py): `RBP/database/loader.py`
- [Feature engineering](https://github.com/munquantsociety/mqsmaster/blob/main/RBP/features/engineer.py): `RBP/features/engineer.py`
- [RBP predictor](https://github.com/munquantsociety/mqsmaster/blob/main/RBP/models/predictor.py): `RBP/models/predictor.py`
- [Relevance scoring](https://github.com/munquantsociety/mqsmaster/blob/main/RBP/core/relevance.py): `RBP/core/relevance.py`

### Shared Infrastructure

- **PostgreSQL**
- [Database connector](https://github.com/munquantsociety/mqsmaster/blob/main/src/common/database/MQSDBConnector.py): `src/common/database/MQSDBConnector.py`

### Other components

- **Trading operator**

## Connections

- Trading operator → Live entry point: starts (evidence: `src/main.py`)
- Live entry point → Trading engine: starts (evidence: `src/main.py`)
- Live entry point → Trade executor: constructs (evidence: `src/main.py`)
- Trading engine → Portfolio strategies: runs (evidence: `src/live_trading/engine.py`)
- Trading engine → Trade executor: executes children (evidence: `src/live_trading/engine.py`)
- Trading engine → OMS factory: uses (evidence: `src/live_trading/engine.py`)
- OMS factory → Order manager: creates (evidence: `src/oms/factory.py`)
- Order manager → Order scheduler: releases due orders (evidence: `src/oms/order_manager.py`)
- Trade executor → Broker / trading API: submits orders
- Live entry point → Risk management: configures overlay (evidence: `src/main.py`)
- Realtime ingestion → FMP market data: requests data (evidence: `src/orchestrator/realTime/realtimeDataIngestor.py`)
- FMP market data → Financial Modeling Prep: requests quotes (evidence: `src/orchestrator/marketData/fmpMarketData.py`)
- FMP market data → PostgreSQL: stores market data
- Database connector → PostgreSQL: queries (evidence: `src/common/database/MQSDBConnector.py`)
- Trade executor → FMP market data: uses market data (evidence: `src/live_trading/executor.py`)
- Backtest engine → Backtest runtime: uses components (evidence: `src/backtest/backtest_engine.py`)
- Backtest engine → Portfolio strategies: loads portfolio strategy (evidence: `src/backtest/backtest_engine.py`)
- Backtest engine → PostgreSQL: queries data (evidence: `src/backtest/backtest_engine.py`)
- Portfolio strategies → Technical indicators: uses indicators
- Trading operator → Sentiment CLI: runs (evidence: `NLP/process_sentiment_pipeline.py`)
- Sentiment CLI → Sentiment pipeline: invokes (evidence: `NLP/process_sentiment_pipeline.py`)
- Sentiment pipeline → FinBERT scorer: scores articles (evidence: `NLP/sentiment/pipeline.py`)
- Sentiment pipeline → Sentiment repository: persists scores (evidence: `NLP/sentiment/pipeline.py`)
- FinBERT scorer → Article files: reads articles (evidence: `NLP/sentiment/scorer.py`)
- Article collection → Article files: writes articles (evidence: `NLP/scrapers/fmp.py`)
- Sentiment repository → Database connector: queries (evidence: `NLP/persistence/repository.py`)
- RBP pipeline → Market-data loader: loads prices (evidence: `RBP/pipeline.py`)
- RBP pipeline → Feature engineering: engineers features (evidence: `RBP/pipeline.py`)
- RBP pipeline → RBP predictor: predicts outcomes (evidence: `RBP/pipeline.py`)
- RBP pipeline → Relevance scoring: calculates relevance (evidence: `RBP/pipeline.py`)
- Market-data loader → Database connector: reads market data (evidence: `RBP/database/loader.py`)
- Feature engineering → Technical indicators: updates indicators (evidence: `RBP/features/engineer.py`)
