🧪 We're running a cheminformatics notebook competition!

Enter by October 4
3 / 103
Portfolio Calculator

Portfolio Calculator

by marimo team

An interactive tool for portfolio analysis and investment calculations.

About this notebook

This notebook tracks the value of a stock portfolio over time. An editable table holds the investments: a date, a ticker, and an amount for each purchase. Edit the rows and the analysis below updates.

The notebook downloads 72 months of price history for each ticker with the yfinance library and caches it on disk as CSV files. A polars pipeline joins the purchases to the price history, computes the shares each purchase bought, and tracks total shares, portfolio value, and profit and loss over time.

Two charts summarize the result: an Altair area chart compares the portfolio value to the invested amount, and a line chart shows the return percentage over time. The full table of results is shown at the bottom.

Related notebooks