Portfolio Visualizer and Alpha Vantage for free portfolio analysis in Python

Portfolio Visualizer and Alpha Vantage for free portfolio analysis in Python
Portfolio Visualizer and Alpha Vantage: Free Market Data and Portfolio Analysis in Python
Portfolio Visualizer and Alpha Vantage handle two different jobs that fit together well. Portfolio Visualizer is a free website where you can test how a mix of assets would have performed in the past without writing code. Alpha Vantage is an API (a way for your Python code to request data from an external service) that delivers historical prices and, for some endpoints, live or near-live updates directly into your scripts.
Together, they cover a useful pair of tasks. Alpha Vantage gives you raw price data in Python, and Portfolio Visualizer helps you test whether a portfolio idea looked reasonable on past data before you use real money. If you're new to working with market data in Python, the course Getting Started with Python for Quant Finance walks through the basics from scratch.
You can also read about pulling financial data with Python APIs to see how Alpha Vantage fits into a broader data workflow.
What Portfolio Visualizer Can and Can't Do
Portfolio Visualizer works best for testing portfolio allocations and asset mixes on historical data. You can check how a 60/40 stock-and-bond portfolio would have performed over the past 20 years, or see whether two assets usually rise and fall at the same time (which matters because holding assets that always move together does not reduce your risk much). It is less useful if you want to test custom buy and sell rules.
The free version includes the features most beginners will use first. You can test how a portfolio allocation performed in the past. You can also run a Monte Carlo simulation, which creates many possible future paths from past return patterns so you can see a range of what might happen. Another useful report shows how much of your portfolio's movement came from big drivers such as the overall stock market or changes in interest rates.
Portfolio Visualizer also has limits for Python users. It's a point-and-click tool, so you can't automate it or feed it data you've calculated yourself. Once you want to go beyond the preset options, you need code.
Pulling Data with Alpha Vantage in Python
Once you want to compare many assets, save your data, or repeat the same analysis often, it helps to pull the data in Python. Alpha Vantage gives you free access to stock prices, foreign exchange rates, and cryptocurrency prices going back as far as 20 years.
The free plan has strict request limits, and those limits can change. Check the Alpha Vantage documentation before you depend on it, because slow request caps matter if you need data for many symbols.
To get started, register for a free API key on the Alpha Vantage website, then install the requests library if you don't have it. Here's how to pull daily closing prices for a stock:
import requests
import pandas as pd
API_KEY = "your_api_key_here"
symbol = "AAPL"
url = (
f"https://www.alphavantage.co/query"
f"?function=TIME_SERIES_DAILY_ADJUSTED"
f"&symbol={symbol}"
f"&outputsize=full"
f"&apikey={API_KEY}"
)
response = requests.get(url, timeout=10)
data = response.json()
if "Time Series (Daily)" not in data:
raise ValueError(data)
prices = pd.DataFrame(data["Time Series (Daily)"]).T
prices.index = pd.to_datetime(prices.index)
prices = prices["5. adjusted close"].astype(float).sort_index()
print(prices.tail())
This code returns adjusted closing prices, which account for stock splits and dividends so past prices remain comparable. That matters because a stock split can make an old price look like a crash if you use raw closing prices. The error check on line 14 catches cases where Alpha Vantage returns a rate-limit warning or error message instead of price data.
From there, you can calculate percentage gains and losses. You can also measure how sharply the price moves up and down, or choose portfolio weights with your own code.
Connecting Alpha Vantage and Portfolio Visualizer in Practice
Here's a simple way to use the two tools together. You pull price data for the assets you're interested in with Alpha Vantage. You calculate each asset's past percentage gain or loss and check whether the assets usually rise and fall at the same time. Then you take those assets and their weights into Portfolio Visualizer to see the worst 12-month loss the portfolio experienced, or how it compared with a simple index fund.
For example, you might pull monthly prices for SPY, TLT, and GLD with Alpha Vantage, calculate their past percentage gains and how often they rose or fell together, then enter a 60/30/10 portfolio in Portfolio Visualizer to see its past losses and recovery periods.
This is more useful than relying on either tool alone. Portfolio Visualizer shows you the big picture quickly. Python lets you customize the analysis and test ideas the web tool doesn't support. You can read more about Portfolio Visualizer correlation analysis in Python to see how this combination works in practice.
When to Move Beyond These Free Tools
Both tools have real limits. Alpha Vantage's free tier restricts how many requests you can make per day, which becomes a problem if you're testing ideas across dozens of assets. Portfolio Visualizer doesn't let you set fully custom rules for when to buy back to target weights, and it can't easily test strategies based on indicators you calculate in Python.
When those limits get in the way, the next step is to build your own Python setup for testing a strategy on past market data. That means your code fetches the data automatically. Then you calculate results such as total return or worst loss, and check whether the strategy still works on a later time period that you did not use to design it.
If you want to see how to compare investment strategies in Python or improve a portfolio's return relative to its risk, those are natural next steps once you've tested your basic ideas in Portfolio Visualizer.
A good first project is simple. Pull adjusted closing prices for two or three ETFs in Python, then compare the same portfolio in Portfolio Visualizer and see whether your numbers match.