Back to EODHD APIs in Google Sheets
SheetXAI logo
EODHD APIs logo
EODHD APIs · Google Sheets Guide

Pull Live Quotes Into a Google Sheet and Calculate Unrealized P&L

2026-05-14
5 min read

The Scenario

Your portfolio tracking sheet has 25 rows — ticker, shares held, average cost basis. The numbers have sat there for three weeks. Today someone from the investment committee sent a message asking for an updated P&L summary by end of day. Current prices aren't in the sheet. Calculating unrealized gains without them means either opening each position in a browser tab and typing the price by hand, or pulling a delayed quote feed you don't trust.

The bad version:

  • Open a financial data site, look up the current price for position one, type it into column D, move to position two.
  • Do that 25 times, aware that by the time you reach position 25, position 1's price is already 8 minutes stale.
  • Build a formula column manually for unrealized gain/loss — (D2-B2)*C2 — then copy it down and discover that two rows had their cost basis entered as a text string, not a number, so the formula silently returns zero instead of an error.

You submit the summary and spend the next hour wondering whether the numbers are right.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent that lives inside your Google Sheet. It reads the portfolio table, fetches live quotes from EODHD for every ticker simultaneously, writes the prices into column D, and calculates unrealized P&L in column E — in one pass, without you touching a formula.

Fetch the current market price from EODHD for each ticker in column A of my 'Portfolio' sheet and write it into column D, then calculate unrealized P&L in column E as (column D - column B) × column C.

What You Get

  • Column D populated with the latest EODHD quote for each ticker
  • Column E populated with calculated unrealized P&L
  • Any position where the price returned null (halted stock, delisted ticker) flagged in column F with a note
  • Numbers formatted consistently — no mixed text/number types

What If the Data Is Not Quite Ready

The cost basis column has mixed currency entries

Some positions were entered in USD, others in GBP from a UK account. The P&L column will be meaningless without normalization.

For each ticker in column A of my 'Portfolio' sheet, fetch the current price from EODHD in the ticker's native currency. Where column B (cost basis) is flagged in column C as GBP, convert the current price to GBP using today's EODHD FX rate before calculating P&L in column E.

The portfolio sheet has multiple account tabs

Positions are split across three tabs — 'Retirement', 'Taxable', and 'Crypto'. You need a consolidated current-price update across all of them.

Fetch live quotes from EODHD for every ticker in column A of my 'Retirement', 'Taxable', and 'Crypto' sheets, write the current price into column D of each tab, and then build a 'Summary' tab with total unrealized P&L by account and overall.

Some tickers are ETFs with delayed pricing

A few rows hold ETF tickers that EODHD returns with a 15-minute delay. You want those flagged so the committee knows which numbers are real-time and which aren't.

Pull current prices from EODHD for all tickers in column A of my 'Portfolio' sheet, write them to column D, and mark column F as 'Real-time' or '15-min delay' based on the EODHD data type returned.

Full committee prep: price update + percentage moves + sector breakdown

Fetch live quotes from EODHD for every position in my 'Portfolio' sheet, calculate unrealized P&L in column E, add a column F for today's percentage price change, look up each ticker's sector from EODHD fundamentals, write the sector into column G, and build a 'Sector Summary' tab showing total P&L by sector.

One prompt handles the data fetch, the derived calculations, the enrichment lookup, and the summary tab.

Try It

Get the 7-day free trial of SheetXAI and open your portfolio tracking sheet, then ask it to pull live prices from EODHD and compute the P&L column. You can also see how to pull historical OHLCV data for backtesting or browse all EODHD use cases at the integration overview.

Stop memorizing formulas.
Tell your spreadsheet what to do.

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

Learn more