polly-gamba 1.0.20 → 1.0.22

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.
@@ -108,7 +108,7 @@ RULES:
108
108
 
109
109
  ## POSITION DISCIPLINE:
110
110
  - Max $100 per market (20% of $500 budget). The MCP enforces this — don't fight it.
111
- - To add to an existing position: you MUST cite a specific new catalyst (news published in last 24h, not price movement). Price dipping is NOT a catalyst. Price rising is NOT a catalyst. New information is a catalyst.
111
+ - To add to an existing position with the SAME outcome: (1) you MUST cite a specific new catalyst (news published in last 24h, not price movement), AND (2) the current price must be ≥20% below your last entry price (e.g. if you bought YES at 0.15, new entry only valid at ≤0.12). The MCP enforces this — attempts at a smaller discount will be rejected. Price dipping alone is NOT a catalyst. New information is a catalyst.
112
112
  - exit_trigger is required on every trade. Be specific: "Exit when price hits 0.X" or "Exit when [specific news event]" — not "when narrative converges."
113
113
  - Call get_budget_status at the start of each scan to know available capital.`
114
114
  }
@@ -272,7 +272,7 @@ CLOSE RULES — apply ALL that match, no thesis override allowed:
272
272
  2. Position is down >35% AND the fundamental thesis has materially weakened or been disproven (market structure changed, key assumption invalidated).
273
273
  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.
274
274
  4. Position is down >50% — HARD CLOSE regardless of thesis. Cut losses. No exceptions.
275
- 5. You have 2+ open positions in the SAME market and both are losing — close the one with the higher percentage loss to reduce duplicate exposure.
275
+ 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.
276
276
 
277
277
  HOLD RULES: If NONE of the close rules apply and exit trigger NOT triggered, do nothing (no output needed).`;
278
278
  const msg = JSON.stringify({
@@ -137,6 +137,20 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (req) => {
137
137
  }]
138
138
  };
139
139
  }
140
+ // Check 1b: Same-outcome re-entry requires ≥20% price improvement (prevents pyramiding into losers)
141
+ const sameOutcomePositions = sameMarketPositions.filter((p) => String(p.outcome).toLowerCase() === String(a.outcome).toLowerCase());
142
+ if (sameOutcomePositions.length > 0) {
143
+ const lastEntry = Math.max(...sameOutcomePositions.map((p) => p.price || 0));
144
+ const requiredPrice = lastEntry * 0.80;
145
+ if (a.price > requiredPrice) {
146
+ return {
147
+ content: [{
148
+ type: 'text',
149
+ text: `Error: Re-entry blocked. Last ${a.outcome} entry at ${lastEntry.toFixed(4)}. Require price ≤ ${requiredPrice.toFixed(4)} (20% better) to add same-direction position. Current price ${a.price.toFixed(4)} is too close to last entry. Wait for a larger dislocation before averaging.`
150
+ }]
151
+ };
152
+ }
153
+ }
140
154
  // Check 2: $500 total budget cap
141
155
  const totalDeployed = openPositions.reduce((s, p) => s + (p.size_usdc || 0), 0);
142
156
  if (totalDeployed + a.size_usdc > TOTAL_BUDGET) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polly-gamba",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "Coinbase price signal → Claude brain → Polymarket CLOB execution",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/service.log CHANGED
@@ -177,3 +177,115 @@ npm warn deprecated prebuild-install@7.1.3: No longer maintained. Please contact
177
177
  [gamma] Loaded 496 markets (filtered from 500)
178
178
  [expiring] 0 expiring markets for review
179
179
  [expiring] no expiring markets found this cycle
180
+ [polly-gamba] Starting paper trading service
181
+ [polly-gamba] Claude cwd: /Users/feral/polly-gamba
182
+ [polly-gamba] Expiring trader cwd: /Users/feral/polly-gamba-expiring
183
+ [coinbase-ws] Connecting to wss://ws-feed.exchange.coinbase.com
184
+ [polly-gamba] Listening for BTC/ETH price signals (threshold: 0.5% in 60s)...
185
+ [scan] fetching high-quality markets (vol24h>$50k, liq>$50k, price 0.10-0.90)
186
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
187
+ [expiring] fetching expiring markets (closing within 72h, vol24h>$10k, liq>$10k, price 0.05-0.95)
188
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
189
+ [coinbase-ws] Connected
190
+ [position-monitor] checked=24 review_candidates=7 hard_stops=0 (moved>5% or <72h expiry)
191
+ [gamma] Loaded 496 markets (filtered from 500)
192
+ [expiring] 0 expiring markets for review
193
+ [expiring] no expiring markets found this cycle
194
+ [gamma] Loaded 496 markets (filtered from 500)
195
+ [scan] 16 high-quality markets for autonomous review
196
+ [claude-trader:anthropic] ready
197
+ [claude-trader:ollama] ready
198
+ [claude-trader:expiring] ready
199
+ [scan] fetching high-quality markets (vol24h>$50k, liq>$50k, price 0.10-0.90)
200
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
201
+ [expiring] fetching expiring markets (closing within 72h, vol24h>$10k, liq>$10k, price 0.05-0.95)
202
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
203
+ [position-monitor] checked=25 review_candidates=7 hard_stops=0 (moved>5% or <72h expiry)
204
+ [gamma] Loaded 496 markets (filtered from 500)
205
+ [expiring] 0 expiring markets for review
206
+ [expiring] no expiring markets found this cycle
207
+ [gamma] Loaded 496 markets (filtered from 500)
208
+ [scan] 16 high-quality markets for autonomous review
209
+ [scan] fetching high-quality markets (vol24h>$50k, liq>$50k, price 0.10-0.90)
210
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
211
+ [expiring] fetching expiring markets (closing within 72h, vol24h>$10k, liq>$10k, price 0.05-0.95)
212
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
213
+ [position-monitor] checked=25 review_candidates=7 hard_stops=0 (moved>5% or <72h expiry)
214
+ [gamma] Loaded 496 markets (filtered from 500)
215
+ [scan] 16 high-quality markets for autonomous review
216
+ [gamma] Loaded 496 markets (filtered from 500)
217
+ [expiring] 0 expiring markets for review
218
+ [expiring] no expiring markets found this cycle
219
+ [scan] fetching high-quality markets (vol24h>$50k, liq>$50k, price 0.10-0.90)
220
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
221
+ [position-monitor] checked=25 review_candidates=7 hard_stops=0 (moved>5% or <72h expiry)
222
+ [gamma] Loaded 496 markets (filtered from 500)
223
+ [scan] 16 high-quality markets for autonomous review
224
+ [expiring] fetching expiring markets (closing within 72h, vol24h>$10k, liq>$10k, price 0.05-0.95)
225
+ [expiring] 0 expiring markets for review
226
+ [expiring] no expiring markets found this cycle
227
+ [position-monitor] checked=25 review_candidates=7 hard_stops=0 (moved>5% or <72h expiry)
228
+ [scan] fetching high-quality markets (vol24h>$50k, liq>$50k, price 0.10-0.90)
229
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
230
+ [gamma] Loaded 496 markets (filtered from 500)
231
+ [scan] 16 high-quality markets for autonomous review
232
+ [expiring] fetching expiring markets (closing within 72h, vol24h>$10k, liq>$10k, price 0.05-0.95)
233
+ [expiring] 0 expiring markets for review
234
+ [expiring] no expiring markets found this cycle
235
+ [polly-gamba] Starting paper trading service
236
+ [polly-gamba] Claude cwd: /Users/feral/polly-gamba
237
+ [polly-gamba] Expiring trader cwd: /Users/feral/polly-gamba-expiring
238
+ [coinbase-ws] Connecting to wss://ws-feed.exchange.coinbase.com
239
+ [polly-gamba] Listening for BTC/ETH price signals (threshold: 0.5% in 60s)...
240
+ [scan] fetching high-quality markets (vol24h>$50k, liq>$50k, price 0.10-0.90)
241
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
242
+ [expiring] fetching expiring markets (closing within 72h, vol24h>$10k, liq>$10k, price 0.05-0.95)
243
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
244
+ [gamma] Loaded 496 markets (filtered from 500)
245
+ [expiring] 0 expiring markets for review
246
+ [expiring] no expiring markets found this cycle
247
+ [gamma] Loaded 496 markets (filtered from 500)
248
+ [scan] 16 high-quality markets for autonomous review
249
+ [coinbase-ws] Connected
250
+ [position-monitor] checked=25 review_candidates=7 hard_stops=0 (moved>5% or <72h expiry)
251
+ [claude-trader:anthropic] ready
252
+ [claude-trader:ollama] ready
253
+ [claude-trader:expiring] ready
254
+ [scan] fetching high-quality markets (vol24h>$50k, liq>$50k, price 0.10-0.90)
255
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
256
+ [expiring] fetching expiring markets (closing within 72h, vol24h>$10k, liq>$10k, price 0.05-0.95)
257
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
258
+ [position-monitor] checked=25 review_candidates=7 hard_stops=0 (moved>5% or <72h expiry)
259
+ [gamma] Loaded 496 markets (filtered from 500)
260
+ [expiring] 0 expiring markets for review
261
+ [expiring] no expiring markets found this cycle
262
+ [gamma] Loaded 496 markets (filtered from 500)
263
+ [scan] 16 high-quality markets for autonomous review
264
+ [scan] fetching high-quality markets (vol24h>$50k, liq>$50k, price 0.10-0.90)
265
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
266
+ [expiring] fetching expiring markets (closing within 72h, vol24h>$10k, liq>$10k, price 0.05-0.95)
267
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
268
+ [position-monitor] checked=25 review_candidates=7 hard_stops=0 (moved>5% or <72h expiry)
269
+ [gamma] Loaded 496 markets (filtered from 500)
270
+ [scan] 16 high-quality markets for autonomous review
271
+ [gamma] Loaded 496 markets (filtered from 500)
272
+ [expiring] 0 expiring markets for review
273
+ [expiring] no expiring markets found this cycle
274
+ [scan] fetching high-quality markets (vol24h>$50k, liq>$50k, price 0.10-0.90)
275
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
276
+ [expiring] fetching expiring markets (closing within 72h, vol24h>$10k, liq>$10k, price 0.05-0.95)
277
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
278
+ [position-monitor] checked=25 review_candidates=7 hard_stops=0 (moved>5% or <72h expiry)
279
+ [gamma] Loaded 496 markets (filtered from 500)
280
+ [scan] 16 high-quality markets for autonomous review
281
+ [gamma] Loaded 496 markets (filtered from 500)
282
+ [expiring] 0 expiring markets for review
283
+ [expiring] no expiring markets found this cycle
284
+ [position-monitor] checked=25 review_candidates=7 hard_stops=0 (moved>5% or <72h expiry)
285
+ [scan] fetching high-quality markets (vol24h>$50k, liq>$50k, price 0.10-0.90)
286
+ [gamma] Fetching active markets from https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=500
287
+ [gamma] Loaded 496 markets (filtered from 500)
288
+ [scan] 16 high-quality markets for autonomous review
289
+ [expiring] fetching expiring markets (closing within 72h, vol24h>$10k, liq>$10k, price 0.05-0.95)
290
+ [expiring] 0 expiring markets for review
291
+ [expiring] no expiring markets found this cycle
@@ -124,7 +124,7 @@ RULES:
124
124
 
125
125
  ## POSITION DISCIPLINE:
126
126
  - Max $100 per market (20% of $500 budget). The MCP enforces this — don't fight it.
127
- - To add to an existing position: you MUST cite a specific new catalyst (news published in last 24h, not price movement). Price dipping is NOT a catalyst. Price rising is NOT a catalyst. New information is a catalyst.
127
+ - To add to an existing position with the SAME outcome: (1) you MUST cite a specific new catalyst (news published in last 24h, not price movement), AND (2) the current price must be ≥20% below your last entry price (e.g. if you bought YES at 0.15, new entry only valid at ≤0.12). The MCP enforces this — attempts at a smaller discount will be rejected. Price dipping alone is NOT a catalyst. New information is a catalyst.
128
128
  - exit_trigger is required on every trade. Be specific: "Exit when price hits 0.X" or "Exit when [specific news event]" — not "when narrative converges."
129
129
  - Call get_budget_status at the start of each scan to know available capital.`
130
130
  }
@@ -323,7 +323,7 @@ CLOSE RULES — apply ALL that match, no thesis override allowed:
323
323
  2. Position is down >35% AND the fundamental thesis has materially weakened or been disproven (market structure changed, key assumption invalidated).
324
324
  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.
325
325
  4. Position is down >50% — HARD CLOSE regardless of thesis. Cut losses. No exceptions.
326
- 5. You have 2+ open positions in the SAME market and both are losing — close the one with the higher percentage loss to reduce duplicate exposure.
326
+ 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.
327
327
 
328
328
  HOLD RULES: If NONE of the close rules apply and exit trigger NOT triggered, do nothing (no output needed).`
329
329
 
package/src/mcp-server.ts CHANGED
@@ -138,6 +138,23 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
138
138
  }
139
139
  }
140
140
 
141
+ // Check 1b: Same-outcome re-entry requires ≥20% price improvement (prevents pyramiding into losers)
142
+ const sameOutcomePositions = sameMarketPositions.filter((p: any) =>
143
+ String(p.outcome).toLowerCase() === String(a.outcome).toLowerCase()
144
+ )
145
+ if (sameOutcomePositions.length > 0) {
146
+ const lastEntry = Math.max(...sameOutcomePositions.map((p: any) => p.price || 0))
147
+ const requiredPrice = lastEntry * 0.80
148
+ if (a.price > requiredPrice) {
149
+ return {
150
+ content: [{
151
+ type: 'text',
152
+ text: `Error: Re-entry blocked. Last ${a.outcome} entry at ${lastEntry.toFixed(4)}. Require price ≤ ${requiredPrice.toFixed(4)} (20% better) to add same-direction position. Current price ${a.price.toFixed(4)} is too close to last entry. Wait for a larger dislocation before averaging.`
153
+ }]
154
+ }
155
+ }
156
+ }
157
+
141
158
  // Check 2: $500 total budget cap
142
159
  const totalDeployed = openPositions.reduce((s: number, p: any) => s + (p.size_usdc || 0), 0)
143
160
  if (totalDeployed + a.size_usdc > TOTAL_BUDGET) {