A single-user, read-only research and trading-assist platform for Polymarket Shanghai daily max temperature markets.
- No auto-trading
- No wallet/private key integration
- Core output:
Decision/Position/Reason
Core docs:
- Product Spec (CN):
docs/PRODUCT_SPEC.zh-CN.md - Change Workflow (CN):
docs/CHANGE_WORKFLOW.zh-CN.md
This project is not a generic weather app. It is a decision terminal built around Polymarket resolution rules.
Core principle:
Polymarket Rules -> Resolution Station -> Resolution Source -> Final Value
Current scope:
- City:
Shanghai - Station:
Shanghai Pudong International Airport Station (ZSPD) - Resolution reference: Wunderground (as defined by Polymarket rules)
- Real-time Polymarket market fetch (Shanghai max temperature)
- Auto target-date rollover:
- Use same-day market if still active
- Switch to next-day market when closed/near settlement window
- Multi-source weather fusion (strict success/failure separation)
- Weather source policy layer:
sourceKind/ station match / freshness / health - Probability distribution, Edge, risk flags, score, decision
- Nowcasting panel (current + next 1–6h)
- Snapshot and replay support
- Source bias stats for calibration
- Bilingual UI (
?lang=zh/?lang=en)
- Next.js (App Router)
- TypeScript
- Tailwind CSS
- shadcn/ui
- Prisma + SQLite
- Recharts
- Zod
- date-fns
- node-cron
Path: /src/lib/trading-engine
Main modules:
tradingEngine.ts(entry:runTradingDecision)edge.tstimingScore.tsweatherScore.tsdataQuality.tsriskEngine.tspositionSizer.tsmodel.ts
Formula:
Edge = ModelProbability - MarketPriceTradeScore = 0.35*EdgeScore + 0.25*TimingScore + 0.20*WeatherScore + 0.20*DataQualityScore
Decision mapping:
tradableEV > 0.06 -> BUY0.02 ~ 0.06 -> WATCH< 0.02 -> PASS
- Polymarket Gamma API
- Wunderground/Weather.com (station anchor)
- Open-Meteo
- wttr
- met.no
- WeatherAPI (optional)
- QWeather (optional)
- AviationWeather (METAR/TAF for short-term risk)
Notes:
- Assist weather sources are not the final settlement source.
- If a source fails, status and reason are shown; no fake fallback data is injected.
- Open-Meteo is fetched with forced model:
models=ecmwf_ifs04. - Weight formula:
rawWeight = baseSourceWeight × matchScore × stationPenalty × accuracyScore × scenarioScore × regimeScore × freshnessScore × healthScore
/Home terminal/three-pm3PM scanner/market/[slug]Market detail
Schema file: /prisma/schema.prisma
Core tables:
marketsmarket_binsresolution_metadataweather_assist_snapshotsmodel_runsmodel_bin_outputssnapshotsnotessettled_resultsforecast_source_biases
npm install
cp .env.example .env
npm run db:generate
npm run db:push
npm run db:seed
npm run devnpm run dev runs one initial job:once -- all before starting Next.js.
npm run dev
npm run typecheck
npm run test
npm run job:once -- all
npm run job:once -- market
npm run job:once -- weather
npm run job:once -- model
npm run job:once -- settled
npm run jobs
npm run compare:openmeteo-wuThis repo is now maintained as local-first only.
- No Cloudflare deployment path
- No Node service split deployment path
- Use local
Next.js + Prisma + SQLiteas the single source of truth
Copy .env.example and configure as needed.
Important keys:
DATABASE_URLPOLYMARKET_API_BASEPOLYMARKET_EVENT_SLUGMARKET_ROLLOVER_WINDOW_MINUTESTOTAL_CAPITALMAX_SINGLE_TRADE_PERCENTWEATHER_STRICT_SOURCESENABLE_NWS_HOURLYFUSION_EXCLUDED_SOURCESWEATHERAPI_KEYQWEATHER_API_KEYAVIATIONWEATHER_API_BASE
- Default:
3000 - If occupied: fallback to
3001 - Always use terminal
Local:URL
npm run jobs (node-cron):
- Market: every 5 min
- Weather: every 10 min
- Model: every 5 min
- Settled sync: daily 01:10
Manual APIs:
POST /api/refreshPOST /api/jobs/run(job=market|weather|model|settled|all)
Decision:BUY / WATCH / PASSPosition: suggested sizeReason: explanation
This project is for research and decision support only, not investment advice.