- live/portfolio.py:336 — catch OverflowError alongside ValueError in _end_ts (mktime on out-of-range dates raises OverflowError on Windows; previously crashed the whole window_bets() on certain operator-resolved markets) - live/dashboard.py — open(out,'w',encoding='utf-8') so dashboard.html renders Chinese titles correctly on Windows - .gitignore — ignore session-local artifacts (PolymarketDocumentation-main/, wwf_state.json, live/portfolio.json, etc.) - Add Chinese-language docs: USAGE.md (项目使用手册), live/仪表盘说明.md, live/钱包筛选完整流程.md, 实盘配置.md
5.6 KiB
邮箱登录钱包的实盘配置
对照官方 PolymarketDocumentation-main/docs/api-reference/authentication.md 第 349-361 行,签名类型是固定的:
| Sig Type | 值 | 适用 |
|---|---|---|
| EOA | 0 | MetaMask 等浏览器钱包(你自己持有私钥) |
| POLY_PROXY | 1 | Magic Link 邮箱/Google 登录 ← 你这种 |
| GNOSIS_SAFE | 2 | 老 Safe 用户 |
| POLY_1271 | 3 | 新 API 用户推荐(存款钱包,私钥完全自管) |
官方 Tip:
New API users should use deposit wallets with POLY_1271.新用户建议用 deposit wallet (signature_type=3)。如果你已经有邮箱钱包、不想动现有余额,走路径 A;想干净开始或风险更可控,走路径 B。
路径 A:保留现有邮箱钱包(signature_type=1)
1) 拿到私钥——官方 docs/polymarket-learn/FAQ/how-to-export-private-key.md 写得很清楚:
Exporting your private key on Magic.Link. This process is applicable if you've signed up via email. Access the Export Link while signed into Polymarket: https://reveal.magic.link/polymarket Sign-in on Magic.Link → Export Private Key. Once revealed, you should store it somewhere safe.
操作步骤:
- 浏览器登录 polymarket.com(已登录状态)
- 访问 https://reveal.magic.link/polymarket
- 用你的邮箱走 Magic.link 登录
- 点 "Export Private Key"
- 看到一个
0x...的 64 位十六进制私钥,离线保存(密码管理器 / 加密文件,不要 commit)
2) 拿到 funder address——访问 https://polymarket.com/settings 看你的 Polygon profile address。这个就是你 LIVE_FUNDER_ADDRESS(USDC 实际存放的代理合约地址)。
3) 填环境变量(不要写进 JSON):
export LIVE_PRIVATE_KEY=0x... # 上一步导出的私钥
export LIVE_FUNDER_ADDRESS=0x... # polymarket.com/settings 显示的地址
export LIVE_SIGNATURE_TYPE=1 # POLY_PROXY,邮箱登录固定值
export LIVE_CONFIRM="I understand real money is at risk"
4) config.live.json 改两处:
"mode": "live",
"bankroll_usd": 22.28, ← 改成你邮箱钱包里实际 USDC.e 余额(启动时 copybot 会和链上比对)
"live": {
- "private_key": "",
- "funder_address": "",
- "signature_type": 1,
+ "private_key": "", ← 留空,靠 env 注入
+ "funder_address": "", ← 留空,靠 env 注入
+ "signature_type": 1, ← 邮箱登录 = 1
"order_type": "FAK",
...
},
路径 B:新建 deposit wallet(signature_type=3,更推荐)
PolymarketDocumentation-main/docs/api-reference/authentication.md 第 354 行 + Tip:
POLY_1271|3| Deposit wallet flow for new API users. The funder is the deposit wallet address and orders are validated through ERC-1271.
意思是:你创建一个 Polygon 钱包(MetaMask 私钥),用 deposit flow 把 USDC 存进去,下单时用 ERC-1271 签名校验。具体步骤官方文档的 Deposit Wallet Guide 有,HANDOFF.md 第 239 行 SecureClient.create(private_key) — deposit wallet auto-resolves 也是同一个意思。
这种路径私钥你自己完全控制(不像邮箱路径依赖 Magic.link),跟 MetaMask 的 EOA 体验一样,风险更低。
区分两种类型的关键(先确认你是哪一种)
打开 https://polymarket.com/settings 看你自己的 profile address:
0x开头 + 一串 hex- 在 Polymarket 里是真实的 EOA 钱包(不是合约)→ signature_type = 1(POLY_PROXY,邮箱登录)
- 或者是 Gnosis Safe 地址 → signature_type = 2(如果你曾用过 Safe 登录)
最简单的判定方式:如果你的钱包余额页面显示 "Email" 登录、是普通地址(不是 Safe),就是 signature_type=1。
启动
python copybot.py --config config.live.json --live --poll 60
copytrade.py:92注释里写的是0 EOA · 1 email/magic proxy · 2 browser proxy—— 这个注释漏了 type 3(POLY_1271,新 API 用户的 deposit wallet 模式)。但signature_type字段本身是直接透传给py_clob_client.ClobClient(signature_type=...)的(copytrade.py:256),传 1 或 3 都支持,无需改代码。
建议先只读模拟跑一周:python copybot.py --config config.live.json --poll 60(不加 --live,不设 LIVE_CONFIRM,看实盘钱包的对账逻辑和链上 cash-anchor 是否对得上)。对得上再开 --live。
确认了:项目里没有 .env 文件,也没有 .env.example 模板。我上一条消息里把 .env 当作 "方式 2" 提了一句,那是泛指行业惯例,不是说项目里有。抱歉让你去找。
项目实际只有两个相关的模板/示例:
| 文件 | 用途 |
|---|---|
config.example.json |
通用配置示例(应该是 paper 模式或空模板) |
config.live.example.json |
实盘模板,私钥字段已留空——按上一条说的复制成 config.live.json 即可 |
cp config.live.example.json config.live.json
然后私钥/funder/signature_type 通过环境变量(LIVE_PRIVATE_KEY 等)注入,copybot.py:2303-2308 会自动从 env 读,不用碰 JSON。