Skip to content

Latest commit

 

History

History
152 lines (107 loc) · 5.29 KB

File metadata and controls

152 lines (107 loc) · 5.29 KB

Equity Portfolio Rebalancer Workflow

Equity Portfolio Rebalancer

Automated portfolio rebalancing using n8n, AI agents, Google Sheets, and live market data.


📌 Overview

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.


🚀 Features

  • 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.


🧠 Architecture

Workflow Components

  • 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

Data Flow

  1. User submits rebalancing instruction
  2. AI agent reads portfolio from Google Sheets
  3. Marketstack provides latest prices
  4. AI agent updates sheet with new prices
  5. AI agent calculates new quantities
  6. Sheet is re-read to verify 60/40 target
  7. Workflow iterates until target is met
  8. Notifications are sent

📈 Rebalancing Logic

The AI agent follows a structured sequence:

  1. Read current portfolio allocations
  2. Fetch latest market prices
  3. Update the price column
  4. Calculate new total values
  5. Determine new quantities to achieve:
    • 60% Equity
    • 40% Fixed Income
  6. Write new quantities back to the sheet
  7. Re-read the sheet to confirm the target
  8. Iterate until the target is met
  9. Send final trading decisions

This ensures the workflow is accurate, repeatable, and verifiable.


🛠️ Tech Stack

  • 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

🎯 Why This Project Matters

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

🔮 Future Improvements

  • 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

⚠️ Disclaimer

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.