This project is part of the ISL course. It aims to implement the paper "Financial News-Driven LLM Reinforcement Learning" by Krish (B23143)
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
-
Clone the repository:
-
Navigate to the project directory:
-
(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 -
Install dependencies:
pip install -r requirements.txt
-
Configure the project:
- Check the
configfile and update any necessary settings according to your environment. - Create a
.envfile 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.
- Check the
-
Run the data pipeline manually or with a script:
- Manual steps:
- Run
fetch_prices.pyto download price data:python scripts/fetch_prices.py
- Run
fetch_news.pyto collect news articles:python scripts/fetch_news.py
- Run
sentiment-analysis.pyto analyze sentiment:python scripts/sentiment-analysis.py
- If you get an error about the config file not being accessible, open a terminal and run:
Then try running the previous command again.
env_setup.bat
- Run
- Or run the pipeline script:
- On Windows:
scripts\run_data_pipeline.bat - On Linux/macOS:
bash scripts/run_data_pipeline.sh
- On Windows:
- Manual steps:
-
Open the notebooks and run the implementation:
- Make sure your
.venvenvironment is activated and selected as the kernel in your Jupyter notebook interface. - Open either
notebooks/train_and_test_portfolio.ipynbornotebooks/train_and_test_single_stock.ipynbto run the implementation and experiments.
- Make sure your
Refer to the individual script or notebook documentation for more details on usage.
Contributions are welcome! Please open issues or submit pull requests.
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.
- Krish B23143 IIT Mandi.