Automated portfolio rebalancing using n8n, AI agents, Google Sheets, and live market data.
The Equity Portfolio Rebalancer is an automated workflow built in n8n that reads a user’s portfolio, fetches the latest market prices, calculates new allocations, and rebalances the portfolio to a target ratio (default: 60% Equity / 40% Fixed Income).
The system uses an AI agent to make decisions, verify results, and send final trading recommendations via email and push notification.
This project demonstrates how AI + automation can streamline financial workflows with accuracy, repeatability, and minimal manual intervention.
-
AI-driven rebalancing logic
Reads portfolio data, calculates new quantities, and determines rebalancing actions. -
Live market data integration
Fetches end-of-day prices using the Marketstack API. -
Automated spreadsheet updates
Updates Google Sheets with new prices and rebalanced quantities. -
Iterative verification loop
Re-checks the sheet until the 60/40 target allocation is achieved. -
Automated notifications
Sends trading decisions via Gmail and push notifications via Pushover. -
No-code orchestration
Entire workflow built using n8n’s visual automation engine.
- Form Trigger – User submits rebalancing instructions
- AI Agent – Reads instructions, performs calculations, and controls tool usage
- Google Sheets Tool – Reads and updates portfolio data
- Marketstack Tool – Fetches latest market prices
- Gmail Tool – Sends trading decisions
- Pushover Tool – Sends push notifications
- IF Node – Confirms whether rebalancing succeeded
- User submits rebalancing instruction
- AI agent reads portfolio from Google Sheets
- Marketstack provides latest prices
- AI agent updates sheet with new prices
- AI agent calculates new quantities
- Sheet is re-read to verify 60/40 target
- Workflow iterates until target is met
- Notifications are sent
The AI agent follows a structured sequence:
- Read current portfolio allocations
- Fetch latest market prices
- Update the price column
- Calculate new total values
- Determine new quantities to achieve:
- 60% Equity
- 40% Fixed Income
- Write new quantities back to the sheet
- Re-read the sheet to confirm the target
- Iterate until the target is met
- Send final trading decisions
This ensures the workflow is accurate, repeatable, and verifiable.
- n8n – Workflow automation
- LangChain AI Agent – Decision logic
- OpenRouter LLM – Reasoning model
- Google Sheets API – Portfolio data
- Marketstack API – Market prices
- Gmail API – Email notifications
- Pushover – Push notifications
This project demonstrates:
- How AI agents can automate financial workflows
- How no-code tools can orchestrate complex multi-step logic
- How market data and spreadsheets can be integrated into automated decision systems
- How iterative verification ensures accuracy and reliability
It is a strong example of AI-enabled workflow automation, relevant to roles in:
- AI enablement
- Automation engineering
- Fintech prototyping
- Data operations
- No-code/low-code solution development
- Support for additional asset classes (commodities, ETFs, alternatives)
- Risk‑based or volatility‑adjusted rebalancing models
- Multi‑portfolio support with user‑specific configurations
- Conversation memory for more natural AI agent interactions
- Source citations for market data and calculation transparency
- Authentication and user access management
- Analytics dashboard for portfolio performance and rebalance history
- Integration with additional market data providers and brokerage APIs
This project was developed for educational and portfolio demonstration purposes to showcase AI workflow automation, financial data processing, and automated decision support using n8n.
It is not intended to provide financial advice, investment recommendations, or trading guidance.
The AI agent performs calculations based on spreadsheet data and market APIs, but users should always consult qualified financial professionals before making investment decisions.
AI Automation • Agentic AI • n8n • Python • Google Gemini • Market Data Integrations • Workflow Engineering
If you found this project helpful or interesting, feel free to ⭐ the repository.
