Class TradingTools

java.lang.Object
com.tnsai.tools.trading.TradingTools

public class TradingTools extends Object
Function-shape Polymarket tools — read-only prediction-market data via the public Gamma + CLOB APIs. Replaces the legacy PolymarketTool (single dispatched tool). No API key required.
MethodEndpointIdempotent
polymarketMarkets(java.lang.String, int)GET gamma /marketstrue
polymarketSearch(java.lang.String, int)GET gamma /markets?search=…true
polymarketPrices(java.lang.String)GET clob /book?token_id=…true

Returns the raw JSON from Polymarket so the LLM can structure the response itself (orderbooks / outcome prices / volumes have a lot of fields and the right view depends on the question being asked).

Since:
0.5.7 (Phase 2 batch 15a — built-in tool migration to function shape, see #188)
  • Constructor Details

    • TradingTools

      public TradingTools()
      Default constructor — uses the public Polymarket APIs (no auth).
    • TradingTools

      public TradingTools(okhttp3.OkHttpClient http, com.fasterxml.jackson.databind.ObjectMapper mapper)
      Full constructor for tests / shared HTTP.
  • Method Details

    • polymarketMarkets

      @Tool(name="polymarket_markets", description="List active Polymarket prediction markets. Optional {tag} filters by category (\"politics\", \"sports\", \"crypto\", \u2026). {limit} clamps to [1, 100]. Returns the raw Gamma-API JSON array of market objects with question / outcomes / outcomePrices / volume / endDate.", keywords={"polymarket","prediction","market","list","betting"}, idempotent=true) public String polymarketMarkets(@ToolParam(description="Optional category tag (e.g. \"politics\")",required=false,defaultValue="") String tag, @ToolParam(description="Max results (1..100); 0 \u2192 default 10",required=false,defaultValue="0") int limit) throws IOException
      Throws:
      IOException
    • polymarketSearch

      @Tool(name="polymarket_search", description="Search Polymarket prediction markets by free-text {query}. {limit} clamps to [1, 100]. Returns the raw Gamma-API JSON array. Useful for finding markets by person/event name (e.g. \"trump\", \"world cup\", \"bitcoin price\").", keywords={"polymarket","search","prediction","market"}, idempotent=true) public String polymarketSearch(@ToolParam(description="Free-text market search query") String query, @ToolParam(description="Max results (1..100); 0 \u2192 default 10",required=false,defaultValue="0") int limit) throws IOException
      Throws:
      IOException
    • polymarketPrices

      @Tool(name="polymarket_prices", description="Fetch the current order book for a Polymarket outcome token. {tokenId} comes from a market\'s clobTokenIds array (one per outcome). Returns the raw CLOB JSON response with bids / asks / midpoint.", keywords={"polymarket","prices","orderbook","clob","token"}, idempotent=true) public String polymarketPrices(@ToolParam(description="Outcome token id (CLOB token id, hex string)") String tokenId) throws IOException
      Throws:
      IOException