Back to Twelve Data in Google Sheets
SheetXAI logo
Twelve Data logo
Twelve Data · Google Sheets Guide

Pull a Year of Daily Closing Prices Into a Google Sheet for Rolling Return Calculations

2026-05-15
5 min read

The Scenario

You built the watchlist six months ago. Twenty stocks, one ticker per row in column A, a handful of manual notes in the adjacent columns. Every time you want to calculate rolling returns — 1-month, 3-month, 12-month — you go hunting for historical prices one ticker at a time, pasting close prices into a temporary tab and running your formulas from there. You did it twice last quarter. You're about to do it a third time.

The bad version:

  1. Open Twelve Data's API console, build an endpoint for the first ticker, copy the JSON output, paste it into a scratch tab, and manually align the dates into row 1.
  2. Repeat for each of the 19 remaining tickers, adjusting the row order every time a ticker has a slightly different date range because of a trading halt or a listing date.
  3. Go back and fix three tickers where the date column pasted in a different format, recalculate the return formulas, and discover that ticker 14 pulled a duplicate date.

The report is due Friday. This is Thursday afternoon, and you still have a model to update before the data is even ready to use.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent that lives inside your Google Sheet. It reads the sheet, sees the tickers in column A, and through its built-in Twelve Data integration it fetches a full year of daily closing prices and writes them into the grid — dates across row 1, ticker rows down the left. No console, no JSON parsing, no date formatting.

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 across columns B onward, newest date first.
  • Each ticker row filled with closing prices under the matching date column.
  • Trading-day gaps (holidays, halts) left as empty cells so your return formulas see them correctly.
  • Any ticker that returns an error (invalid symbol, no data for range) gets an error note in the leftmost cell of that row so you know immediately.

What If the Data Is Not Quite Ready

If your tickers include international stocks with 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 correctly. Write dates and prices in the same grid layout, but skip dates where a given exchange was closed rather than filling a zero.

If you want only the last 90 days instead of a full year

Fetch 90 days of daily closing prices from Twelve Data for each ticker in column A and write the dates across row 1 from column B, newest first. Only include trading days where all tickers in the list have a valid close — drop days where any ticker has no data.

If your watchlist has duplicate tickers that crept in

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

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

Check column A for duplicate tickers and remove them. Then fetch 365 days of daily closing prices from Twelve Data for each remaining ticker, write the price grid with dates across row 1 from column B. After the grid is populated, calculate the 12-month return for each ticker using the oldest and newest close price and write the result in the column immediately to the right of the last date.

One prompt does the cleanup, the data pull, and the return calculation together — no intermediate tab required.

Try It

Get the 7-day free trial of SheetXAI and open any Google Sheet with a stock watchlist in column A, then ask it to pull a full year of closing prices and calculate the rolling returns you need. You can also explore building a dividend and earnings calendar or see 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