API Reference
DBot OfficialDBot DashboardPricing

多钱包快速买卖(WS)

用于同时使用多个钱包进行快速买入和卖出

FreePlusProEnterprise积分消耗
0

URL

wss://api-bot-v1.dbotx.com/trade/ws/

说明

为保证WebSocket连接的可用性和稳定性,需要至少每1分钟(建议每30-55秒)进行一次心跳订阅,否则系统会自动断开超时链接

请求示例

{
    "id": 1761291309, // 调用id,响应结果返回相同ID
    "method": "createSwapOrdersMultiWallet", // 调用创建多钱包快速买卖方法
    "params": {
        "chain": "solana", // 链 (solana/ethereum/base/bsc/tron)
        "pair": "BAS6Cv5qG2FnEQ8W1wXKGfU2r6MFAiSdgGgkUM7NsStE", // 需要买入/卖出的代币地址或交易对地址
        "walletIdList": [
            "mglqkeq5009dol",
            "mglnkaeh0009pd"
        ], // 使用的钱包的id列表,可通过“钱包信息 API”获取,最多5个钱包
        "type": "buy", // 交易类型,buy或sell
        "customFeeAndTip": false, // "true"表示优先费 (priorityFee) 和贿赂费 (jitoTip) 两个字段均有效,系统将按填写的值执行交易 (null表示自动优先费/自动贿赂费),"false"表示高速模式下只有优先费 (priorityFee) 有效,防夹模式下只有贿赂费 (jitoTip) 有效,系统将自动进行分配
        "priorityFee": "", // 优先费 (SOL),对Solana有效,空字符串表示使用自动优先费
        "gasFeeDelta": 5, // 额外增加的gas (Gwei),对EVM链有效
        "maxFeePerGas": 100, // 基础gas超过此值时将不进行交易 (Gwei),对EVM链有效
        "jitoEnabled": true, // "true"表示启用防夹模式 (Solana & Ethereum & Bsc)
        "jitoTip": 0.001, // 防夹模式使用的贿赂费 (Solana),"jitoEnabled"或"customFeeAndTip"为true时必填 (null表示自动优先费/自动贿赂费)
        "maxSlippage": 0.1, // 最大滑点(0.00-1.00),买入时表示实际成交价格和期望价格之间的差距,卖出时表示期望价格和实际成交价格之间的差距,相差倍数=1/(1-滑点),0.5即最多接受2倍价差,1 即不限制价差
        "concurrentNodes": 2, // 并发节点数(1-3)
        "retries": 1, // 失败后的重试次数(0-10)
        "minAmount": 100, // 最小买入金额(ETH/SOL/BNB/TRX),"type"为"buy"时,和"maxAmount"至少填写一个,实际买入金额介于最大和最小买入金额之间,填写的两个值相等时,表示全部买入此金额
        "maxAmount": 100, // 最大买入金额(ETH/SOL/BNB/TRX),"type"为"buy"时,和"minAmount"至少填写一个,实际买入金额介于最大和最小买入金额之间,填写的两个值相等时,表示全部买入此金额
        "sellPercent": 0.5, // 卖出比例(0.00-1.00),"type"为"sell"时必填,所有钱包都会按此比例卖出代币
        "stopEarnPercent": 0.5, // 止盈比例,0.5表示上涨50%时卖出,"null"表示不启用止盈
        "stopLossPercent": 0.5, // 止损比例(0.00-1.00),0.5表示下跌50%时卖出,"null"表示不启用止损
        "stopEarnGroup": [
            { "pricePercent": 0.2, "amountPercent": 0.5 },
            { "pricePercent": 0.8, "amountPercent": 1 }
        ], // 止盈分组,type为“buy”时有效,最多支持设置6个,"null"表示不启用止盈,若同时设置了"stopEarnGroup"和"stopEarnPercent",则"stopEarnPercent"将失效;pricePercent表示价格涨跌百分比 (0.5表示50%),在止盈分组里表示上涨多少卖出;amountPercent表示卖出比例 (0-1,0.5表示50%),例如涨100%卖50%,涨200%全卖,卖出比例需要设置为0.5和1,而不是0.5和0.5
        "stopLossGroup": [
            { "pricePercent": 0.2, "amountPercent": 0.5 },
            { "pricePercent": 0.8, "amountPercent": 1 }
        ], // 止损分组,type为“buy”时有效,最多支持设置6个,"null"表示不启用止损,若同时设置了"stopLossGroup"和"stopLossPercent",则"stopLossPercent"将失效;pricePercent表示价格涨跌百分比 (0.5表示50%),在止损分组里表示下跌多少卖出;amountPercent表示卖出比例 (0-1,0.5表示50%),例如涨100%卖50%,涨200%全卖,卖出比例需要设置为0.5和1,而不是0.5和0.5
        "trailingStopGroup": [
            { "pricePercent": 0.2, "amountPercent": 1 }
        ], // 移动止盈止损分组,在快速买卖的type为“buy”,以及跟单卖出模式为“mixed”或“only_pnl”时有效,当前仅支持设置1组,"null"表示不启用移动止盈止损;pricePercent表示回撤比例,表示回撤多少时卖出(不能大于等于1);amountPercent表示卖出比例 (0-1,0.5表示50%),例如涨100%卖50%,涨200%全卖,卖出比例需要设置为0.5和1,而不是0.5和0.5
        "pnlOrderExpireDelta": 43200000, // 止盈止损任务的过期时间,最大值为432000000 (毫秒)
        "pnlOrderExpireExecute": false, // "true"表示止盈止损任务创建后若有效期内未触发,则在任务结束时自动执行
        "pnlOrderUseMidPrice": false, // "true"表示启用防插针模式,将使用1秒内的中间价格作为触发价,会尽可能但无法100%保证避免插针
        "pnlCustomConfigEnabled": true, // "true"表示将使用自定义参数创建止盈止损任务,否则将使用买入的参数
        "pnlCustomConfig": {
            "customFeeAndTip": false, // "true"表示优先费 (priorityFee) 和贿赂费 (jitoTip) 两个字段均有效,系统将按填写的值执行交易 (null表示自动优先费/自动贿赂费),"false"表示高速模式下只有优先费 (priorityFee) 有效,防夹模式下只有贿赂费 (jitoTip) 有效,系统将自动进行分配
            "priorityFee": "", // 优先费 (SOL),对Solana有效,空字符串表示使用自动优先费
            "gasFeeDelta": 5, // 额外增加的gas (Gwei),对EVM链有效
            "maxFeePerGas": 100, // 基础gas超过此值时将不进行交易 (Gwei),对EVM链有效
            "jitoEnabled": true, // "true"表示启用防夹模式 (Solana & Ethereum & Bsc)
            "jitoTip": 0.001, // 防夹模式使用的贿赂费 (Solana),"jitoEnabled"或"customFeeAndTip"为true时必填 (null表示自动优先费/自动贿赂费)
            "maxSlippage": 0.1, // 最大滑点(0.00-1.00),买入时表示实际成交价格和期望价格之间的差距,卖出时表示期望价格和实际成交价格之间的差距,相差倍数=1/(1-滑点),0.5即最多接受2倍价差,1 即不限制价差
            "concurrentNodes": 2, // 并发节点数(1-3)
            "retries": 1 // 失败后的重试次数(0-10)
        }
    }
}

响应数据

{
    "method": "rpcResponse", // rpc响应
    "id": 1761291309, // 调用id
    "result": {
        "err": false, // 是否发生错误
        "res": [
            "mh36i0nm0009mv", // 快速买卖任务ID
            "mh36i0nn0009co"
        ] 
    }
}

以NodeJS为例

const WebSocket = require('ws')

function main() {
  const ws = new WebSocket('wss://api-data-v1.dbotx.com/trade/ws/', {
    headers: {
      'x-api-key': 'YOUR_API_KEY',
    },
  })

  ws.on('open', () => {
    ws.send(
      JSON.stringify({
        "id": 1761291309,
        "method": "createSwapOrdersMultiWallet",
        "params": {
          "chain": "solana",
          "pair": "BAS6Cv5qG2FnEQ8W1wXKGfU2r6MFAiSdgGgkUM7NsStE",
          "walletIdList": [
            "mglqkeq5009dol",
            "mglnkaeh0009pd"
          ],
          "type": "buy",
          "customFeeAndTip": false,
          "priorityFee": "",
          "gasFeeDelta": 5,
          "maxFeePerGas": 100,
          "jitoEnabled": true,
          "jitoTip": 0.001,
          "maxSlippage": 0.1,
          "concurrentNodes": 2,
          "retries": 1,
          "minAmount": 100,
          "maxAmount": 100,
          "sellPercent": 0.5,
          "stopEarnPercent": 0.5,
          "stopLossPercent": 0.5,
          "stopEarnGroup": [
            { "pricePercent": 0.2, "amountPercent": 0.5 },
            { "pricePercent": 0.8, "amountPercent": 1 }
          ],
          "stopLossGroup": [
            { "pricePercent": 0.2, "amountPercent": 0.5 },
            { "pricePercent": 0.8, "amountPercent": 1 }
          ],
          "trailingStopGroup": [
            { "pricePercent": 0.2, "amountPercent": 1 }
          ],
          "pnlOrderExpireDelta": 43200000,
          "pnlOrderExpireExecute": false,
          "pnlOrderUseMidPrice": false,
          "pnlCustomConfigEnabled": true,
          "pnlCustomConfig": {
            "customFeeAndTip": false,
            "priorityFee": "",
            "gasFeeDelta": 5,
            "maxFeePerGas": 100,
            "jitoEnabled": true,
            "jitoTip": 0.001,
            "maxSlippage": 0.1,
            "concurrentNodes": 2,
            "retries": 1
          }
        }
      })
    )

    setInterval(() => {
      ws.ping()
    }, 30000)
  })

  ws.on('message', res => {
    console.log('res:', res.toString('utf-8'))
  })
}

main()

以Python为例

import asyncio
import websockets
import json

async def main():
    uri = "wss://api-data-v1.dbotx.com/trade/ws/"
    headers = {"x-api-key": "YOUR_API_KEY"}
    msg = {
        "id": 1761291309, 
        "method": "createSwapOrdersMultiWallet",
        "chain": "solana",
        "pair": "BAS6Cv5qG2FnEQ8W1wXKGfU2r6MFAiSdgGgkUM7NsStE",
        "walletIdList": [
            "mglqkeq5009dol",
            "mglnkaeh0009pd"
        ],
        "type": "buy",
        "customFeeAndTip": false,
        "priorityFee": "",
        "gasFeeDelta": 5,
        "maxFeePerGas": 100,
        "jitoEnabled": true,
        "jitoTip": 0.001,
        "maxSlippage": 0.1,
        "concurrentNodes": 2,
        "retries": 1,
        "minAmount": 100,
        "maxAmount": 100,
        "sellPercent": 0.5,
        "stopEarnPercent": 0.5,
        "stopLossPercent": 0.5,
        "stopEarnGroup": [
            { "pricePercent": 0.2, "amountPercent": 0.5 },
            { "pricePercent": 0.8, "amountPercent": 1 }
        ],
        "stopLossGroup": [
            { "pricePercent": 0.2, "amountPercent": 0.5 },
            { "pricePercent": 0.8, "amountPercent": 1 }
        ],
        "trailingStopGroup": [
            { "pricePercent": 0.2, "amountPercent": 1 }
        ],
        "pnlOrderExpireDelta": 43200000,
        "pnlOrderExpireExecute": false,
        "pnlOrderUseMidPrice": false,
        "pnlCustomConfigEnabled": true,
        "pnlCustomConfig": {
            "customFeeAndTip": false,
            "priorityFee": "",
            "gasFeeDelta": 5,
            "maxFeePerGas": 100,
            "jitoEnabled": true,
            "jitoTip": 0.001,
            "maxSlippage": 0.1,
            "concurrentNodes": 2,
            "retries": 1
        }
    }

    async with websockets.connect(uri, additional_headers=headers) as ws:
        await ws.send(json.dumps(msg))
        async def keep_alive():
            while True:
                await ws.ping()
                await asyncio.sleep(30)

        async def listen_for_messages():
            async for message in ws:
                print(message)

        await asyncio.gather(keep_alive(), listen_for_messages())

if __name__ == "__main__":
    asyncio.run(main())

请求参数可视化参考