Back to Twelve Data in Excel
SheetXAI logo
Twelve Data logo
Twelve Data · Excel Guide

Pull a Year of Daily Closing Prices Into an Excel workbook for Rolling Return Calculations

2026-05-15
5 min read

The Scenario

You've been managing the same Excel watchlist for eight months. Twenty stock symbols in column A, a few notes columns, and a "rolling returns" worksheet that's always behind by at least two weeks because populating it requires a manual price pull you keep deferring. Your fund administrator asked last Friday why the three-month return figure for two positions looks like it predates the last rebalancing. You told them you'd send an updated version by Monday.

It's Sunday evening.

The bad version:

  1. Construct a Twelve Data API call for the first ticker, parse the JSON time series response, and paste the closing prices into the correct row of the returns worksheet, aligning dates carefully across columns.
  2. Repeat for the other 19 tickers, spending extra time on the three that have slightly different date ranges because one was halted for a day and another was added to the watchlist mid-year.
  3. Fix the date-alignment issues introduced by the halted trading day and discover that the return formulas in the adjacent columns have broken references from the last time you restructured the worksheet.

The price grid is never ready when you need it, because building it costs more than the insight it enables.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent that lives inside your Excel workbook. It reads the tickers in column A and, through its built-in Twelve Data integration, fetches a full year of daily closing prices and writes them into a date-stamped grid — dates across row 1, prices down each ticker row.

Fetch 365 days of daily closing prices from Twelve Data for each ticker in column A. Write dates across row 1 starting at column B, newest on the left, and fill closing prices under each date for the corresponding ticker row.

What You Get

  • Row 1 populated with date headers from column B onward, newest date first.
  • Each ticker row filled with closing prices aligned to the matching date column.
  • Trading-day gaps left as blank cells so your return formulas handle them correctly.
  • Any ticker returning an error (invalid symbol, insufficient history) noted in the ticker's leftmost cell rather than silently leaving the row empty.

What If the Data Is Not Quite Ready

If your tickers include international stocks across different exchange calendars

Fetch 365 days of daily closing prices from Twelve Data for each ticker in column A. Use the exchange listed in column B to scope each call. Write dates and prices in the same grid but skip dates where a given exchange was closed rather than inserting zeros.

If you want only the last 90 days of data for a shorter lookback

Fetch 90 days of daily closing prices from Twelve Data for each ticker in column A. Write dates across row 1 from column B, newest first. Only include trading days where all tickers have a valid close — drop days with any missing data to keep the grid clean.

If your watchlist has duplicate symbols that crept in over time

Before fetching prices, scan column A for duplicate ticker symbols and flag any in column B with DUPLICATE. Then fetch 365 days of closes from Twelve Data for each unique ticker and write the price grid starting at column C, with dates in row 1.

Kill-chain: deduplicate, fetch prices, and compute 12-month returns in one prompt

Check column A for duplicate tickers and remove them in place. Fetch 365 days of daily closing prices from Twelve Data for each remaining ticker and write the date-stamped grid starting at column B. After the grid is complete, calculate the 12-month return for each ticker using the oldest and newest close price and write the result in the first column to the right of the last date. Sort the workbook rows by 12-month return descending.

Try It

Get the 7-day free trial of SheetXAI and open your Excel watchlist workbook with tickers in column A, then ask it to populate the full year of closing prices before the Monday deadline. Also see building a dividend and earnings calendar and the full Twelve Data overview.

Stop memorizing formulas.
Tell your spreadsheet what to do.

Join 4,000+ professionals saving hours every week with SheetXAI.

Learn more