# Analyze commodity portfolio diversification with Sheets: n8n workflow

> Started by an event in a connected app, and works across Gmail and Google Sheets. It hands the judgement calls to Gemini.

Source: https://millionrounds.com/workflow/analyze-commodity-portfolio-diversification-with-sheets (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Data collection](https://millionrounds.com/workflows?category=Data+collection#library)

# Analyze commodity portfolio diversification with Sheets

Started by an event in a connected app, and works across Gmail and Google Sheets. It hands the judgement calls to Gemini. 24 steps, 1 branch: large, and worth reading before you trust it with anything live.

Large Calls a model: Gemini

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fanalyze-commodity-portfolio-diversification-with-sheets)

**24 steps** Large: read it before trusting it with anything live

**1** Branch: places the flow splits

**0** Loops or waits

**2** Services it connects to

## The flow

Starts it 1 Model 1 Logic 16 Service 6

The steps in the order they run, from what starts it.

- 1 **Start Workflow** Manual trigger *Starts it*
- 2 **Initialize Configuration & API Keys** Set *Logic*
- 3 **Load Portfolio Data from Sheets** Google Sheets *Service*
- 4 **Get Gold Price (INR)** Http Request *Service*
- 5 **Get Silver Price (INR)** Http Request *Service*
- 6 **Get Crude Oil Price (USD)** Http Request *Service*
- 7 **Get Gold Trend Time Series** Http Request *Service*
- 8 **Merge Portfolio + Market Data** Merge *Logic*
- 9 **Extract Gold Price Value** Set *Logic*
- 10 **Extract Silver Price Value** Set *Logic*
- 11 **Convert Oil Price USD to INR** Set *Logic*
- 12 **Extract Trend Values (Latest vs Previous)** Set *Logic*
- 13 **calculate Portfolio Allocation & HHI Risk Score** Code *Logic*
- 14 **Merge Commodity & Trend Data** Merge *Logic*
- 15 **Generate AI Portfolio Analysis (Gemini)** Google Gemini *Model*
- 16 **Aggregate Prices & Trend Data** Code *Logic*
- 17 **Parse AI Response into Structured Fields** Code *Logic*
- 18 **Tag Commodities (Category + Symbol)** Set *Logic*
- 19 **Generate HTML Report Template** Set *Logic*
- 20 **Evaluate Market Trend Direction** If *Logic*
- 21 **Send Portfolio Report via Email** Gmail *Service*
- 22 **Set Trend UP** Set *Logic*
- 23 **Set Trend DOWN** Set *Logic*
- 24 **Finalize Trend Output** Merge *Logic*

## How it's built

- **Starts on:** An event in a connected app
- **Steps:** 24, with 1 branch
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Gmail, Google Sheets
- **Model:** Gemini

## Questions

What does it need to run?

An n8n account, plus your own Gmail and Google Sheets accounts, and a key for Gemini. You connect your own accounts after importing it; none are included.

What starts it?

It starts on an event in a connected app.

Does it use AI?

Yes. It calls Gemini. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 24 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 24 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fanalyze-commodity-portfolio-diversification-with-sheets)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Gmail](https://millionrounds.com/workflows?service=Gmail#library)[Google Sheets](https://millionrounds.com/workflows?service=Google+Sheets#library)

## Workflows like it

Also data collection, with the same services where possible, closest in size first.

- [**AI Facebook ad spy tool with Apify and OpenAI** 24 steps · calls a model · Google Drive, Google Sheets](https://millionrounds.com/workflow/ai-facebook-ad-spy-tool-with-apify-and-openai)
- [**AI-powered visual regression testing with Gemini and Linear** 24 steps · calls a model · Google Drive, Google Sheets](https://millionrounds.com/workflow/ai-powered-visual-regression-testing-with-gemini-and-linear)
- [**Detect visual regressions with Apify and Gemini** 24 steps · calls a model · Google Drive, Google Sheets](https://millionrounds.com/workflow/detect-visual-regressions-with-apify-and-gemini)
- [**Email subscription service with Airtable** 24 steps · calls a model · Airtable, Gmail](https://millionrounds.com/workflow/email-subscription-service-with-airtable)
- [**Facebook ad library spy with OpenAI and Google Drive** 24 steps · calls a model · Google Drive, Google Sheets](https://millionrounds.com/workflow/facebook-ad-library-spy-with-openai-and-google-drive)
- [**Send regulatory update digest emails with Google Sheets** 24 steps · calls a model · Email, Excel](https://millionrounds.com/workflow/send-regulatory-update-digest-emails-with-google-sheets)
