State-of-the-art Financial Analysis & Deep Learning Library
Project description
State-of-the-art Financial Analysis & Deep Learning Library
Installation | Quick Start | ๐ Theory | Documentation | Contributing
๐ฅ What is FinLearner?
FinLearner is a comprehensive Python library designed for quantitative researchers, algorithmic traders, and data scientists. It provides production-ready tools for:
- ๐ Deep Learning Forecasting โ LSTM, GRU, Transformer, CNN-LSTM, Ensemble models
- ๐ผ Portfolio Optimization โ Markowitz, Black-Litterman, Risk Parity
- ๐ Technical Analysis โ 20+ indicators including RSI, MACD, Bollinger Bands, Ichimoku Cloud
- ๐ฏ Options Pricing โ Black-Scholes-Merton model with Greeks calculation
- ๐ง Physics-Informed Neural Networks โ PINN for solving Black-Scholes PDE
- ๐ Risk Metrics โ VaR (Historical, Parametric, Monte Carlo), CVaR, Max Drawdown
- ๐ Anomaly Detection โ VAE for price pattern anomalies
- ๐ค Gradient Boosting โ XGBoost/LightGBM with auto feature engineering
- ๐ Interactive Visualization โ Beautiful Plotly-powered financial charts
Philosophy: One library. All the tools you need. From data fetching to model deployment.
๐ฐ News
| Date | News |
|---|---|
| 2026-02 | 02/2026 |
| 02/2026 | v0.1.0 Major Release |
| 2025-12 | ๐ Added Ichimoku Cloud and advanced technical indicators |
| 2025-12 | ๐ FinLearner is now available on PyPI! |
๐ฆ Installation
Install with pip (recommended)
pip install finlearner
Install from source
git clone https://github.com/ankitdutta428/finlearner.git
cd finlearner
pip install -e .
Requirements
- Python 3.8+
- TensorFlow 2.10+
- NumPy, Pandas, SciPy, Scikit-learn
- Plotly, Matplotlib, Seaborn
- yfinance
โก Quick Start
๐ฎ Stock Price Prediction with LSTM
Train a deep learning model to predict stock prices with just a few lines of code:
from finlearner import DataLoader, TimeSeriesPredictor, Plotter
# 1. Fetch and preprocess data
df = DataLoader.download_data('AAPL', start='2020-01-01', end='2024-01-01')
# 2. Initialize and train the LSTM predictor
predictor = TimeSeriesPredictor(lookback_days=60)
predictor.fit(df, epochs=25, batch_size=32)
# 3. Generate predictions
predictions = predictor.predict(df)
# 4. Visualize results
Plotter.plot_prediction(df, predictions, title="Apple Stock Prediction")
๐ผ Portfolio Optimization (Markowitz)
Find the optimal asset allocation using Modern Portfolio Theory:
from finlearner import PortfolioOptimizer
# Define your portfolio
tickers = ['AAPL', 'GOOG', 'MSFT', 'AMZN', 'TSLA']
# Run optimization with Monte Carlo simulation
optimizer = PortfolioOptimizer(tickers=tickers, start='2023-01-01', end='2024-01-01')
results, optimal_allocation, metrics = optimizer.optimize(num_portfolios=10000)
print("๐ Optimal Allocation (Max Sharpe Ratio):")
print(optimal_allocation)
print(f"\n๐ Expected Return: {metrics[1]:.2%}")
print(f"๐ Volatility: {metrics[0]:.2%}")
๐ Technical Analysis
Apply comprehensive technical indicators to your data:
from finlearner import DataLoader, TechnicalIndicators, Plotter
# Load data
df = DataLoader.download_data('NVDA', start='2023-01-01', end='2024-01-01')
# Add all technical indicators at once
ti = TechnicalIndicators(df)
df_enriched = ti.add_all() # Adds RSI, MACD, Bollinger Bands, ATR, Ichimoku, etc.
# Or add specific indicators
df = ti.rsi(window=14)
df = ti.macd(fast=12, slow=26, signal=9)
df = ti.bollinger_bands(window=20, num_std=2)
# Interactive candlestick chart
Plotter.candlestick(df_enriched, title="NVIDIA Technical Analysis")
๐ฏ Options Pricing (Black-Scholes-Merton)
Price European options and calculate Greeks:
from finlearner.options import BlackScholesMerton
# Create option pricer
option = BlackScholesMerton(
S=100, # Spot price
K=100, # Strike price
T=1, # Time to maturity (years)
r=0.05, # Risk-free rate
sigma=0.2, # Volatility
q=0.02 # Dividend yield
)
# Calculate prices
call_price = option.price('call')
put_price = option.price('put')
# Calculate Greeks
greeks = option.greeks('call')
print(f"Call Price: ${call_price:.2f}")
print(f"Delta: {greeks['delta']:.4f}")
print(f"Gamma: {greeks['gamma']:.4f}")
print(f"Vega: {greeks['vega']:.4f}")
๐๏ธ Architecture
graph TB
subgraph Data Layer
A[DataLoader] --> |yfinance| B[Raw OHLCV Data]
end
subgraph Analysis Layer
B --> C[TechnicalIndicators]
B --> D[PortfolioOptimizer]
B --> E[TimeSeriesPredictor]
end
subgraph Pricing Layer
F[BlackScholesMerton] --> G[Option Prices + Greeks]
H[BlackScholesPINN] --> I[PDE Solutions]
end
subgraph Visualization Layer
C --> J[Plotter]
D --> J
E --> J
J --> K[Interactive Charts]
end
style A fill:#4CAF50,color:#fff
style E fill:#2196F3,color:#fff
style F fill:#FF9800,color:#fff
style J fill:#9C27B0,color:#fff
๐ Module Reference
| Module | Class | Description |
|---|---|---|
finlearner.data |
DataLoader |
Unified data fetching wrapper for Yahoo Finance |
finlearner.models |
TimeSeriesPredictor |
LSTM-based time series forecasting |
finlearner.models |
GRUPredictor |
GRU-based predictor (faster than LSTM) |
finlearner.models |
CNNLSTMPredictor |
CNN-LSTM hybrid for pattern extraction |
finlearner.models |
TransformerPredictor |
Transformer with self-attention |
finlearner.models |
EnsemblePredictor |
LSTM + GRU + Attention ensemble |
finlearner.ml_models |
GradientBoostPredictor |
XGBoost/LightGBM for tabular data |
finlearner.anomaly |
VAEAnomalyDetector |
VAE for price anomaly detection |
finlearner.risk |
RiskMetrics |
VaR, CVaR, Max Drawdown calculations |
finlearner.portfolio |
PortfolioOptimizer |
Markowitz Mean-Variance optimization |
finlearner.portfolio |
BlackLittermanOptimizer |
Black-Litterman with investor views |
finlearner.portfolio |
RiskParityOptimizer |
Equal risk contribution portfolio |
finlearner.technical |
TechnicalIndicators |
20+ technical analysis indicators |
finlearner.options |
BlackScholesMerton |
European option pricing with Greeks |
finlearner.pinn |
BlackScholesPINN |
Physics-Informed Neural Network for Black-Scholes |
finlearner.plotting |
Plotter |
Interactive visualization with Plotly |
finlearner.utils |
check_val |
Model validation utilities |
๐ Technical Indicators Available
| Category | Indicators |
|---|---|
| Trend | SMA, EMA, MACD, Ichimoku Cloud |
| Momentum | RSI, Stochastic Oscillator, CCI |
| Volatility | Bollinger Bands, ATR |
| Volume | OBV (On-Balance Volume) |
๐งช Testing
Run the test suite:
# Run all tests
pytest tests/ -v
# Run with coverage report
pytest tests/ --cov=finlearner --cov-report=term-missing
# Run specific test module
pytest tests/test_options.py -v
๐ค Contributing
We welcome contributions from the community! Here's how to get started:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Write tests for your changes
- Commit your changes (
git commit -m 'Add AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Development Setup
# Clone your fork
git clone https://github.com/YOUR_USERNAME/finlearner.git
cd finlearner
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
๐ Documentation
- ๐ User Guide
- ๐ API Reference
- ๐ Examples
๐บ๏ธ Roadmap
- Risk metrics โ VaR (Historical, Parametric, Monte Carlo), CVaR, Maximum Drawdown โ
- Transformer-based forecasting โ TransformerPredictor with self-attention โ
- Advanced ML models โ GRU, CNN-LSTM, Ensemble, XGBoost/LightGBM โ
- Anomaly detection โ VAE for price pattern anomalies โ
- Advanced portfolio optimization โ Black-Litterman, Risk Parity โ
- Backtesting engine for strategy testing
- Sentiment analysis integration
- Additional data sources (Alpha Vantage, Polygon.io)
- CLI interface for quick analysis
๐ Citation
If you use FinLearner in your research, please cite:
@software{finlearner2024,
author = {Dutta, Ankit},
title = {FinLearner: A Comprehensive Financial Analysis and Deep Learning Library},
year = {2025},
publisher = {GitHub},
url = {https://github.com/ankitdutta428/finlearner}
}
๐ License
Distributed under the Apache 2.0 License. See LICENSE for more information.
๐ Acknowledgments
- yfinance for financial data
- TensorFlow for deep learning infrastructure
- Plotly for interactive visualizations
- The open-source quantitative finance community
Built with โค๏ธ by Ankit Dutta
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file finlearner-0.1.2.tar.gz.
File metadata
- Download URL: finlearner-0.1.2.tar.gz
- Upload date:
- Size: 48.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cdb0f2fa1f33c8e70916481fdc7f9ac02519555d07a3e9e3665656c51c96eee
|
|
| MD5 |
49a84d9ef58a1eb800f68ecc672d5c76
|
|
| BLAKE2b-256 |
f4c171abf3d0bd99b3f4c545ee664f65ad6de07b82740b1f32a8d3b6562fb504
|
Provenance
The following attestation bundles were made for finlearner-0.1.2.tar.gz:
Publisher:
publish.yml on ankitdutta428/finlearner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
finlearner-0.1.2.tar.gz -
Subject digest:
3cdb0f2fa1f33c8e70916481fdc7f9ac02519555d07a3e9e3665656c51c96eee - Sigstore transparency entry: 908848562
- Sigstore integration time:
-
Permalink:
ankitdutta428/finlearner@534455c2f1d37fd65e560aa3470c6c447614d2a8 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/ankitdutta428
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@534455c2f1d37fd65e560aa3470c6c447614d2a8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file finlearner-0.1.2-py3-none-any.whl.
File metadata
- Download URL: finlearner-0.1.2-py3-none-any.whl
- Upload date:
- Size: 38.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd1a904d4e0790921c200063faa2d13815bbdcc5d896c8f8b2f6ed4d2efde8d9
|
|
| MD5 |
beaef4faa1d8045e0a69c61ce6a6d6af
|
|
| BLAKE2b-256 |
1de0ffd3b1912c9df349f091ca46e9f07b1dbe1be187075ac1a19156e282fb8d
|
Provenance
The following attestation bundles were made for finlearner-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on ankitdutta428/finlearner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
finlearner-0.1.2-py3-none-any.whl -
Subject digest:
dd1a904d4e0790921c200063faa2d13815bbdcc5d896c8f8b2f6ed4d2efde8d9 - Sigstore transparency entry: 908848563
- Sigstore integration time:
-
Permalink:
ankitdutta428/finlearner@534455c2f1d37fd65e560aa3470c6c447614d2a8 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/ankitdutta428
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@534455c2f1d37fd65e560aa3470c6c447614d2a8 -
Trigger Event:
push
-
Statement type: