8
n8n 中文网amn8n.com

币安现货交易器-云端无凭证

高级

这是一个Finance领域的自动化工作流,包含 30 个节点。主要使用 Set, Code, Crypto, HttpRequest, ManualTrigger 等节点。 币安现货交易器 - 通过API进行限价和市价订单

前置要求
  • 可能需要目标 API 的认证凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "8p4wKxUqY1fAABOu",
  "meta": {
    "instanceId": "6585ca078ed5b28a93952b5698b0afc81474ac00ac5460a2d5d58ca9f7d86532"
  },
  "name": "trader-binance-spot-cloud-no-credential",
  "tags": [
    {
      "id": "1EML6gc9DSYmybCZ",
      "name": "trader",
      "createdAt": "2025-06-16T02:31:44.015Z",
      "updatedAt": "2025-06-16T02:31:44.015Z"
    }
  ],
  "nodes": [
    {
      "id": "93a8429c-b9ef-43de-934b-2c6fd9db1bb3",
      "name": "当点击“执行工作流”时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1880,
        360
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "250640b9-95f7-48b7-bf1d-07fc90026bee",
      "name": "设置账户查询",
      "type": "n8n-nodes-base.set",
      "position": [
        -1200,
        -180
      ],
      "parameters": {
        "mode": "raw",
        "include": "selected",
        "options": {},
        "jsonOutput": "={\n  \"timestamp\": \"{{ $now.toMillis() }}\"\n}\n",
        "includeFields": "timestamp"
      },
      "typeVersion": 3
    },
    {
      "id": "6dcb5a49-149d-4f62-bb69-137cec92f81f",
      "name": "签名获取账户",
      "type": "n8n-nodes-base.crypto",
      "position": [
        -800,
        -180
      ],
      "parameters": {
        "type": "SHA256",
        "value": "={{ $json.queryString }}",
        "action": "hmac",
        "secret": "={{ $('Set Credentials').item.json.api_secret }}",
        "dataPropertyName": "signature"
      },
      "typeVersion": 1
    },
    {
      "id": "4983062d-1e68-4f15-a4d2-955fc81267b5",
      "name": "账户信息查询",
      "type": "n8n-nodes-base.code",
      "position": [
        -1000,
        -180
      ],
      "parameters": {
        "jsCode": "// แปลง JSON object เป็น query string\nconst data = items[0].json;\n\n// วิธีที่ 1: ใช้ Object.keys() และ map()\nconst queryString = Object.keys(data)\n  .map(key => `${key}=${data[key]}`)\n  .join('&');\n\nreturn [{\n  json: {\n    queryString: queryString,\n    originalData: data\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "57699751-49fa-4420-aa5a-291bc11fa631",
      "name": "订单查询",
      "type": "n8n-nodes-base.code",
      "position": [
        -1000,
        0
      ],
      "parameters": {
        "jsCode": "// แปลง JSON object เป็น query string\nconst data = items[0].json;\n\n// วิธีที่ 1: ใช้ Object.keys() และ map()\nconst queryString = Object.keys(data)\n  .map(key => `${key}=${data[key]}`)\n  .join('&');\n\nreturn [{\n  json: {\n    queryString: queryString,\n    originalData: data\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "92ff9826-2f60-4d35-8c58-30b483db49d6",
      "name": "限价买入参数",
      "type": "n8n-nodes-base.set",
      "position": [
        -1200,
        0
      ],
      "parameters": {
        "mode": "raw",
        "include": "none",
        "options": {},
        "jsonOutput": "={\n  \"symbol\": \"BTCUSDT\",\n  \"side\": \"BUY\",\n  \"type\": \"LIMIT\",\n  \"price\": 98000.20,\n  \"quantity\": 0.0001,\n  \"timeInForce\": \"GTC\",\n  \"timestamp\": \"{{ $now.toMillis() }}\"\n}"
      },
      "typeVersion": 3
    },
    {
      "id": "94a537dd-b59d-49cd-9daf-848a22df9e8d",
      "name": "设置凭据",
      "type": "n8n-nodes-base.set",
      "notes": "กรุณาสร้าง Binance API Credentials ใน n8n:\n1. ไปที่ Credentials > New\n2. เลือก Binance API\n3. ใส่ API Key และ Secret Key\n4. ตั้งชื่อว่า 'Binance API'\n5. Save\n\nทุก node จะใช้ credential เดียวกันนี้",
      "position": [
        -1680,
        360
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "api_key"
            },
            {
              "name": "api_secret"
            }
          ]
        },
        "options": {}
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "9850ff29-6d6a-4fcc-bcc9-ed14c0fe1e7b",
      "name": "获取账户信息",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -580,
        -180
      ],
      "parameters": {
        "url": "https://api.binance.com/api/v3/account",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "timestamp",
              "value": "={{ $('Set Account Query').item.json.timestamp }}"
            },
            {
              "name": "signature",
              "value": "={{ $json.signature }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "X-MBX-APIKEY",
              "value": "={{ $('Set Credentials').item.json.api_key }}"
            }
          ]
        }
      },
      "typeVersion": 3
    },
    {
      "id": "9a3e31fc-7da7-48dc-8758-4d109addea56",
      "name": "限价卖出参数",
      "type": "n8n-nodes-base.set",
      "position": [
        -1200,
        180
      ],
      "parameters": {
        "mode": "raw",
        "include": "none",
        "options": {},
        "jsonOutput": "={\n  \"symbol\": \"BTCUSDT\",\n  \"side\": \"SELL\",\n  \"type\": \"LIMIT\",\n  \"price\": 98000.20,\n  \"quantity\": 0.0001,\n  \"timeInForce\": \"GTC\",\n  \"timestamp\": \"{{ $now.toMillis() }}\"\n}"
      },
      "typeVersion": 3
    },
    {
      "id": "4d43ab9f-69a8-4eb3-a700-234f480cb8d7",
      "name": "卖出查询",
      "type": "n8n-nodes-base.code",
      "position": [
        -1000,
        180
      ],
      "parameters": {
        "jsCode": "// แปลง JSON object เป็น query string\nconst data = items[0].json;\n\n// วิธีที่ 1: ใช้ Object.keys() และ map()\nconst queryString = Object.keys(data)\n  .map(key => `${key}=${data[key]}`)\n  .join('&');\n\nreturn [{\n  json: {\n    queryString: queryString,\n    originalData: data\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "684e1d96-a2ef-4075-9545-ed904c8d798a",
      "name": "执行限价卖出",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -580,
        180
      ],
      "parameters": {
        "url": "https://api.binance.com/api/v3/order",
        "body": "={{ $json.queryString }}&signature={{ $json.signature }}",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "sendHeaders": true,
        "specifyBody": "string",
        "headerParameters": {
          "parameters": [
            {
              "name": "X-MBX-APIKEY",
              "value": "={{ $('Set Credentials').item.json.api_key }}"
            }
          ]
        }
      },
      "typeVersion": 3
    },
    {
      "id": "96ca7f7d-e60d-4944-80ec-c2b9ba02876a",
      "name": "执行限价买入",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -580,
        0
      ],
      "parameters": {
        "url": "https://api.binance.com/api/v3/order",
        "body": "={{ $json.queryString }}&signature={{ $json.signature }}",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "sendHeaders": true,
        "specifyBody": "string",
        "headerParameters": {
          "parameters": [
            {
              "name": "X-MBX-APIKEY",
              "value": "={{ $('Set Credentials').item.json.api_key }}"
            }
          ]
        }
      },
      "typeVersion": 3
    },
    {
      "id": "b13d8b19-0222-45fe-9558-b33aeffa2bc1",
      "name": "市价买入查询",
      "type": "n8n-nodes-base.code",
      "position": [
        -1000,
        360
      ],
      "parameters": {
        "jsCode": "// แปลง JSON object เป็น query string\nconst data = items[0].json;\n\n// วิธีที่ 1: ใช้ Object.keys() และ map()\nconst queryString = Object.keys(data)\n  .map(key => `${key}=${data[key]}`)\n  .join('&');\n\nreturn [{\n  json: {\n    queryString: queryString,\n    originalData: data\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "4fb1f7a5-9a70-4870-bfd7-5575d587cb43",
      "name": "市价买入参数",
      "type": "n8n-nodes-base.set",
      "position": [
        -1200,
        360
      ],
      "parameters": {
        "mode": "raw",
        "include": "none",
        "options": {},
        "jsonOutput": "={\n  \"symbol\": \"BTCUSDT\",\n  \"side\": \"BUY\",\n  \"type\": \"MARKET\",\n  \"quantity\": 0.0001,\n  \"timestamp\": \"{{ $now.toMillis() }}\"\n}"
      },
      "typeVersion": 3
    },
    {
      "id": "b4e45c9e-5a1c-4cf0-aed3-30520bf92cb9",
      "name": "签名市价买入",
      "type": "n8n-nodes-base.crypto",
      "position": [
        -800,
        360
      ],
      "parameters": {
        "type": "SHA256",
        "value": "={{ $json.queryString }}",
        "action": "hmac",
        "secret": "={{ $('Set Credentials').item.json.api_secret }}",
        "dataPropertyName": "signature"
      },
      "typeVersion": 1
    },
    {
      "id": "4c9f4a4d-049e-431d-b053-a694698bd0ba",
      "name": "签名限价买入",
      "type": "n8n-nodes-base.crypto",
      "position": [
        -800,
        0
      ],
      "parameters": {
        "type": "SHA256",
        "value": "={{ $json.queryString }}",
        "action": "hmac",
        "secret": "={{ $('Set Credentials').item.json.api_secret }}",
        "dataPropertyName": "signature"
      },
      "typeVersion": 1
    },
    {
      "id": "5c148d9e-c980-4485-944e-9535ca79d7af",
      "name": "签名限价卖出",
      "type": "n8n-nodes-base.crypto",
      "position": [
        -800,
        180
      ],
      "parameters": {
        "type": "SHA256",
        "value": "={{ $json.queryString }}",
        "action": "hmac",
        "secret": "={{ $('Set Credentials').item.json.api_secret }}",
        "dataPropertyName": "signature"
      },
      "typeVersion": 1
    },
    {
      "id": "d519fced-aaca-4dfb-bae0-818491d9791f",
      "name": "执行市价买入",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -580,
        360
      ],
      "parameters": {
        "url": "https://api.binance.com/api/v3/order",
        "body": "={{ $json.queryString }}&signature={{ $json.signature }}",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "sendHeaders": true,
        "specifyBody": "string",
        "headerParameters": {
          "parameters": [
            {
              "name": "X-MBX-APIKEY",
              "value": "={{ $('Set Credentials').item.json.api_key }}"
            }
          ]
        }
      },
      "typeVersion": 3
    },
    {
      "id": "916751cf-0525-4d7e-b6ee-6412beecf870",
      "name": "市价卖出参数",
      "type": "n8n-nodes-base.set",
      "position": [
        -1200,
        560
      ],
      "parameters": {
        "mode": "raw",
        "include": "none",
        "options": {},
        "jsonOutput": "={\n  \"symbol\": \"BTCUSDT\",\n  \"side\": \"SELL\",\n  \"type\": \"MARKET\",\n  \"quantity\": 0.0001,\n  \"timestamp\": \"{{ $now.toMillis() }}\"\n}"
      },
      "typeVersion": 3
    },
    {
      "id": "0e03892e-4c5d-4a7c-9bff-acc014fbff03",
      "name": "市价卖出查询",
      "type": "n8n-nodes-base.code",
      "position": [
        -1000,
        560
      ],
      "parameters": {
        "jsCode": "// แปลง JSON object เป็น query string\nconst data = items[0].json;\n\n// วิธีที่ 1: ใช้ Object.keys() และ map()\nconst queryString = Object.keys(data)\n  .map(key => `${key}=${data[key]}`)\n  .join('&');\n\nreturn [{\n  json: {\n    queryString: queryString,\n    originalData: data\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "493074d1-7a6d-4b63-956d-55cda01e885d",
      "name": "签名市价卖出",
      "type": "n8n-nodes-base.crypto",
      "position": [
        -800,
        560
      ],
      "parameters": {
        "type": "SHA256",
        "value": "={{ $json.queryString }}",
        "action": "hmac",
        "secret": "={{ $('Set Credentials').item.json.api_secret }}",
        "dataPropertyName": "signature"
      },
      "typeVersion": 1
    },
    {
      "id": "537afa17-ac5e-4d73-ac9c-ceabc644cc22",
      "name": "执行市价卖出",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -580,
        560
      ],
      "parameters": {
        "url": "https://api.binance.com/api/v3/order",
        "body": "={{ $json.queryString }}&signature={{ $json.signature }}",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "sendHeaders": true,
        "specifyBody": "string",
        "headerParameters": {
          "parameters": [
            {
              "name": "X-MBX-APIKEY",
              "value": "={{ $('Set Credentials').item.json.api_key }}"
            }
          ]
        }
      },
      "typeVersion": 3
    },
    {
      "id": "877a0eb7-866b-4c73-bbee-cb5b9e49b786",
      "name": "未成交订单查询",
      "type": "n8n-nodes-base.code",
      "position": [
        -1000,
        760
      ],
      "parameters": {
        "jsCode": "// แปลง JSON object เป็น query string\nconst data = items[0].json;\n\n// วิธีที่ 1: ใช้ Object.keys() และ map()\nconst queryString = Object.keys(data)\n  .map(key => `${key}=${data[key]}`)\n  .join('&');\n\nreturn [{\n  json: {\n    queryString: queryString,\n    originalData: data\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "641c40ab-e673-4acd-8a48-5d7592800da2",
      "name": "未成交订单参数",
      "type": "n8n-nodes-base.set",
      "position": [
        -1200,
        760
      ],
      "parameters": {
        "mode": "raw",
        "include": "none",
        "options": {},
        "jsonOutput": "={\n  \"timestamp\": \"{{ $now.toMillis() }}\",\n  \"symbol\": \"BTCUSDT\",\n  \"recvWindow\": 2000\n}\n"
      },
      "typeVersion": 3
    },
    {
      "id": "d0457455-134c-4425-bbbc-b4e1c3eedccf",
      "name": "签名未成交订单",
      "type": "n8n-nodes-base.crypto",
      "position": [
        -800,
        760
      ],
      "parameters": {
        "type": "SHA256",
        "value": "={{ $json.queryString }}",
        "action": "hmac",
        "secret": "={{ $('Set Credentials').item.json.api_secret }}",
        "dataPropertyName": "signature"
      },
      "typeVersion": 1
    },
    {
      "id": "3e8f723a-22ae-418c-9def-f95588d51080",
      "name": "获取未成交订单",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -580,
        760
      ],
      "parameters": {
        "url": "=https://api.binance.com/api/v3/openOrders?{{ $json.queryString }}",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "signature",
              "value": "={{ $json.signature }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "X-MBX-APIKEY",
              "value": "={{ $('Set Credentials').item.json.api_key }}"
            }
          ]
        }
      },
      "typeVersion": 3
    },
    {
      "id": "4c65712a-2a49-4dd6-b346-1b61fbfed417",
      "name": "取消所有订单参数",
      "type": "n8n-nodes-base.set",
      "position": [
        -1200,
        960
      ],
      "parameters": {
        "mode": "raw",
        "include": "none",
        "options": {},
        "jsonOutput": "={\n  \"timestamp\": \"{{ $now.toMillis() }}\",\n  \"symbol\": \"BTCUSDT\",\n  \"recvWindow\": 2000\n}\n"
      },
      "typeVersion": 3
    },
    {
      "id": "cde8a4d3-678a-464f-886b-763982ebfe01",
      "name": "取消所有订单查询",
      "type": "n8n-nodes-base.code",
      "position": [
        -1000,
        960
      ],
      "parameters": {
        "jsCode": "// แปลง JSON object เป็น query string\nconst data = items[0].json;\n\n// วิธีที่ 1: ใช้ Object.keys() และ map()\nconst queryString = Object.keys(data)\n  .map(key => `${key}=${data[key]}`)\n  .join('&');\n\nreturn [{\n  json: {\n    queryString: queryString,\n    originalData: data\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "bcb50ec1-cf95-464d-989f-e5c577b6695f",
      "name": "签名取消所有订单",
      "type": "n8n-nodes-base.crypto",
      "position": [
        -800,
        960
      ],
      "parameters": {
        "type": "SHA256",
        "value": "={{ $json.queryString }}",
        "action": "hmac",
        "secret": "={{ $('Set Credentials').item.json.api_secret }}",
        "dataPropertyName": "signature"
      },
      "typeVersion": 1
    },
    {
      "id": "2ceec541-944d-42c8-b36d-dee7abef0a26",
      "name": "取消所有订单",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -580,
        960
      ],
      "parameters": {
        "url": "=https://api.binance.com/api/v3/openOrders",
        "body": "={{ $json.queryString }}",
        "method": "DELETE",
        "options": {},
        "sendBody": true,
        "sendQuery": true,
        "contentType": "form-urlencoded",
        "sendHeaders": true,
        "specifyBody": "string",
        "queryParameters": {
          "parameters": [
            {
              "name": "signature",
              "value": "={{ $json.signature }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "X-MBX-APIKEY",
              "value": "={{ $('Set Credentials').item.json.api_key }}"
            }
          ]
        }
      },
      "typeVersion": 3
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "9625a34a-ecfe-42fd-adef-c57e036d3d7d",
  "connections": {
    "Sale Query": {
      "main": [
        [
          {
            "node": "Signature Limit SELL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Order Query": {
      "main": [
        [
          {
            "node": "Signature Limit BUY",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenOrder Query": {
      "main": [
        [
          {
            "node": "Signature OpenOrder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Credentials": {
      "main": [
        [
          {
            "node": "Set Account Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Market Buy Query": {
      "main": [
        [
          {
            "node": "Signature MarketBuy",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LimitBuy Parmeter": {
      "main": [
        [
          {
            "node": "Order Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Market Sell Query": {
      "main": [
        [
          {
            "node": "Signature MarketSell",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Account Query": {
      "main": [
        [
          {
            "node": "Account Info Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Account Info Query": {
      "main": [
        [
          {
            "node": "Signature Get Account",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Open Orders Params": {
      "main": [
        [
          {
            "node": "OpenOrder Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LimitSale Parameter": {
      "main": [
        [
          {
            "node": "Sale Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MarketBuy Parameter": {
      "main": [
        [
          {
            "node": "Market Buy Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Signature Limit BUY": {
      "main": [
        [
          {
            "node": "Execute Limit BUY",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Signature MarketBuy": {
      "main": [
        [
          {
            "node": "Execute MarketBuy",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Signature OpenOrder": {
      "main": [
        [
          {
            "node": "Get Open Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CancelAllOrder Query": {
      "main": [
        [
          {
            "node": "Signature Cancel All Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MarketSell Parameter": {
      "main": [
        [
          {
            "node": "Market Sell Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Signature Limit SELL": {
      "main": [
        [
          {
            "node": "Execute Limit SELL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Signature MarketSell": {
      "main": [
        [
          {
            "node": "Execute MarketSell",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Signature Get Account": {
      "main": [
        [
          {
            "node": "Get Account Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cancel All Order Params": {
      "main": [
        [
          {
            "node": "CancelAllOrder Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Signature Cancel All Order": {
      "main": [
        [
          {
            "node": "Cancell All Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Set Credentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 财务

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量30
分类1
节点类型5
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Todsaporn Sangboon

Todsaporn Sangboon

@nolifelover

Teaching AI & Automation for devs, teams & business owners. Sharing real-world workflows & tools to work smarter with n8n. Follow for weekly tips — Diary of a Dev 🧠✨

外部链接
在 n8n.io 查看

分享此工作流