[ICAIF 2024] Adaptive and Explainable Margin Trading via Large Language Models on Portfolio Management
Python
10
12 commits
updated Feb 25, 2025
We introduce the source code of our paper "Adaptive and Explainable Margin Trading via Large Language Models on Portfolio Management" (ICAIF 2024).

python inference_open_source_llm.py --model Llama-3-70B
python interaction_llm_rl.py
The Dow Jones Industrial Average (DJIA) is selected as the portfolio pool. We follow Margin Trader Paper for the training, validation, and testing periods. Note that the test period is extended to 2020/5 - 2024/2 in our paper, as it includes complex economic fluctuations marked by a significant rise (COVID-19 pandemic recovery) and subsequent variations (supply chain disruptions and inflation). The price data of companies in DJIA for RL is sourced from Yahoo Finance.
Additionally, two distinct external data sources are collected and tested to evaluate their impact on near-future (six-month) US market trend prediction:
Our adaptive and explainable framework for portfolio management represents a significant advancement in financial strategies, offering secure and efficient methods for dynamic long-short position adjustments using LLMs and RL. Its adaptability and transparent reasoning enhance decision-making, ensuring both profitability and stability in diverse market conditions.
During training, the best model along with predictions and labels will be saved to the result directory.
If you use this code for your research, please kindly cite our paper:
@inproceedings{gu2024adaptive,
title={Adaptive and Explainable Margin Trading via Large Language Models on Portfolio Management},
author={Gu, Jingyi and Ye, Junyi and Wang, Guiling and Yin, Wenpeng},
booktitle={Proceedings of the 5th ACM International Conference on AI in Finance},
pages={248--256},
year={2024}
}
[ICAIF 2024] Adaptive and Explainable Margin Trading via Large Language Models on Portfolio Management
Python
10
12 commits
updated Feb 25, 2025
We introduce the source code of our paper "Adaptive and Explainable Margin Trading via Large Language Models on Portfolio Management" (ICAIF 2024).

python inference_open_source_llm.py --model Llama-3-70B
python interaction_llm_rl.py
The Dow Jones Industrial Average (DJIA) is selected as the portfolio pool. We follow Margin Trader Paper for the training, validation, and testing periods. Note that the test period is extended to 2020/5 - 2024/2 in our paper, as it includes complex economic fluctuations marked by a significant rise (COVID-19 pandemic recovery) and subsequent variations (supply chain disruptions and inflation). The price data of companies in DJIA for RL is sourced from Yahoo Finance.
Additionally, two distinct external data sources are collected and tested to evaluate their impact on near-future (six-month) US market trend prediction:
Our adaptive and explainable framework for portfolio management represents a significant advancement in financial strategies, offering secure and efficient methods for dynamic long-short position adjustments using LLMs and RL. Its adaptability and transparent reasoning enhance decision-making, ensuring both profitability and stability in diverse market conditions.
During training, the best model along with predictions and labels will be saved to the result directory.
If you use this code for your research, please kindly cite our paper:
@inproceedings{gu2024adaptive,
title={Adaptive and Explainable Margin Trading via Large Language Models on Portfolio Management},
author={Gu, Jingyi and Ye, Junyi and Wang, Guiling and Yin, Wenpeng},
booktitle={Proceedings of the 5th ACM International Conference on AI in Finance},
pages={248--256},
year={2024}
}