A tutorial demonstrating how to combine traditional momentum investing with LLM-generated sentiment scores using R. The strategy screens the top 20 S&P 500 stocks by YTD returns, queries Bing News for recent headlines, sends them to a Microsoft Azure AI Foundry-hosted LLM, and uses the resulting sentiment scores (0–1) to re-weight and narrow the portfolio to 10 high-conviction stocks. Key parameters include a 5-day lookback window, 5-day forecast horizon, and weekly rebalancing. Full R code is provided using tidyquant, httr, and gt packages. The resulting portfolio shows heavy energy sector concentration, attributed to geopolitical tensions boosting oil and gas sentiment.

7m read timeFrom r-bloggers.com
Post cover image
Table of contents
Related

Sort: