Hey everyone!
So, I’ve been trying to figure out how to use yfinance for mutual fund percent change tracking, and honestly, it’s been a bit of a journey lol. I’m not super techy, but I managed to get it working after some trial and error.
Basically, you can pull mutual fund data using yfinance (just like stocks) and calculate the percent change over time. The trick is to use the `.history()` method to get historical prices and then do some simple math to find the % change.
For example:
```python
import yfinance as yf
mf = yf.Ticker("VFIAX")
data = mf.history(period="1y")
percent_change = (data['Close'][-1] - data['Close'][0]) / data['Close'][0] * 100
```
It’s not perfect, but it gets the job done. Anyone else using yfinance for mutual fund percent change tracking? Would love to hear your tips or if there’s a better way!
Cheers!
So, I’ve been trying to figure out how to use yfinance for mutual fund percent change tracking, and honestly, it’s been a bit of a journey lol. I’m not super techy, but I managed to get it working after some trial and error.
Basically, you can pull mutual fund data using yfinance (just like stocks) and calculate the percent change over time. The trick is to use the `.history()` method to get historical prices and then do some simple math to find the % change.
For example:
```python
import yfinance as yf
mf = yf.Ticker("VFIAX")
data = mf.history(period="1y")
percent_change = (data['Close'][-1] - data['Close'][0]) / data['Close'][0] * 100
```
It’s not perfect, but it gets the job done. Anyone else using yfinance for mutual fund percent change tracking? Would love to hear your tips or if there’s a better way!
Cheers!
