Skip to main content

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

CI/CD PyPI version License Python 3.8+

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, finlearner 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 finlearner directly from PyPI:

pip install finlearner
Or build from source:Bashgit clone [https://github.com/ankitdutta428/finlearner.git](https://github.com/ankitdutta428/finlearner.git)
cd finlearner
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 finlearner 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 finlearner 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 finlearner 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
finlearner.models Contains Deep Learning classes (TimeSeriesPredictor) using TensorFlow/Keras.
finlearner.portfolio Tools for asset allocation and portfolio optimization (PortfolioOptimizer).
finlearner.technical Library of technical indicators (RSI, MACD, Bollinger Bands).
finlearner.data Data ingestion layer wrapping yfinance.
finlearner.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 LICENSE for 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

finlearner-0.0.91.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

finlearner-0.0.91-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file finlearner-0.0.91.tar.gz.

File metadata

  • Download URL: finlearner-0.0.91.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

Hashes for finlearner-0.0.91.tar.gz
Algorithm Hash digest
SHA256 e06a56c5abfb48222c2bfe151adbf990f130b0603e4860a334dffbd2a1975bd9
MD5 684758c2fff0f3ae588b5422979a621f
BLAKE2b-256 1206d131062b6a27afd116c9570d89df089edced0d79a4f302f6e1feffbb897e

See more details on using hashes here.

File details

Details for the file finlearner-0.0.91-py3-none-any.whl.

File metadata

  • Download URL: finlearner-0.0.91-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

Hashes for finlearner-0.0.91-py3-none-any.whl
Algorithm Hash digest
SHA256 209b93c092e2f2271984e598cab20886b09e68842e0678057bfcf088865def85
MD5 b7c23aca6ee54658b1da7e66628b0aa8
BLAKE2b-256 d5a1ef72ff5acdb1f5f3cf60c81b63093a0614cb93141e18b44a4ca70ac1238e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page