Add 6 Polymarket trading skills with paper trading engine
Composable Agent Skills (SKILL.md format) for Polymarket prediction market trading. Includes scanner, analyzer, monitor, paper trader, strategy advisor, and live executor. All tested against live Polymarket APIs. Security audited with all HIGH/MEDIUM findings resolved. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
6a03bbe2e5
commit
068b2adc75
@@ -0,0 +1,68 @@
|
||||
# Pre-Flight Checklist for Live Trading
|
||||
|
||||
Complete ALL items before executing your first live trade.
|
||||
|
||||
## Wallet Setup
|
||||
|
||||
- [ ] Created a dedicated burner wallet (NOT your main wallet)
|
||||
- [ ] Funded with an amount you can afford to lose entirely
|
||||
- [ ] Verified wallet has USDC on Polygon network
|
||||
- [ ] Verified wallet has small MATIC balance for gas
|
||||
- [ ] Private key stored in environment variable only (not in files or code)
|
||||
|
||||
## Environment Configuration
|
||||
|
||||
- [ ] `POLYMARKET_PRIVATE_KEY` is set to burner wallet key
|
||||
- [ ] `POLYMARKET_CONFIRM=true` is set (required safety gate)
|
||||
- [ ] `POLYMARKET_MAX_SIZE` is set to your per-trade limit (default: $10)
|
||||
- [ ] `POLYMARKET_DAILY_LOSS_LIMIT` is set (default: $50)
|
||||
- [ ] Verified configuration with `check_positions.py --balance`
|
||||
|
||||
## Analysis Completed
|
||||
|
||||
- [ ] Identified specific market and opportunity using polymarket-analyzer
|
||||
- [ ] Reviewed order book depth with `analyze_orderbook.py`
|
||||
- [ ] Confirmed sufficient liquidity at target price
|
||||
- [ ] Understood the market's resolution criteria
|
||||
- [ ] Checked market end date (not expiring imminently)
|
||||
|
||||
## Paper Trading Validation
|
||||
|
||||
- [ ] Tested the same strategy in paper trading mode first
|
||||
- [ ] Paper trading results reviewed and acceptable
|
||||
- [ ] Understand expected win rate and risk/reward ratio
|
||||
- [ ] Strategy has shown positive expectancy in paper trades
|
||||
|
||||
## Risk Management
|
||||
|
||||
- [ ] Set maximum position size per trade
|
||||
- [ ] Set daily loss limit
|
||||
- [ ] Decided on exit strategy (when to take profit, when to cut loss)
|
||||
- [ ] Understand that prediction markets can go to 0 or 1
|
||||
- [ ] Accepted that all funds in burner wallet could be lost
|
||||
- [ ] Not trading with money needed for bills, rent, or essentials
|
||||
|
||||
## Execution Plan
|
||||
|
||||
- [ ] Know the exact token ID for the trade
|
||||
- [ ] Know the side (BUY or SELL)
|
||||
- [ ] Know the size (number of shares or dollar amount)
|
||||
- [ ] Know the price (limit) or willing to accept market price
|
||||
- [ ] Reviewed current bid-ask spread
|
||||
- [ ] Will carefully review the confirmation prompt before approving
|
||||
|
||||
## After the Trade
|
||||
|
||||
- [ ] Verified trade executed at expected price (check trades.log)
|
||||
- [ ] Set a reminder to check position before market resolution
|
||||
- [ ] Know how to cancel open limit orders if needed
|
||||
- [ ] Plan for monitoring: will check at least daily
|
||||
|
||||
## Emergency Procedures
|
||||
|
||||
If something goes wrong:
|
||||
1. Unset `POLYMARKET_CONFIRM` to prevent any further trades
|
||||
2. Use `check_positions.py --orders` to see open orders
|
||||
3. Cancel all open orders if needed
|
||||
4. Transfer remaining funds out of burner wallet if compromised
|
||||
5. Create a new burner wallet if the old one may be exposed
|
||||
@@ -0,0 +1,123 @@
|
||||
# Security Guide for Live Polymarket Trading
|
||||
|
||||
## Rule #1: NEVER Use Your Main Wallet
|
||||
|
||||
Always create a dedicated **burner wallet** for bot trading. This wallet should:
|
||||
- Be a fresh address with no connection to your primary holdings
|
||||
- Hold only the amount you are willing to lose entirely
|
||||
- Never be used for any other purpose
|
||||
|
||||
If your private key is compromised (through env var leaks, log exposure, or
|
||||
prompt injection attacks), only the burner wallet funds are at risk.
|
||||
|
||||
## Creating a Burner Wallet
|
||||
|
||||
### Option A: Using Python
|
||||
|
||||
```python
|
||||
from eth_account import Account
|
||||
acct = Account.create()
|
||||
print(f"Address: {acct.address}")
|
||||
print(f"Private Key: {acct.key.hex()}")
|
||||
# SAVE THESE SECURELY. Fund address with USDC on Polygon.
|
||||
```
|
||||
|
||||
### Option B: Using MetaMask
|
||||
|
||||
1. Create a new MetaMask profile (not just a new account in existing profile)
|
||||
2. Create a new wallet
|
||||
3. Export the private key (Settings > Security > Export Private Key)
|
||||
4. Fund with USDC on Polygon network
|
||||
|
||||
### Option C: Using cast (Foundry)
|
||||
|
||||
```bash
|
||||
cast wallet new
|
||||
# Save the address and private key
|
||||
```
|
||||
|
||||
## Funding the Burner Wallet
|
||||
|
||||
1. Bridge USDC to Polygon (use official Polygon bridge or a reputable DEX)
|
||||
2. Send only your maximum acceptable loss to the burner address
|
||||
3. Keep some MATIC for gas fees (~0.1 MATIC is usually sufficient)
|
||||
|
||||
## Setting Up L2 Authentication
|
||||
|
||||
The Polymarket CLOB API uses three-tier authentication:
|
||||
|
||||
- **L0**: No auth. Read-only market data.
|
||||
- **L1**: Wallet signature. Can create/sign orders.
|
||||
- **L2**: API key + secret + passphrase. Can post orders, manage positions.
|
||||
|
||||
To set up L2:
|
||||
|
||||
```python
|
||||
from py_clob_client.client import ClobClient
|
||||
|
||||
# Initialize with L1 (private key)
|
||||
client = ClobClient(
|
||||
"https://clob.polymarket.com",
|
||||
chain_id=137, # Polygon mainnet
|
||||
key="0xYOUR_PRIVATE_KEY"
|
||||
)
|
||||
|
||||
# Create API credentials (L2)
|
||||
creds = client.create_or_derive_api_creds()
|
||||
print(f"API Key: {creds.api_key}")
|
||||
print(f"API Secret: {creds.api_secret}")
|
||||
print(f"API Passphrase: {creds.api_passphrase}")
|
||||
```
|
||||
|
||||
Store these credentials securely. The execute_live.py script handles this
|
||||
automatically when POLYMARKET_PRIVATE_KEY is set.
|
||||
|
||||
## Private Key Handling Best Practices
|
||||
|
||||
### DO:
|
||||
- Store the private key in an environment variable (`POLYMARKET_PRIVATE_KEY`)
|
||||
- Use a `.env` file with strict permissions (`chmod 600 .env`)
|
||||
- Unset the variable when not actively trading (`unset POLYMARKET_PRIVATE_KEY`)
|
||||
- Rotate burner wallets periodically (create new wallet, transfer remaining funds)
|
||||
|
||||
### DO NOT:
|
||||
- Hardcode private keys in any script or config file
|
||||
- Commit `.env` files to version control
|
||||
- Share private keys in chat, logs, or error reports
|
||||
- Use the same key for testing and production
|
||||
- Give the LLM/agent direct access to your private key in conversation
|
||||
- Store keys in world-readable files
|
||||
|
||||
### Gitignore Template
|
||||
|
||||
Add to your `.gitignore`:
|
||||
```
|
||||
.env
|
||||
.env.*
|
||||
*.key
|
||||
polymarket-live/
|
||||
~/.polymarket-live/
|
||||
```
|
||||
|
||||
## Prompt Injection Defense
|
||||
|
||||
When using AI agents for trading, be aware of prompt injection risks:
|
||||
|
||||
1. **Never paste untrusted content into agent context** when live trading is enabled
|
||||
2. **Market descriptions could contain malicious instructions** -- the agent should
|
||||
never execute trades based on text found in market descriptions
|
||||
3. **The POLYMARKET_CONFIRM=true env var** acts as a safety gate -- without it,
|
||||
no trade can execute regardless of what the agent is told to do
|
||||
4. **Review every trade confirmation** before approving -- the agent must show you
|
||||
the exact parameters before execution
|
||||
|
||||
## Maximum Funding Recommendations
|
||||
|
||||
| Experience Level | Max Wallet Fund | Max Per Trade | Daily Loss Limit |
|
||||
|------------------|-----------------|---------------|------------------|
|
||||
| First time | $25 | $5 | $10 |
|
||||
| Learning | $100 | $10 | $25 |
|
||||
| Experienced | $500 | $50 | $100 |
|
||||
| Advanced | $2,000+ | $200 | $500 |
|
||||
|
||||
Start small. You can always add more funds later.
|
||||
Reference in New Issue
Block a user