Stock AI Research Assistant
Stock ARA(AI Research Assistant) is an innovative stock screening and portfolio optimization system that leverages a Large Language Model(LLM) and Retrieval-Augmented Generation(RAG).
This is an official implementation of the paper: A Novel Stock Screening Approach using Large Language Models and Correlation-Aware Retrieval.
- Advanced stock screening using LLM and RAG
- User query augmentation for improved search accuracy
- Correlation-aware retrieval combining business report similarity and stock return correlation
- Portfolio optimization based on the Mean-Variance model and Black-Litterman approach
- Cost-efficient use of GPT-3.5 and GPT-4 APIs
- Python
- OpenAI GPT API (GPT-3.5 and GPT-4o)
- PostgreSQL with pgvector and Timescale
- Redis
- Docker
- KRX listed stock information from KRX Market Data System
- Business reports from DART
- Stock price data from Yahoo Finance
-
Clone the repository
git clone https://github.com/Astro36/stock-ara.git
-
Set up the required environment variables: .env
APP_ID
: app name, used in database (ex.demo
)POSTGRES_PASSWORD
: user password for PostgreSQLOPENAI_API_KEY
: see OpenAI API KeyOPENDART_API_KEY
: see Open DART API Key (optional)TELEGRAM_BOT_TOKEN
: see Telegram BotFather
-
Load stock data and business reports into the database
COPY companies FROM '/tmp/db_data/companies.csv' DELIMITER ',' CSV HEADER; COPY company_filings FROM '/tmp/db_data/company_filings.csv' DELIMITER ',' CSV HEADER; COPY assets FROM '/tmp/db_data/assets.csv' DELIMITER ',' CSV HEADER; COPY asset_stocks FROM '/tmp/db_data/asset_stocks.csv' DELIMITER ',' CSV HEADER; COPY asset_prices FROM '/tmp/db_data/db_data/asset_prices.csv' DELIMITER ',' CSV HEADER; CALL refresh_continuous_aggregate('asset_weekly_close_prices', '2020-01-01', '2024-12-31'); REFRESH MATERIALIZED VIEW stock_market_caps;
-
Run docker compose
docker compose up