Polymarket PnL精准计算:为什么你算的盈亏可能是错的?

marsbit2026-05-02 tarihinde yayınlandı2026-05-02 tarihinde güncellendi

我在 Polymarket 自研自动化交易半年,踩过的最大坑不是策略失灵,是连自己赚了多少钱都算不对。

不是我菜。是 PM 的 PnL 计算本身就是雷区。官方 API 给你的数字是错的,第三方分析网站展示的排名也是错的。你自己写脚本算?大概率还是错的。

偏差有多离谱?排行榜第 3 名 kch123,用错误方法算出来亏 $350 万,实际盈利 $1140 万。不是差几个百分点——是盈亏符号都反了。

这篇把我踩过的每个坑拆开讲。做交易的、写工具的、看排行榜的,迟早会遇到。

坑 1:cashPnl 不包含已结算的盈利

最直觉的做法:拉 /positions 接口,求和 cashPnl(现金盈亏)字段。

拿排行榜前 15 的三个地址实测:

swisstony:cashPnl 求和 +$3.5 万,排行榜实际 +$560 万,差 158 倍

kch123:cashPnl 求和 -$352 万,排行榜实际 +$1140 万,符号反转

gmanas:cashPnl 求和 -$264 万,排行榜实际 +$502 万,符号反转

三个地址,两个盈亏符号直接反了。

原因:/positions 接口返回的 cashPnl 不包含已 closed/redeemed 的 realized PnL。赢了的仓位被自动赎回成 USDC 后,这个 position 就从 API 响应里消失了。留下来的是未结算的持仓——往往以浮亏为主。

你以为在算全部盈亏,其实只拿到了未结算的部分。

坑 2:makerPnl 字段与链上现金流不一致

交易数据 JSONL 里有个 makerPnl(做市盈亏)字段,看名字就是给你算 PnL 用的。别信。

我在做市数据中观察到,SUM(makerPnl) 算出来的数字跟链上现金流核算结果差了一个数量级。具体倍数可能因场景不同而变化,但方向一致:makerPnl 的内部计算逻辑跟实际 USDC 流动对不上。

不管偏差多大,结论一样:不要用这个字段算 PnL。

坑 3:不能按 txHash 单独去重

这个最反直觉。

同一个 txHash(交易哈希)出现了多条记录,正常人第一反应:重复数据,去重。

不能这么做。PM 的 CLOB(链上限价订单簿)在一笔链上交易里可以撮合多个 maker 订单,同一个 txHash 下的多条记录是真实的独立 fill。

我之前按 txHash + asset 去重,BUY 侧少算了 $133。上 Polygon 链验证,一个交易哈希里确实有多个独立的 USDC Transfer event,每条都对应一笔真实成交。

结论:不能按 txHash alone 去重。要算 PnL,直接对 /activity 原始数据求和。

坑 4:offset 翻页有天花板

/activity 接口翻页,用 offset(偏移量)?超过 3000 条直接 400 报错。文档里没写。

上面三个地址全部验证过:GET /activity?offset=3100 返回 HTTP 400,错误信息 max historical activity offset of 3000 exceeded。头部玩家动辄上万笔交易,3000 条根本不够。

用 end 参数(传上一页最后一条的时间戳 - 1)做游标翻页,没有上限。

坑 5:排行榜 PnL 口径差异

你算完一个地址的 PnL,去排行榜一对比,差了一点。

大多数情况下差距在 $10 以内(来自持仓市值的实时波动)。但如果差距明显更大,可能的原因包括:排行榜的聚合窗口、缓存刷新延迟、或者用户绑定了多个 proxy wallet。

实测中,用现金流法算出的单地址 PnL 跟 lb-api 返回值高度一致。如果你的结果差距较大,先检查翻页是否完整(坑 4)、是否用了错误字段(坑 1-2)。

正确做法

试了各种歪路之后,我验证下来最可靠的方法是 Data API 现金流汇总。不用任何预计算字段,直接从原始交易记录算资金进出。

公式:

PnL = SUM(TRADE where side=SELL) + SUM(REDEEM) + SUM(MERGE) + SUM(MAKER_REBATE) + SUM(REWARD) - SUM(TRADE where side=BUY) - SUM(SPLIT) + 持仓市值

· TRADE BUY:花 USDC 买 token(支出)

· TRADE SELL:卖 token 回收 USDC(收入)

· REDEEM:赢的仓位赎回 USDC(收入)

· SPLIT:USDC 铸造成 token 对(支出)

· MERGE:token 对合并回 USDC(收入)

· MAKER_REBATE:Maker 返佣(收入)

· REWARD:奖励/空投(收入)

· 数据来源:

GET /activity?user=&limit=500,用 end 翻页,全量拉取后按类型求和。

· 持仓市值:

GET /positions?user=,size × curPrice。

· 交叉验证:

拿计算结果跟 Polymarket 排行榜 API(lb-api.polymarket.com/profit?window=all&address=X)对比,差 <$10 就算过。差距来自持仓市值的实时波动。

验证:排行榜前 15 实测

用现金流法算完后,拿排行榜 API 交叉验证:

swisstony:现金流法 +$560.1 万,排行榜 +$560.1 万,差距 < $10

kch123:现金流法 +$1139.6 万,排行榜 +$1139.6 万,差距 < $10

gmanas:现金流法 +$502.4 万,排行榜 +$502.4 万,差距 < $10

三个地址误差均在 $10 以内,差距来自持仓市值的实时波动。

方法跑通之后,我拿它分析了上百个头部地址的真实盈亏。那是另一回事了。

汇总

SUM(cashPnl) from /positions → 不行,不含已结算盈利,符号可能反转

makerPnl 字段求和 → 不行,与链上现金流不一致

按 txHash 去重后计算 → 不行,$100+,删了真实 fill

offset 翻页 + 求和 → 不行,数据截断,>3000 报错

Data API 现金流法 → 目前最可靠,<$10

做量化的第一步不是找 alpha。是先确认你算得对。

以上全部来自实盘踩坑,不是理论推导。PM 的 API 随时可能调整行为,建议定期用排行榜 API 交叉验证你的计算结果。

İlgili Okumalar

GPT-5.6 Countdown: Abandon the Illusion of a Single API, Computational Iteration Can't Outpace a Single Page of Compliance

In mid-June, three seemingly independent industry events—the compliance-driven throttling of Fable 5, the open-sourcing of GLM-5.2, and the leaked release timeline for GPT-5.6—are pushing the global AI industry toward a watershed moment. These shifts signal a fundamental restructuring of the industry's underlying logic. First, **"usability" has substantially overtaken "advanced capabilities"** as the primary weight, pushing the global large language model (LLM) supply chain into a "dual-track" phase of controlled closed-source and local open-source coexistence. Second, **the competitive moats of closed-source giants are shifting**. Their technical focus is moving from "language intelligence" toward "spatial intelligence (world models)"—a domain heavily reliant on computing power. Third, faced with常态化 transnational compliance risks, **a "model-agnostic" decoupled design has become a survival necessity for application-layer developers to maintain business continuity.** The article details how Anthropic's Fable 5, despite its advanced engineering feats, was restricted for non-U.S. citizens within 72 hours of launch, highlighting how geopolitical compliance can instantly limit even the most advanced models. In response, the open-source camp, exemplified by Zhipu AI's MIT-licensed GLM-5.2, is gaining market share by offering stable performance improvements and significant cost advantages (up to 70% savings for enterprises), while achieving full adaptation with domestic semiconductor platforms. Meanwhile, closed-source leaders like OpenAI are pivoting. The anticipated GPT-5.6 reportedly shifts focus from language to spatial intelligence and world models, aiming to rebuild a generational gap in areas like 3D understanding, simulation, and industrial design that demand immense compute. The core conclusion is that the LLM supply chain's logic has changed. Enterprises must now evaluate infrastructure based on a composite of technical performance and policy compliance. For developers, complete reliance on a single closed-source API poses unacceptable risk. Implementing a truly model-agnostic architecture—enabling swift switches to compliant, locally deployable open-source alternatives—is no longer just good practice but a fundamental baseline for business continuity.

marsbit2 saat önce

GPT-5.6 Countdown: Abandon the Illusion of a Single API, Computational Iteration Can't Outpace a Single Page of Compliance

marsbit2 saat önce

Is the 'Token Subsidy War' Among AI Giants Almost Over?

The article discusses the ongoing "token subsidy war" among AI giants like OpenAI and Anthropic, questioning whether it's nearing its end. It reveals that current AI subscription prices are heavily subsidized, with some plans offering tokens at up to 70 times the actual cost to attract and retain heavy users, especially developers and enterprises. This strategy mirrors past internet-era subsidy battles, but with a key difference: AI tokens lack "lock-in" effects. Unlike ride-hailing or food delivery apps, users can easily switch between AI providers as APIs become standardized, making it difficult for companies to raise prices post-subsidy. The piece highlights a structural asymmetry in the competition. Giants like Google, with massive advertising revenue, can afford to subsidize tokens indefinitely, akin to using "tokens as a weapon." In contrast, venture-backed companies like OpenAI and Anthropic face pressure to become profitable, especially as they approach IPO. The article cites Google Ventures founder Bill Maris, who suggests Google could slash token prices by 80%, putting immense pressure on competitors. Two potential endgames are presented: the "internet service" model (subsidize, monopolize, then raise prices) and the "utility" model (tokens become a standardized, low-margin commodity like electricity). Given the low switching costs, the latter seems more likely. The competition may not have a single winner but could instead accelerate AI's evolution into a foundational, infrastructure-level technology, akin to a public utility. For now, users continue to benefit from heavily subsidized token costs.

marsbit2 saat önce

Is the 'Token Subsidy War' Among AI Giants Almost Over?

marsbit2 saat önce

Beyond the Stadium: The Profitable Games Surrounding the World Cup

"Beyond the Pitch: The Profit Game Around the World Cup" The FIFA World Cup transcends being a sporting spectacle, evolving into a massive global arena for speculation and profit-seeking. The 2026 tournament has amplified this dynamic, creating a multi-layered ecosystem of financial opportunism alongside the football. **Prediction markets** have surged into the mainstream. Platforms like Polymarket and Kalshi saw trading volumes for World Cup contracts soar, attracting new users with their financial trading model and high-profile, chain-based wealth stories that overshadow traditional sports betting in terms of growth and narrative. However, **traditional sportsbooks** remain the dominant force, leveraging established user habits, legal markets, and comprehensive product offerings to handle the vast majority of speculative wagers, with projections suggesting record-breaking betting volumes. Capital markets also react. **"Concept stocks"** in countries like South Korea and Japan experience volatile price swings based on team performance and anticipated fan spending on items like chicken, beer, and viewing parties, effectively becoming a stock market reflecting fan sentiment. The **ticket resale market** has become a sophisticated arena for arbitrage. Prices fluctuate wildly based on team draws and star power, with sellers sometimes listing tickets they don't yet own in a practice akin to short-selling, while FIFA's own "Right to Buy" tokens add another layer of speculative trading. **Collectibles and merchandise** offer another avenue. Panini sticker albums, with their inherent scarcity and nostalgic value, can become high-value collectibles. Limited-edition or locally themed jerseys command significant premiums on secondary markets, and even counterfeit vendors profit from fans' desire for affordable match-day identity. The **cryptocurrency** space has seen a frenzy of speculative, unauthorized World Cup-themed meme coins on chains like Solana. These tokens, often exploiting team names and player imagery, experience extreme pump-and-dump cycles, creating stories of massive gains for a few early entrants and steep losses for many others. Finally, an entire industry thrives on **providing information and tools** to other speculators. Developers create platforms like SeatSidekick to track ticket inventory and prices, while paid Telegram groups and subscriptions sell betting tips and predictions, monetizing the widespread desire for an informational edge. In essence, the World Cup has become a compressed, global laboratory for speculation. While the games determine champions on the field, a parallel, complex network of financial transactions—spanning prediction contracts, bets, stocks, tickets, collectibles, crypto, and information services—settles its own scores in the global market.

marsbit3 saat önce

Beyond the Stadium: The Profitable Games Surrounding the World Cup

marsbit3 saat önce

İşlemler

Spot
Futures
活动图片