How to Automate Crypto Portfolio Tracking with n8n + CoinGecko

The Problem with Manual Crypto Portfolio Tracking

If you hold more than three cryptocurrencies, manually tracking your portfolio becomes a daily chore. Checking CoinMarketCap, updating spreadsheets, calculating P&L, monitoring allocation drift — it is repetitive, error-prone, and frankly beneath your time as a serious investor or developer.

In this guide, you will build a fully automated crypto portfolio tracker using n8n and the CoinGecko API. Every morning at 8 AM, your workflow will automatically fetch live prices, calculate your total portfolio value, measure allocation drift, generate an AI-written market summary, and email you a clean daily report — all without any manual intervention.

This is what n8n crypto automation looks like when applied to real investment management: a personal finance AI that runs quietly while you sleep.

Why CoinGecko? The Best Free Crypto API for Automation

CoinGecko offers the most comprehensive free crypto API integration available. Key advantages include data for 10,000 plus coins, completely free tier with 10 to 30 calls per minute, no registration required for basic use, and extremely reliable uptime with extensive documentation.

The free tier is sufficient for a personal portfolio tracker. If you are building a commercial product or need higher rate limits, the paid CoinGecko Pro tier starts at $129 per month and removes all restrictions.

Designing Your Portfolio Tracker Architecture

Before building, define your workflow structure:

Schedule Trigger (8:00 AM daily)
  HTTP Request: CoinGecko /simple/price (bulk fetch all holdings)
  Function Node: calculate total value, P&L, allocation percentages
  IF Node: check for significant allocation drift greater than 10 percent
  OpenAI Node: generate brief market commentary
  Email / Gmail Node: send formatted daily report
  Airtable / Supabase Node: log daily snapshot for historical tracking

Step 1: Define Your Portfolio in n8n

Create a Set node at the start of your workflow to define your holdings. This is your single source of truth, easily updated when you buy or sell:

holdings:
  BTC: 0.15
  ETH: 2.3
  SOL: 45
  BNB: 8
  AVAX: 20

currency: usd
target_allocations:
  BTC: 40
  ETH: 30
  SOL: 15
  BNB: 10
  AVAX: 5

Storing this in a Set node rather than hardcoding it throughout the workflow means you only need to update one place when your portfolio changes.

Step 2: Fetch Live Prices via CoinGecko API

Add an HTTP Request node with the following configuration:

Method: GET
URL: https://api.coingecko.com/api/v3/simple/price
Query Parameters:
  ids: bitcoin,ethereum,solana,binancecoin,avalanche-2
  vs_currencies: usd
  include_24hr_change: true
  include_market_cap: true
  include_24hr_vol: true
Authentication: None (public endpoint)

CoinGecko returns all prices in a single clean JSON response. Use the coin IDs exactly as CoinGecko defines them. You can find any coin ID by visiting the CoinGecko page and checking the API ID field at the top.

This single API call fetches current price, 24-hour percentage change, market cap, and 24-hour volume for your entire portfolio simultaneously.

Step 3: Calculate Portfolio Value and P&L

Add a Function node to crunch the numbers:

// Map CoinGecko IDs to your portfolio symbols
const idMap = {
  bitcoin: {symbol: "BTC", amount: 0.15},
  ethereum: {symbol: "ETH", amount: 2.3},
  solana: {symbol: "SOL", amount: 45},
  binancecoin: {symbol: "BNB", amount: 8},
  "avalanche-2": {symbol: "AVAX", amount: 20}
};

const prices = items[0].json;
let totalValue = 0;
const holdings = [];

for (const [coinId, data] of Object.entries(prices)) {
  const holding = idMap[coinId];
  const value = holding.amount * data.usd;
  totalValue += value;
  holdings.push({
    symbol: holding.symbol,
    amount: holding.amount,
    price: data.usd,
    value: value,
    change24h: data.usd_24h_change,
    marketCap: data.usd_market_cap
  });
}

// Calculate allocation percentages
holdings.forEach(h => {
  h.currentAllocation = ((h.value / totalValue) * 100).toFixed(1);
});

return [{ json: { totalValue, holdings, timestamp: new Date().toISOString() } }];

Step 4: Check for Allocation Drift

Add an IF node to check whether your portfolio has drifted significantly from your target allocations. This is the rebalancing signal that tells you when to act:

Condition: any holding's currentAllocation deviates from targetAllocation by more than 5 percentage points
TRUE branch: add a REBALANCE ALERT to your report
FALSE branch: continue to standard report

Allocation drift above 5 percent in crypto can happen within days during volatile markets. This automated check gives you an objective signal to rebalance, removing emotion from portfolio management decisions.

Step 5: Generate AI Market Commentary with OpenAI

This is where your crypto portfolio automation gets genuinely powerful. Add an OpenAI node after your calculations:

Model: gpt-4o-mini
System Prompt: You are a professional crypto portfolio analyst. Write a concise 3-sentence market update.
User Prompt: Here is today's portfolio data: {{ JSON.stringify($json.holdings) }}
Total value: ${{ $json.totalValue.toFixed(2) }}
Date: {{ $now.toFormat("dd MMMM yyyy") }}

Provide: 1) Brief market sentiment, 2) Notable performer or laggard, 3) One-sentence portfolio health assessment.

GPT-4o-mini costs roughly $0.001 per summary, making this essentially free to run daily. The output is a personalized, intelligent market commentary based on your actual holdings — not generic crypto news.

Step 6: Format and Send the Daily Email Report

Add a Gmail or SMTP node to send your morning briefing:

Subject: Daily Crypto Portfolio Report - {{ $now.toFormat("dd MMM yyyy") }}

HTML Body:
<h2>Your Portfolio: ${{ $json.totalValue.toFixed(2) }}</h2>

<table>
  <thead><tr><th>Asset</th><th>Amount</th><th>Price</th><th>Value</th><th>24h Change</th><th>Allocation</th></tr></thead>
  <tbody>
    {{ holdings.map(h => build row) }}
  </tbody>
</table>

<h3>AI Market Commentary</h3>
<p>{{ $json.aiCommentary }}</p>

{{ if rebalanceAlert }}
<div style="background: #fff3cd; padding: 10px;">
  REBALANCING ALERT: Portfolio drift detected. Review your allocations.
</div>
{{ endif }}

You wake up every morning to a professional portfolio report that would cost $50 per month from any crypto portfolio app, delivered free by automation you own and control.

Step 7: Log Data to Supabase for Historical Analysis

Add a Supabase node at the end of your workflow to build a historical record:

Table: portfolio_snapshots
Columns:
  date: {{ $now.toISO() }}
  total_value_usd: {{ $json.totalValue }}
  btc_price: {{ prices.bitcoin.usd }}
  eth_price: {{ prices.ethereum.usd }}
  portfolio_json: {{ JSON.stringify($json.holdings) }}

After 30 days, you have a complete dataset to analyze. Use this data to measure your portfolio performance against BTC-only holding, track rebalancing effectiveness, and build charts. After 90 days, you can feed this into an OpenAI analysis node that identifies your personal trading patterns and provides optimization recommendations.

Advanced Extension: Multi-Exchange Portfolio

If your holdings are spread across multiple exchanges and wallets, extend the workflow with additional data sources. Add Binance API calls to fetch your Binance wallet balances automatically. Add Coinbase API integration for Coinbase holdings. For cold storage, maintain a manual Set node for hardware wallet amounts since these are not queryable via API without a dedicated blockchain node.

The CoinGecko price feed remains the single pricing source for all holdings regardless of which exchange holds them, ensuring consistent valuation across your entire portfolio.

Deployment: Run This on Railway.app

Deploy your n8n instance on Railway.app for 24/7 operation. The workflow needs persistent storage to maintain your holding definitions and historical logs between executions. Railway.app volumes provide this persistence automatically. Our complete Railway.app deployment guide walks through the full setup including environment variable configuration for your API keys and Supabase connection string.

What You Get: Your Complete Daily Crypto Intelligence Stack

Once this workflow is live, you have a professional-grade crypto portfolio management system: automatic daily valuation across all holdings, 24-hour performance tracking for every asset, AI-generated market commentary personalized to your portfolio, automatic rebalancing alerts when drift exceeds your threshold, and a growing historical database for trend analysis. All of this runs automatically, costs roughly $0.001 per day in API fees, and is completely owned by you.

Ready for Part 3? See how to build an AI Agent That Scans 50 Altcoins for Patterns Using n8n and OpenAI, a fully autonomous market scanner that identifies technical opportunities across the entire altcoin market while you sleep.

Scroll to Top