Skip to main content

LSTM-ARIMA with attention mechanisms and multiplicative decomposition for sophisticated stock forecasting.

Project description

Neural Stock Prophet

PyPI PyPI - Downloads GitHub license badge

neuralstockprophet integrates a variety of advanced techniques and algorithms to enhance the robustness, stability, and interoperability of stock price prediction methodologies. By leveraging machine learning, this package aims to accurately forecast the future values of company stocks and other financial assets traded on exchanges. Unlike existing approaches that predominantly focus on model configuration and tuning—often neglecting the inherent variability within the data—NeuralStockProphet addresses these challenges. Furthermore, it effectively mitigates issues related to overfitting and performance constraints that are commonly encountered in machine learning models.

Combined techniques:

  • LSTM model with attention mechanisms
  • Multiplicative decomposition
  • ARIMA model

Installation

  • Stable version
pip install neuralstockprophet

Getting Started

import neuralstockprophet as nsp
import pandas as pd

prophet = nsp.NeuralStockProphet(
        stock_names=["AAPL", "GOOGL"],
        scaler_func=lambda: MinMaxScaler(feature_range=(0, 1)),
        train_start_date="2010-01-01",
        train_end_date="2019-12-31",
        test_start_date="2020-01-01",
        test_end_date="2020-12-31",
    )

forecasts, real_vals = prophet.forecast()

# Use the forecasted results to design the portfolio and get the assets allocation
portfolio = nsp.RiskParityPortfolio(prices=forecasts)

# Evaluate the performance of the portfolio with the forecasted results and the true stock prices
forecast_performance = portfolio.evaluate(forecasts)
real_performance = portfolio.evaluate(real_vals)

analyze_result_df = pd.concat([forecast_performance, real_performance], axis=0)
analyze_result_df.index = ["Forecast portfolio", "True portfolio"]

Get the historical data simply by inputting the stock codes.

License

This project is licensed under the MIT License - see the LICENSE file for details.

TODO

There are further improvements that can be made. Please have a look at the TODO.

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

neuralstockprophet-0.0.3.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

neuralstockprophet-0.0.3-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file neuralstockprophet-0.0.3.tar.gz.

File metadata

  • Download URL: neuralstockprophet-0.0.3.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for neuralstockprophet-0.0.3.tar.gz
Algorithm Hash digest
SHA256 cc179e07131c9d46f0861e2cdf33c1045f832f19acf11a6edd72f69a2250ddc0
MD5 3bc8b4817b6d8d37a26377cba76905e6
BLAKE2b-256 005d2ef1c9d25cddd68149ce54fe5a410e74614554c07bf411ef98d33a068ad8

See more details on using hashes here.

File details

Details for the file neuralstockprophet-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for neuralstockprophet-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0f16d5ea2d7b82c7d17d9849239abe62a60d80190245781393a2ba7c01b05428
MD5 31f45763bc72ecedd49911f86dfcca8f
BLAKE2b-256 40c09a693efa0251bf5fb3ad3e8b9bcfc2c230ef62a90381559f5327804b587b

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