investing 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -60
- package/dist/algo-stategies/tv-scraper.d.ts +2 -0
- package/dist/algo-stategies/tv-scraper.d.ts.map +1 -0
- package/dist/alpaca/alpaca-mcp-client.d.ts +174 -0
- package/dist/alpaca/alpaca-mcp-client.d.ts.map +1 -0
- package/dist/alpaca/client.d.ts +21 -0
- package/dist/alpaca/client.d.ts.map +1 -0
- package/dist/archiver-web.es-BgXzilRH.cjs +1 -0
- package/dist/archiver-web.es-EPYdovFt.js +1 -0
- package/dist/correlate/metrics.d.ts +40 -0
- package/dist/correlate/metrics.d.ts.map +1 -0
- package/dist/correlate/model-persistence.d.ts +26 -0
- package/dist/correlate/model-persistence.d.ts.map +1 -0
- package/dist/correlate/predict-statistics.d.ts +14 -0
- package/dist/correlate/predict-statistics.d.ts.map +1 -0
- package/dist/correlate/rolling-stats.d.ts +27 -0
- package/dist/correlate/rolling-stats.d.ts.map +1 -0
- package/dist/correlate/types.d.ts +78 -0
- package/dist/correlate/types.d.ts.map +1 -0
- package/dist/correlate/xgboost-predictor.d.ts +19 -0
- package/dist/correlate/xgboost-predictor.d.ts.map +1 -0
- package/dist/correlate/xgboost-trainer.d.ts +112 -0
- package/dist/correlate/xgboost-trainer.d.ts.map +1 -0
- package/dist/db/client.d.ts +10 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/d1-http.d.ts +38 -0
- package/dist/db/d1-http.d.ts.map +1 -0
- package/dist/db/index.d.ts +8870 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/relations.d.ts +21 -0
- package/dist/db/relations.d.ts.map +1 -0
- package/dist/db/schema.d.ts +8845 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/debate-research/stock-agents-api.d.ts +129 -0
- package/dist/debate-research/stock-agents-api.d.ts.map +1 -0
- package/dist/index-C9OpAHBe.js +15 -0
- package/dist/index-CLlAnStL-B7EBGdAY.cjs +1 -0
- package/dist/index-CLlAnStL-C554ZmGF.js +1 -0
- package/dist/index-CcyBsxYm.cjs +13 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/leaders/nvsty-leaders.d.ts +63 -0
- package/dist/leaders/nvsty-leaders.d.ts.map +1 -0
- package/dist/leaders/zulu.d.ts +167 -0
- package/dist/leaders/zulu.d.ts.map +1 -0
- package/dist/live-data/dukascopy-client.d.ts +102 -0
- package/dist/live-data/dukascopy-client.d.ts.map +1 -0
- package/dist/llm/debate-generator.d.ts +32 -0
- package/dist/llm/debate-generator.d.ts.map +1 -0
- package/dist/prediction/analysis/categories.d.ts +37 -0
- package/dist/prediction/analysis/categories.d.ts.map +1 -0
- package/dist/prediction/analysis/detector.d.ts +15 -0
- package/dist/prediction/analysis/detector.d.ts.map +1 -0
- package/dist/prediction/analysis/greeks.d.ts +11 -0
- package/dist/prediction/analysis/greeks.d.ts.map +1 -0
- package/dist/prediction/analysis/price-changes.d.ts +12 -0
- package/dist/prediction/analysis/price-changes.d.ts.map +1 -0
- package/dist/prediction/api/analytics.d.ts +46 -0
- package/dist/prediction/api/analytics.d.ts.map +1 -0
- package/dist/prediction/api/gamma.d.ts +30 -0
- package/dist/prediction/api/gamma.d.ts.map +1 -0
- package/dist/prediction/api/leaderboard.d.ts +113 -0
- package/dist/prediction/api/leaderboard.d.ts.map +1 -0
- package/dist/prediction/api/markets.d.ts +62 -0
- package/dist/prediction/api/markets.d.ts.map +1 -0
- package/dist/prediction/api/prices.d.ts +32 -0
- package/dist/prediction/api/prices.d.ts.map +1 -0
- package/dist/prediction/constants.d.ts +7 -0
- package/dist/prediction/constants.d.ts.map +1 -0
- package/dist/prediction/db/debates.d.ts +41 -0
- package/dist/prediction/db/debates.d.ts.map +1 -0
- package/dist/prediction/db/leaderboard.d.ts +37 -0
- package/dist/prediction/db/leaderboard.d.ts.map +1 -0
- package/dist/prediction/db/markets.d.ts +91 -0
- package/dist/prediction/db/markets.d.ts.map +1 -0
- package/dist/prediction/db/positions.d.ts +73 -0
- package/dist/prediction/db/positions.d.ts.map +1 -0
- package/dist/prediction/db/prices.d.ts +37 -0
- package/dist/prediction/db/prices.d.ts.map +1 -0
- package/dist/prediction/db/trade-history.d.ts +108 -0
- package/dist/prediction/db/trade-history.d.ts.map +1 -0
- package/dist/prediction/index.d.ts +26 -0
- package/dist/prediction/index.d.ts.map +1 -0
- package/dist/prediction/sync/holders.d.ts +10 -0
- package/dist/prediction/sync/holders.d.ts.map +1 -0
- package/dist/prediction/sync/incremental-markets.d.ts +18 -0
- package/dist/prediction/sync/incremental-markets.d.ts.map +1 -0
- package/dist/prediction/sync/leaderboard.d.ts +25 -0
- package/dist/prediction/sync/leaderboard.d.ts.map +1 -0
- package/dist/prediction/sync/markets.d.ts +25 -0
- package/dist/prediction/sync/markets.d.ts.map +1 -0
- package/dist/prediction/sync/orchestration.d.ts +12 -0
- package/dist/prediction/sync/orchestration.d.ts.map +1 -0
- package/dist/prediction/sync/prices.d.ts +25 -0
- package/dist/prediction/sync/prices.d.ts.map +1 -0
- package/dist/prediction/sync/trade-history.d.ts +96 -0
- package/dist/prediction/sync/trade-history.d.ts.map +1 -0
- package/dist/prediction/sync.d.ts +4 -0
- package/dist/prediction/sync.d.ts.map +1 -0
- package/dist/prediction/types.d.ts +131 -0
- package/dist/prediction/types.d.ts.map +1 -0
- package/dist/prediction/utils/categorizer.d.ts +37 -0
- package/dist/prediction/utils/categorizer.d.ts.map +1 -0
- package/dist/predictos/index.d.ts +12 -0
- package/dist/predictos/index.d.ts.map +1 -0
- package/dist/stock-names-data/stock-names.json.d.ts +4 -0
- package/dist/stocks/find-wikipedia-urls.d.ts +6 -0
- package/dist/stocks/find-wikipedia-urls.d.ts.map +1 -0
- package/dist/stocks/finnhub-utils.d.ts +42 -0
- package/dist/stocks/finnhub-utils.d.ts.map +1 -0
- package/dist/stocks/finnhub-wrapper.d.ts +49 -0
- package/dist/stocks/finnhub-wrapper.d.ts.map +1 -0
- package/dist/stocks/import-stock-names.d.ts +2 -0
- package/dist/stocks/import-stock-names.d.ts.map +1 -0
- package/dist/stocks/index.d.ts +12 -0
- package/dist/stocks/index.d.ts.map +1 -0
- package/dist/stocks/quote-cache-service.d.ts +94 -0
- package/dist/stocks/quote-cache-service.d.ts.map +1 -0
- package/dist/stocks/sec-filing-api.d.ts +35 -0
- package/dist/stocks/sec-filing-api.d.ts.map +1 -0
- package/dist/stocks/stock-names-client.d.ts +10 -0
- package/dist/stocks/stock-names-client.d.ts.map +1 -0
- package/dist/stocks/stock-names.d.ts +26 -0
- package/dist/stocks/stock-names.d.ts.map +1 -0
- package/dist/stocks/types.d.ts +547 -0
- package/dist/stocks/types.d.ts.map +1 -0
- package/dist/stocks/unified-quote-example.d.ts +30 -0
- package/dist/stocks/unified-quote-example.d.ts.map +1 -0
- package/dist/stocks/unified-quote-service.d.ts +111 -0
- package/dist/stocks/unified-quote-service.d.ts.map +1 -0
- package/dist/stocks/yahoo-finance-wrapper.d.ts +344 -0
- package/dist/stocks/yahoo-finance-wrapper.d.ts.map +1 -0
- package/dist/stocks/yfinance-wrapper.d.ts +10 -0
- package/dist/stocks/yfinance-wrapper.d.ts.map +1 -0
- package/dist/trading-agents/agents/debate-facilitator.d.ts +26 -0
- package/dist/trading-agents/agents/debate-facilitator.d.ts.map +1 -0
- package/dist/trading-agents/agents/fund-manager.d.ts +11 -0
- package/dist/trading-agents/agents/fund-manager.d.ts.map +1 -0
- package/dist/trading-agents/agents/improved-researchers.d.ts +16 -0
- package/dist/trading-agents/agents/improved-researchers.d.ts.map +1 -0
- package/dist/trading-agents/agents/market-analyst.d.ts +8 -0
- package/dist/trading-agents/agents/market-analyst.d.ts.map +1 -0
- package/dist/trading-agents/agents/news-analyst.d.ts +8 -0
- package/dist/trading-agents/agents/news-analyst.d.ts.map +1 -0
- package/dist/trading-agents/agents/researchers.d.ts +22 -0
- package/dist/trading-agents/agents/researchers.d.ts.map +1 -0
- package/dist/trading-agents/agents/risk-team.d.ts +22 -0
- package/dist/trading-agents/agents/risk-team.d.ts.map +1 -0
- package/dist/trading-agents/agents/trader.d.ts +10 -0
- package/dist/trading-agents/agents/trader.d.ts.map +1 -0
- package/dist/trading-agents/example.d.ts +7 -0
- package/dist/trading-agents/example.d.ts.map +1 -0
- package/dist/trading-agents/graph/trading-graph.d.ts +59 -0
- package/dist/trading-agents/graph/trading-graph.d.ts.map +1 -0
- package/dist/trading-agents/index.d.ts +13 -0
- package/dist/trading-agents/index.d.ts.map +1 -0
- package/dist/trading-agents/tools/alpaca-mcp-tools.d.ts +46 -0
- package/dist/trading-agents/tools/alpaca-mcp-tools.d.ts.map +1 -0
- package/dist/trading-agents/tools/data-tools.d.ts +18 -0
- package/dist/trading-agents/tools/data-tools.d.ts.map +1 -0
- package/dist/trading-agents/tools/langchain-tools.d.ts +78 -0
- package/dist/trading-agents/tools/langchain-tools.d.ts.map +1 -0
- package/dist/trading-agents/types/index.d.ts +171 -0
- package/dist/trading-agents/types/index.d.ts.map +1 -0
- package/dist/trading-agents/utils/llm-client.d.ts +45 -0
- package/dist/trading-agents/utils/llm-client.d.ts.map +1 -0
- package/dist/trading-agents/utils/memory.d.ts +38 -0
- package/dist/trading-agents/utils/memory.d.ts.map +1 -0
- package/dist/trending-topics/wiki-page-views.d.ts +133 -0
- package/dist/trending-topics/wiki-page-views.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/package.json +47 -17
- package/data/globe.json +0 -182
- package/data/sector-info.json +0 -1540
- package/data/sectors-industries.json +0 -327
- package/data/stock-indexes.json +0 -106
- package/data/stock-names.json +0 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { PolymarketCategory } from '../constants';
|
|
2
|
+
/**
|
|
3
|
+
* Fetches the Polymarket leaderboard with top traders ranked by volume or PnL.
|
|
4
|
+
* @param options - Configuration options for the leaderboard query
|
|
5
|
+
* @param options.timePeriod - Time period filter: "all", "1d", "7d", or "30d" (default: "all")
|
|
6
|
+
* @param options.orderBy - Sort order: "VOL" for volume or "PNL" for profit/loss (default: "VOL")
|
|
7
|
+
* @param options.limit - Maximum number of entries to retrieve (default: 20)
|
|
8
|
+
* @param options.offset - Number of entries to skip for pagination (default: 0)
|
|
9
|
+
* @param options.category - Category filter (default: "overall")
|
|
10
|
+
* @returns Array of leaderboard entries
|
|
11
|
+
* @throws Error if the API request fails
|
|
12
|
+
*/
|
|
13
|
+
export declare function fetchLeaderboard(options?: {
|
|
14
|
+
timePeriod?: "all" | "1d" | "7d" | "30d";
|
|
15
|
+
orderBy?: "VOL" | "PNL";
|
|
16
|
+
limit?: number;
|
|
17
|
+
offset?: number;
|
|
18
|
+
category?: PolymarketCategory | Lowercase<PolymarketCategory>;
|
|
19
|
+
}): Promise<unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* Fetches top traders from Polymarket Analytics API sorted by overall gain.
|
|
22
|
+
* @param limit - Maximum number of traders to retrieve (default: 50)
|
|
23
|
+
* @returns Array of trader objects with performance metrics
|
|
24
|
+
* @throws Error if the API request fails
|
|
25
|
+
*/
|
|
26
|
+
export declare function fetchTopTraders(limit?: number): Promise<any[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Fetches all positions for a specific trader from Polymarket Analytics API.
|
|
29
|
+
* @param traderId - The unique identifier of the trader
|
|
30
|
+
* @returns Array of position objects for the trader
|
|
31
|
+
* @throws Error if the API request fails
|
|
32
|
+
*/
|
|
33
|
+
export declare function fetchTraderPositions(traderId: string): Promise<unknown>;
|
|
34
|
+
export interface TraderProfile {
|
|
35
|
+
address: string;
|
|
36
|
+
userName?: string;
|
|
37
|
+
profileImage?: string;
|
|
38
|
+
overallGain: number;
|
|
39
|
+
winRate: number;
|
|
40
|
+
totalProfit: number;
|
|
41
|
+
totalLoss: number;
|
|
42
|
+
totalPositions: number;
|
|
43
|
+
activePositions: number;
|
|
44
|
+
currentValue: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Fetches profile stats for multiple traders from Polymarket Analytics API.
|
|
48
|
+
* Uses the traders-tag-performance API to get bulk trader data.
|
|
49
|
+
* @param addresses - Array of trader wallet addresses
|
|
50
|
+
* @returns Map of address to trader profile data
|
|
51
|
+
*/
|
|
52
|
+
export declare function fetchTraderProfiles(addresses: string[]): Promise<Map<string, TraderProfile>>;
|
|
53
|
+
/**
|
|
54
|
+
* Activity types available from Polymarket Data API
|
|
55
|
+
*/
|
|
56
|
+
export type ActivityType = "TRADE" | "SPLIT" | "MERGE" | "REDEEM" | "REWARD" | "CONVERSION" | "MAKER_REBATE";
|
|
57
|
+
/**
|
|
58
|
+
* Options for fetching trader activity
|
|
59
|
+
*/
|
|
60
|
+
export interface FetchActivityOptions {
|
|
61
|
+
user: string;
|
|
62
|
+
limit?: number;
|
|
63
|
+
offset?: number;
|
|
64
|
+
market?: string[];
|
|
65
|
+
type?: ActivityType[];
|
|
66
|
+
start?: number;
|
|
67
|
+
end?: number;
|
|
68
|
+
sortBy?: "TIMESTAMP" | "TOKENS" | "CASH";
|
|
69
|
+
sortDirection?: "ASC" | "DESC";
|
|
70
|
+
side?: "BUY" | "SELL";
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Activity record from Polymarket Data API
|
|
74
|
+
*/
|
|
75
|
+
export interface TraderActivity {
|
|
76
|
+
proxyWallet: string;
|
|
77
|
+
timestamp: number;
|
|
78
|
+
conditionId: string;
|
|
79
|
+
type: ActivityType;
|
|
80
|
+
size: string;
|
|
81
|
+
usdcSize: string;
|
|
82
|
+
transactionHash: string;
|
|
83
|
+
price?: string;
|
|
84
|
+
asset?: string;
|
|
85
|
+
side?: "BUY" | "SELL";
|
|
86
|
+
outcomeIndex?: number;
|
|
87
|
+
title?: string;
|
|
88
|
+
slug?: string;
|
|
89
|
+
icon?: string;
|
|
90
|
+
eventSlug?: string;
|
|
91
|
+
outcome?: string;
|
|
92
|
+
name?: string;
|
|
93
|
+
pseudonym?: string;
|
|
94
|
+
bio?: string;
|
|
95
|
+
profileImage?: string;
|
|
96
|
+
profileImageOptimized?: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Fetches on-chain activity for a specific trader from Polymarket Data API.
|
|
100
|
+
* @param options - Configuration options for the activity query
|
|
101
|
+
* @returns Array of activity objects for the trader
|
|
102
|
+
* @throws Error if the API request fails
|
|
103
|
+
*/
|
|
104
|
+
export declare function fetchTraderActivity(options: FetchActivityOptions): Promise<TraderActivity[]>;
|
|
105
|
+
/**
|
|
106
|
+
* Fetches all activity for a trader by paginating through all pages.
|
|
107
|
+
* @param user - Trader wallet address
|
|
108
|
+
* @param options - Additional fetch options
|
|
109
|
+
* @param onProgress - Optional callback for progress updates
|
|
110
|
+
* @returns Array of all activity objects for the trader
|
|
111
|
+
*/
|
|
112
|
+
export declare function fetchAllTraderActivity(user: string, options?: Omit<FetchActivityOptions, "user" | "offset">, onProgress?: (fetched: number, total: number | null) => void): Promise<TraderActivity[]>;
|
|
113
|
+
//# sourceMappingURL=leaderboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leaderboard.d.ts","sourceRoot":"","sources":["../../../src/prediction/api/leaderboard.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches active prediction markets from the Polymarket Gamma API.
|
|
3
|
+
* @param limit - Maximum number of markets to retrieve (default: 50)
|
|
4
|
+
* @param sortBy - Field to sort results by (default: "volume24hr")
|
|
5
|
+
* @param offset - Number of markets to skip for pagination (default: 0)
|
|
6
|
+
* @returns Array of market objects from Polymarket
|
|
7
|
+
* @throws Error if the API request fails
|
|
8
|
+
*/
|
|
9
|
+
export declare function fetchMarkets(limit?: number, sortBy?: string, offset?: number): Promise<unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Fetches all active prediction markets from the Polymarket Gamma API using pagination.
|
|
12
|
+
* @param sortBy - Field to sort results by (default: "volume24hr")
|
|
13
|
+
* @param maxMarkets - Maximum total number of markets to retrieve (default: 1000, set to 0 for unlimited)
|
|
14
|
+
* @returns Array of all market objects from Polymarket
|
|
15
|
+
* @throws Error if the API request fails
|
|
16
|
+
*/
|
|
17
|
+
export declare function fetchAllMarkets(sortBy?: string, maxMarkets?: number): Promise<any[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Searches for active markets matching a query string.
|
|
20
|
+
* @param query - The search query string
|
|
21
|
+
* @param limit - Maximum number of results to return (default: 100)
|
|
22
|
+
* @returns Array of market objects matching the search query
|
|
23
|
+
* @throws Error if the API request fails
|
|
24
|
+
*/
|
|
25
|
+
export declare function searchMarkets(query: string, limit?: number): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* Performs a public search across Polymarket events, markets, and profiles.
|
|
28
|
+
* @param options - Search configuration options
|
|
29
|
+
* @param options.q - The search query string (required)
|
|
30
|
+
* @param options.cache - Whether to use cached results
|
|
31
|
+
* @param options.events_status - Filter by event status
|
|
32
|
+
* @param options.limit_per_type - Maximum results per type
|
|
33
|
+
* @param options.page - Page number for pagination
|
|
34
|
+
* @param options.events_tag - Array of tags to filter events
|
|
35
|
+
* @param options.keep_closed_markets - Include closed markets (0 or 1)
|
|
36
|
+
* @param options.sort - Sort field
|
|
37
|
+
* @param options.ascending - Sort direction
|
|
38
|
+
* @param options.search_tags - Include tags in search
|
|
39
|
+
* @param options.search_profiles - Include profiles in search
|
|
40
|
+
* @param options.recurrence - Recurrence filter
|
|
41
|
+
* @param options.exclude_tag_id - Array of tag IDs to exclude
|
|
42
|
+
* @param options.optimized - Use optimized search
|
|
43
|
+
* @returns Search results object
|
|
44
|
+
* @throws Error if the API request fails
|
|
45
|
+
*/
|
|
46
|
+
export declare function searchPublic(options: {
|
|
47
|
+
q: string;
|
|
48
|
+
cache?: boolean;
|
|
49
|
+
events_status?: string;
|
|
50
|
+
limit_per_type?: number;
|
|
51
|
+
page?: number;
|
|
52
|
+
events_tag?: string[];
|
|
53
|
+
keep_closed_markets?: number;
|
|
54
|
+
sort?: string;
|
|
55
|
+
ascending?: boolean;
|
|
56
|
+
search_tags?: boolean;
|
|
57
|
+
search_profiles?: boolean;
|
|
58
|
+
recurrence?: string;
|
|
59
|
+
exclude_tag_id?: number[];
|
|
60
|
+
optimized?: boolean;
|
|
61
|
+
}): Promise<unknown>;
|
|
62
|
+
//# sourceMappingURL=markets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markets.d.ts","sourceRoot":"","sources":["../../../src/prediction/api/markets.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,KAAK,SAAK,EACV,MAAM,SAAe,EACrB,MAAM,SAAI,oBAiCX;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,MAAM,SAAe,EACrB,UAAU,SAAO,kBAyDlB;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAM,gBAkB7D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE;IAC1C,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,oBAqDA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches historical price data for a specific token/market.
|
|
3
|
+
* @param options - Configuration options for the price history query
|
|
4
|
+
* @param options.market - The token ID of the market outcome
|
|
5
|
+
* @param options.interval - Time interval for data points (e.g., "1h", "1d", "max")
|
|
6
|
+
* @param options.startTs - Optional start timestamp (Unix timestamp in seconds)
|
|
7
|
+
* @param options.endTs - Optional end timestamp (Unix timestamp in seconds)
|
|
8
|
+
* @param options.abs - Optional flag to return absolute prices instead of 0-1 probability scale
|
|
9
|
+
* @returns Object containing history array with { t: timestamp, p: price } entries
|
|
10
|
+
* @throws Error if the API request fails
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Get entire 1-hour interval history for a token
|
|
14
|
+
* const history = await fetchPriceHistory({ market: "token_id", interval: "1h" });
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Get history for a specific time range
|
|
18
|
+
* const history = await fetchPriceHistory({
|
|
19
|
+
* market: "token_id",
|
|
20
|
+
* interval: "1h",
|
|
21
|
+
* startTs: 1700000000,
|
|
22
|
+
* endTs: 1700086400
|
|
23
|
+
* });
|
|
24
|
+
*/
|
|
25
|
+
export declare function fetchPriceHistory(options: {
|
|
26
|
+
market: string;
|
|
27
|
+
interval?: string;
|
|
28
|
+
startTs?: number;
|
|
29
|
+
endTs?: number;
|
|
30
|
+
abs?: boolean;
|
|
31
|
+
}): Promise<unknown>;
|
|
32
|
+
//# sourceMappingURL=prices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prices.d.ts","sourceRoot":"","sources":["../../../src/prediction/api/prices.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,oBA2CA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Polymarket prediction market categories
|
|
3
|
+
* Separated from main polymarket.ts to avoid importing database client in client components
|
|
4
|
+
*/
|
|
5
|
+
export declare const POLYMARKET_CATEGORIES: readonly ["Overall", "Politics", "Sports", "Crypto", "Culture", "Mentions", "Weather", "Economics", "Tech", "Finance"];
|
|
6
|
+
export type PolymarketCategory = typeof POLYMARKET_CATEGORIES[number];
|
|
7
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/prediction/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,qBAAqB,wHAWxB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saves or updates AI-generated debate analysis for a market.
|
|
3
|
+
* @param marketId - The unique identifier of the market
|
|
4
|
+
* @param debateData - Debate analysis data object
|
|
5
|
+
*/
|
|
6
|
+
export declare function saveDebate(marketId: string, debateData: {
|
|
7
|
+
question: string;
|
|
8
|
+
yesArguments: string[];
|
|
9
|
+
noArguments: string[];
|
|
10
|
+
yesSummary: string;
|
|
11
|
+
noSummary: string;
|
|
12
|
+
keyFactors: string[];
|
|
13
|
+
uncertainties: string[];
|
|
14
|
+
currentYesPrice: number;
|
|
15
|
+
currentNoPrice: number;
|
|
16
|
+
llmProvider?: string;
|
|
17
|
+
model?: string;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves the debate analysis for a specific market from the database.
|
|
21
|
+
* @param marketId - The unique identifier of the market
|
|
22
|
+
* @returns Debate record if found, or null if no debate exists for the market
|
|
23
|
+
*/
|
|
24
|
+
export declare function getMarketDebate(marketId: string): Promise<{
|
|
25
|
+
id: string;
|
|
26
|
+
marketId: string;
|
|
27
|
+
question: string;
|
|
28
|
+
yesArguments: string;
|
|
29
|
+
noArguments: string;
|
|
30
|
+
yesSummary: string;
|
|
31
|
+
noSummary: string;
|
|
32
|
+
keyFactors: string;
|
|
33
|
+
uncertainties: string;
|
|
34
|
+
currentYesPrice: number | null;
|
|
35
|
+
currentNoPrice: number | null;
|
|
36
|
+
llmProvider: string | null;
|
|
37
|
+
model: string | null;
|
|
38
|
+
createdAt: Date;
|
|
39
|
+
updatedAt: Date;
|
|
40
|
+
} | null>;
|
|
41
|
+
//# sourceMappingURL=debates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debates.d.ts","sourceRoot":"","sources":["../../../src/prediction/db/debates.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,iBAyCF;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;UAQrD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saves or updates leader data in the database.
|
|
3
|
+
* Uses upsert to update existing records or insert new ones.
|
|
4
|
+
* @param leadersData - Array of leader objects from the API
|
|
5
|
+
*/
|
|
6
|
+
export declare function saveLeaders(leadersData: any[]): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Saves or updates leaderboard data in the database.
|
|
9
|
+
* Includes user profile information like username and verification status.
|
|
10
|
+
* @param leaderboardData - Array of leaderboard entries from the API
|
|
11
|
+
*/
|
|
12
|
+
export declare function saveLeaderboardData(leaderboardData: any[]): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves leaders from the database sorted by specified metric.
|
|
15
|
+
* @param orderBy - Sort metric: "vol" for volume, "pnl" for profit/loss, or "overallGain" (default: "vol")
|
|
16
|
+
* @param limit - Maximum number of leaders to retrieve (default: 50)
|
|
17
|
+
* @returns Array of leader records from the database
|
|
18
|
+
*/
|
|
19
|
+
export declare function getLeaders(orderBy?: "vol" | "pnl" | "overallGain", limit?: number): Promise<{
|
|
20
|
+
trader: string;
|
|
21
|
+
rank: number | null;
|
|
22
|
+
userName: string | null;
|
|
23
|
+
xUsername: string | null;
|
|
24
|
+
verifiedBadge: boolean | null;
|
|
25
|
+
profileImage: string | null;
|
|
26
|
+
vol: number | null;
|
|
27
|
+
pnl: number | null;
|
|
28
|
+
overallGain: number | null;
|
|
29
|
+
winRate: number | null;
|
|
30
|
+
activePositions: number | null;
|
|
31
|
+
totalPositions: number | null;
|
|
32
|
+
currentValue: number | null;
|
|
33
|
+
winAmount: number | null;
|
|
34
|
+
lossAmount: number | null;
|
|
35
|
+
updatedAt: Date | null;
|
|
36
|
+
}[]>;
|
|
37
|
+
//# sourceMappingURL=leaderboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leaderboard.d.ts","sourceRoot":"","sources":["../../../src/prediction/db/leaderboard.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,WAAW,EAAE,GAAG,EAAE,iBAiCnD;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,eAAe,EAAE,GAAG,EAAE,iBA+B/D;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,OAAO,GAAE,KAAK,GAAG,KAAK,GAAG,aAAqB,EAC9C,KAAK,SAAK;;;;;;;;;;;;;;;;;KAcX"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saves or updates market data in the database.
|
|
3
|
+
* Handles outcomes, prices, tags, and other market metadata.
|
|
4
|
+
* @param marketsData - Array of market objects from the API
|
|
5
|
+
*/
|
|
6
|
+
export declare function saveMarkets(marketsData: any[]): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves markets from the database with filtering and sorting options.
|
|
9
|
+
* @param options - Query configuration options
|
|
10
|
+
* @param options.limit - Maximum number of markets to retrieve (default: 50)
|
|
11
|
+
* @param options.sortBy - Sort field: "volume24hr", "volumeTotal", or "createdAt" (default: "volume24hr")
|
|
12
|
+
* @param options.category - Optional category tag to filter by
|
|
13
|
+
* @param options.activeOnly - Only include active markets (default: true)
|
|
14
|
+
* @returns Array of market records matching the criteria
|
|
15
|
+
*/
|
|
16
|
+
export declare function getMarkets(options?: {
|
|
17
|
+
limit?: number;
|
|
18
|
+
offset?: number;
|
|
19
|
+
sortBy?: "volume24hr" | "volumeTotal" | "createdAt";
|
|
20
|
+
category?: string;
|
|
21
|
+
activeOnly?: boolean;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
id: string;
|
|
24
|
+
conditionId: string | null;
|
|
25
|
+
question: string;
|
|
26
|
+
slug: string;
|
|
27
|
+
eventSlug: string | null;
|
|
28
|
+
description: string | null;
|
|
29
|
+
image: string | null;
|
|
30
|
+
volume24hr: number | null;
|
|
31
|
+
volumeTotal: number | null;
|
|
32
|
+
active: boolean | null;
|
|
33
|
+
closed: boolean | null;
|
|
34
|
+
outcomes: string;
|
|
35
|
+
outcomePrices: string;
|
|
36
|
+
clobTokenIds: string | null;
|
|
37
|
+
tags: string | null;
|
|
38
|
+
category: string | null;
|
|
39
|
+
subcategory: string | null;
|
|
40
|
+
endDate: string | null;
|
|
41
|
+
groupItemTitle: string | null;
|
|
42
|
+
enableOrderBook: boolean | null;
|
|
43
|
+
createdAt: Date;
|
|
44
|
+
updatedAt: Date;
|
|
45
|
+
}[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Searches markets in the database by question text.
|
|
48
|
+
* @param searchTerm - The search term to match against market questions
|
|
49
|
+
* @param options - Query configuration options
|
|
50
|
+
* @param options.limit - Maximum number of markets to retrieve (default: 50)
|
|
51
|
+
* @param options.sortBy - Sort field: "volume24hr", "volumeTotal", or "createdAt" (default: "volume24hr")
|
|
52
|
+
* @param options.category - Optional category tag to filter by
|
|
53
|
+
* @param options.activeOnly - Only include active markets (default: true)
|
|
54
|
+
* @returns Array of market records matching the search term
|
|
55
|
+
*/
|
|
56
|
+
export declare function searchMarketsInDB(searchTerm: string, options?: {
|
|
57
|
+
limit?: number;
|
|
58
|
+
offset?: number;
|
|
59
|
+
sortBy?: "volume24hr" | "volumeTotal" | "createdAt";
|
|
60
|
+
category?: string;
|
|
61
|
+
activeOnly?: boolean;
|
|
62
|
+
}): Promise<{
|
|
63
|
+
id: string;
|
|
64
|
+
conditionId: string | null;
|
|
65
|
+
question: string;
|
|
66
|
+
slug: string;
|
|
67
|
+
eventSlug: string | null;
|
|
68
|
+
description: string | null;
|
|
69
|
+
image: string | null;
|
|
70
|
+
volume24hr: number | null;
|
|
71
|
+
volumeTotal: number | null;
|
|
72
|
+
active: boolean | null;
|
|
73
|
+
closed: boolean | null;
|
|
74
|
+
outcomes: string;
|
|
75
|
+
outcomePrices: string;
|
|
76
|
+
clobTokenIds: string | null;
|
|
77
|
+
tags: string | null;
|
|
78
|
+
category: string | null;
|
|
79
|
+
subcategory: string | null;
|
|
80
|
+
endDate: string | null;
|
|
81
|
+
groupItemTitle: string | null;
|
|
82
|
+
enableOrderBook: boolean | null;
|
|
83
|
+
createdAt: Date;
|
|
84
|
+
updatedAt: Date;
|
|
85
|
+
}[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Retrieves active markets grouped by their category tags.
|
|
88
|
+
* @returns Object with category tags as keys and arrays of market records as values
|
|
89
|
+
*/
|
|
90
|
+
export declare function getMarketsByCategory(): Promise<Record<string, any[]>>;
|
|
91
|
+
//# sourceMappingURL=markets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markets.d.ts","sourceRoot":"","sources":["../../../src/prediction/db/markets.ts"],"names":[],"mappings":"AAoCA;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,WAAW,EAAE,GAAG,EAAE,iBAwFnD;AAED;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAC9B,OAAO,GAAE;IACP,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,YAAY,GAAG,aAAa,GAAG,WAAW,CAAC;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACjB;;;;;;;;;;;;;;;;;;;;;;;KA0CP;AAED;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IACP,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,YAAY,GAAG,aAAa,GAAG,WAAW,CAAC;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACjB;;;;;;;;;;;;;;;;;;;;;;;KA4CP;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,mCAyBzC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saves or updates position data for a specific trader in the database.
|
|
3
|
+
* @param traderId - The unique identifier of the trader
|
|
4
|
+
* @param positionsData - Array of position objects from the API
|
|
5
|
+
*/
|
|
6
|
+
export declare function savePositions(traderId: string, positionsData: any[]): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Saves order book positions for a specific market.
|
|
9
|
+
* Clears existing positions and saves new bids and asks.
|
|
10
|
+
* @param marketId - The unique identifier of the market
|
|
11
|
+
* @param orderBookData - Order book object containing bids and asks arrays
|
|
12
|
+
*/
|
|
13
|
+
export declare function saveMarketPositions(marketId: string, orderBookData: any): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Saves top holders for a specific market.
|
|
16
|
+
* @param marketId - The unique identifier of the market
|
|
17
|
+
* @param holdersData - Array of holder objects
|
|
18
|
+
*/
|
|
19
|
+
export declare function saveHolders(marketId: string, holdersData: any[]): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves all positions for a specific trader from the database.
|
|
22
|
+
* @param traderId - The unique identifier of the trader
|
|
23
|
+
* @returns Array of position records for the trader
|
|
24
|
+
*/
|
|
25
|
+
export declare function getTraderPositions(traderId: string): Promise<{
|
|
26
|
+
id: string;
|
|
27
|
+
traderId: string;
|
|
28
|
+
marketId: string | null;
|
|
29
|
+
marketTitle: string | null;
|
|
30
|
+
cashPnl: number | null;
|
|
31
|
+
realizedPnl: number | null;
|
|
32
|
+
tags: string | null;
|
|
33
|
+
createdAt: Date | null;
|
|
34
|
+
}[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves order book positions for a specific market from the database.
|
|
37
|
+
* @param marketId - The unique identifier of the market
|
|
38
|
+
* @returns Array of position records sorted by total value descending
|
|
39
|
+
*/
|
|
40
|
+
export declare function getMarketPositions(marketId: string): Promise<{
|
|
41
|
+
id: string;
|
|
42
|
+
marketId: string;
|
|
43
|
+
outcome: string;
|
|
44
|
+
price: number;
|
|
45
|
+
size: number;
|
|
46
|
+
side: string;
|
|
47
|
+
totalValue: number;
|
|
48
|
+
createdAt: Date;
|
|
49
|
+
}[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Retrieves top holders for a specific market from the database.
|
|
52
|
+
* @param marketId - The unique identifier of the market
|
|
53
|
+
* @param limit - Maximum number of holders to retrieve (default: 10)
|
|
54
|
+
* @returns Array of holder records sorted by rank
|
|
55
|
+
*/
|
|
56
|
+
export declare function getMarketHolders(marketId: string, limit?: number): Promise<{
|
|
57
|
+
id: string;
|
|
58
|
+
marketId: string;
|
|
59
|
+
address: string;
|
|
60
|
+
userName: string | null;
|
|
61
|
+
profileImage: string | null;
|
|
62
|
+
rank: number;
|
|
63
|
+
outcome: string | null;
|
|
64
|
+
balance: number;
|
|
65
|
+
value: number;
|
|
66
|
+
overallGain: number | null;
|
|
67
|
+
winRate: number | null;
|
|
68
|
+
totalProfit: number | null;
|
|
69
|
+
totalLoss: number | null;
|
|
70
|
+
totalPositions: number | null;
|
|
71
|
+
updatedAt: Date;
|
|
72
|
+
}[]>;
|
|
73
|
+
//# sourceMappingURL=positions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"positions.d.ts","sourceRoot":"","sources":["../../../src/prediction/db/positions.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,iBA4BzE;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,GAAG,iBA4CnB;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,iBA8BrE;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;KAKxD;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;KAMxD;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,SAAK;;;;;;;;;;;;;;;;KAOlE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saves historical price data for a specific token/market.
|
|
3
|
+
* Stores each price point as a separate record.
|
|
4
|
+
* @param tokenId - The unique identifier of the market token
|
|
5
|
+
* @param priceHistory - Price history object containing history array with { t: timestamp, p: price } entries
|
|
6
|
+
* @param interval - The interval used for the price data (e.g., "1h", "1d")
|
|
7
|
+
*/
|
|
8
|
+
export declare function savePriceHistory(tokenId: string, priceHistory: {
|
|
9
|
+
history: Array<{
|
|
10
|
+
t: number;
|
|
11
|
+
p: number;
|
|
12
|
+
}>;
|
|
13
|
+
}, interval?: string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves historical price data for a specific token from the database.
|
|
16
|
+
* @param tokenId - The unique identifier of the market token
|
|
17
|
+
* @param options - Query configuration options
|
|
18
|
+
* @param options.interval - Optional interval filter (e.g., "1h", "1d")
|
|
19
|
+
* @param options.startTimestamp - Optional start timestamp to filter from
|
|
20
|
+
* @param options.endTimestamp - Optional end timestamp to filter to
|
|
21
|
+
* @param options.limit - Maximum number of records to retrieve
|
|
22
|
+
* @returns Array of price history records sorted by timestamp ascending
|
|
23
|
+
*/
|
|
24
|
+
export declare function getPriceHistory(tokenId: string, options?: {
|
|
25
|
+
interval?: string;
|
|
26
|
+
startTimestamp?: number;
|
|
27
|
+
endTimestamp?: number;
|
|
28
|
+
limit?: number;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
id: string;
|
|
31
|
+
tokenId: string;
|
|
32
|
+
timestamp: number;
|
|
33
|
+
price: number;
|
|
34
|
+
interval: string;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
}[]>;
|
|
37
|
+
//# sourceMappingURL=prices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prices.d.ts","sourceRoot":"","sources":["../../../src/prediction/db/prices.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,EAC1D,QAAQ,GAAE,MAAa,iBA8CxB;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IACP,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CACX;;;;;;;KAuCP"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { TraderActivity } from '../api/leaderboard';
|
|
2
|
+
/**
|
|
3
|
+
* Saves trade activity records to the database.
|
|
4
|
+
* Uses upsert to handle duplicates.
|
|
5
|
+
* @param traderId - The trader wallet address
|
|
6
|
+
* @param activities - Array of activity records from the API
|
|
7
|
+
* @returns Number of trades saved
|
|
8
|
+
*/
|
|
9
|
+
export declare function saveTradeHistory(traderId: string, activities: TraderActivity[]): Promise<number>;
|
|
10
|
+
/**
|
|
11
|
+
* Updates the sync status for a trader.
|
|
12
|
+
* @param traderId - The trader wallet address
|
|
13
|
+
* @param status - Status update fields
|
|
14
|
+
*/
|
|
15
|
+
export declare function updateTradeSyncStatus(traderId: string, status: {
|
|
16
|
+
syncStatus?: "pending" | "in_progress" | "completed" | "error";
|
|
17
|
+
lastSyncedTimestamp?: Date;
|
|
18
|
+
totalTradesSynced?: number;
|
|
19
|
+
errorMessage?: string | null;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the sync status for a trader.
|
|
23
|
+
* @param traderId - The trader wallet address
|
|
24
|
+
* @returns Sync status record or null if not found
|
|
25
|
+
*/
|
|
26
|
+
export declare function getTradeSyncStatus(traderId: string): Promise<{
|
|
27
|
+
traderId: string;
|
|
28
|
+
lastSyncedTimestamp: Date | null;
|
|
29
|
+
totalTradesSynced: number | null;
|
|
30
|
+
syncStatus: string;
|
|
31
|
+
errorMessage: string | null;
|
|
32
|
+
lastSyncAttempt: Date | null;
|
|
33
|
+
createdAt: Date;
|
|
34
|
+
updatedAt: Date;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Gets all traders that need syncing (pending or error status).
|
|
38
|
+
* @param limit - Maximum number of traders to return
|
|
39
|
+
* @returns Array of trader IDs
|
|
40
|
+
*/
|
|
41
|
+
export declare function getTradersNeedingSync(limit?: number): Promise<string[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Gets trade history for a specific trader.
|
|
44
|
+
* @param traderId - The trader wallet address
|
|
45
|
+
* @param options - Query options
|
|
46
|
+
* @returns Array of trade history records
|
|
47
|
+
*/
|
|
48
|
+
export declare function getTraderTradeHistory(traderId: string, options?: {
|
|
49
|
+
limit?: number;
|
|
50
|
+
offset?: number;
|
|
51
|
+
type?: string;
|
|
52
|
+
startDate?: Date;
|
|
53
|
+
endDate?: Date;
|
|
54
|
+
}): Promise<{
|
|
55
|
+
id: string;
|
|
56
|
+
traderId: string;
|
|
57
|
+
transactionHash: string;
|
|
58
|
+
conditionId: string;
|
|
59
|
+
marketTitle: string | null;
|
|
60
|
+
marketSlug: string | null;
|
|
61
|
+
eventSlug: string | null;
|
|
62
|
+
type: string;
|
|
63
|
+
side: string | null;
|
|
64
|
+
outcome: string | null;
|
|
65
|
+
outcomeIndex: number | null;
|
|
66
|
+
size: number;
|
|
67
|
+
usdcSize: number;
|
|
68
|
+
price: number | null;
|
|
69
|
+
traderName: string | null;
|
|
70
|
+
traderBio: string | null;
|
|
71
|
+
traderProfileImage: string | null;
|
|
72
|
+
timestamp: Date;
|
|
73
|
+
syncedAt: Date;
|
|
74
|
+
createdAt: Date;
|
|
75
|
+
}[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Gets trade statistics for a trader.
|
|
78
|
+
* @param traderId - The trader wallet address
|
|
79
|
+
* @returns Trade statistics object
|
|
80
|
+
*/
|
|
81
|
+
export declare function getTraderTradeStats(traderId: string): Promise<{
|
|
82
|
+
totalTrades: number;
|
|
83
|
+
totalVolume: number;
|
|
84
|
+
buyCount: number;
|
|
85
|
+
sellCount: number;
|
|
86
|
+
firstTradeDate: Date;
|
|
87
|
+
lastTradeDate: Date;
|
|
88
|
+
uniqueMarkets: number;
|
|
89
|
+
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Gets the most recent trade timestamp for a trader.
|
|
92
|
+
* Used for incremental syncing.
|
|
93
|
+
* @param traderId - The trader wallet address
|
|
94
|
+
* @returns Unix timestamp of most recent trade or null
|
|
95
|
+
*/
|
|
96
|
+
export declare function getLatestTradeTimestamp(traderId: string): Promise<number | null>;
|
|
97
|
+
/**
|
|
98
|
+
* Gets aggregate sync status statistics.
|
|
99
|
+
* @returns Object with sync progress counts
|
|
100
|
+
*/
|
|
101
|
+
export declare function getSyncStatusStats(): Promise<{
|
|
102
|
+
pending: number;
|
|
103
|
+
in_progress: number;
|
|
104
|
+
completed: number;
|
|
105
|
+
error: number;
|
|
106
|
+
total: number;
|
|
107
|
+
}>;
|
|
108
|
+
//# sourceMappingURL=trade-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trade-history.d.ts","sourceRoot":"","sources":["../../../src/prediction/db/trade-history.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,cAAc,EAAE,GAC3B,OAAO,CAAC,MAAM,CAAC,CAqDjB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE;IACN,UAAU,CAAC,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,OAAO,CAAC;IAC/D,mBAAmB,CAAC,EAAE,IAAI,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,GACA,OAAO,CAAC,IAAI,CAAC,CAgCf;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;GAQxD;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,SAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAU1E;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IACP,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,OAAO,CAAC,EAAE,IAAI,CAAC;CACX;;;;;;;;;;;;;;;;;;;;;KAuBP;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;GAezD;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CASxB;AAED;;;GAGG;AACH,wBAAsB,kBAAkB;;;;;;GAuBvC"}
|