### Install polymarket-go-gamma-client Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/README.md Install the Go SDK for the Polymarket Gamma API. Requires Go 1.24 or later. ```bash go get github.com/ivanzzeth/polymarket-go-gamma-client ``` -------------------------------- ### Run Find Wide Spread Markets Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-wide-spread-markets/README.md Navigate to the example directory and run the Go program to find markets with wide spreads. ```bash cd examples/find-wide-spread-markets go run main.go ``` -------------------------------- ### Confirm Underpricing Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-negrisk-opportunities/README.md This example demonstrates how to confirm if a market is underpriced for arbitrage. It shows the standard cost, payout, and resulting profit. ```text Example: Sum = 0.98 ✅ Standard cost: $0.98 ✅ Payout: $1.00 ✅ Profit: $0.02 (2% guaranteed) ``` -------------------------------- ### Run New Active Markets Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/README.md Execute the example script to find recently launched markets with potential early mover advantages. It includes an opportunity scoring system. ```bash cd examples/find-new-active-markets go run main.go ``` -------------------------------- ### Spread Compression Response Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-low-liquidity-high-volume/README.md Compares profitability under different spread and turnover scenarios to guide decisions on whether to accept lower margins or exit an opportunity. ```text Previous: 4% spread, 10x turnover = 40% monthly New: 2% spread, 12x turnover = 24% monthly Decision: Still good? Or find better opportunity? ``` -------------------------------- ### Run NegRisk Opportunities Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/README.md Execute the example script to discover capital-efficient trading opportunities using Negative Risk markets. It includes detailed fee impact calculations. ```bash cd examples/find-negrisk-opportunities go run main.go ``` -------------------------------- ### Run Low Liquidity, High Volume Markets Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/README.md Execute the example script to discover markets with high trading activity but insufficient liquidity. This helps identify opportunities for liquidity providers. ```bash cd examples/find-low-liquidity-high-volume go run main.go ``` -------------------------------- ### Daily Reconciliation Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-low-liquidity-high-volume/README.md Provides an end-of-day reconciliation example, detailing total buys and sells, net position, gross profit, unrealized profit, fees, and net profit. ```text End of Day: - Total buys: 2,500 shares @ avg 0.485 - Total sells: 2,300 shares @ avg 0.515 - Net position: +200 shares @ avg 0.485 - Gross profit: 2,300 × (0.515-0.485) = $69 - Unrealized: 200 × (current-0.485) - Fees: ~$25 (2% of $1,250 volume) - Net profit: $44/day Current position value: 200 × 0.50 = $100 Available capital: $900 ``` -------------------------------- ### Run Related Markets Arbitrage Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/README.md Execute the example script to identify events where market probabilities do not sum to 100%, indicating potential arbitrage opportunities. It calculates expected returns. ```bash cd examples/find-related-markets-arbitrage go run main.go ``` -------------------------------- ### Quick Start: Fetch Markets with Go SDK Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/README.md Initialize the Polymarket Gamma client and fetch a list of markets. Filters markets by closed status and limits the results. ```go package main import ( "context" "fmt" "log" "net/http" polymarketgamma "github.com/ivanzzeth/polymarket-go-gamma-client" ) func main() { client := polymarketgamma.NewClient(http.DefaultClient) // Fetch markets closed := false params := &polymarketgamma.GetMarketsParams{ Limit: 10, Closed: &closed, } markets, err := client.GetMarkets(context.Background(), params) if err != nil { log.Fatal(err) } for _, market := range markets { fmt.Printf("%s: $%.2f (24h vol: $%.2f)\n", market.Question, market.LastTradePrice, market.Volume24hr) } } ``` -------------------------------- ### Real-World Example Analysis Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-low-liquidity-high-volume/README.md Analyzes a real-world market example, detailing metrics like volume, liquidity, spread, and calculating a score based on these factors. ```text Market: "Will Trump deport 1.5M+ by...?" Category: Politics 24h Volume: $125,000 (HIGH activity ✅) Liquidity: $7,500 (LOW liquidity ✅) Metrics: - Volume/Liquidity: 16.7x (EXCELLENT turnover) - Spread: 3.5% (WIDE spread) - Best Bid: 0.12 - Best Ask: 0.155 - Spread: 0.035 (3.5¢) Score: 92/100 (EXCELLENT) ``` -------------------------------- ### Configuration Options in Go Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-rapid-price-movement/README.md Go code snippet showing configurable parameters for the trading example. Adjust these values to modify the sensitivity and scope of the analysis. ```go minPriceChange := 0.15 // 15% minimum price change targetCount := 5 // Number of opportunities to find minVolume := 5000.0 // Minimum 24h volume ``` -------------------------------- ### Example Order Book Analysis Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-low-liquidity-high-volume/README.md Demonstrates how to analyze an order book, including bids, asks, spread, and mid-price, and how to set your own quotes. ```text Example order book: Bids: 0.48: $500 0.47: $1,200 0.46: $800 Asks: 0.52: $600 0.53: $1,000 0.54: $1,500 Spread: 0.04 (4¢) Mid: 0.50 Your strategy: Bid: 0.49 ($400) - inside current best Ask: 0.51 ($400) - inside current best Your spread: 0.02 (2¢) - tighter than market ``` -------------------------------- ### Configure Closing Soon Markets Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-closing-soon-markets/README.md Configuration parameters within the `main.go` file to customize the search for closing soon markets, including time frame, minimum volume, and desired count. ```go hoursUntilClose := 48.0 // Find markets closing within 48 hours minVolume := 1000.0 // Minimum trading volume targetCount := 5 // Number of opportunities ``` -------------------------------- ### Movement Characterization Examples Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-rapid-price-movement/README.md Provides examples of how different levels of price movement (percentage change) are characterized in the output. These labels help in quickly assessing the significance of a price change. ```plaintext Strong Movement (>30%): "SIGNIFICANT" movement or "VERY STRONG" Moderate Movement (20-30%): "SUBSTANTIAL" or "STRONG" Notable Movement (15-20%): "SIGNIFICANT" or "NOTABLE" ``` -------------------------------- ### Good Arbitrage Opportunity Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-related-markets-arbitrage/README.md This example shows a good arbitrage opportunity with a 4% deviation, yielding a 4.2% expected return. It advises considering this opportunity after calculating fees. ```text Sum: 0.96 (4% deviation) Expected Return: $0.04 per $0.96 invested = 4.2% Risk: Low (check fees don't exceed profit) Action: Consider after fee calculation ``` -------------------------------- ### Inventory Risk Management Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-low-liquidity-high-volume/README.md Illustrates inventory risk management by setting maximum position limits, defining alert and forced rebalance thresholds based on capital. ```text Capital: $1,000 Max long: +$200 (200 shares if price ~1.0) Max short: -$200 Alert at: ±$150 Forced rebalance at: ±$200 ``` -------------------------------- ### Example Market Analysis and Return Calculation Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-low-liquidity-high-volume/README.md Illustrates a hypothetical market scenario to calculate potential daily and monthly returns, including considerations for fees and a conservative estimate. ```text Example Market: - 24h Volume: $50,000 - Current Spread: 2% (0.02) - Your planned liquidity: $5,000 - Estimated market share: 20% Daily volume capture: $50,000 × 20% = $10,000 Spread captured: $10,000 × 2% = $200/day Monthly projection: $200 × 30 = $6,000 ROI on $5,000: 120% per month Reality checks: - Fees: ~2% of volume = $200/month = -$200 - Net projection: $5,800 - ROI: 116% per month (excellent!) - Risk: Inventory risk, adverse selection Conservative estimate: 50% of theoretical - Expected monthly: $2,900 - ROI: 58% per month (still excellent) ``` -------------------------------- ### Capital Rotation Example: With and Without NegRisk Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-negrisk-opportunities/README.md Demonstrates how using NegRisk can increase capital efficiency by reducing the amount of locked capital, freeing up funds for other trades. ```text Portfolio: $10,000 Without NegRisk: Trade A: $1,030 locked (sum 1.03) Trade B: $1,050 locked (sum 1.05) Trade C: $980 locked (sum 0.98) Remaining: $6,940 With NegRisk (for A and B only): Trade A: $1,000 locked (NegRisk) Trade B: $1,000 locked (NegRisk) Trade C: $980 locked (standard - true arb!) Remaining: $7,020 Extra capital: $80 (0.8% more efficient) ``` -------------------------------- ### Arbitrage Profit Calculation Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-related-markets-arbitrage/README.md Illustrates the profit calculation for an arbitrage strategy, including gross profit, fees, and net profit. This example assumes a specific payout scenario at market resolution. ```plaintext At Resolution: - One market pays: 1,111 shares × $1.00 = $1,111 - Other markets pay: $0 - Total payout: $1,111 Profit Calculation: - Investment: $1,000 - Payout: $1,111 - Gross profit: $111 (11.1%) - Fees (2% avg): $20 - Net profit: $91 (9.1%) ``` -------------------------------- ### Excellent Opportunity Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-low-liquidity-high-volume/README.md Provides an example of an excellent market making opportunity with characteristics like very high volume, low liquidity, a wide spread, and high turnover, resulting in a high market making score. ```text Example: 24h Volume: $125,000 Liquidity: $7,500 Turnover: 16.7x Spread: 3.5% Score: 92 Action: Strong candidate for market making ``` -------------------------------- ### Very Good Opportunity Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-low-liquidity-high-volume/README.md Presents an example of a very good market making opportunity, characterized by high volume, low-to-moderate liquidity, a good spread, and good turnover, yielding a solid market making score. ```text Example: 24h Volume: $35,000 Liquidity: $12,000 Turnover: 2.9x Spread: 2.2% Score: 75 Action: Solid opportunity ``` -------------------------------- ### Excellent Arbitrage Opportunity Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-related-markets-arbitrage/README.md This example illustrates an excellent arbitrage opportunity with a 10% deviation from 1.0, resulting in an 11.1% expected return. It emphasizes very low risk if markets are mutually exclusive. ```text Sum: 0.90 (10% deviation) Expected Return: $0.10 per $0.90 invested = 11.1% Risk: Very low (if markets truly mutually exclusive) Action: STRONG BUY opportunity ``` -------------------------------- ### Example CLOB API Order Placement Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-low-liquidity-high-volume/README.md Shows how to place buy and sell limit orders using a hypothetical CLOB (Central Limit Order Book) API, including order details and capital requirements. ```go Buy order: Side: BUY Price: 0.49 Size: 1000 shares ($490) Type: LIMIT Sell order: Side: SELL Price: 0.51 Size: 1000 shares ($510 collateral needed) Type: LIMIT Total capital needed: ~$1,000 ``` -------------------------------- ### Position Sizing Examples Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-low-liquidity-high-volume/README.md Demonstrates conservative and moderate position sizing strategies, including capital allocation, shares per side, and projected monthly P&L. ```text Conservative: - Capital: $500 (6.7% of liquidity) - Per side: $250 - Shares: ~2,000 per side Moderate: - Capital: $1,000 (13.3% of liquidity) - Per side: $500 - Shares: ~4,000 per side Expected monthly P&L (moderate): - Daily capture: 13.3% × $125k = $16,625 - Spread capture: $16,625 × 3.5% = $582 - Days/month: 30 - Gross: $17,460 - Fees: ~$333 - Net: $17,127 - ROI: 1,713% (likely too optimistic!) Realistic (conservative estimate at 10% of theoretical): - Monthly net: $1,713 - ROI: 171% per month - Still excellent if achievable! ``` -------------------------------- ### Fee Optimization Example: NegRisk vs. Standard Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-negrisk-opportunities/README.md Calculates and compares the total costs, including maker and NegRisk fees, for a given position to show potential savings with NegRisk. ```text Position: $1,000 Maker fee: 2% = $20 NegRisk fee: 0.5% = $5 Total cost: $1,025 Compare to standard: Standard cost: $1,030 Standard fee: 2% = $20.60 Total: $1,050.60 NegRisk savings: $25.60 ``` -------------------------------- ### Fill Management Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-low-liquidity-high-volume/README.md Illustrates a recurring fill management process, including checking orders, calculating positions, assessing inventory, and replacing/adjusting orders based on market movement. ```text Fill management: Every 15-30 minutes: ✅ Check which orders filled ✅ Calculate current position ✅ Assess inventory skew ✅ Replace filled orders ✅ Adjust for market movement Example: Time: 10:00 AM - Bid filled: Bought 500 @ 0.49 - Position: +500 shares (long) - Action: - Replace bid: 0.48 (wider, slow down) - Keep ask: 0.51 - Or sell 500 at market to rebalance Time: 10:30 AM - Ask filled: Sold 700 @ 0.51 - Position: -200 shares (short from previous +500) - Profit: 500 × (0.51-0.49) = $10 - Action: - Replace ask: 0.51 - Tighten bid: 0.495 (encourage buying) ``` -------------------------------- ### Marginal Arbitrage Opportunity Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-related-markets-arbitrage/README.md This example represents a marginal arbitrage opportunity with a 2% deviation, offering a 2.0% expected return. It warns that fees might eliminate the profit and advises careful cost calculation. ```text Sum: 0.98 (2% deviation) Expected Return: $0.02 per $0.98 invested = 2.0% Risk: May be eliminated by fees Action: Calculate total costs carefully ``` -------------------------------- ### Example Trade Cycle Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-low-liquidity-high-volume/README.md Illustrates a simplified market making trade cycle, showing how to profit from the bid-ask spread by buying at the bid price and selling at the ask price, and projecting potential daily and monthly profits. ```text Market: "Will it rain tomorrow?" Current spread: 0.48 bid / 0.52 ask (4¢ spread) Your quotes: - Bid: 0.49 (willing to buy) - Ask: 0.51 (willing to sell) Trade sequence: 1. Someone sells to you: Buy at 0.49 2. Someone buys from you: Sell at 0.51 3. Profit: 0.02 per share (2¢ or 4% on capital) If this happens 50 times per day: Daily profit: 50 × 0.02 = 1.00 per share On $1,000 position: $100/day potential Monthly: $3,000 (if sustained) ``` -------------------------------- ### Real-World Example: Probability Sum and Savings Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-negrisk-opportunities/README.md Analyzes a real-world event to calculate capital efficiency savings using NegRisk compared to the standard approach, considering fees and liquidity. ```text Event: "How many people will Trump deport in 2025?" Markets: 9 mutually exclusive outcomes Probability Sum: 1.018 (1.8% overpriced) NegRisk Enabled: Yes Analysis - Standard approach: Need $1.018 collateral per position - NegRisk approach: Need $1.000 collateral per position - Savings: $0.018 per dollar (1.8% capital efficiency) Decision Framework 1. Is 1.8% efficiency worth it? - For $10,000 position: Saves $180 in locked capital - Consider holding period and alternative uses 2. Fee impact: - Trading fees: ~2% = $200 - NegRisk fees: Check output - Net benefit after fees 3. Liquidity check: - Total liquidity: Check output - Your size vs market depth - Slippage estimate ``` -------------------------------- ### Identify New Active Markets Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/ANALYSIS.md Discover recently launched markets with low liquidity, offering early mover advantages for market makers. Check market start date, active status, order acceptance, and CLOB liquidity. ```go market.StartDate // Market launch date market.Active // Market is active market.AcceptingOrders // Currently accepting orders market.LiquidityClob // Current CLOB liquidity ``` -------------------------------- ### Example Output for Wide Spread Markets Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-wide-spread-markets/README.md This is a sample output showing the identification of markets with spreads exceeding 3x the tick size, including market details and spread analysis. ```text 🔍 Finding markets with spread > 3x tick size... ============================================================ 📊 Fetched 100 active markets Analyzing spreads... ✅ Found 3 market(s) with wide spreads: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Market #1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📌 Basic Information: Question: Will X happen before Y? Market ID: 12345 ... 💰 Spread & Tick Information: Tick Size: 0.010000 Spread: 0.045000 Spread Ratio: 4.50x tick size ⚠️ ... ``` -------------------------------- ### Example Market Closing Soon Scenario Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-closing-soon-markets/README.md Illustrates a scenario where a market is closing soon, and the current price does not reflect the highly predictable or already determined outcome, presenting an arbitrage opportunity. ```plaintext Market closes in 6 hours: "Will it rain in NYC today?" Current price: 0.30 (30% probability) Your information: It's currently raining heavily in NYC Opportunity: - Outcome is already determined/highly predictable - Price hasn't adjusted to reality - Information asymmetry = profit potential ``` -------------------------------- ### Mean Reversion Strategy Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-rapid-price-movement/README.md Illustrates a mean reversion trading scenario where a market price has spiked significantly and is assumed to revert to its fair value. This strategy is suitable when a market shows overreaction. ```plaintext Market suddenly moves: Price: 0.30 → 0.50 (+67% in 24h) Assumption: Overreaction, will reverse Action: SELL at 0.50 Target: Price returns to 0.35-0.40 Profit: Capture the reversion ``` -------------------------------- ### Good Opportunity Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-low-liquidity-high-volume/README.md Details a good market making opportunity, featuring moderate volume, moderate liquidity, an adequate spread, and moderate turnover, resulting in a score that suggests consideration for experienced traders. ```text Example: 24h Volume: $18,000 Liquidity: $15,500 Turnover: 1.2x Spread: 1.5% Score: 65 Action: Consider if you have experience ``` -------------------------------- ### Client Initialization Source: https://context7.com/ivanzzeth/polymarket-go-gamma-client/llms.txt Demonstrates how to initialize the Polymarket Go Gamma Client and perform a health check on the API. ```APIDOC ## Client Initialization Creates a new Gamma API client for querying market data, events, and metadata. ### Method N/A (Client Initialization) ### Endpoint N/A (Client Initialization) ### Request Example ```go package main import ( "context" "fmt" "log" "net/http" polymarketgamma "github.com/ivanzzeth/polymarket-go-gamma-client" ) func main() { // Create client with default HTTP client client := polymarketgamma.NewClient(http.DefaultClient) // Verify API is healthy health, err := client.HealthCheck(context.Background()) if err != nil { log.Fatal(err) } fmt.Printf("API Status: %s\n", health.Data) // Output: API Status: OK } ``` ### Response #### Success Response (200) - **Data** (string) - Status of the API, e.g., "OK" ``` -------------------------------- ### Configuration Parameters Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-new-active-markets/README.md Adjust these parameters in `main.go` to customize the market search criteria, such as market age and liquidity. ```go daysOld := 7.0 // Markets less than 7 days old maxLiquidity := 10000.0 // Maximum liquidity (early stage) targetCount := 5 // Number of opportunities ``` -------------------------------- ### Initialize Polymarket Gamma Client Source: https://context7.com/ivanzzeth/polymarket-go-gamma-client/llms.txt Creates a new Gamma API client using the default HTTP client. Verifies API health after initialization. ```go package main import ( "context" "fmt" "log" "net/http" polymarketgamma "github.com/ivanzzeth/polymarket-go-gamma-client" ) func main() { // Create client with default HTTP client client := polymarketgamma.NewClient(http.DefaultClient) // Verify API is healthy health, err := client.HealthCheck(context.Background()) if err != nil { log.Fatal(err) } fmt.Printf("API Status: %s\n", health.Data) // Output: API Status: OK } ``` -------------------------------- ### GET /markets/{id} Source: https://context7.com/ivanzzeth/polymarket-go-gamma-client/llms.txt Fetches a specific market by its numeric ID, optionally including tag information. ```APIDOC ## GET /markets/{id} Fetches a specific market by its numeric ID, optionally including tag information. ### Method GET ### Endpoint /markets/{id} ### Path Parameters - **id** (string) - Required - The unique identifier of the market. ### Query Parameters - **includeTag** (bool) - Optional - Whether to include tag information in the response. ### Request Example ```go package main import ( "context" "fmt" "log" "net/http" polymarketgamma "github.com/ivanzzeth/polymarket-go-gamma-client" ) func main() { client := polymarketgamma.NewClient(http.DefaultClient) ctx := context.Background() // Fetch market by ID with tags includeTag := true params := &polymarketgamma.GetMarketByIDQueryParams{ IncludeTag: &includeTag, } market, err := client.GetMarketByID(ctx, "123456", params) if err != nil { log.Fatal(err) } fmt.Printf("Market: %s\n", market.Question) fmt.Printf("Condition ID: %s\n", market.ConditionID) fmt.Printf("Category: %s\n", market.Category) fmt.Printf("Market Type: %s\n", market.MarketType) fmt.Printf("End Date: %s\n", market.EndDate.Format("2006-01-02")) fmt.Printf("Resolution Source: %s\n", market.ResolutionSource) fmt.Printf("Price Changes - 1h: %.2f%%, 1d: %.2f%%, 1w: %.2f%%\n", market.OneHourPriceChange*100, market.OneDayPriceChange*100, market.OneWeekPriceChange*100) // Print associated tags for _, tag := range market.Tags { fmt.Printf("Tag: %s (ID: %s)\n", tag.Label, tag.ID) } } ``` ### Response #### Success Response (200) - **ID** (string) - Unique identifier for the market. - **Question** (string) - The question posed by the market. - **ConditionID** (string) - The ID of the market's condition. - **Category** (string) - The category the market belongs to. - **MarketType** (string) - The type of the market (e.g., "binary", "scalar"). - **EndDate** (string) - The end date of the market. - **ResolutionSource** (string) - The source for market resolution. - **OneHourPriceChange** (float64) - The price change in the last hour (as a decimal). - **OneDayPriceChange** (float64) - The price change in the last day (as a decimal). - **OneWeekPriceChange** (float64) - The price change in the last week (as a decimal). - **Tags** (array) - An array of tag objects associated with the market. - **Label** (string) - The label of the tag. - **ID** (string) - The ID of the tag. #### Response Example ```json { "ID": "123456", "Question": "Will the S&P 500 close above 5000 on December 31st, 2024?", "ConditionID": "cond-abc", "Category": "Finance", "MarketType": "binary", "EndDate": "2024-12-31T00:00:00Z", "ResolutionSource": "polymarket", "OneHourPriceChange": 0.02, "OneDayPriceChange": 0.05, "OneWeekPriceChange": 0.10, "Tags": [ { "Label": "S&P 500", "ID": "sp500" }, { "Label": "Finance", "ID": "finance" } ] } ``` ``` -------------------------------- ### Correlated Events Arbitrage Scenario Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/ANALYSIS.md Example scenario for arbitrage in correlated events, highlighting logical inconsistencies in implied probabilities between related events. ```text Event A: "Trump wins 2024 election" = 0.55 Event B: "Republican wins 2024 election" = 0.50 ``` -------------------------------- ### GET /markets Source: https://context7.com/ivanzzeth/polymarket-go-gamma-client/llms.txt Fetches markets with optional filtering and pagination. Supports extensive filtering by liquidity, volume, dates, tags, and market status. ```APIDOC ## GET /markets Fetches markets with optional filtering and pagination. Supports extensive filtering by liquidity, volume, dates, tags, and market status. ### Method GET ### Endpoint /markets ### Query Parameters - **limit** (int) - Optional - Maximum number of markets to return. - **offset** (int) - Optional - Number of markets to skip. - **closed** (bool) - Optional - Filter by market closed status. - **liquidityNumMin** (float64) - Optional - Minimum numeric liquidity. - **order** (string) - Optional - Field to order results by (e.g., "volume24hr"). ### Request Example ```go package main import ( "context" "fmt" "log" "net/http" polymarketgamma "github.com/ivanzzeth/polymarket-go-gamma-client" ) func main() { client := polymarketgamma.NewClient(http.DefaultClient) ctx := context.Background() // Fetch active markets with filtering closed := false minLiquidity := 10000.0 params := &polymarketgamma.GetMarketsParams{ Limit: 10, Offset: 0, Closed: &closed, LiquidityNumMin: &minLiquidity, Order: "volume24hr", } markets, err := client.GetMarkets(ctx, params) if err != nil { log.Fatal(err) } for _, market := range markets { fmt.Printf("Question: %s\n", market.Question) fmt.Printf(" ID: %s\n", market.ID) fmt.Printf(" Last Price: %.4f\n", market.LastTradePrice) fmt.Printf(" Spread: %.4f (Best Bid: %.4f, Best Ask: %.4f)\n", market.Spread, market.BestBid, market.BestAsk) fmt.Printf(" 24h Volume: $%.2f\n", market.Volume24hr) fmt.Printf(" Liquidity: $%.2f (CLOB: $%.2f, AMM: $%.2f)\n", market.LiquidityNum, market.LiquidityClob, market.LiquidityAmm) fmt.Printf(" Tick Size: %.6f, Min Order: %.6f\n", market.OrderPriceMinTickSize, market.OrderMinSize) fmt.Printf(" Outcomes: %v\n", market.Outcomes) fmt.Printf(" Accepting Orders: %t\n\n", market.AcceptingOrders) } } ``` ### Response #### Success Response (200) - **ID** (string) - Unique identifier for the market. - **Question** (string) - The question posed by the market. - **LastTradePrice** (float64) - The price of the last trade. - **Spread** (float64) - The difference between the best bid and best ask. - **BestBid** (float64) - The highest bid price. - **BestAsk** (float64) - The lowest ask price. - **Volume24hr** (float64) - The trading volume in the last 24 hours. - **LiquidityNum** (float64) - Total numeric liquidity. - **LiquidityClob** (float64) - Liquidity from the CLOB (Central Limit Order Book). - **LiquidityAmm** (float64) - Liquidity from the AMM (Automated Market Maker). - **OrderPriceMinTickSize** (float64) - The minimum tick size for orders. - **OrderMinSize** (float64) - The minimum order size. - **Outcomes** (array) - List of possible outcomes for the market. - **AcceptingOrders** (bool) - Indicates if the market is currently accepting orders. #### Response Example ```json [ { "ID": "123", "Question": "Will it rain tomorrow?", "LastTradePrice": 0.5, "Spread": 0.1, "BestBid": 0.45, "BestAsk": 0.55, "Volume24hr": 15000.0, "LiquidityNum": 12000.0, "LiquidityClob": 10000.0, "LiquidityAmm": 2000.0, "OrderPriceMinTickSize": 0.001, "OrderMinSize": 0.01, "Outcomes": ["Yes", "No"], "AcceptingOrders": true } ] ``` ``` -------------------------------- ### Related Markets Arbitrage Scenario Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/ANALYSIS.md Example scenario for arbitrage in related markets where probabilities should sum to 1.0. Identifies discrepancies for potential risk-free profit. ```text Event: "2024 Presidential Election Winner" - Market A: "Trump wins" = 0.48 - Market B: "Biden wins" = 0.47 - Market C: "Other wins" = 0.03 Sum = 0.98 (should be 1.0) ``` -------------------------------- ### Fetch Markets with Filtering Source: https://context7.com/ivanzzeth/polymarket-go-gamma-client/llms.txt Fetches active markets with optional filtering by liquidity, volume, dates, and market status. Requires specifying parameters like Limit, Offset, Closed status, and minimum liquidity. ```go package main import ( "context" "fmt" "log" "net/http" polymarketgamma "github.com/ivanzzeth/polymarket-go-gamma-client" ) func main() { client := polymarketgamma.NewClient(http.DefaultClient) ctx := context.Background() // Fetch active markets with filtering closed := false minLiquidity := 10000.0 params := &polymarketgamma.GetMarketsParams{ Limit: 10, Offset: 0, Closed: &closed, LiquidityNumMin: &minLiquidity, Order: "volume24hr", } markets, err := client.GetMarkets(ctx, params) if err != nil { log.Fatal(err) } for _, market := range markets { fmt.Printf("Question: %s\n", market.Question) fmt.Printf(" ID: %s\n", market.ID) fmt.Printf(" Last Price: %.4f\n", market.LastTradePrice) fmt.Printf(" Spread: %.4f (Best Bid: %.4f, Best Ask: %.4f)\n", market.Spread, market.BestBid, market.BestAsk) fmt.Printf(" 24h Volume: $%.2f\n", market.Volume24hr) fmt.Printf(" Liquidity: $%.2f (CLOB: $%.2f, AMM: $%.2f)\n", market.LiquidityNum, market.LiquidityClob, market.LiquidityAmm) fmt.Printf(" Tick Size: %.6f, Min Order: %.6f\n", market.OrderPriceMinTickSize, market.OrderMinSize) fmt.Printf(" Outcomes: %v\n", market.Outcomes) fmt.Printf(" Accepting Orders: %t\n\n", market.AcceptingOrders) } } ``` -------------------------------- ### Fetch Event by ID with Chat Source: https://context7.com/ivanzzeth/polymarket-go-gamma-client/llms.txt Retrieves a specific event using its ID. This example demonstrates how to include chat channel information in the response by setting `IncludeChat` to true. ```go package main import ( "context" "fmt" "log" "net/http" polymarketgamma "github.com/ivanzzeth/polymarket-go-gamma-client" ) func main() { client := polymarketgamma.NewClient(http.DefaultClient) ctx := context.Background() includeChat := true params := &polymarketgamma.GetEventByIDQueryParams{ IncludeChat: &includeChat, } event, err := client.GetEventByID(ctx, "12345", params) if err != nil { log.Fatal(err) } fmt.Printf("Event: %s\n", event.Title) fmt.Printf("Category: %s / %s\n", event.Category, event.Subcategory) fmt.Printf("Start: %s, End: %s\n", event.StartDate.Format("2006-01-02"), event.EndDate.Format("2006-01-02")) fmt.Printf("NegRisk Market ID: %s\n", event.NegRiskMarketID) fmt.Printf("NegRisk Fee: %d bps\n", event.NegRiskFeeBips) // Print chat channels if available for _, chat := range event.Chats { fmt.Printf("Chat: %s (ID: %s, Live: %t)\n", chat.ChannelName, chat.ChannelID, chat.Live) } // Calculate probability sum for arbitrage detection var probSum float64 for _, market := range event.Markets { probSum += market.LastTradePrice } fmt.Printf("Probability Sum: %.4f (deviation from 1.0: %.2f%%)\n", probSum, (probSum-1.0)*100) } ``` -------------------------------- ### Fetch Market by Slug Source: https://context7.com/ivanzzeth/polymarket-go-gamma-client/llms.txt Retrieves a specific market using its URL-friendly slug. Ensure the slug is correct for the desired market. ```go package main import ( "context" "fmt" "log" "net/http" polymarketgamma "github.com/ivanzzeth/polymarket-go-gamma-client" ) func main() { client := polymarketgamma.NewClient(http.DefaultClient) ctx := context.Background() market, err := client.GetMarketBySlug(ctx, "will-bitcoin-reach-100k-by-2024", nil) if err != nil { log.Fatal(err) } fmt.Printf("Market: %s\n", market.Question) fmt.Printf("Slug: %s\n", market.Slug) fmt.Printf("Last Trade Price: %.4f\n", market.LastTradePrice) fmt.Printf("Total Volume: $%.2f\n", market.VolumeNum) fmt.Printf("Active: %t, Closed: %t\n", market.Active, market.Closed) } ``` -------------------------------- ### Position Sizing Strategies Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-low-liquidity-high-volume/README.md Outlines different approaches to sizing your initial position in a market, ranging from conservative to aggressive, with rationale for each. ```text Conservative Approach: - Start with 5-10% of current liquidity - Market liquidity: $10,000 - Your capital: $500-1,000 - Quotes: $250-500 per side Rationale: - Test the market first - Learn the dynamics - Minimize risk - Scale up if successful Moderate Approach: - Use 10-20% of liquidity - Market liquidity: $10,000 - Your capital: $1,000-2,000 - Quotes: $500-1,000 per side Aggressive Approach (not recommended initially): - Use 25%+ of liquidity - Risk: Market impact, harder to rebalance - Only if very confident ``` -------------------------------- ### Momentum Strategy Example Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-rapid-price-movement/README.md Illustrates a momentum trading scenario where a market price is showing a strong trend and is assumed to continue in the same direction. This strategy is suitable for capitalizing on sustained trends. ```plaintext Market starts moving: Price: 0.30 → 0.50 (+67% in 24h) Assumption: Strong trend, will continue Action: BUY at 0.50 Target: Price continues to 0.60-0.70 Profit: Ride the momentum ``` -------------------------------- ### Calculate Position Size with NegRisk Source: https://github.com/ivanzzeth/polymarket-go-gamma-client/blob/main/examples/find-negrisk-opportunities/README.md Demonstrates how to calculate the potential position size and capital advantage when using NegRisk compared to standard markets, given a fixed capital amount. ```plaintext Example with $1,000 capital: - Without NegRisk: Can take ~$971 position (1000/1.03) - With NegRisk: Can take $1,000 position - Advantage: 2.9% more exposure with same capital ```