copy-trading

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Copy Trading - Complete API Reference

复制交易 - 完整API参考

Automatically mirror trades from successful wallets with configurable sizing, delays, and risk controls.
自动镜像成功钱包的交易操作,支持可配置的交易规模、延迟时间及风险控制。

Features

功能特性

  • Follow whale wallets on Polymarket and crypto chains
  • Configurable sizing: Fixed, proportional, or % of portfolio
  • Trade delay to avoid detection and front-running
  • Risk limits: Max position, daily loss limits
  • Stop-loss / Take-profit monitoring with auto-exit

  • 追踪巨鲸钱包:支持Polymarket及加密货币链上的巨鲸钱包
  • 可配置交易规模:固定金额、比例模式或占投资组合的百分比
  • 交易延迟:避免被侦测及抢先交易
  • 风险限额:最大持仓、每日亏损限额
  • 止盈/止损监控:触发时自动平仓

Chat Commands

聊天命令

Following Wallets

追踪钱包

/copy follow <address>                      # Start following a wallet
/copy follow 0x1234... --size 100           # Follow with $100 fixed size
/copy follow 0x1234... --size 50%           # Follow with 50% of their size
/copy follow 0x1234... --delay 30           # 30 second delay before copying

/copy unfollow <address>                    # Stop following
/copy list                                  # List followed wallets
/copy status                                # Show copy trading status
/copy follow <address>                      # 开始追踪钱包
/copy follow 0x1234... --size 100           # 以100美元固定规模追踪
/copy follow 0x1234... --size 50%           # 以目标钱包50%的规模追踪
/copy follow 0x1234... --delay 30           # 延迟30秒后再复制交易

/copy unfollow <address>                    # 停止追踪钱包
/copy list                                  # 列出已追踪的钱包
/copy status                                # 查看复制交易状态

Sizing Modes

规模模式

/copy size <address> fixed 100              # Always trade $100
/copy size <address> proportional 0.5       # 50% of their size
/copy size <address> portfolio 5%           # 5% of your portfolio
/copy size <address> fixed 100              # 每次交易固定为100美元
/copy size <address> proportional 0.5       # 为目标交易规模的50%
/copy size <address> portfolio 5%           # 占您投资组合的5%

Risk Controls

风险控制

/copy limits --max-position 1000            # Max $1000 per position
/copy limits --daily-loss 500               # Stop after $500 daily loss
/copy limits --max-trades 20                # Max 20 trades per day

/copy sl <address> 10%                      # 10% stop-loss on copies
/copy tp <address> 20%                      # 20% take-profit on copies
/copy limits --max-position 1000            # 单仓位最大1000美元
/copy limits --daily-loss 500               # 每日亏损达500美元时停止交易
/copy limits --max-trades 20                # 每日最多20笔交易

/copy sl <address> 10%                      # 复制交易设置10%止损
/copy tp <address> 20%                      # 复制交易设置20%止盈

Discovery

发现优质交易者

/copy top 10                                # Top 10 traders to copy
/copy top 10 --min-winrate 60               # Min 60% win rate
/copy top 10 --min-volume 100000            # Min $100k volume
/copy analyze <address>                     # Analyze a trader's performance

/copy top 10                                # 获取Top 10可复制的交易者
/copy top 10 --min-winrate 60               # 胜率不低于60%的Top 10交易者
/copy top 10 --min-volume 100000            # 交易量不低于10万美元的Top 10交易者
/copy analyze <address>                     # 分析某一交易者的表现

TypeScript API Reference

TypeScript API参考

Create Copy Trading Service

创建复制交易服务

typescript
import { createCopyTradingService } from 'clodds/trading/copy-trading';

const copyTrader = createCopyTradingService({
  // Polymarket credentials
  polymarket: {
    apiKey: process.env.POLY_API_KEY,
    apiSecret: process.env.POLY_API_SECRET,
    passphrase: process.env.POLY_API_PASSPHRASE,
    privateKey: process.env.PRIVATE_KEY,
  },

  // Default settings
  defaults: {
    sizingMode: 'proportional',
    sizingValue: 0.5,           // 50% of their size
    delaySeconds: 15,           // 15s delay
    maxPositionSize: 1000,      // $1000 max
    stopLossPct: 10,            // 10% stop-loss
    takeProfitPct: 25,          // 25% take-profit
  },

  // Risk limits
  limits: {
    maxDailyLoss: 500,
    maxDailyTrades: 20,
    maxTotalExposure: 5000,
  },
});
typescript
import { createCopyTradingService } from 'clodds/trading/copy-trading';

const copyTrader = createCopyTradingService({
  // Polymarket 凭证
  polymarket: {
    apiKey: process.env.POLY_API_KEY,
    apiSecret: process.env.POLY_API_SECRET,
    passphrase: process.env.POLY_API_PASSPHRASE,
    privateKey: process.env.PRIVATE_KEY,
  },

  // 默认设置
  defaults: {
    sizingMode: 'proportional',
    sizingValue: 0.5,           // 目标规模的50%
    delaySeconds: 15,           // 15秒延迟
    maxPositionSize: 1000,      // 最大1000美元
    stopLossPct: 10,            // 10%止损
    takeProfitPct: 25,          // 25%止盈
  },

  // 风险限额
  limits: {
    maxDailyLoss: 500,
    maxDailyTrades: 20,
    maxTotalExposure: 5000,
  },
});

Follow Wallets

追踪钱包

typescript
// Follow a wallet with default settings
await copyTrader.follow('0x1234...');

// Follow with custom settings
await copyTrader.follow('0x1234...', {
  sizingMode: 'fixed',
  sizingValue: 100,            // $100 per trade
  delaySeconds: 30,            // 30s delay
  stopLossPct: 15,             // 15% stop-loss
  takeProfitPct: 30,           // 30% take-profit

  // Filters
  minTradeSize: 50,            // Only copy trades > $50
  maxTradeSize: 5000,          // Skip trades > $5000
  markets: ['politics'],       // Only copy politics markets
});

// Unfollow
await copyTrader.unfollow('0x1234...');

// List followed
const followed = await copyTrader.listFollowed();
typescript
// 使用默认设置追踪钱包
await copyTrader.follow('0x1234...');

// 使用自定义设置追踪钱包
await copyTrader.follow('0x1234...', {
  sizingMode: 'fixed',
  sizingValue: 100,            // 每笔交易100美元
  delaySeconds: 30,            // 30秒延迟
  stopLossPct: 15,             // 15%止损
  takeProfitPct: 30,           // 30%止盈

  // 过滤条件
  minTradeSize: 50,            // 仅复制金额大于50美元的交易
  maxTradeSize: 5000,          // 跳过金额大于5000美元的交易
  markets: ['politics'],       // 仅复制政治类市场的交易
});

// 停止追踪
await copyTrader.unfollow('0x1234...');

// 列出已追踪的钱包
const followed = await copyTrader.listFollowed();

Sizing Modes

规模模式

typescript
// Fixed: Always trade same dollar amount
await copyTrader.follow(address, {
  sizingMode: 'fixed',
  sizingValue: 100,  // Always $100
});

// Proportional: Percentage of their trade size
await copyTrader.follow(address, {
  sizingMode: 'proportional',
  sizingValue: 0.5,  // 50% of their size
});

// Portfolio: Percentage of your portfolio
await copyTrader.follow(address, {
  sizingMode: 'portfolio',
  sizingValue: 0.05,  // 5% of portfolio per trade
});
typescript
// 固定模式:每次交易金额相同
await copyTrader.follow(address, {
  sizingMode: 'fixed',
  sizingValue: 100,  // 固定100美元
});

// 比例模式:目标交易规模的百分比
await copyTrader.follow(address, {
  sizingMode: 'proportional',
  sizingValue: 0.5,  // 目标规模的50%
});

// 投资组合模式:占您投资组合的百分比
await copyTrader.follow(address, {
  sizingMode: 'portfolio',
  sizingValue: 0.05,  // 每笔交易占投资组合的5%
});

Event Handling

事件处理

typescript
copyTrader.on('trade_copied', (event) => {
  console.log(`Copied ${event.side} on ${event.market}`);
  console.log(`Original: $${event.originalSize}, Copied: $${event.copiedSize}`);
});

copyTrader.on('stop_loss_triggered', (event) => {
  console.log(`Stop-loss hit on ${event.market}`);
  console.log(`Loss: $${event.loss}`);
});

copyTrader.on('take_profit_triggered', (event) => {
  console.log(`Take-profit hit on ${event.market}`);
  console.log(`Profit: $${event.profit}`);
});

copyTrader.on('limit_reached', (event) => {
  console.log(`Limit reached: ${event.type}`);
});
typescript
copyTrader.on('trade_copied', (event) => {
  console.log(`已复制${event.side}交易,市场:${event.market}`);
  console.log(`原交易规模:${event.originalSize}美元,复制规模:${event.copiedSize}美元`);
});

copyTrader.on('stop_loss_triggered', (event) => {
  console.log(`${event.market}市场触发止损`);
  console.log(`亏损金额:${event.loss}美元`);
});

copyTrader.on('take_profit_triggered', (event) => {
  console.log(`${event.market}市场触发止盈`);
  console.log(`盈利金额:${event.profit}美元`);
});

copyTrader.on('limit_reached', (event) => {
  console.log(`已达限额:${event.type}`);
});

Start/Stop

启动/停止

typescript
// Start copy trading (monitors followed wallets)
await copyTrader.start();

// Stop copy trading
await copyTrader.stop();

// Get status
const status = copyTrader.getStatus();
console.log(`Following: ${status.followedCount} wallets`);
console.log(`Today's P&L: $${status.dailyPnl}`);
console.log(`Active positions: ${status.activePositions}`);
typescript
// 启动复制交易(监控已追踪的钱包)
await copyTrader.start();

// 停止复制交易
await copyTrader.stop();

// 获取状态
const status = copyTrader.getStatus();
console.log(`已追踪钱包数量:${status.followedCount}`);
console.log(`今日盈亏:${status.dailyPnl}美元`);
console.log(`活跃持仓:${status.activePositions}`);

Find Best Traders

寻找最佳交易者

typescript
import { findBestAddressesToCopy } from 'clodds/trading/copy-trading';

// Find top traders
const topTraders = await findBestAddressesToCopy({
  minWinRate: 0.6,           // 60%+ win rate
  minVolume: 100000,         // $100k+ volume
  minTrades: 50,             // 50+ trades
  timeframeDays: 30,         // Last 30 days
  limit: 10,                 // Top 10
});

for (const trader of topTraders) {
  console.log(`${trader.address}`);
  console.log(`  Win rate: ${(trader.winRate * 100).toFixed(1)}%`);
  console.log(`  Volume: $${trader.totalVolume.toLocaleString()}`);
  console.log(`  P&L: $${trader.pnl.toLocaleString()}`);
  console.log(`  Trades: ${trader.tradeCount}`);
}
typescript
import { findBestAddressesToCopy } from 'clodds/trading/copy-trading';

// 寻找优质交易者
const topTraders = await findBestAddressesToCopy({
  minWinRate: 0.6,           // 胜率不低于60%
  minVolume: 100000,         // 交易量不低于10万美元
  minTrades: 50,             // 交易次数不低于50次
  timeframeDays: 30,         // 近30天数据
  limit: 10,                 // 取Top 10
});

for (const trader of topTraders) {
  console.log(`${trader.address}`);
  console.log(`  胜率:${(trader.winRate * 100).toFixed(1)}%`);
  console.log(`  交易量:${trader.totalVolume.toLocaleString()}美元`);
  console.log(`  盈亏:${trader.pnl.toLocaleString()}美元`);
  console.log(`  交易次数:${trader.tradeCount}`);
}

Analyze Trader

分析交易者

typescript
const analysis = await copyTrader.analyzeTrader('0x1234...');

console.log(`Win rate: ${analysis.winRate}%`);
console.log(`Avg trade size: $${analysis.avgTradeSize}`);
console.log(`Best market: ${analysis.bestMarket}`);
console.log(`Worst market: ${analysis.worstMarket}`);
console.log(`Avg hold time: ${analysis.avgHoldTime} hours`);
console.log(`Sharpe ratio: ${analysis.sharpeRatio}`);

typescript
const analysis = await copyTrader.analyzeTrader('0x1234...');

console.log(`胜率:${analysis.winRate}%`);
console.log(`平均交易规模:${analysis.avgTradeSize}美元`);
console.log(`最佳交易市场:${analysis.bestMarket}`);
console.log(`最差交易市场:${analysis.worstMarket}`);
console.log(`平均持仓时间:${analysis.avgHoldTime}小时`);
console.log(`夏普比率:${analysis.sharpeRatio}`);

Risk Management

风险管理

Stop-Loss Monitoring

止损监控

Copy trading includes automatic stop-loss monitoring with 5-second price polling:
typescript
// Configure stop-loss per followed wallet
await copyTrader.follow(address, {
  stopLossPct: 10,  // Exit at 10% loss
});

// Or set global stop-loss
copyTrader.setGlobalStopLoss(15);  // 15% for all positions
复制交易包含自动止损监控,价格轮询间隔为5秒:
typescript
// 为单个已追踪钱包配置止损
await copyTrader.follow(address, {
  stopLossPct: 10,  // 亏损达10%时平仓
});

// 或设置全局止损
copyTrader.setGlobalStopLoss(15);  // 所有持仓设置15%止损

Take-Profit Monitoring

止盈监控

typescript
// Configure take-profit per followed wallet
await copyTrader.follow(address, {
  takeProfitPct: 25,  // Exit at 25% profit
});

// Trailing take-profit
await copyTrader.follow(address, {
  trailingTakeProfit: true,
  trailingPct: 5,  // Trail by 5%
});
typescript
// 为单个已追踪钱包配置止盈
await copyTrader.follow(address, {
  takeProfitPct: 25,  // 盈利达25%时平仓
});

// 移动止盈
await copyTrader.follow(address, {
  trailingTakeProfit: true,
  trailingPct: 5,  // 移动幅度5%
});

Daily Limits

每日限额

typescript
const copyTrader = createCopyTradingService({
  limits: {
    maxDailyLoss: 500,      // Stop after $500 loss
    maxDailyTrades: 20,     // Max 20 trades
    maxTotalExposure: 5000, // Max $5k total exposure
  },
});

typescript
const copyTrader = createCopyTradingService({
  limits: {
    maxDailyLoss: 500,      // 每日亏损达500美元时停止交易
    maxDailyTrades: 20,     // 每日最多20笔交易
    maxTotalExposure: 5000, // 总持仓最大5000美元
  },
});

Best Practices

最佳实践

  1. Start with small sizes - Test with 10-25% proportional sizing
  2. Use delays - 15-30 second delays reduce front-running risk
  3. Set stop-losses - Always use 10-15% stop-loss
  4. Diversify - Follow 3-5 wallets, not just one
  5. Monitor regularly - Check performance daily
  6. Filter markets - Focus on categories you understand
  1. 从小规模开始 - 先以10-25%的比例模式进行测试
  2. 使用延迟功能 - 15-30秒的延迟可降低抢先交易风险
  3. 设置止损 - 始终使用10-15%的止损
  4. 分散追踪 - 追踪3-5个钱包,而非单个
  5. 定期监控 - 每日检查交易表现
  6. 过滤交易市场 - 专注于您熟悉的品类