OpenMM Exchange Setup
Interactive guide for configuring exchange API credentials in OpenMM.
When to Use
Use this skill when:
- - Setting up OpenMM for the first time
- Adding a new exchange
- Troubleshooting connection issues
Supported Exchanges
| Exchange | Min Order | Credentials Required |
|---|
| MEXC | 1 USDT | API key + Secret |
| Gate.io |
1 USDT | API key + Secret |
| Bitget | 1 USDT | API key + Secret + Passphrase |
| Kraken | 5 EUR/USD | API key + Secret |
Setup Workflow
Step 1: Create API Keys
Guide user to the exchange's API management page:
CODEBLOCK0
Step 2: Configure Permissions
Required permissions for each exchange:
MEXC:
- - Enable Spot Trading
- Enable Reading
- Disable Withdrawals (safety)
- IP whitelist recommended
Gate.io:
- - Spot Trade
- Spot Read
- No Withdraw permission
- IP whitelist recommended
Kraken:
- - Query Funds
- Query Open Orders & Trades
- Create & Modify Orders
- No Withdraw permission
Bitget:
- - Trade
- Read Only
- No Transfer permission
- Note the Passphrase — it is set when creating the API key
Step 3: Set Environment Variables
OpenMM uses environment variables for credentials. Add them to your .env file or export in your shell:
CODEBLOCK1
Or create a .env file in the project root:
CODEBLOCK2
Step 4: Verify Connection
Test that credentials work by checking balances:
CODEBLOCK3
Step 5: Test Market Data
Confirm market data access:
CODEBLOCK4
MCP Server Setup
To use OpenMM as an MCP server, add to your MCP client config:
CODEBLOCK5
Only include env vars for exchanges you want to use.
Troubleshooting
"credentials not found"
- - Verify environment variables are set: INLINECODE2
- Check
.env file is in the correct directory - Ensure variable names match exactly (e.g.
MEXC_SECRET not MEXC_SECRET_KEY)
"credentials validation failed" (Bitget)
- - Verify all three vars:
BITGET_API_KEY, BITGET_SECRET, INLINECODE8 - The passphrase is set when creating the API key on Bitget
"authentication failed" (Kraken)
- - Verify
KRAKEN_API_KEY and INLINECODE10 - Check key permissions on Kraken API settings page
"Timestamp Error"
- - System clock may be out of sync
- Run: INLINECODE11
"Rate Limited"
- - Reduce request frequency
- Check exchange's rate limit docs
Security Best Practices
- 1. Never enable withdrawals — trading doesn't need it
- Use IP whitelisting — restrict to your server's IP
- Never commit
.env files — add .env to INLINECODE14 - Rotate keys periodically — every 90 days recommended
- Use separate keys for testing — don't mix testnet/mainnet
OpenMM 交易所设置
在OpenMM中配置交易所API凭证的交互式指南。
何时使用
在以下情况下使用此技能:
- - 首次设置OpenMM
- 添加新的交易所
- 排查连接问题
支持的交易所
| 交易所 | 最小订单 | 所需凭证 |
|---|
| MEXC | 1 USDT | API密钥 + 密钥 |
| Gate.io |
1 USDT | API密钥 + 密钥 |
| Bitget | 1 USDT | API密钥 + 密钥 + 密码短语 |
| Kraken | 5 EUR/USD | API密钥 + 密钥 |
设置工作流程
步骤1:创建API密钥
引导用户访问交易所的API管理页面:
MEXC: https://www.mexc.com/ucenter/api
Gate.io: https://www.gate.io/myaccount/apikeys
Kraken: https://www.kraken.com/u/security/api
Bitget: https://www.bitget.com/account/newapi
步骤2:配置权限
每个交易所所需的权限:
MEXC:
- - 启用现货交易
- 启用读取
- 禁用提现(安全考虑)
- 建议设置IP白名单
Gate.io:
Kraken:
- - 查询资金
- 查询未成交订单与交易
- 创建与修改订单
- 无提现权限
Bitget:
- - 交易
- 只读
- 无转账权限
- 注意密码短语——在创建API密钥时设置
步骤3:设置环境变量
OpenMM使用环境变量存储凭证。将其添加到您的.env文件或在shell中导出:
bash
MEXC
export MEXC
APIKEY=your
mexcapi_key
export MEXC
SECRET=yourmexc
secretkey
Gate.io
export GATEIO
APIKEY=your
gateioapi_key
export GATEIO
SECRET=yourgateio
secretkey
Bitget(需要密码短语)
export BITGET
APIKEY=your
bitgetapi_key
export BITGET
SECRET=yourbitget
secretkey
export BITGET
PASSPHRASE=yourbitget_passphrase
Kraken
export KRAKEN
APIKEY=your
krakenapi_key
export KRAKEN
SECRET=yourkraken
secretkey
或者在项目根目录创建.env文件:
env
MEXCAPIKEY=yourmexcapi_key
MEXCSECRET=yourmexcsecretkey
GATEIOAPIKEY=yourgateioapi_key
GATEIOSECRET=yourgateiosecretkey
BITGETAPIKEY=yourbitgetapi_key
BITGETSECRET=yourbitgetsecretkey
BITGETPASSPHRASE=yourbitget_passphrase
KRAKENAPIKEY=yourkrakenapi_key
KRAKENSECRET=yourkrakensecretkey
步骤4:验证连接
通过检查余额测试凭证是否有效:
bash
MEXC
openmm balance --exchange mexc
Gate.io
openmm balance --exchange gateio
Bitget
openmm balance --exchange bitget
Kraken
openmm balance --exchange kraken
步骤5:测试市场数据
确认市场数据访问:
bash
openmm ticker --exchange mexc --symbol BTC/USDT
openmm orderbook --exchange kraken --symbol ADA/EUR --limit 5
MCP服务器设置
要将OpenMM用作MCP服务器,请添加到您的MCP客户端配置:
json
{
mcpServers: {
openmm: {
command: npx,
args: [@qbtlabs/openmm-mcp],
env: {
MEXCAPIKEY: your_key,
MEXCSECRET: yoursecret,
KRAKENAPIKEY: your_key,
KRAKENSECRET: yoursecret
}
}
}
}
仅包含您要使用的交易所的环境变量。
故障排除
未找到凭证
- - 验证环境变量是否已设置:echo $MEXCAPIKEY
- 检查.env文件是否在正确的目录中
- 确保变量名称完全匹配(例如MEXCSECRET而非MEXCSECRET_KEY)
凭证验证失败(Bitget)
- - 验证所有三个变量:BITGETAPIKEY、BITGETSECRET、BITGETPASSPHRASE
- 密码短语在Bitget上创建API密钥时设置
身份验证失败(Kraken)
- - 验证KRAKENAPIKEY和KRAKEN_SECRET
- 在Kraken API设置页面检查密钥权限
时间戳错误
- - 系统时钟可能不同步
- 运行:sudo ntpdate time.google.com
请求频率限制
安全最佳实践
- 1. 切勿启用提现——交易不需要此权限
- 使用IP白名单——限制为您的服务器IP
- 切勿提交.env文件——将.env添加到.gitignore
- 定期轮换密钥——建议每90天一次
- 使用单独的密钥进行测试——不要混合测试网/主网