Skill: polymarket-weather-bands
This skill defines a compact one-shot weather trading flow on top of aionmarket-trading.
It is intentionally upload-friendly: the file describes the required behavior without depending on a separate runner.py.
Scope
- Ask only for
AIONMARKET_API_KEY and WALLET_PRIVATE_KEY
- Auto-derive wallet address and Polymarket CLOB credentials
- Auto-register wallet credentials with AION Market
- Auto-check USDC balance, Polygon gas, and required allowance
- Auto-approve if allowance is insufficient and gas is available
- Fetch the hottest active weather markets from Polymarket
- Auto-pick a suitable market and prefer a market buy order
- Default to
2 USDC spend unless the user overrides size or requests a limit order
- Verify the actual result through Polymarket if the SDK response is weak
This skill does not implement forecasting models or unattended recurring trading.
Required Inputs
| Input | Required | Default |
|---|
AIONMARKET_API_KEY | yes | none |
WALLET_PRIVATE_KEY | yes | none |
orderMode | no | market |
orderSize | no | 2 USDC |
outcome | no | auto |
price | only for explicit limit order | auto |
The agent should not ask for additional confirmation on steps it can execute directly.
Mandatory Rules
- If either secret is missing, stop and ask for it.
- Never ask the user to manually provide Polymarket API credentials.
- After the private key is available, automatically perform wallet derivation, wallet registration, balance checks, gas checks, allowance checks, and approval when needed.
- Show the selected market snapshot and final order parameters before submission, but do not block on confirmation unless the user explicitly requested manual confirmation mode.
- Default to a market buy order.
- Default spend is
2 USDC.
- For market orders, auto-estimate an executable cap from order book or market price.
- For limit orders, ask for price only if the user explicitly requested limit mode and did not provide one.
- Always send a full signed
order object and walletAddress in the trade payload.
- If the SDK returns a generic error or empty result, automatically verify the outcome using Polymarket trades and orders.
Market Selection Policy
Use Polymarket Gamma weather markets and rank candidates by:
volume24hr descending
liquidity descending
- valid
conditionId, clobTokenIds, and usable YES/NO prices
- prices not pinned too close to
0 or 1
- better immediate fill characteristics for market orders
Choose the best candidate automatically unless the user requested a specific market.
Recommended endpoint:
GET https://gamma-api.polymarket.com/events/pagination?tag_slug=weather&active=true&closed=false&archived=false&order=volume24hr&ascending=false&limit=20&offset=0
Execution Policy
The agent should follow this sequence:
- Derive wallet address and CLOB credentials from
WALLET_PRIVATE_KEY
- Register wallet credentials in AION Market if missing
- Check USDC balance, Polygon gas, and allowance
- Auto-approve the needed spender if allowance is insufficient
- Fetch and rank hot weather markets
- Show the selected market snapshot
- Resolve defaults:
orderMode=market, orderSize=2, side=BUY
- Build a signed Polymarket order
- Submit through
client.trade()
- Verify the actual result from Polymarket CLOB if the SDK wrapper response is incomplete
Required Trade Payload
| Field | Required |
|---|
marketConditionId | yes |
marketQuestion | yes |
outcome | yes |
orderSize | yes |
price | yes |
isLimitOrder | yes |
orderType | yes |
order | yes |
walletAddress | yes |
reasoning | yes |
Important:
marketConditionId must be the sub-market conditionId, not the event id
order must be the full signed object from py-clob-client
- market orders should use
FAK or FOK semantics
- limit orders should respect tick size and minimum size
Failure Handling
- If balance is insufficient, stop and report the deficit
- If gas is insufficient, stop and report the shortfall
- If allowance is insufficient and gas exists, auto-approve and continue
- If
get_market_context() fails in sandbox, continue using direct market data and CLOB read-only validation as fallback
- Never execute fallback orders directly through Polymarket SDK; trade and cancel actions must use AION API endpoints only
- If SDK returns
tradeResult: null or INTERNAL_ERROR, verify recent trades and open orders before reporting failure
Minimal Example
from aionmarket_sdk import AionMarketClient
from py_clob_client.client import ClobClient
client = AionMarketClient(api_key=AIONMARKET_API_KEY)
bootstrap = ClobClient("https://clob.polymarket.com", key=WALLET_PRIVATE_KEY, chain_id=137)
wallet_address = bootstrap.get_address()
creds = bootstrap.create_or_derive_api_creds()
check = client.check_wallet_credentials(wallet_address)
if not check.get("hasCredentials"):
client.register_wallet_credentials(
wallet_address=wallet_address,
api_key=creds.api_key,
api_secret=creds.api_secret,
api_passphrase=creds.api_passphrase,
)
# Then: auto-check balance/gas/allowance -> fetch hot weather markets ->
# auto-pick candidate -> build signed market order -> client.trade(payload) ->
# verify with Polymarket trades if needed.
This skill file is self-contained and intended to be uploaded on its own.