A professional-grade financial analysis library featuring Deep Learning (LSTM, PINNs), Portfolio Optimization, and Advanced Technical Analysis. It is the final beta upgrade of finlearn.
Project description
FinLearner is a comprehensive Python library for financial analysis, algorithmic trading research, and deep learning-based market prediction. It combines advanced technical analysis, modern portfolio theory, and state-of-the-art LSTM models into a single, production-ready API.
Whether you are a researcher, a quant developer, or a data scientist, FinLearn provides the robust tools needed to analyze markets and build predictive models.
Key Features
- Deep Learning Models: Pre-configured LSTM and GRU architectures optimized for time-series forecasting.
- Portfolio Optimization: Implementation of Markowitz Mean-Variance Optimization to find the Efficient Frontier and maximize Sharpe Ratios.
- Technical Analysis: A suite of 20+ technical indicators (RSI, MACD, Bollinger Bands, etc.) optimized for Pandas.
- Interactive Visualization: Beautiful, interactive financial charts powered by Plotly.
- Data Pipeline: Unified data fetching wrapper for Yahoo Finance.
Installation
You can install finlearn directly from PyPI:
pip install finlearn
Or build from source:Bashgit clone [https://github.com/ankitdutta428/finlearn.git](https://github.com/ankitdutta428/finlearn.git)
cd finlearn
pip install -e .
⚡ Quick Start1. Market Prediction (Deep Learning)Train an LSTM model to predict future stock prices with just a few lines of code.
from finlearn import DataLoader, TimeSeriesPredictor, Plotter
# 1. Fetch Data
# Automatically handles cleaning and preprocessing
df = DataLoader.download_data('AAPL', start='2020-01-01', end='2024-01-01')
# 2. Train Model
# Initialize the predictor with a 60-day lookback window
predictor = TimeSeriesPredictor(lookback_days=60)
predictor.fit(df, epochs=25, batch_size=32)
# 3. Predict
predictions = predictor.predict(df)
# 4. Visualize Results
# Plot actual vs predicted prices
Plotter.plot_prediction(df, predictions, title="Apple Stock Prediction")
2. Portfolio OptimizationUse Modern Portfolio Theory to allocate assets efficiently.Pythonfrom finlearn import PortfolioOptimizer
# Define your portfolio assets
tickers = ['AAPL', 'GOOG', 'MSFT', 'AMZN', 'TSLA']
# Initialize Optimizer
opt = PortfolioOptimizer(tickers=tickers, start='2023-01-01', end='2024-01-01')
# Run Monte Carlo Simulation to find the optimal allocation
results, allocation, metrics = opt.optimize(num_portfolios=5000)
print("Optimal Asset Allocation (Max Sharpe Ratio):")
print(allocation)
3. Technical Analysis & PlottingAnalyze trends using standard indicators.Pythonfrom finlearn import TechnicalIndicators, Plotter
# Load Data
df = DataLoader.download_data('NVDA', start='2023-01-01', end='2024-01-01')
# Add Indicators
ti = TechnicalIndicators(df)
df_tech = ti.add_all() # Adds RSI, MACD, Bollinger Bands, etc.
# Interactive Candlestick Chart
Plotter.candlestick(df_tech, title="NVIDIA Technical Analysis")
Modules Overview
| Module | Description |
|---|---|
finlearn.models |
Contains Deep Learning classes (TimeSeriesPredictor) using TensorFlow/Keras. |
finlearn.portfolio |
Tools for asset allocation and portfolio optimization (PortfolioOptimizer). |
finlearn.technical |
Library of technical indicators (RSI, MACD, Bollinger Bands). |
finlearn.data |
Data ingestion layer wrapping yfinance. |
finlearn.plotting |
Visualization tools based on plotly for interactive charts. |
Contributing
We welcome contributions! Please see the guidelines below:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
- Please ensure all new modules include unit tests in the
tests/directory.
License
- Distributed under the Apache 2.0 License. See
LICENSEfor more information. - 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.0.9.tar.gz.
File metadata
- Download URL: finlearner-0.0.9.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f100dbae49a04c489ad61a4b99dd0d5349c9c9b3535117d16ab45a8ec386176a
|
|
| MD5 |
a5fc241e18df607929374dfa1846b311
|
|
| BLAKE2b-256 |
1e5890a1aa253af5f20da4bc1454de24d1db25b68cc1654eaa6aa5deabe38a7c
|
File details
Details for the file finlearner-0.0.9-py3-none-any.whl.
File metadata
- Download URL: finlearner-0.0.9-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba223c0602c85e38a4dd927edae12a49052e58cd552adf58a6d9b9cd2efc37d5
|
|
| MD5 |
4146b32c0f1400f2c59a9c735b6268fa
|
|
| BLAKE2b-256 |
6326a04679a1d3d3f4890e2f1e409473d42d36b8edd628f125560fa39e20cf2c
|