polly-gamba 1.0.40 → 1.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/claude-trader.js +4 -3
- package/dist/position-monitor.js +2 -2
- package/dist/test/stress.js +12 -12
- package/package.json +1 -1
- package/service.log +1065 -0
- package/src/claude-trader.ts +4 -3
- package/src/position-monitor.ts +2 -2
- package/src/test/stress.ts +12 -12
package/dist/claude-trader.js
CHANGED
|
@@ -212,6 +212,7 @@ ${m.description ? `- Description: ${m.description.slice(0, 200)}` : ''}`).join('
|
|
|
212
212
|
- Correlation examples: "Will Jesus return before GTA VI", "Will BTC hit $1M before GTA VI", "Will China invade Taiwan before GTA VI" — all three resolve based on GTA VI's release date. They are the SAME theme.
|
|
213
213
|
- Similarly: "Will Orbán be PM" and "Will Magyar be PM" are both the Hungary 2026 election — treat as same theme (you may hold both as a hedge pair, but do not add a third Hungary position).
|
|
214
214
|
- IMPORTANT: All 2028 US election markets share one theme — "2028 US election". This includes: Dem primary nominees (Newsom, Harris, etc.), Rep primary nominees (Vance, Rubio, etc.), and the general election winner. Do NOT hold more than 2 positions across this entire cycle.
|
|
215
|
+
- IMPORTANT: All Russia-Ukraine conflict markets share one theme — "Russia-Ukraine conflict". This includes: Putin removal, Zelenskyy removal, ceasefire timing, territorial outcomes, and any other market that resolves based on the Russia-Ukraine war's trajectory. Do NOT hold more than 2 positions across this entire theme.
|
|
215
216
|
- If you're uncertain whether a market correlates to an existing theme, assume it does and skip.
|
|
216
217
|
|
|
217
218
|
## CLOSED MARKET DISCIPLINE (absolute rule — never override):
|
|
@@ -310,14 +311,14 @@ ${positionLines}
|
|
|
310
311
|
|
|
311
312
|
CLOSE RULES — apply ALL that match, no thesis override allowed:
|
|
312
313
|
1. Exit trigger condition has been met (e.g. specific price level hit, event occurred). Apply literally.
|
|
313
|
-
2. Position is down >35%
|
|
314
|
+
2. Position is down >35% — HARD CLOSE. This is a programmatic rule enforced server-side; by the time you see this position it may already be closed. Do NOT override with thesis defense.
|
|
314
315
|
3. Your side of the position is priced below 10% — HARD CLOSE. The market has strongly repriced against you. Do NOT override this with "thesis not disproven yet." At <10%, expected value of holding is near zero.
|
|
315
316
|
4. Position is down >50% — HARD CLOSE regardless of thesis. Cut losses. No exceptions.
|
|
316
317
|
5. You have 2+ open positions in the SAME market with the SAME outcome — close the NEWER entry (higher ts value) regardless of P&L. Duplicate same-outcome positions double exposure without incremental edge. Keep the original entry.
|
|
317
318
|
6. Position is UP >25% from entry AND has been held >48h — CLOSE to lock in profits. The market has moved significantly in your favor; gains are now vulnerable to reversion. Use take_profit reason. Exception: if the resolution event is within 7 days AND the position is still clearly on the right side, you may hold until resolution.
|
|
318
319
|
7. STALE POSITION: Position held >7 days AND price has moved <5% from entry AND resolution event is >30 days away — CLOSE to redeploy capital. A position that doesn't move over 7 days means the mispricing wasn't as large as estimated. Cut it, accept the small loss/gain, and redeploy to markets with active price movement.
|
|
319
|
-
8. CONCENTRATION VIOLATION: Count open positions by underlying theme (the single real-world event that resolves all of them). Examples: "Will Jesus return before GTA VI", "Will BTC hit $1M before GTA VI", "Will China invade Taiwan before GTA VI" all share the theme "GTA VI release date". Similarly "Will Spurs win NBA Finals", "Will OKC win NBA Finals", "Will Celtics win NBA Finals" all share the theme "2026 NBA Finals". IMPORTANT: All positions tied to the 2028 US election cycle share one theme — "2028 US election". This includes: 2028 Dem primary nominees (Newsom, etc.), 2028 Rep primary nominees (Vance, Rubio, etc.), and the 2028 general election winner — regardless of which stage of the race resolves each market. If you have 3+ positions in the same theme: close positions one by one (starting with the one whose current price is closest to 50/50) until you have ≤2 in that theme. If you have 4, you must close 2. If you have 5, close 3. Do NOT stop after closing just one if the theme still has 3+ positions. Apply this BEFORE checking other rules. This check requires the FULL position list — which is why Step 0 mandates calling get_positions first.
|
|
320
|
-
9. SPORTSBOOK THESIS DECAY: If the original reasoning cited a sportsbook cross-reference (e.g. "sportsbooks imply X%, Polymarket shows Y%") AND the position is currently down >20%:
|
|
320
|
+
8. CONCENTRATION VIOLATION: Count open positions by underlying theme (the single real-world event that resolves all of them). Examples: "Will Jesus return before GTA VI", "Will BTC hit $1M before GTA VI", "Will China invade Taiwan before GTA VI" all share the theme "GTA VI release date". Similarly "Will Spurs win NBA Finals", "Will OKC win NBA Finals", "Will Celtics win NBA Finals" all share the theme "2026 NBA Finals". IMPORTANT: All positions tied to the 2028 US election cycle share one theme — "2028 US election". This includes: 2028 Dem primary nominees (Newsom, etc.), 2028 Rep primary nominees (Vance, Rubio, etc.), and the 2028 general election winner — regardless of which stage of the race resolves each market. IMPORTANT: All Russia-Ukraine conflict positions share one theme — "Russia-Ukraine conflict". This includes: Putin removal/survival, Zelenskyy removal/survival, ceasefire timing, territorial outcomes — any market that resolves based on how the Russia-Ukraine war progresses. If you have 3+ positions in the same theme: close positions one by one (starting with the one whose current price is closest to 50/50) until you have ≤2 in that theme. If you have 4, you must close 2. If you have 5, close 3. Do NOT stop after closing just one if the theme still has 3+ positions. Apply this BEFORE checking other rules. This check requires the FULL position list — which is why Step 0 mandates calling get_positions first.
|
|
321
|
+
9. SPORTSBOOK THESIS DECAY: If the original reasoning cited a sportsbook cross-reference (e.g. "sportsbooks imply X%, Polymarket shows Y%") AND the position is currently down >20%: CLOSE immediately with reason "thesis_decayed". This is a mechanical rule — a -20% drawdown on a sportsbook arb trade is itself the signal that the cross-market gap has closed or the thesis was wrong. Do NOT attempt to re-estimate current sportsbook consensus or override based on "the sportsbook line is still there." The drawdown is the verdict. No exceptions.
|
|
321
322
|
|
|
322
323
|
HOLD RULES: If NONE of the close rules apply and exit trigger NOT triggered, do nothing (no output needed).
|
|
323
324
|
|
package/dist/position-monitor.js
CHANGED
|
@@ -144,9 +144,9 @@ class PositionMonitor {
|
|
|
144
144
|
const hardStopClosed = [];
|
|
145
145
|
for (const candidate of reviewCandidates) {
|
|
146
146
|
const isPriceBelowFloor = candidate.current_price <= 0.10;
|
|
147
|
-
const isLargeEnoughLoss = candidate.gain_pct <= -0.
|
|
147
|
+
const isLargeEnoughLoss = candidate.gain_pct <= -0.35;
|
|
148
148
|
if (isPriceBelowFloor || isLargeEnoughLoss) {
|
|
149
|
-
await this.executeHardStop(candidate, isPriceBelowFloor ? 'price_below_floor' : '
|
|
149
|
+
await this.executeHardStop(candidate, isPriceBelowFloor ? 'price_below_floor' : 'stop_loss_35pct');
|
|
150
150
|
hardStopClosed.push(candidate.market_id);
|
|
151
151
|
}
|
|
152
152
|
}
|
package/dist/test/stress.js
CHANGED
|
@@ -257,15 +257,15 @@ async function runHardStopTests() {
|
|
|
257
257
|
const isPriceBelowFloor = price <= 0.10;
|
|
258
258
|
assert(isPriceBelowFloor, 'price=0.08 should trigger floor stop');
|
|
259
259
|
});
|
|
260
|
-
await test('F2: loss = -
|
|
261
|
-
const gain = -0.
|
|
262
|
-
const isLargeEnoughLoss = gain <= -0.
|
|
263
|
-
assert(isLargeEnoughLoss, 'exactly -
|
|
260
|
+
await test('F2: loss = -35% triggers stop-loss', async () => {
|
|
261
|
+
const gain = -0.35;
|
|
262
|
+
const isLargeEnoughLoss = gain <= -0.35;
|
|
263
|
+
assert(isLargeEnoughLoss, 'exactly -35% should trigger stop-loss');
|
|
264
264
|
});
|
|
265
|
-
await test('F3: loss = -
|
|
266
|
-
const gain = -0.
|
|
267
|
-
const isLargeEnoughLoss = gain <= -0.
|
|
268
|
-
assert(!isLargeEnoughLoss, '-
|
|
265
|
+
await test('F3: loss = -34.9% does NOT trigger stop-loss', async () => {
|
|
266
|
+
const gain = -0.349;
|
|
267
|
+
const isLargeEnoughLoss = gain <= -0.35;
|
|
268
|
+
assert(!isLargeEnoughLoss, '-34.9% should NOT trigger stop-loss');
|
|
269
269
|
});
|
|
270
270
|
await test('F4: price = 0.10 triggers floor (boundary — off-by-one vs stated rule)', async () => {
|
|
271
271
|
// Code uses <= 0.10 but the Claude prompt rule says "priced below 10%"
|
|
@@ -275,12 +275,12 @@ async function runHardStopTests() {
|
|
|
275
275
|
assert(isPriceBelowFloor, 'price=0.10 triggers stop (code behavior)');
|
|
276
276
|
console.log('\n [NOTE] Boundary: price=0.10 triggers hard stop. Prompt says "<10%" but code uses "<=0.10".');
|
|
277
277
|
});
|
|
278
|
-
await test('F5: price > 0.10 and loss <
|
|
278
|
+
await test('F5: price > 0.10 and loss < 35% — no hard stop', async () => {
|
|
279
279
|
const price = 0.12;
|
|
280
|
-
const gain = -0.
|
|
280
|
+
const gain = -0.30;
|
|
281
281
|
const isPriceBelowFloor = price <= 0.10;
|
|
282
|
-
const isLargeEnoughLoss = gain <= -0.
|
|
283
|
-
assert(!isPriceBelowFloor && !isLargeEnoughLoss, 'price=0.12, -
|
|
282
|
+
const isLargeEnoughLoss = gain <= -0.35;
|
|
283
|
+
assert(!isPriceBelowFloor && !isLargeEnoughLoss, 'price=0.12, -30% should not trigger hard stop');
|
|
284
284
|
});
|
|
285
285
|
}
|
|
286
286
|
// ─── G) Double-Close Bug ─────────────────────────────────────────────────────
|