Coinbase AIエージェント v1.02

上級

これはCrypto Trading, AI Chatbot分野の自動化ワークフローで、35個のノードを含みます。主にSet, Code, Telegram, Agent, HttpRequestToolなどのノードを使用。 GPT-4o + Telegram を使用して Coinbase スポット市場のリアルタイム データを取得する

前提条件
  • Telegram Bot Token
  • ターゲットAPIの認証情報が必要な場合あり
  • OpenAI API Key
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "9aTix0CxjipAFy56",
  "meta": {
    "instanceId": "a5283507e1917a33cc3ae615b2e7d5ad2c1e50955e6f831272ddd5ab816f3fb6"
  },
  "name": "Coinbase AI Agent v1.02",
  "tags": [],
  "nodes": [
    {
      "id": "a55bf961-08ec-4b57-bc79-5d61f25fd56d",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1264,
        736
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "yUizd8t0sD5wMYVG",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a6a4ee3a-efe9-4ab0-a201-bb98780f9d0b",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1008,
        240
      ],
      "webhookId": "3a41e209-f915-4251-9cfc-510889a178dd",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "NRLKuLR7z8vCesub",
          "name": "BinanceSpotTradingAIAgent_Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5b32884d-b376-4775-a47c-07bec03191b9",
      "name": "ユーザー認証 (Replace Telegram ID)",
      "type": "n8n-nodes-base.code",
      "position": [
        -688,
        240
      ],
      "parameters": {
        "jsCode": "if ($input.first().json.message.from.id !== <<Replace>>) { // Replace with your actual ID\n  return {unauthorized: true};\n} else {\n  // Return the original data when authorized\n  return $input.all();\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "75eb688d-d8b7-4498-be72-73f2f31ac8aa",
      "name": "\"SessionId\"を追加",
      "type": "n8n-nodes-base.set",
      "position": [
        -416,
        240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "47598bf1-e55f-4cc0-ae75-272085e7ce02",
              "name": "=sessionId",
              "type": "string",
              "value": "={{ $json.message.chat.id }}"
            },
            {
              "id": "daa49d74-e55e-47bc-ac52-8686d591ab83",
              "name": "message",
              "type": "string",
              "value": "={{ $json.message.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d1e44ee5-6f45-4cca-9b0c-e0d1ce43a65a",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        896,
        240
      ],
      "webhookId": "d8929443-0757-4121-8384-d12c076d3156",
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "NRLKuLR7z8vCesub",
          "name": "BinanceSpotTradingAIAgent_Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "302330a2-2f5f-44a3-b1b5-18979ae3681a",
      "name": "メッセージが4000文字を超える場合に分割",
      "type": "n8n-nodes-base.code",
      "position": [
        464,
        240
      ],
      "parameters": {
        "jsCode": "// Input: assumes incoming message in `item.json.message`\nconst input = $json.output;\nconst chunkSize = 4000;\n\n// Function to split text\nfunction splitMessage(text, size) {\n  const result = [];\n  for (let i = 0; i < text.length; i += size) {\n    result.push(text.substring(i, i + size));\n  }\n  return result;\n}\n\n// Logic\nif (input.length <= chunkSize) {\n  return [{ json: { message: input } }];\n} else {\n  const chunks = splitMessage(input, chunkSize);\n  return chunks.map(chunk => ({ json: { message: chunk } }));\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "4b9e1661-7200-41fd-a832-1105989dec6d",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        -32
      ],
      "parameters": {
        "color": 4,
        "height": 460,
        "content": "## Trigger Incoming Telegram Command\nNode: Telegram Trigger\n**Listens for new Telegram messages** from users.\nTriggers the full agent process and passes raw user input downstream."
      },
      "typeVersion": 1
    },
    {
      "id": "1ab48202-ada4-44c7-b8f8-767bdcc63a55",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        -32
      ],
      "parameters": {
        "color": 2,
        "height": 460,
        "content": "## Validate User Access\nNode: User **Authentication\nChecks incoming Telegram ID** against the approved user list."
      },
      "typeVersion": 1
    },
    {
      "id": "cdbe47f8-2fd9-4532-8f0b-b326f269197f",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -32
      ],
      "parameters": {
        "color": 5,
        "height": 460,
        "content": "## Generate Session Metadata\nNode: Add S**essionId\nCreates a sessionId using the Telegram chat_id**.\nThis is passed into all downstream tools for memory and workflow routing."
      },
      "typeVersion": 1
    },
    {
      "id": "4b9e5cdb-f05c-4554-9c89-42ad66fb4955",
      "name": "付箋3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        -368
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 804,
        "content": "## Main AI Agent: Data Fetcher\n\n**Node: Coinbase Data Agent**\nThis is the **core orchestrator**. It uses OpenAI only to **format and present raw Coinbase market data**, not to analyze or generate strategies.\n\nIt has direct **HTTP request access** to the Coinbase Exchange REST API and retrieves:\n\n* **Live price** (`/products/{product_id}/ticker`)\n* **24h ticker stats** (`/products/{product_id}/stats`)\n* **Order book depth** (`/products/{product_id}/book?level=2`)\n* **Best bid/ask** (`/products/{product_id}/book?level=1`)\n* **Klines/candlesticks** (`/products/{product_id}/candles`)\n* **Recent trades** (`/products/{product_id}/trades`)\n* **Average price (derived)** → midpoint from best bid/ask\n\nThe agent calls these endpoints in parallel for the requested `product_id` (e.g., `BTC-USD`), validates results, and then **presents the data in clean Telegram HTML format**.\n\nIt does **not**:\n\n* Perform technical analysis\n* Generate strategies or predictions\n* Fetch sentiment or news\n"
      },
      "typeVersion": 1
    },
    {
      "id": "8543d31f-9681-4cf9-9d45-fd243075c83e",
      "name": "付箋4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        -32
      ],
      "parameters": {
        "color": 5,
        "width": 260,
        "height": 460,
        "content": "## Handle Telegram Message Limits\nNode: Code (split logic)\nChecks if the **GPT output exceeds 4000 characters**.\nIf so, it splits the message into safe chunks and passes them on sequentially."
      },
      "typeVersion": 1
    },
    {
      "id": "6030ece9-6513-45ae-8680-4d38e792eee4",
      "name": "付箋5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        -32
      ],
      "parameters": {
        "color": 4,
        "height": 460,
        "content": "## Send Final Report to Telegram\nNode: Telegram sendMessage\nSends **formatted HTML report (or split chunks)** directly to the authenticated user via Telegram bot."
      },
      "typeVersion": 1
    },
    {
      "id": "89de4e6a-21c6-4b57-9297-ea03e424c2fe",
      "name": "付箋6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1344,
        640
      ],
      "parameters": {
        "height": 540,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## GPT Model for Reasoning\nNode: OpenAI Chat Model\nModel: **gpt-4o-mini**\nUsed to:\n\nInterpret signal values\n\nGenerate structured HTML\n\n**Recommend spot and leverage trades**\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0a5588cc-2ad7-4b40-b595-3e2045103bca",
      "name": "付箋7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 980,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **Order Book Depth**\n\n**Endpoint:** `GET /products/{product_id}/book?level=2`\n**What it does:** Returns the **order book** for a product. Use `level=1` for best bid/ask (L1) or `level=2` for aggregated depth (L2).\n**Params:**\n\n* `product_id` (STRING, required) → format `BASE-QUOTE` (e.g., BTC-USD)\n* `level` (INT, optional) → `1` (top of book) or `2` (aggregated depth). Default: `2`.\n\n**Returns (L2):** `bids: [[price, size], ...]`, `asks: [[price, size], ...]` plus metadata.\n**n8n query mapping:**\n\n```txt\nproduct_id = $fromAI('product_id', 'BTC-USD', 'string')\nlevel      = $fromAI('level', 2, 'number')\n```\n\nhttps://api.exchange.coinbase.com/products/{{ $fromAI('product_id','BTC-USD','string') }}/book"
      },
      "typeVersion": 1
    },
    {
      "id": "661bcfce-269d-40b3-9a1d-1ae0e0300cea",
      "name": "付箋8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 916,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **Best Bid/Ask (Book Ticker)**\n\n**Endpoint:** `GET /products/{product_id}/book?level=1`\n**What it does:** Returns the best **bid/ask** with sizes for the product.\n**Params:**\n\n* `product_id` (STRING, required) → format: `BASE-QUOTE` (e.g., BTC-USD)\n* `level` (INT, fixed = 1)\n\n**Returns:** `{ \"bids\": [[price, size]], \"asks\": [[price, size]], \"sequence\": ... }`\n\n**n8n query mapping:**\n\n```txt\nproduct_id = $fromAI('product_id', 'BTC-USD', 'string')\nlevel      = 1\n```\n\nhttps://api.exchange.coinbase.com/products/{{ $fromAI('product_id','BTC-USD','string') }}/book"
      },
      "typeVersion": 1
    },
    {
      "id": "1a6f0427-35f1-4799-889a-9ec534caacbe",
      "name": "付箋9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        640
      ],
      "parameters": {
        "color": 3,
        "height": 540,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Short-Term Memory Module\nNode: **Simple Memory\nStores the sessionId**, symbol, and other state data.\nUseful for:\n\nMulti-turn Telegram interactions\n\nTracking indicator agreement across timeframes\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "1600fc25-60f5-495e-8aad-93e9632a9cf3",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -992,
        736
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "cdb20aa4-7b22-40e6-95b4-4a480a819064",
      "name": "付箋10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -784,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 852,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **24h Stats**\n\n**Endpoint:** `GET /products/{product_id}/stats`\n**What it does:** 24-hour rolling window stats: **open/high/low/last**, **volume**.\n**Params:**\n\n* `product_id` (STRING, required) → format: `BASE-QUOTE` (e.g., BTC-USD)\n\n**Returns (FULL):** open, high, low, last, volume (24h).\n**n8n query mapping:**\n\n```txt\nproduct_id = $fromAI('product_id', 'BTC-USD', 'string')\n```\n\nhttps://api.exchange.coinbase.com/products/{{$fromAI('product_id','BTC-USD','string')}}/stats"
      },
      "typeVersion": 1
    },
    {
      "id": "8f91da18-3d8e-4788-bf8e-a33b6addceb4",
      "name": "付箋11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 884,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **Price (Latest)**\n\n**Endpoint:** `GET /products/{product_id}/ticker`\n**What it does:** Returns the **latest trade price** plus best bid/ask and volume for a product.\n**Params:**\n\n* `product_id` (STRING, required) → format: `BASE-QUOTE` (e.g., BTC-USD)\n\n**Returns:** `{ \"trade_id\": ..., \"price\": \"...\", \"size\": \"...\", \"bid\": \"...\", \"ask\": \"...\", \"volume\": \"...\", \"time\": \"...\" }`\n\n**n8n query mapping:**\n\n```txt\nproduct_id = $fromAI('product_id', 'BTC-USD', 'string')\n```\nhttps://api.exchange.coinbase.com/products/{{ $fromAI('product_id','BTC-USD','string') }}/ticker"
      },
      "typeVersion": 1
    },
    {
      "id": "76abe339-9456-472f-b3f0-11b37f3950e8",
      "name": "付箋12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 964,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **Klines (Candles)**\n\n**Endpoint:** `GET /products/{product_id}/candles`\n**What it does:** Candlestick (OHLCV) data for a product.\n**Params:**\n\n* `product_id` (STRING, required) → format: `BASE-QUOTE` (e.g., BTC-USD)\n* `granularity` (INT, required) → supported: 60, 300, 900, 3600, 21600, 86400 (1m, 5m, 15m, 1h, 6h, 1d)\n* `start`, `end` (ISO8601, optional)\n\n**Returns (array per candle):** `[ time, low, high, open, close, volume ]`\n\n**n8n query mapping:**\n\n```txt\nproduct_id  = $fromAI('product_id', 'BTC-USD', 'string')\ngranularity = $fromAI('granularity', 900, 'number')   # 900 = 15m default\n```\nhttps://api.exchange.coinbase.com/products/{{ $fromAI('product_id','BTC-USD','string') }}/candles"
      },
      "typeVersion": 1
    },
    {
      "id": "2ef6ad08-14c2-417b-8dc3-e09bb653203c",
      "name": "付箋13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 1044,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **Average Price (Derived)**\n\n**Endpoint:** `GET /products/{product_id}/book?level=1`\n**What it does:** Coinbase does not provide a direct average price endpoint. This tool fetches the **best bid/ask** and you can derive a midpoint average `(bid + ask)/2`.\n**Params:**\n\n* `product_id` (STRING, required) → format: `BASE-QUOTE` (e.g., BTC-USD)\n* `level` (INT, fixed = 1)\n\n**Returns:** `{ \"bids\": [[price, size]], \"asks\": [[price, size]] }`\n\n**n8n query mapping:**\n\n```txt\nproduct_id = $fromAI('product_id', 'BTC-USD', 'string')\nlevel      = 1\n```\n\n**Notes:** Use Calculator node to compute midpoint from bid/ask.\n\nhttps://api.exchange.coinbase.com/products/{{ $fromAI('product_id','BTC-USD','string') }}/book"
      },
      "typeVersion": 1
    },
    {
      "id": "ff624f1e-6101-4d93-9c6d-c0194edbedef",
      "name": "付箋14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 1092,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **Recent Trades**\n\n**Endpoint:** `GET /products/{product_id}/trades`\n**What it does:** Returns the **most recent trades** for a Coinbase product.\n**Params:**\n\n* `product_id` (STRING, required) → format: `BASE-QUOTE` (e.g., BTC-USD)\n* `limit` (INT, optional) → number of trades to return (defaults ~100)\n\n**Returns (array):** `[ { \"time\": \"...\", \"trade_id\": 123, \"price\": \"...\", \"size\": \"...\", \"side\": \"buy|sell\" }, ... ]`\n\n**n8n query mapping:**\n\n```txt\nproduct_id = $fromAI('product_id', 'BTC-USD', 'string')\nlimit      = $fromAI('limit', 100, 'number')\n```\n\n**Notes:** Endpoint supports pagination via `before` / `after` cursors if you later need historical pages.\n\nhttps://api.exchange.coinbase.com/products/{{ $fromAI('product_id','BTC-USD','string') }}/trades"
      },
      "typeVersion": 1
    },
    {
      "id": "00e14a00-38db-455a-b771-30585e0a8570",
      "name": "Calculator",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "position": [
        1520,
        592
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "89546696-8844-4378-b8ed-36c5431ca957",
      "name": "Think",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        1808,
        592
      ],
      "parameters": {
        "description": "### 🏷 Tool: **Think**\n\n**Purpose:**\n\n* Lightweight **reasoning helper**.\n* Lets the AI Agent process intermediate logic, format outputs, or decide how to combine multiple API results before sending the final report.\n* Does not fetch data itself.\n\n**Use cases:**\n\n* Clean/reshape JSON from Binance endpoints\n* Extract only the needed fields (e.g., `lastPrice`, `volume`)\n* Help prepare data for Telegram message formatting\n\n**n8n setup notes:**\n\n* No API call, just an **AI Tool** node.\n* Connect upstream API results → Think → Report Agent."
      },
      "typeVersion": 1.1
    },
    {
      "id": "077de91e-f21c-4fa7-984c-3604ae546082",
      "name": "付箋15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 836,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **Calculator**\n\n**Purpose:**\n\n* Perform **math operations** inside the workflow.\n* Supports add/subtract/multiply/divide, percentages, rounding, etc.\n\n**Use cases:**\n\n* Calculate spreads (ask – bid)\n* Compute % changes from open vs. last price\n* Normalize volumes or confidence scores\n\n**n8n setup notes:**\n\n* Node: `Calculator` (n8n built-in)\n* Input fields can come from Binance API JSON\n* Output can be chained into Think → Final Report\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b84095a1-b007-4ba2-8ec5-544d64156925",
      "name": "付箋16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1728,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 932,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **Think**\n\n**Purpose:**\n\n* Lightweight **reasoning helper**.\n* Lets the AI Agent process intermediate logic, format outputs, or decide how to combine multiple API results before sending the final report.\n* Does not fetch data itself.\n\n**Use cases:**\n\n* Clean/reshape JSON from Binance endpoints\n* Extract only the needed fields (e.g., `lastPrice`, `volume`)\n* Help prepare data for Telegram message formatting\n\n**n8n setup notes:**\n\n* No API call, just an **AI Tool** node.\n* Connect upstream API results → Think → Report Agent."
      },
      "typeVersion": 1
    },
    {
      "id": "a52823fe-fc0a-4612-ae21-67748ad38c33",
      "name": "Coinbase AIエージェント",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -96,
        240
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "options": {
          "systemMessage": "You are the **Coinbase Spot Market Data Agent**.\n\nYou have **HTTP request access** to the official **Coinbase Exchange REST API** to retrieve market data for any requested Coinbase spot trading pair.\nYour job is to **fetch and present data only**. You do **not** analyze, predict, or recommend.\n\n---\n\n## 🔗 API Access\n\n**Base endpoint (primary default):** `https://api.exchange.coinbase.com` :contentReference[oaicite:0]{index=0}  \n**Format rules:**\n- All requests are **HTTP GET**; responses are **JSON**:contentReference[oaicite:1]{index=1}.\n- `product_id` format is `BASE-QUOTE` (e.g., `BTC-USD`) and **lowercase URLs** are required:contentReference[oaicite:2]{index=2}.\n- Public endpoints don’t require auth; private endpoints do (signed headers):contentReference[oaicite:3]{index=3}.\n- Public REST rate limit: **10 rps per IP** (burst up to 15). Private: **15 rps per profile** (burst up to 30). Exceeding returns **429**:contentReference[oaicite:4]{index=4}.\n\n---\n\n## 📌 Available Market Data Endpoints (Public REST)\n\n1) **Order Book Depth**  \n   `GET /products/{product_id}/book?level=2` → top-of-book depth (aggregated):contentReference[oaicite:5]{index=5}  \n   - Use `level=1` for best bid/ask only (L1).  \n   - Use `level=2` for aggregated L2 (recommended over L3 via REST).\n\n2) **Recent Trades**  \n   `GET /products/{product_id}/trades` → latest trades (price, size, side, time):contentReference[oaicite:6]{index=6}  \n\n3) **Aggregate Trades**  \n   **Not provided** as a REST endpoint on Coinbase. Use **Recent Trades** or simulate aggregation in workflow (optional).  \n\n4) **Klines / Candles**  \n   `GET /products/{product_id}/candles?granularity=900` → OHLCV arrays:contentReference[oaicite:7]{index=7}  \n   - Supported `granularity` (seconds): **60, 300, 900, 3600, 21600, 86400** (1m, 5m, 15m, 1h, 6h, 1d).\n\n5) **Current Average Price**  \n   **Not provided** as a REST endpoint. Optionally derive from midpoint of `/book?level=1` ( (bid+ask)/2 ) in your Calculator node.\n\n6) **24h Ticker Price Change Statistics**  \n   `GET /products/{product_id}/stats` → 24h open, high, low, last, volume:contentReference[oaicite:8]{index=8}  \n\n7) **Latest Symbol Price**  \n   `GET /products/{product_id}/ticker` → last price, best bid/ask, volume:contentReference[oaicite:9]{index=9}  \n\n8) **Order Book Best Bid/Ask**  \n   `GET /products/{product_id}/book?level=1` → best bid/ask only (L1):contentReference[oaicite:10]{index=10}  \n\n---\n\n## 🧩 Utility Tools\n- **Calculator** → simple math (e.g., spread, pct change, midpoint).  \n- **Think** → reshape JSON, pick fields, and prepare the Telegram HTML.\n\n---\n\n## 📤 Output Format (Telegram HTML)\n\nStart with:\n```html\n<b>{{PRODUCT_ID}} — Coinbase Spot Data</b>\n````\n\nThen group:\n\n```html\n<b>Price</b>\n• Last: {{lastPrice}}\n• Mid (derived): {{midPrice}}  <!-- optional: (best_bid+best_ask)/2 -->\n• Change (24h): {{pctChange}}%\n\n<b>24h Stats</b>\n• Open: {{open}} • High: {{high}} • Low: {{low}} • Last: {{last}}\n• Volume: {{baseVol}}\n\n<b>Order Book (Top 5)</b>\n• Bids: [price x size] …\n• Asks: [price x size] …\n\n<b>Candles (latest N)</b>\n• Interval: {{interval}} (O/H/L/C per candle)\n```\n\n---\n\n## ⚠️ Rules\n\n* Always **call the correct Coinbase endpoint** for the requested data.\n* Do **not** fabricate or compute indicators; only basic formatting/derivations (e.g., midpoint) are allowed.\n* Do **not** provide advice, sentiment, or predictions.\n* Do **not** dump raw JSON; present clean, human-readable values.\n* If a request fails or a field is missing, show `N/A` and continue with available data.\n\n---\n\n## 🔧 n8n parameter bindings (suggested)\n\nFor each HTTP Request node:\n\n* `product_id` → `={{ /*n8n-auto-generated-fromAI*/ $fromAI('product_id', 'BTC-USD', 'string') }}`\n* `granularity` → `={{ $fromAI('granularity', 900, 'number') }}`  <!-- 15m default -->\n* `limit` (if you add pagination elsewhere) → `={{ $fromAI('limit', 100, 'number') }}`\n\nExample URL for **Ticker**:\n\n```\nhttps://api.exchange.coinbase.com/products/={{$fromAI('product_id','BTC-USD','string')}}/ticker\n```\n\n```\n\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "52aee742-d806-4d15-82fe-4a6eba03deed",
      "name": "24h統計1",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -704,
        592
      ],
      "parameters": {
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('URL', `BTC-USD`, 'string') }}",
        "options": {},
        "toolDescription": "### 🏷 Tool: **24h Stats**\n\n**Endpoint:** `GET /products/{product_id}/stats`\n**What it does:** 24-hour rolling window stats: **open/high/low/last**, **volume**.\n**Params:**\n\n* `product_id` (STRING, required) → format: `BASE-QUOTE` (e.g., BTC-USD)\n\n**Returns (FULL):** open, high, low, last, volume (24h).\n**n8n query mapping:**\n\n```txt\nproduct_id = $fromAI('product_id', 'BTC-USD', 'string')\n```\n\nhttps://api.exchange.coinbase.com/products/{{$fromAI('product_id','BTC-USD','string')}}/stats"
      },
      "typeVersion": 4.2
    },
    {
      "id": "fce2f2ac-c799-4c6c-8402-8ff6f49e6a0d",
      "name": "板情報(深度)1",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -400,
        592
      ],
      "parameters": {
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('URL', `BTC-USD`, 'string') }}",
        "options": {},
        "toolDescription": "### 🏷 Tool: **Order Book Depth**\n\n**Endpoint:** `GET /products/{product_id}/book?level=2`\n**What it does:** Returns the **order book** for a product. Use `level=1` for best bid/ask (L1) or `level=2` for aggregated depth (L2).\n**Params:**\n\n* `product_id` (STRING, required) → format `BASE-QUOTE` (e.g., BTC-USD)\n* `level` (INT, optional) → `1` (top of book) or `2` (aggregated depth). Default: `2`.\n\n**Returns (L2):** `bids: [[price, size], ...]`, `asks: [[price, size], ...]` plus metadata.\n**n8n query mapping:**\n\n```txt\nproduct_id = $fromAI('product_id', 'BTC-USD', 'string')\nlevel      = $fromAI('level', 2, 'number')\n```\n\nhttps://api.exchange.coinbase.com/products/{{ $fromAI('product_id','BTC-USD','string') }}/book"
      },
      "typeVersion": 4.2
    },
    {
      "id": "84fd5218-005b-44eb-b4bf-c307267a29f1",
      "name": "価格(最新)1",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -112,
        592
      ],
      "parameters": {
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('URL', `BTC-USD`, 'string') }}",
        "options": {},
        "toolDescription": "### 🏷 Tool: **Price (Latest)**\n\n**Endpoint:** `GET /products/{product_id}/ticker`\n**What it does:** Returns the **latest trade price** plus best bid/ask and volume for a product.\n**Params:**\n\n* `product_id` (STRING, required) → format: `BASE-QUOTE` (e.g., BTC-USD)\n\n**Returns:** `{ \"trade_id\": ..., \"price\": \"...\", \"size\": \"...\", \"bid\": \"...\", \"ask\": \"...\", \"volume\": \"...\", \"time\": \"...\" }`\n\n**n8n query mapping:**\n\n```txt\nproduct_id = $fromAI('product_id', 'BTC-USD', 'string')\n```\nhttps://api.exchange.coinbase.com/products/{{ $fromAI('product_id','BTC-USD','string') }}/ticker"
      },
      "typeVersion": 4.2
    },
    {
      "id": "89182a5b-03c0-453e-b0d9-974ec3e7edda",
      "name": "最良気配値1",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        208,
        592
      ],
      "parameters": {
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('URL', `BTC-USD`, 'string') }}",
        "options": {},
        "toolDescription": "### 🏷 Tool: **Best Bid/Ask (Book Ticker)**\n\n**Endpoint:** `GET /products/{product_id}/book?level=1`\n**What it does:** Returns the best **bid/ask** with sizes for the product.\n**Params:**\n\n* `product_id` (STRING, required) → format: `BASE-QUOTE` (e.g., BTC-USD)\n* `level` (INT, fixed = 1)\n\n**Returns:** `{ \"bids\": [[price, size]], \"asks\": [[price, size]], \"sequence\": ... }`\n\n**n8n query mapping:**\n\n```txt\nproduct_id = $fromAI('product_id', 'BTC-USD', 'string')\nlevel      = 1\n```\n\nhttps://api.exchange.coinbase.com/products/{{ $fromAI('product_id','BTC-USD','string') }}/book"
      },
      "typeVersion": 4.2
    },
    {
      "id": "33a2447c-1026-40ff-bdf0-b18a4c1a1ee2",
      "name": "Kライン(ローソク足)1",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        528,
        592
      ],
      "parameters": {
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('URL', `BTC-USD`, 'string') }}",
        "options": {},
        "toolDescription": "### 🏷 Tool: **Klines (Candles)**\n\n**Endpoint:** `GET /products/{product_id}/candles`\n**What it does:** Candlestick (OHLCV) data for a product.\n**Params:**\n\n* `product_id` (STRING, required) → format: `BASE-QUOTE` (e.g., BTC-USD)\n* `granularity` (INT, required) → supported: 60, 300, 900, 3600, 21600, 86400 (1m, 5m, 15m, 1h, 6h, 1d)\n* `start`, `end` (ISO8601, optional)\n\n**Returns (array per candle):** `[ time, low, high, open, close, volume ]`\n\n**n8n query mapping:**\n\n```txt\nproduct_id  = $fromAI('product_id', 'BTC-USD', 'string')\ngranularity = $fromAI('granularity', 900, 'number')   # 900 = 15m default\n```\nhttps://api.exchange.coinbase.com/products/{{ $fromAI('product_id','BTC-USD','string') }}/candles"
      },
      "typeVersion": 4.2
    },
    {
      "id": "a1b19454-5272-4122-a1be-95eff5923847",
      "name": "平均価格(算出値)",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        880,
        592
      ],
      "parameters": {
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('URL', `BTC-USD`, 'string') }}",
        "options": {},
        "toolDescription": "### 🏷 Tool: **Average Price (Derived)**\n\n**Endpoint:** `GET /products/{product_id}/book?level=1`\n**What it does:** Coinbase does not provide a direct average price endpoint. This tool fetches the **best bid/ask** and you can derive a midpoint average `(bid + ask)/2`.\n**Params:**\n\n* `product_id` (STRING, required) → format: `BASE-QUOTE` (e.g., BTC-USD)\n* `level` (INT, fixed = 1)\n\n**Returns:** `{ \"bids\": [[price, size]], \"asks\": [[price, size]] }`\n\n**n8n query mapping:**\n\n```txt\nproduct_id = $fromAI('product_id', 'BTC-USD', 'string')\nlevel      = 1\n```\n\n**Notes:** Use Calculator node to compute midpoint from bid/ask.\n\nhttps://api.exchange.coinbase.com/products/{{ $fromAI('product_id','BTC-USD','string') }}/book"
      },
      "typeVersion": 4.2
    },
    {
      "id": "9c5657f8-1c31-46f3-8146-93f36fa25e49",
      "name": "直近約定履歴1",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        1200,
        592
      ],
      "parameters": {
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('URL', `BTC-USD`, 'string') }}",
        "options": {},
        "toolDescription": "### 🏷 Tool: **Recent Trades**\n\n**Endpoint:** `GET /products/{product_id}/trades`\n**What it does:** Returns the **most recent trades** for a Coinbase product.\n**Params:**\n\n* `product_id` (STRING, required) → format: `BASE-QUOTE` (e.g., BTC-USD)\n* `limit` (INT, optional) → number of trades to return (defaults ~100)\n\n**Returns (array):** `[ { \"time\": \"...\", \"trade_id\": 123, \"price\": \"...\", \"size\": \"...\", \"side\": \"buy|sell\" }, ... ]`\n\n**n8n query mapping:**\n\n```txt\nproduct_id = $fromAI('product_id', 'BTC-USD', 'string')\nlimit      = $fromAI('limit', 100, 'number')\n```\n\n**Notes:** Endpoint supports pagination via `before` / `after` cursors if you later need historical pages.\n\nhttps://api.exchange.coinbase.com/products/{{ $fromAI('product_id','BTC-USD','string') }}/trades"
      },
      "typeVersion": 4.2
    },
    {
      "id": "4e47f927-47c3-4f73-a790-4d44606ce7a5",
      "name": "付箋17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2128,
        -496
      ],
      "parameters": {
        "width": 1664,
        "height": 2016,
        "content": "# 🧠 Coinbase Spot Market Quant AI Agent – Full System Documentation\n\nA professional-grade AI automation system for **spot market trading insights** on **Coinbase**.  \nIt analyzes **price data**, **order book depth**, **candlestick (OHLCV) data**, and **trade history**, then delivers structured outputs for trading decisions.\n\n---\n\n## 🧩 Included Workflows\n\nYou must install and activate **all of the following workflows** for the system to function correctly:\n\n| ✅ Workflow Name            | 📌 Function Description                                                          |\n| --------------------------- | -------------------------------------------------------------------------------- |\n| Coinbase AI Agent           | Final AI orchestrator. Parses user prompts and generates structured outputs.     |\n| Coinbase Price Tool         | Returns the latest trade price for any symbol.                                   |\n| Coinbase Order Book Tool    | Returns live order book depth (bids/asks up to configured limit).                 |\n| Coinbase Candles Tool       | Pulls candlestick OHLCV data across multiple intervals (AI chooses timeframe).   |\n| Coinbase Trades Tool        | Returns most recent trade history for a symbol.                                  |\n\n---\n\n## ⚙️ Installation Instructions\n\n### Step 1: Import Workflows\n* Open your **n8n Editor UI**  \n* Import each workflow JSON file one by one  \n* Activate them or ensure they're called via `Execute Workflow`  \n\n### Step 2: Set Credentials\n* **OpenAI API Credential** → Required (for agent reasoning & orchestration)  \n* **Coinbase Price Data** → Public endpoints (no authentication required)  \n\n### Step 3: Configure Webhooks (if applicable)\n* Ensure your webhook endpoints are deployed and accessible if you integrate with external bots or dashboards  \n\n### Step 4: Optional Integrations\n* Telegram, Discord, or Slack can be connected for message delivery  \n* Update recipient IDs or channels inside n8n nodes if required  \n\n---\n\n## 🖥️ System Workflow Overview\n\n```\n\n\\[User Prompt / Trigger]\n→ \\[Coinbase AI Agent Orchestrator]\n→ \\[Price Tool]\n→ \\[Order Book Tool]\n→ \\[Candles Tool]\n→ \\[Trades Tool]\n→ \\[Reasoning + Signal Formatting]\n→ \\[Final Output to Messaging/Report]\n\n````\n\n---\n\n## 📊 Example Output\n\n```html\n<b>COIN-USD Market Report</b>\n\n<b>Spot Strategy</b>  \n• Action: Buy  \n• Entry: $245.30 | SL: $240.00 | TP: $252.00  \n• Reason:  \n - Strong bid support at $245  \n - RSI Rebound on 1h Candles  \n - Trade history shows accumulation  \n\n<b>Leverage Strategy</b>  \n• Position: Long 3x  \n• Entry: $245.30  \n• SL/TP zones same as above  \n\n<b>Market Sentiment:</b> Neutral-Bullish  \n• Recent trades show buyers dominating order flow  \n````\n\n---\n\n## 🚀 Support & Licensing\n\n🔗 **Don Jayamaha – LinkedIn**\n[linkedin.com/in/donjayamahajr](http://linkedin.com/in/donjayamahajr)\n\n© 2025 Treasurium Capital Limited Company.\nAll rights reserved. This system architecture, prompts, and workflow structure are proprietary and protected by **U.S. copyright law**.\nReuse or resale prohibited without license.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "6d33dd3b-6ec0-4fca-86cd-0387726696d9",
  "connections": {
    "89546696-8844-4378-b8ed-36c5431ca957": {
      "ai_tool": [
        [
          {
            "node": "a52823fe-fc0a-4612-ae21-67748ad38c33",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "52aee742-d806-4d15-82fe-4a6eba03deed": {
      "ai_tool": [
        [
          {
            "node": "a52823fe-fc0a-4612-ae21-67748ad38c33",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "00e14a00-38db-455a-b771-30585e0a8570": {
      "ai_tool": [
        [
          {
            "node": "a52823fe-fc0a-4612-ae21-67748ad38c33",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "89182a5b-03c0-453e-b0d9-974ec3e7edda": {
      "ai_tool": [
        [
          {
            "node": "a52823fe-fc0a-4612-ae21-67748ad38c33",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "1600fc25-60f5-495e-8aad-93e9632a9cf3": {
      "ai_memory": [
        [
          {
            "node": "a52823fe-fc0a-4612-ae21-67748ad38c33",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "9c5657f8-1c31-46f3-8146-93f36fa25e49": {
      "ai_tool": [
        [
          {
            "node": "a52823fe-fc0a-4612-ae21-67748ad38c33",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "84fd5218-005b-44eb-b4bf-c307267a29f1": {
      "ai_tool": [
        [
          {
            "node": "a52823fe-fc0a-4612-ae21-67748ad38c33",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "75eb688d-d8b7-4498-be72-73f2f31ac8aa": {
      "main": [
        [
          {
            "node": "a52823fe-fc0a-4612-ae21-67748ad38c33",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a6a4ee3a-efe9-4ab0-a201-bb98780f9d0b": {
      "main": [
        [
          {
            "node": "5b32884d-b376-4775-a47c-07bec03191b9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "33a2447c-1026-40ff-bdf0-b18a4c1a1ee2": {
      "ai_tool": [
        [
          {
            "node": "a52823fe-fc0a-4612-ae21-67748ad38c33",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "a55bf961-08ec-4b57-bc79-5d61f25fd56d": {
      "ai_languageModel": [
        [
          {
            "node": "a52823fe-fc0a-4612-ae21-67748ad38c33",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "fce2f2ac-c799-4c6c-8402-8ff6f49e6a0d": {
      "ai_tool": [
        [
          {
            "node": "a52823fe-fc0a-4612-ae21-67748ad38c33",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "a52823fe-fc0a-4612-ae21-67748ad38c33": {
      "main": [
        [
          {
            "node": "302330a2-2f5f-44a3-b1b5-18979ae3681a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a1b19454-5272-4122-a1be-95eff5923847": {
      "ai_tool": [
        [
          {
            "node": "a52823fe-fc0a-4612-ae21-67748ad38c33",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "5b32884d-b376-4775-a47c-07bec03191b9": {
      "main": [
        [
          {
            "node": "75eb688d-d8b7-4498-be72-73f2f31ac8aa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "302330a2-2f5f-44a3-b1b5-18979ae3681a": {
      "main": [
        [
          {
            "node": "d1e44ee5-6f45-4cca-9b0c-e0d1ce43a65a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

上級 - 仮想通貨取引, AIチャットボット

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

ワークフロー情報
難易度
上級
ノード数35
カテゴリー2
ノードタイプ11
難易度説明

上級者向け、16ノード以上の複雑なワークフロー

作成者
Don Jayamaha Jr

Don Jayamaha Jr

@don-the-gem-dealer

With 12 years of experience as a Blockchain Strategist and Web3 Architect, I specialize in bridging the gap between traditional industries and decentralized technologies. My expertise spans tokenized assets, crypto payment integrations, and blockchain-driven market solutions.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34