@bbigu0898/copy-trading-mcp-server
Version:
跟单交易 MCP Server - 支持创建和管理复杂的跟单任务,自动跟随其他用户的交易策略
81 lines • 2.52 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DbotCopyTradingClient = void 0;
const axios_1 = __importDefault(require("axios"));
class DbotCopyTradingClient {
client;
apiKey;
baseUrl;
constructor(apiKey, baseUrl = 'https://api-bot-v1.dbotx.com') {
this.apiKey = apiKey || process.env.DBOT_API_KEY;
if (!this.apiKey) {
throw new Error('请设置 DBOT_API_KEY 环境变量');
}
this.baseUrl = baseUrl;
this.client = axios_1.default.create({
baseURL: this.baseUrl,
headers: {
'X-API-KEY': this.apiKey,
'Content-Type': 'application/json',
},
timeout: 30000,
});
}
/**
* 创建跟单交易任务
*/
async createCopyTrading(request) {
const url = '/automation/follow_order';
const response = await this.client.post(url, request);
return response.data;
}
/**
* 编辑跟单交易任务
*/
async editCopyTrading(request) {
const url = '/automation/follow_order';
const response = await this.client.post(url, request);
return response.data;
}
/**
* 开关跟单交易任务
*/
async switchCopyTrading(request) {
const url = '/automation/follow_order';
const data = {
id: request.id,
enabled: request.enabled,
closePnlOrder: request.closePnlOrder
};
const response = await this.client.patch(url, data);
return response.data;
}
/**
* 删除跟单交易任务
*/
async deleteCopyTrading(request) {
const url = `/automation/follow_order/${request.id}`;
const params = {
deletePnlOrder: request.deletePnlOrder
};
const response = await this.client.delete(url, { params });
return response.data;
}
/**
* 获取跟单任务列表 (如果API支持的话)
*/
async getCopyTradingTasks(page = 0, size = 20) {
const url = '/automation/follow_orders';
const params = {
page,
size,
};
const response = await this.client.get(url, { params });
return response.data;
}
}
exports.DbotCopyTradingClient = DbotCopyTradingClient;
//# sourceMappingURL=client.js.map