wallet-analytics
Wallet Analytics
Overview
Analyze Polymarket wallet performance including trading metrics, positions, realized PnL, and performance indicators like Sharpe ratio and win rate.
Security
This skill implements defense-in-depth measures against indirect prompt injection (Snyk W011):
- Input Sanitization: All user-generated content (handles, pseudonyms, position titles, labels) is sanitized using
security.ts - Pattern Filtering: Known prompt injection patterns are removed (e.g., "ignore previous instructions", "system:")
- Content Validation: Suspicious content with excessive special characters is flagged
- Fail-Safe: Processing errors return original data rather than corrupting it
The skill fetches data from the trusted DOME API (api.domeapi.io) which provides structured wallet and position data from the Polymarket protocol.
Setup
npm install
npm run build
Quick Start
import {
fetchWalletInfo,
fetchPositions,
fetchWalletPnL,
calculateTradingPerformance,
getPositionSummary
} from "./scripts/walletAnalytics.js";
// Get wallet info with metrics
const wallet = await fetchWalletInfo(apiKey, {
proxy: "0x...",
with_metrics: true
});
// Get current positions
const positions = await fetchAllPositions(apiKey, wallet.proxy);
// Get PnL history
const pnl = await fetchWalletPnL(apiKey, wallet.proxy, {
granularity: "day"
});
// Calculate performance
const performance = calculateTradingPerformance(pnl.pnl_over_time);
console.log(`Sharpe ratio: ${performance.sharpe_ratio}`);
Core Functions
fetchWalletInfo()
Fetch wallet information with optional trading metrics.
const wallet = await fetchWalletInfo(apiKey, {
eoa: "0x...", // Or proxy, or handle
with_metrics: true,
start_time: 1700000000,
end_time: 1700000000
});
fetchPositions()
Fetch wallet positions with pagination.
const result = await fetchPositions(apiKey, walletAddress, {
limit: 100
});
// Returns: { wallet_address, positions: [...], pagination }
fetchAllPositions()
Fetch all positions with automatic pagination.
const positions = await fetchAllPositions(apiKey, walletAddress, {
maxPages: 5
});
fetchWalletPnL()
Fetch realized PnL with time granularity.
const pnl = await fetchWalletPnL(apiKey, walletAddress, {
granularity: "day", // "day" | "week" | "month" | "year" | "all"
start_time: 1700000000,
end_time: 1700000000
});
calculateTradingPerformance()
Calculate comprehensive trading metrics.
const performance = calculateTradingPerformance(pnlPeriods);
// Returns: {
// total_return,
// max_drawdown,
// win_rate,
// profitable_days,
// sharpe_ratio,
// average_daily_return,
// volatility
// }
calculateSharpeRatio()
Calculate risk-adjusted returns.
const sharpe = calculateSharpeRatio(returns, riskFreeRate);
getPositionSummary()
Summarize positions by status and side.
const summary = getPositionSummary(positions);
// Returns: { total_positions, open_positions, closed_positions, by_side, ... }
analyzeSmartMoneyIndicators()
Analyze smart money characteristics.
const indicators = analyzeSmartMoneyIndicators(parsedWallet, performance);
// Returns: { volume_percentile, consistency_score, overall_score, ... }
Important Note
PnL data shows realized gains only - from confirmed sells or redeems. Unrealized gains from open positions are not included until the market is redeemed.
More from 0xweaksheep/dome_skills
market-discovery
Fetch and discover Polymarket markets from DOME API. Use this skill when the user wants to find markets, search for specific topics, filter markets by criteria (volume, status, tags), or identify backtesting candidates. Triggers include phrases like "find markets", "search for markets", "get market data", "filter markets", or "discover markets".
3backtest-planner
|
3historical-trades
Fetch and analyze historical Polymarket trade data. Use this skill when users need to retrieve trade history, analyze trading patterns, calculate volume statistics, or aggregate trades by time periods for specific markets, tokens, or users.
3candlestick-analysis
Analyze historical candlestick data for Polymarket prediction markets. Use this skill when users need to fetch OHLCV data, calculate technical indicators (SMA, EMA, volatility), detect price trends, support/resistance levels, or perform time-series analysis on market prices. Trigger for requests involving price history, chart data, technical analysis, or market trend detection.
3activity-monitor
Monitor and analyze Polymarket trading activity including MERGES, SPLITS, and REDEEMS. Use this skill when the user wants to track large transactions, analyze activity patterns, detect suspicious behavior, or monitor market closing signals. Triggers include phrases like "track activity", "monitor transactions", "large trades", "activity patterns", or "market closing signals".
2event-discovery
Fetch and discover Polymarket events from DOME API. Use this skill when the user wants to find events (groups of related markets), search for specific event topics, filter events by criteria (volume, status, tags), or get markets within an event. Triggers include phrases like "find events", "get event markets", "discover events", "event analysis", or "events by category".
2