Skip to content

knowledgemule/factorlab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FactorLab - Professional Portfolio Analysis Tool

A comprehensive portfolio factor analysis and risk management tool with Interactive Brokers (IBKR) integration. Built for professional portfolio management with institutional-grade analytics.

Features

Core Capabilities

  • Factor Analysis: Fama-French factors, momentum, value, quality, and custom factor definitions
  • Portfolio Optimization: Mean-variance, risk parity, volatility targeting, and Black-Litterman
  • Risk Management: Covariance estimation, risk decomposition, and hedging strategies
  • IBKR Integration: Live data feeds, position management, and trade execution
  • ETF Replication: Factor-based hedging using liquid ETFs

Web Dashboard

  • Responsive web interface optimized for desktop and mobile
  • Real-time portfolio analysis and optimization
  • Interactive factor exposure visualization
  • ETF-based hedging recommendations
  • Multiple data sources: IBKR live data, custom tickers, manual input, demo data

Installation

  1. Install dependencies:
pip install -r requirements.txt
  1. Configure environment variables:
cp .env.example .env
# Edit .env with your settings

Usage

Web Dashboard

# Run the dashboard
python -m factorlab.ui.dashboard

# Access at http://localhost:8052

Python API

from factorlab import fetch_prices, optimize_portfolio, run_backtest

# Fetch data
prices = fetch_prices(['AAPL', 'MSFT', 'GOOGL'], '2020-01-01', '2023-01-01')

# Optimize portfolio
weights = optimize_portfolio(returns, cov_matrix, objective='max_sharpe')

# Run backtest
results = run_backtest(weights, prices, start_date, end_date)

Architecture

factorlab/
├── data/           # Data ingestion and processing
├── factors/        # Factor definitions and calculations
├── risk/           # Risk models and covariance estimation
├── optimize/       # Portfolio optimization algorithms
├── sizing/         # Position sizing methods
├── hedging/        # ETF replication and hedging
├── backtest/       # Backtesting engine
├── ui/             # Web dashboard
└── utils/          # Utilities and helpers

Key Modules

  • factorlab.data.ingest - Fetch prices and factor data
  • factorlab.factors.definitions - Calculate momentum, value, quality factors
  • factorlab.optimize.solvers - Portfolio optimization algorithms
  • factorlab.risk.cov - Covariance estimation and risk decomposition
  • factorlab.hedging.etf_replication - ETF-based hedging strategies
  • factorlab.backtest.engine - Strategy backtesting

IBKR Integration

FactorLab supports live integration with Interactive Brokers:

  1. Install and run IBKR TWS or Gateway
  2. Enable API connections in TWS
  3. Configure connection settings in .env
  4. Use live data mode in the dashboard

Requirements

  • Python 3.8+
  • Interactive Brokers TWS/Gateway (optional, for live data)
  • Market data subscriptions (for comprehensive factor data)

License

MIT License - see LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors