Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TradeFin Quant Intelligence

A quantitative research and trading platform for market data, factor intelligence, strategy backtesting, risk analytics, and decision-ready reporting.

Python C%2B%2B FastAPI Streamlit License

Why TradeFin Quant Intelligence?

TradeFin Quant Intelligence connects the full quantitative workflow:

Market and alternative data
          |
          v
Data ingestion -> processing -> factors and signals -> backtesting
          |                                      |
          v                                      v
   Trading data store       risk and performance analytics
          |                                      |
          +------------+-------------------------+
                       v
       FastAPI operations UI | Streamlit research UI
                       |
       Metabase operational analytics | Power BI executive reporting

The project is designed as a research and engineering platform. It is not a broker-certified execution system, and the current web API contains demonstration responses in several routes. Replace those fixtures with persisted data and authenticated broker adapters before using it with real capital.

Current Capabilities

  • Market data: Yahoo Finance, Binance, Alpha Vantage, and WebSocket-oriented realtime components.
  • Quant research: momentum, value, quality, size, and volatility factors; screening; portfolio optimization; and performance analysis.
  • Strategy development: registry-based strategies, backtesting, parameter optimization, and extensible strategy interfaces.
  • AI-assisted research: NLP preprocessing, sentiment analysis, news/social monitoring components, LLM integration, and sentiment factors.
  • Risk analytics: position sizing, drawdown, VaR/CVaR, leverage, concentration, and portfolio monitoring components.
  • Interfaces: a Streamlit research dashboard, a FastAPI service, and a responsive static web client.
  • Persistence: SQLite by default, PostgreSQL support in the database manager, Redis-oriented realtime support, CSV/JSON/Excel exports, and local backtest artifacts.
  • Performance path: a C++17 backend for data loading, order execution, risk management, and strategy-related components.

Metabase and Power BI Integration

BI tools should read a stable analytics contract, not internal Python objects or live exchange endpoints. The recommended design is:

Trading services -> PostgreSQL operational store -> analytics views/materialized views
                                                     |                 |
                                                   Metabase          Power BI

Recommended division of responsibility

Tool Best fit in this project Initial connection mode
Metabase Team-facing operations: trade activity, system health, strategy runs, data freshness, and risk alerts PostgreSQL database connection; SQLite only for local exploration
Power BI Executive and portfolio reporting: attribution, monthly returns, drawdown, exposure, factor contribution, and scheduled packs PostgreSQL Import mode first; DirectQuery when freshness and database capacity justify it
Streamlit Research workflows and interactive model experimentation Native Python integration
FastAPI Commands, orchestration, and application-facing APIs REST/OpenAPI

Analytics contract

The existing database tables provide a useful starting point:

  • market_data: OHLCV observations by symbol and timestamp
  • trades: order and fill records
  • signals: strategy signals and strength
  • performance: daily P&L, returns, drawdown, Sharpe ratio, win rate, and trade counts

The first BI slice is implemented in bi/analytics_views_postgresql.sql, with views for trade facts, daily performance, latest market state, signal activity, and data quality. Include UTC timestamps, strategy identifiers, benchmark returns, data freshness timestamps, and a source-system/run identifier as the operational schema expands. Power BI and Metabase should consume these views with read-only credentials.

Practical rollout

  1. Foundation: run PostgreSQL, migrate persisted market/trade/performance data from SQLite, and add indexes on symbol, timestamp, strategy, and date.
  2. Semantic layer: create analytics views with consistent definitions for return, P&L, drawdown, exposure, and trade status. Test them against the Python performance analyzer.
  3. Metabase: connect a read-only PostgreSQL user, curate collections for Operations, Risk, Strategies, and Data Quality, then add freshness and failed-run alerts.
  4. Power BI: connect through the PostgreSQL connector, build a star-shaped model around trade/performance facts and date, symbol, and strategy dimensions, then publish an executive report with row-level security where required.
  5. Reliability: schedule ETL/materialized-view refreshes, monitor row counts and freshness, document metric ownership, and keep BI credentials outside config.json.

The repository now provides the storage primitives, curated PostgreSQL views, and a local export utility for this design. The BI connectors, deployment manifests, authentication, and production refresh jobs remain deployment work.

See bi/README.md for setup instructions, CSV export commands, and dashboard ideas inspired by Next Ventures' public focus on trader performance, execution, compliance, and global fintech operations.

Architecture

backend/                  C++17 engine components
data_service/
  fetchers/               market and exchange integrations
  processors/             cleaning and feature preparation
  factors/                factor calculation, screening, optimization
  strategies/             strategy registry and implementations
  backtest/               simulation and performance analysis
  ai/                     NLP, sentiment, LLM, and alternative data
  storage/                database and file persistence
  realtime/               streaming and WebSocket components
  dashboard/              Streamlit research dashboard
  web/                    FastAPI server and dashboard data endpoints
static/                   browser client assets
tests/                    Python test suite
backend/tests/            C++ component tests

Quick Start

Windows PowerShell

python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install -e ".[test,visualization,realtime,web,bi]"
python examples\fetch_public_data.py

For AI features, install the optional group:

pip install -e ".[ai]"

Create a local configuration from config.example.json and add credentials only through environment-specific secret management. Do not commit API keys.

Run the interfaces

# Streamlit research dashboard: http://localhost:8501
python run_dashboard.py

# FastAPI web interface: http://localhost:8000
python run_web_interface.py

The FastAPI application also exposes OpenAPI documentation at /docs when the server is running.

Export datasets for Power BI prototypes

python bi\export_datasets.py --database data\trading_system.db --output bi_exports

For a PostgreSQL deployment, use --db-type postgresql --connection-string "...". Metabase should connect directly to the curated PostgreSQL views; Power BI can use PostgreSQL Import mode or the generated CSVs for an offline prototype.

Build the C++ backend

cmake -S backend -B backend/build
cmake --build backend/build --config Release

Python API Examples

from data_service.backtest import BacktestEngine
from data_service.fetchers import BinanceFetcher

fetcher = BinanceFetcher()
print(fetcher.get_current_price("BTCUSD"))

engine = BacktestEngine(initial_capital=100000)
results = engine.run_backtest(strategy, historical_data)

The project also exposes reusable factor, AI, storage, visualization, and strategy modules. See the examples directory for runnable workflows.

API Surface

The FastAPI service currently includes endpoints for:

  • GET /api/health
  • GET /api/system/status
  • GET /api/strategies
  • POST /api/backtest/run
  • POST /api/factors/analyze
  • POST /api/ai/analyze
  • GET /api/market/data/{symbol}
  • GET /api/portfolio/status
  • GET /api/trades/recent

Before production use, add authentication, restrictive CORS, request limits, structured audit logs, and real repository-backed responses. Several current routes intentionally return sample data for UI demonstration.

Testing

pytest tests -v

The C++ tests can be built through the backend CMake project. Test coverage should be expanded around database migrations, analytics view definitions, broker adapters, and BI refresh validation as those layers are implemented.

Documentation

Resume-ready project description

TradeFin Quant Intelligence | Quantitative Trading and Fintech Intelligence Platform

  • Built a modular Python/C++ quantitative platform that ingests market data, computes multi-factor signals, backtests strategies, and exposes research and operations workflows through Streamlit and FastAPI.
  • Designed a PostgreSQL analytics contract with curated trade, performance, market, signal, and data-quality views for governed Metabase dashboards and Power BI reporting.
  • Implemented reusable risk and performance analytics covering drawdown, VaR/CVaR, Sharpe ratio, win rate, leverage, concentration, and portfolio monitoring use cases.
  • Integrated AI-assisted NLP and sentiment workflows with extensible strategy, storage, realtime, and data-fetching components for research-driven trading decisions.

Disclaimer

This software is for educational and research purposes. It does not constitute investment advice. Trading involves substantial risk, and past performance does not guarantee future results.

License

MIT. See LICENSE.

About

Quantitative Trading, Risk Analytics & Fintech Intelligence Platform.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages