I used to update my portfolio the painful way. Open Yahoo Finance. Search BBCA.JK. Copy the price. Paste it into Excel. Repeat for BMRI, ASII, TLKM, ICBP, ANTM, BBRI, Gold, Bitcoin, and my money market fund. 10 assets. 10 tabs. Every single day. One typo and my whole ROI was wrong. One lazy day and my portfolio was already
outdated. So I built something better: a self-updating portfolio tracker that pulls live prices with one command.
Analisa Portfolio — Auto-Update dengan yfinance
Update 10 aset portfolio dalam 1 perintah. Tanpa copy-paste manual lagi.
Artikel lengkap (English) ada di Dev.to & Codecademy Forum. README ini Bahasa Indonesia, biar yang buka repo ikut pusing dikit. 😅
Kenapa Repo Ini Ada?
Dulu, cara gue update portfolio tuh nyiksa:
Buka Yahoo Finance → Cari BBCA.JK → Copy harga → Paste ke Excel → Ulangi buat BMRI, ASII, TLKM, ICBP, ANTM, BBRI, Emas, BTC, RDPU.
10 aset. 10 tab. Tiap hari.
Sekali typo, ROI langsung salah. Sekali males, portfolio langsung basi.
Akhirnya gue bikin sistem ini: Excel buat analisa, Python buat narik harga.
python update.py
Udah. Beres.
Isi Repo
analisis portfolio/
├── portfolio.xlsx # Template Excel: Dashboard, Holdings, Alokasi, Performa, Harga_Historis
├── update.py # Script Python: yfinance -> Excel (JANGAN DIUBAH, SUDAH VALID)
├── README.md # File ini (Bahasa Indonesia)
└── portfolio_UPDATE.xlsx # Hasil setelah run (auto-generate)
That's it. 9 tickers updated. Currency converted. History filled. Backup created. Here is how I did it, what broke along the way, and the exact validation output that proved it works.
The Problem
My portfolio is mixed, and that's what made it painful:
Indonesian stocks: BBCA, BMRI, ASII, TLKM, ICBP, ANTM, BBRI — priced in IDR
Gold: Antam gold — priced in USD per troy ounce on Yahoo
No single app handled all of them well. Excel could handle the math, but not the live prices. Python could fetch live prices, but I didn't want to live in a Jupyter notebook.
I wanted the best of both: Excel for analysis, Python for fetching.
The Architecture
Two files. Same folder. Nothing else.
- portfolio.xlsx — The Brain The Excel file is not just a table. It does the analysis: python update.py Dashboard: Total value, total gain/loss, ROI, CAGR, Volatility, Sharpe Ratio, Top 5 holdings Holdings: The single source of truth. Each row has a Ticker Yahoo column Alokasi: Actual vs target allocation + rebalance calculator Performa: Monthly return tracking + risk metrics Harga_Historis: Daily history per ticker, used for volatility and drawdown Config: USD/IDR rate, risk-free rate, gold premium The key design decision: Column C in Holdings is Ticker Yahoo .
- update.py — The Muscle The Python script does 4 things:
- Fetches USD/IDR from USDIDR=X
- Fetches the latest price for each ticker
- Converts everything to IDR
- Writes it back to Excel + fills history + creates a backup The core conversion logic is where most people get stuck:
Gold is the tricky one. Yahoo gives you $3,863.70 per troy ounce . My portfolio
is in grams, in IDR, with Antam's premium. So: price * USDIDR / 31.1035 * premium .
And it has safety features I learned to add:
Every real run also creates an automatic backup:
portfolio_BACKUP_20261116_1633.xlsx . I never lose my old data.
What Broke (And What I Learned)
This was not smooth. Three bugs ate my afternoon:
- File Not Found — But The File Was There I ran:
Error: No such file or directory .
The real file was Update-Portofolio-Yfinance-FIX.py — with dashes - , not
underscores _ . My browser had converted _ to - on download. Windows treats
them as different characters.
Fix: I renamed everything to simple names with no confusion: update.py and
portfolio.xlsx .
Lesson: If your filename has both _ and - , you will typo it. Keep it simple.
- VS Code's Run Button Added Double Quotes
When I clicked Run in VS Code, it executed:
Notice the '"...\"' — double quotes inside double quotes. Python threw Errno
22 Invalid argument .
Fix: Don't use the Run button. Type it manually in the terminal. Or use Tab
completion: type python Up + Tab and let PowerShell complete the name.
- Virtual Environment Gotcha My prompt showed (.venv-1) , meaning I was in a venv. I had installed yfinance globally, but the venv couldn't see it.
Fix:
...while the venv is active.
How To Use It
Open portfolio_UPDATE.xlsx . Dashboard, Holdings, and History are all updated.
To add a new stock, just add a row in Holdings:
Kode: GOTO
Ticker Yahoo: GOTO.JK
Run again. Done.
What's Next
This version is manual — I run it when I want. The next version I'm thinking about:
Schedule it with Task Scheduler / cron every Monday 08:00
Send a Telegram summary: "Portfolio today: +1.2%, Top mover ASII +3.64%"
Add dividend tracking from yfinance
But even as-is, it already saved me hours. No more copy-paste. No more stale
prices.
Final Thought
The most valuable part is not the Excel formulas. It's the validation log.
- Install once pip install yfinance openpyxl pandas
- Put both files in the same folder portfolio.xlsx and update.py
- Run python update.py
Anyone can claim their portfolio is up to date. I can prove it in 10 seconds with one
command and one log that shows every ticker, every price, every conversion, and
every change.
That's why I built it. And that's why I'm sharing it.
Disclaimer: This is not financial advice. This is a personal automation tool for tracking,
not for recommending buys/sells. Always do your own research.
Built on Windows 10, Python 3.15, yfinance, openpyxl, and a lot of patience with
dashes vs underscores.









Top comments (0)