FinMem LLM StockTrading

Report Abuse

Basic Information

This repository contains the Python implementation and resources for FINMEM, a research LLM trading agent introduced in the paper "FinMem: A Performance-Enhanced LLM Trading Agent with Layered Memory and Character Design." It provides source code, configuration files, data folders, figures, and scripts to reproduce the agent and simulation workflows described in the paper. The project is structured around an entrypoint run.py and supports building and running in a Docker container. The agent integrates an LLM backbone (HuggingFace models served via TGI or OpenAI models such as GPT-4) together with a fixed embedding model (text-embedding-ada-002). The repo implements training and testing modes, checkpoint save and resume functionality, and configuration via config.toml and environment variables (OPENAI_API_KEY and optional HF_TOKEN). The implementation is intended to recreate the experiments and trading simulations reported in the paper.

Links

App Details

Features
The implementation centers on a three-module agent architecture: Profiling to define agent character and attributes, a layered Memory module that mimics hierarchical trader cognition and supports adjustable cognitive span, and a Decision-making module that converts memory and inputs into trading actions. The codebase includes scripts for simulation, checkpointed resumes, and configurable training or testing runs. It supports multiple LLM backbones through TGI endpoints or OpenAI API settings and relies on text-embedding-ada-002 for embeddings. The repository includes Docker support via a provided devcontainer Dockerfile, configuration templates, example data paths, and visual artifacts illustrating memory flow, workflow, and character design. The project emphasizes interpretability of memory structures and real-time tuning of memory spans to influence trading behavior.
Use Cases
For researchers, practitioners, and developers interested in LLM-driven financial agents, this repo provides a reproducible implementation of an agent architecture that combines LLM reasoning with a cognitive-inspired layered memory. Users can reproduce experiments from the associated paper, train the agent to populate memory, test trained agents, and resume interrupted runs from checkpoints. The configurable integration with HuggingFace TGI or OpenAI models and the use of a consistent embedding model lower engineering effort for swapping LLM backbones. Docker support simplifies environment setup. The layered memory and profiling design enable tuning of the agent"s perceptual span and character, supporting experiments on interpretability, performance optimization, and simulated trading strategies on real financial datasets.

Please fill the required fields*