ZKE交易SDK
官方 ZKE交易所交易SDK 有AI代理支持。
此存储库为与ZKE Exchange交互提供了一个完整的开发人员工具包。
它包括:
•Python交易SDK\ •WebSocket市场数据客户端\ •CLI交易工具\ •用于AI代理的本地MCP服务器\ •OpenClaw插件集成\ •自动安装脚本
SDK使开发人员和AI代理能够与 ZKE现货和期货API安全高效。
______________________________________________________________________
特性
斑点
•市场数据\ •交易\ •钱包余额\ •订单管理\ •资产转移\ •提款历史
期货
•市场数据\ •职位管理\ •订单管理\ •有条件订单\ •利润调整\ •杠杆控制
高级集成
•Python应用程序\ •通过MCP的AI代理\ •OpenClaw插件工具\ •WebSocket实时市场流
______________________________________________________________________
快速开始
安装SDK
curl -s https://raw.githubusercontent.com/ZKE-Exchange/zke-trading-sdk/main/install.sh | bash安装OpenClaw插件
bash <(curl -s "https://raw.githubusercontent.com/ZKE-Exchange/zke-trading-sdk/main/install_openclaw_plugin.sh?v=$RANDOM")______________________________________________________________________
存储库结构
zke-trading-sdk
│
├── main.py
├── mcp_server.py
├── config.example.json
├── requirements.txt
│
├── install.sh
├── install_openclaw_plugin.sh
│
├── tools
│ ├── account_service.py
│ ├── common.py
│ ├── errors.py
│ ├── field_mapper.py
│ ├── formatters.py
│ ├── futures_account_service.py
│ ├── futures_order_service.py
│ ├── futures_private.py
│ ├── futures_public.py
│ ├── futures_service.py
│ ├── margin_order_service.py
│ ├── margin_private.py
│ ├── market_service.py
│ ├── order_service.py
│ ├── spot_private.py
│ ├── spot_public.py
│ ├── symbol_utils.py
│ ├── transfer_service.py
│ ├── withdraw_service.py
│ ├── ws_client.py
│ ├── ws_parser.py
│ └── ws_service.py
│
├── openclaw-plugin
│ ├── src
│ │ ├── index.ts
│ │ ├── python.ts
│ │ └── types.ts
│ │
│ ├── skills
│ │ └── zke_trading
│ │ └── SKILL.md
│ │
│ ├── package.json
│ ├── openclaw.plugin.json
│ └── tsconfig.json
│
├── docs
│ ├── cli.md
│ ├── openclaw.md
│ └── examples
│
└── README.md______________________________________________________________________
配置
创建配置文件
cp config.example.json config.json配置示例
{
"spot": {
"base_url": "https://openapi.zke.com",
"api_key": "YOUR_SPOT_API_KEY",
"api_secret": "YOUR_SPOT_API_SECRET",
"recv_window": 5000
},
"futures": {
"base_url": "https://futuresopenapi.zke.com",
"api_key": "YOUR_FUTURES_API_KEY",
"api_secret": "YOUR_FUTURES_API_SECRET",
"recv_window": 5000
},
"ws": {
"url": "wss://ws.zke.com/kline-api/ws"
}
}创建API密钥
https://www.zke.com/en_US/personal/apiManagement
推荐权限
•阅读\ •贸易
除非需要,否则禁用提款权限。
______________________________________________________________________
CLI使用情况
示例
python main.py ticker BTCUSDT
python main.py depth BTCUSDT
python main.py balance
python main.py positions输出示例
{
"high": "68539.78",
"low": "67446.38",
"last": "67621.67"
}______________________________________________________________________
Python SDK示例
现场示例
from tools.spot_private import SpotPrivateApi
from tools.zke_client import ZKEClient
client = ZKEClient(
base_url="https://openapi.zke.com",
api_key="YOUR_KEY",
api_secret="YOUR_SECRET"
)
spot = SpotPrivateApi(client)
balance = spot.account()
print(balance)______________________________________________________________________
期货示例
from tools.futures_private import FuturesPrivateApi
from tools.zke_client import ZKEClient
client = ZKEClient(
base_url="https://futuresopenapi.zke.com",
api_key="YOUR_KEY",
api_secret="YOUR_SECRET"
)
futures = FuturesPrivateApi(client)
positions = futures.account()
print(positions)______________________________________________________________________
WebSocket支持
模块
tools/ws_client.py
tools/ws_parser.py
tools/ws_service.py支持的流
•自动收报机\ •订单深度\ •贸易流\ •克莱恩
示例
from tools.ws_service import WSService
ws = WSService()
ws.subscribe_ticker("BTCUSDT")
ws.run()______________________________________________________________________
MCP服务器
运行MCP服务器
python mcp_server.py______________________________________________________________________
MCP工具
斑点
zke_get_spot_ticker
zke_get_spot_depth
zke_get_spot_klines
zke_get_spot_account
zke_get_spot_nonzero_balances
zke_get_spot_balance
zke_get_spot_account_by_type
zke_get_spot_open_orders
zke_get_spot_my_trades
zke_get_spot_my_trades_v3
zke_get_spot_history_orders
zke_create_spot_order
zke_cancel_spot_order资产
zke_transfer_spot_to_futures
zke_transfer_futures_to_spot
zke_get_transfer_history
zke_create_withdraw
zke_get_withdraw_history边距
zke_create_margin_order
zke_get_margin_order
zke_cancel_margin_order
zke_get_margin_open_orders
zke_get_margin_my_trades期货
zke_get_futures_ticker
zke_get_futures_index
zke_get_futures_depth
zke_get_futures_klines
zke_get_futures_balance
zke_get_futures_positions
zke_get_futures_order
zke_get_futures_open_orders
zke_get_futures_my_trades
zke_get_futures_order_history
zke_get_futures_profit_history
zke_get_futures_transaction_history
zke_create_futures_order
zke_create_futures_condition_order
zke_cancel_futures_order
zke_cancel_all_futures_orders
zke_edit_futures_position_mode
zke_edit_futures_margin_mode
zke_adjust_futures_position_margin
zke_edit_futures_leverage______________________________________________________________________
OpenClaw插件
安装插件
curl -s https://raw.githubusercontent.com/ZKE-Exchange/zke-trading-sdk/main/install_openclaw_plugin.sh | bash验证
openclaw plugins list预期
ZKE Trading
Status: loaded______________________________________________________________________
重要的OpenClaw设置
编辑
~/.openclaw/openclaw.json集
"tools": {
"profile": "full"
}更新后重新启动OpenClaw。
______________________________________________________________________
建筑
主控程序
AI Agent
│
▼
MCP Server
│
▼
Python SDK
│
├─ REST API
└─ WebSocket开爪
AI Agent
│
▼
OpenClaw Plugin
│
▼
Python SDK
│
├─ REST API
└─ WebSocket______________________________________________________________________
安全通告
永远不要公开您的API密钥。
推荐权限
•阅读\ •贸易
除非必要,否则禁用提款权限。
______________________________________________________________________
ZKE交易所
官方网站
https://www.zke.com
API 文档
https://help.zke.com/api_en/
______________________________________________________________________
许可证
MIT许可证
