Skip to content

KrishSingaria/Financial-News-Driven-RL-trading

Repository files navigation

ISL Project: Paper Implementation.

Overview

This project is part of the ISL course. It aims to implement the paper "Financial News-Driven LLM Reinforcement Learning" by Krish (B23143)

Project Directory

Project/
├── data/
|   └── [Data generated by python files]
├── envs/
|   └── trading_env.py
├── models/
|   ├── finbert-tone/  #model downloaded automatically
│   └── [Saved files]
├── notebooks/
|   ├── train_and_test_portfolio.ipynb
│   └── train_and_test_single_stock.ipynb
├── scripts/
│   ├── fetch_news.py
│   ├── fetch_prices.py
│   ├── sentiment-analysis.py
|   ├── generic.py
|   ├── run_data_pipeline.bat
|   └── run_data_pipeline.sh
├── result/
|   └── [Result of over testing over multiple episodes]
├── README.md
├── .env
├── .gitignore
├── config
├── env_setup.bat
├── Financial News-Driven LLM Reinforcement Learning.pdf # paper implemented
└── requirements.txt

Installation

  1. Clone the repository:

  2. Navigate to the project directory:

  3. (Recommended) Create a virtual environment with access to system site packages:

    On Windows:

    python -m venv .venv --system-site-packages
    .\.venv\Scripts\activate

    On Linux/macOS:

    python3 -m venv .venv --system-site-packages
    source .venv/bin/activate
  4. Install dependencies:

    pip install -r requirements.txt

Usage

  1. Configure the project:

    • Check the config file and update any necessary settings according to your environment.
    • Create a .env file in the project root with the following structure:
      FINNHUB_API_KEY=your_finnhub_api_key_here
      PARENT_DIR="your_dir"
      

    You can obtain a free API key by signing up at Finnhub.

  2. Run the data pipeline manually or with a script:

    • Manual steps:
      1. Run fetch_prices.py to download price data:
        python scripts/fetch_prices.py
      2. Run fetch_news.py to collect news articles:
        python scripts/fetch_news.py
      3. Run sentiment-analysis.py to analyze sentiment:
        python scripts/sentiment-analysis.py
      4. If you get an error about the config file not being accessible, open a terminal and run:
        env_setup.bat
        Then try running the previous command again.
    • Or run the pipeline script:
      • On Windows:
        scripts\run_data_pipeline.bat
      • On Linux/macOS:
        bash scripts/run_data_pipeline.sh
  3. Open the notebooks and run the implementation:

    • Make sure your .venv environment is activated and selected as the kernel in your Jupyter notebook interface.
    • Open either notebooks/train_and_test_portfolio.ipynb or notebooks/train_and_test_single_stock.ipynb to run the implementation and experiments.

Refer to the individual script or notebook documentation for more details on usage.

Contributing

Contributions are welcome! Please open issues or submit pull requests.

License

MIT License

Copyright (c) 2025 Krish

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author

  • Krish B23143 IIT Mandi.

About

This was my DS-413 ISL project where I implemented a paper "Financial News-Driven LLM Reinforcement Learning for Portfolio Management" by Ananya Unnikrishnan

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors