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.
Files changed (180) hide show
  1. package/README.md +88 -60
  2. package/dist/algo-stategies/tv-scraper.d.ts +2 -0
  3. package/dist/algo-stategies/tv-scraper.d.ts.map +1 -0
  4. package/dist/alpaca/alpaca-mcp-client.d.ts +174 -0
  5. package/dist/alpaca/alpaca-mcp-client.d.ts.map +1 -0
  6. package/dist/alpaca/client.d.ts +21 -0
  7. package/dist/alpaca/client.d.ts.map +1 -0
  8. package/dist/archiver-web.es-BgXzilRH.cjs +1 -0
  9. package/dist/archiver-web.es-EPYdovFt.js +1 -0
  10. package/dist/correlate/metrics.d.ts +40 -0
  11. package/dist/correlate/metrics.d.ts.map +1 -0
  12. package/dist/correlate/model-persistence.d.ts +26 -0
  13. package/dist/correlate/model-persistence.d.ts.map +1 -0
  14. package/dist/correlate/predict-statistics.d.ts +14 -0
  15. package/dist/correlate/predict-statistics.d.ts.map +1 -0
  16. package/dist/correlate/rolling-stats.d.ts +27 -0
  17. package/dist/correlate/rolling-stats.d.ts.map +1 -0
  18. package/dist/correlate/types.d.ts +78 -0
  19. package/dist/correlate/types.d.ts.map +1 -0
  20. package/dist/correlate/xgboost-predictor.d.ts +19 -0
  21. package/dist/correlate/xgboost-predictor.d.ts.map +1 -0
  22. package/dist/correlate/xgboost-trainer.d.ts +112 -0
  23. package/dist/correlate/xgboost-trainer.d.ts.map +1 -0
  24. package/dist/db/client.d.ts +10 -0
  25. package/dist/db/client.d.ts.map +1 -0
  26. package/dist/db/d1-http.d.ts +38 -0
  27. package/dist/db/d1-http.d.ts.map +1 -0
  28. package/dist/db/index.d.ts +8870 -0
  29. package/dist/db/index.d.ts.map +1 -0
  30. package/dist/db/relations.d.ts +21 -0
  31. package/dist/db/relations.d.ts.map +1 -0
  32. package/dist/db/schema.d.ts +8845 -0
  33. package/dist/db/schema.d.ts.map +1 -0
  34. package/dist/debate-research/stock-agents-api.d.ts +129 -0
  35. package/dist/debate-research/stock-agents-api.d.ts.map +1 -0
  36. package/dist/index-C9OpAHBe.js +15 -0
  37. package/dist/index-CLlAnStL-B7EBGdAY.cjs +1 -0
  38. package/dist/index-CLlAnStL-C554ZmGF.js +1 -0
  39. package/dist/index-CcyBsxYm.cjs +13 -0
  40. package/dist/index.d.ts +26 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +1 -0
  43. package/dist/index.mjs +1 -0
  44. package/dist/leaders/nvsty-leaders.d.ts +63 -0
  45. package/dist/leaders/nvsty-leaders.d.ts.map +1 -0
  46. package/dist/leaders/zulu.d.ts +167 -0
  47. package/dist/leaders/zulu.d.ts.map +1 -0
  48. package/dist/live-data/dukascopy-client.d.ts +102 -0
  49. package/dist/live-data/dukascopy-client.d.ts.map +1 -0
  50. package/dist/llm/debate-generator.d.ts +32 -0
  51. package/dist/llm/debate-generator.d.ts.map +1 -0
  52. package/dist/prediction/analysis/categories.d.ts +37 -0
  53. package/dist/prediction/analysis/categories.d.ts.map +1 -0
  54. package/dist/prediction/analysis/detector.d.ts +15 -0
  55. package/dist/prediction/analysis/detector.d.ts.map +1 -0
  56. package/dist/prediction/analysis/greeks.d.ts +11 -0
  57. package/dist/prediction/analysis/greeks.d.ts.map +1 -0
  58. package/dist/prediction/analysis/price-changes.d.ts +12 -0
  59. package/dist/prediction/analysis/price-changes.d.ts.map +1 -0
  60. package/dist/prediction/api/analytics.d.ts +46 -0
  61. package/dist/prediction/api/analytics.d.ts.map +1 -0
  62. package/dist/prediction/api/gamma.d.ts +30 -0
  63. package/dist/prediction/api/gamma.d.ts.map +1 -0
  64. package/dist/prediction/api/leaderboard.d.ts +113 -0
  65. package/dist/prediction/api/leaderboard.d.ts.map +1 -0
  66. package/dist/prediction/api/markets.d.ts +62 -0
  67. package/dist/prediction/api/markets.d.ts.map +1 -0
  68. package/dist/prediction/api/prices.d.ts +32 -0
  69. package/dist/prediction/api/prices.d.ts.map +1 -0
  70. package/dist/prediction/constants.d.ts +7 -0
  71. package/dist/prediction/constants.d.ts.map +1 -0
  72. package/dist/prediction/db/debates.d.ts +41 -0
  73. package/dist/prediction/db/debates.d.ts.map +1 -0
  74. package/dist/prediction/db/leaderboard.d.ts +37 -0
  75. package/dist/prediction/db/leaderboard.d.ts.map +1 -0
  76. package/dist/prediction/db/markets.d.ts +91 -0
  77. package/dist/prediction/db/markets.d.ts.map +1 -0
  78. package/dist/prediction/db/positions.d.ts +73 -0
  79. package/dist/prediction/db/positions.d.ts.map +1 -0
  80. package/dist/prediction/db/prices.d.ts +37 -0
  81. package/dist/prediction/db/prices.d.ts.map +1 -0
  82. package/dist/prediction/db/trade-history.d.ts +108 -0
  83. package/dist/prediction/db/trade-history.d.ts.map +1 -0
  84. package/dist/prediction/index.d.ts +26 -0
  85. package/dist/prediction/index.d.ts.map +1 -0
  86. package/dist/prediction/sync/holders.d.ts +10 -0
  87. package/dist/prediction/sync/holders.d.ts.map +1 -0
  88. package/dist/prediction/sync/incremental-markets.d.ts +18 -0
  89. package/dist/prediction/sync/incremental-markets.d.ts.map +1 -0
  90. package/dist/prediction/sync/leaderboard.d.ts +25 -0
  91. package/dist/prediction/sync/leaderboard.d.ts.map +1 -0
  92. package/dist/prediction/sync/markets.d.ts +25 -0
  93. package/dist/prediction/sync/markets.d.ts.map +1 -0
  94. package/dist/prediction/sync/orchestration.d.ts +12 -0
  95. package/dist/prediction/sync/orchestration.d.ts.map +1 -0
  96. package/dist/prediction/sync/prices.d.ts +25 -0
  97. package/dist/prediction/sync/prices.d.ts.map +1 -0
  98. package/dist/prediction/sync/trade-history.d.ts +96 -0
  99. package/dist/prediction/sync/trade-history.d.ts.map +1 -0
  100. package/dist/prediction/sync.d.ts +4 -0
  101. package/dist/prediction/sync.d.ts.map +1 -0
  102. package/dist/prediction/types.d.ts +131 -0
  103. package/dist/prediction/types.d.ts.map +1 -0
  104. package/dist/prediction/utils/categorizer.d.ts +37 -0
  105. package/dist/prediction/utils/categorizer.d.ts.map +1 -0
  106. package/dist/predictos/index.d.ts +12 -0
  107. package/dist/predictos/index.d.ts.map +1 -0
  108. package/dist/stock-names-data/stock-names.json.d.ts +4 -0
  109. package/dist/stocks/find-wikipedia-urls.d.ts +6 -0
  110. package/dist/stocks/find-wikipedia-urls.d.ts.map +1 -0
  111. package/dist/stocks/finnhub-utils.d.ts +42 -0
  112. package/dist/stocks/finnhub-utils.d.ts.map +1 -0
  113. package/dist/stocks/finnhub-wrapper.d.ts +49 -0
  114. package/dist/stocks/finnhub-wrapper.d.ts.map +1 -0
  115. package/dist/stocks/import-stock-names.d.ts +2 -0
  116. package/dist/stocks/import-stock-names.d.ts.map +1 -0
  117. package/dist/stocks/index.d.ts +12 -0
  118. package/dist/stocks/index.d.ts.map +1 -0
  119. package/dist/stocks/quote-cache-service.d.ts +94 -0
  120. package/dist/stocks/quote-cache-service.d.ts.map +1 -0
  121. package/dist/stocks/sec-filing-api.d.ts +35 -0
  122. package/dist/stocks/sec-filing-api.d.ts.map +1 -0
  123. package/dist/stocks/stock-names-client.d.ts +10 -0
  124. package/dist/stocks/stock-names-client.d.ts.map +1 -0
  125. package/dist/stocks/stock-names.d.ts +26 -0
  126. package/dist/stocks/stock-names.d.ts.map +1 -0
  127. package/dist/stocks/types.d.ts +547 -0
  128. package/dist/stocks/types.d.ts.map +1 -0
  129. package/dist/stocks/unified-quote-example.d.ts +30 -0
  130. package/dist/stocks/unified-quote-example.d.ts.map +1 -0
  131. package/dist/stocks/unified-quote-service.d.ts +111 -0
  132. package/dist/stocks/unified-quote-service.d.ts.map +1 -0
  133. package/dist/stocks/yahoo-finance-wrapper.d.ts +344 -0
  134. package/dist/stocks/yahoo-finance-wrapper.d.ts.map +1 -0
  135. package/dist/stocks/yfinance-wrapper.d.ts +10 -0
  136. package/dist/stocks/yfinance-wrapper.d.ts.map +1 -0
  137. package/dist/trading-agents/agents/debate-facilitator.d.ts +26 -0
  138. package/dist/trading-agents/agents/debate-facilitator.d.ts.map +1 -0
  139. package/dist/trading-agents/agents/fund-manager.d.ts +11 -0
  140. package/dist/trading-agents/agents/fund-manager.d.ts.map +1 -0
  141. package/dist/trading-agents/agents/improved-researchers.d.ts +16 -0
  142. package/dist/trading-agents/agents/improved-researchers.d.ts.map +1 -0
  143. package/dist/trading-agents/agents/market-analyst.d.ts +8 -0
  144. package/dist/trading-agents/agents/market-analyst.d.ts.map +1 -0
  145. package/dist/trading-agents/agents/news-analyst.d.ts +8 -0
  146. package/dist/trading-agents/agents/news-analyst.d.ts.map +1 -0
  147. package/dist/trading-agents/agents/researchers.d.ts +22 -0
  148. package/dist/trading-agents/agents/researchers.d.ts.map +1 -0
  149. package/dist/trading-agents/agents/risk-team.d.ts +22 -0
  150. package/dist/trading-agents/agents/risk-team.d.ts.map +1 -0
  151. package/dist/trading-agents/agents/trader.d.ts +10 -0
  152. package/dist/trading-agents/agents/trader.d.ts.map +1 -0
  153. package/dist/trading-agents/example.d.ts +7 -0
  154. package/dist/trading-agents/example.d.ts.map +1 -0
  155. package/dist/trading-agents/graph/trading-graph.d.ts +59 -0
  156. package/dist/trading-agents/graph/trading-graph.d.ts.map +1 -0
  157. package/dist/trading-agents/index.d.ts +13 -0
  158. package/dist/trading-agents/index.d.ts.map +1 -0
  159. package/dist/trading-agents/tools/alpaca-mcp-tools.d.ts +46 -0
  160. package/dist/trading-agents/tools/alpaca-mcp-tools.d.ts.map +1 -0
  161. package/dist/trading-agents/tools/data-tools.d.ts +18 -0
  162. package/dist/trading-agents/tools/data-tools.d.ts.map +1 -0
  163. package/dist/trading-agents/tools/langchain-tools.d.ts +78 -0
  164. package/dist/trading-agents/tools/langchain-tools.d.ts.map +1 -0
  165. package/dist/trading-agents/types/index.d.ts +171 -0
  166. package/dist/trading-agents/types/index.d.ts.map +1 -0
  167. package/dist/trading-agents/utils/llm-client.d.ts +45 -0
  168. package/dist/trading-agents/utils/llm-client.d.ts.map +1 -0
  169. package/dist/trading-agents/utils/memory.d.ts +38 -0
  170. package/dist/trading-agents/utils/memory.d.ts.map +1 -0
  171. package/dist/trending-topics/wiki-page-views.d.ts +133 -0
  172. package/dist/trending-topics/wiki-page-views.d.ts.map +1 -0
  173. package/dist/utils/logger.d.ts +7 -0
  174. package/dist/utils/logger.d.ts.map +1 -0
  175. package/package.json +47 -17
  176. package/data/globe.json +0 -182
  177. package/data/sector-info.json +0 -1540
  178. package/data/sectors-industries.json +0 -327
  179. package/data/stock-indexes.json +0 -106
  180. package/data/stock-names.json +0 -1
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @file predict-statistics.ts
3
+ * @description Statistical analysis and prediction library - main export file.
4
+ *
5
+ * This file serves as a barrel export for all statistical prediction functionality,
6
+ * providing a single import point for all modules.
7
+ */
8
+ export type { XGBoostParams, TrainModelOptions, PredictOptions, TrainTestSplit, } from './types';
9
+ export { trainModels, splitTrainTest } from './xgboost-trainer';
10
+ export { predictFuture } from './xgboost-predictor';
11
+ export { calculateRMSE, calculateR2 } from './metrics';
12
+ export { saveModel, loadModel } from './model-persistence';
13
+ export { calculateRollingStats } from './rolling-stats';
14
+ //# sourceMappingURL=predict-statistics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"predict-statistics.d.ts","sourceRoot":"","sources":["../../src/correlate/predict-statistics.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,cAAc,GACf,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGhE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGvD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @file rolling-stats.ts
3
+ * @description Rolling window statistical calculations for time series data.
4
+ */
5
+ /**
6
+ * Calculate rolling statistics for a given array of values
7
+ *
8
+ * Computes rolling mean and standard deviation over a sliding window.
9
+ * Rolling statistics help identify trends and volatility in time series data.
10
+ *
11
+ * @param data - Array of data objects
12
+ * @param field - Field name to calculate rolling stats for
13
+ * @param window - Rolling window size (default: 7)
14
+ * @returns Array with added rolling statistics fields:
15
+ * - `${field}_rolling_mean_${window}d`: Rolling mean
16
+ * - `${field}_rolling_std_${window}d`: Rolling standard deviation
17
+ * @example
18
+ * let data = [
19
+ * { date: '2024-01-01', price: 100 },
20
+ * { date: '2024-01-02', price: 105 },
21
+ * { date: '2024-01-03', price: 110 },
22
+ * ];
23
+ * let result = calculateRollingStats(data, 'price', 3);
24
+ * // result[2] will have price_rolling_mean_3d and price_rolling_std_3d
25
+ */
26
+ export declare function calculateRollingStats(data: any[], field: string, window?: number): any[];
27
+ //# sourceMappingURL=rolling-stats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rolling-stats.d.ts","sourceRoot":"","sources":["../../src/correlate/rolling-stats.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,GAAG,EAAE,EACX,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,MAAU,GACjB,GAAG,EAAE,CAyCP"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @file types.ts
3
+ * @description Type definitions for XGBoost model training and prediction.
4
+ */
5
+ /**
6
+ * Configuration parameters for XGBoost model training.
7
+ * @see {@link https://xgboost.readthedocs.io/en/release_3.0.0/parameter.html XGBoost Parameters Documentation}
8
+ */
9
+ export interface XGBoostParams {
10
+ /** Controls output verbosity: 0=silent, 1=warnings, 2=info, 3=debug. Default: 1 */
11
+ verbosity?: number;
12
+ /** Maximum depth of each tree. Higher values increase complexity and overfitting risk. Default: 6 */
13
+ max_depth?: number;
14
+ /** Learning rate (step size shrinkage). Smaller values require more rounds but improve generalization. Default: 0.3 */
15
+ eta?: number;
16
+ /** Learning task objective (e.g., 'reg:squarederror' for regression, 'binary:logistic' for classification) */
17
+ objective?: string;
18
+ /** Number of parallel threads for training. Default: maximum available */
19
+ nthread?: number;
20
+ /** Fraction of training instances sampled per tree (0-1). Values <1 reduce overfitting. Default: 1 */
21
+ subsample?: number;
22
+ /** Fraction of features sampled per tree (0-1). Adds diversity like Random Forest. Default: 1 */
23
+ colsample_bytree?: number;
24
+ /** Fraction of features sampled per tree level (0-1). Additional regularization layer. Default: 1 */
25
+ colsample_bylevel?: number;
26
+ /** Minimum sum of instance weights in a leaf. Higher values prevent overly specific splits. Default: 1 */
27
+ min_child_weight?: number;
28
+ /** Minimum loss reduction required for a split. Higher values make splitting more conservative. Default: 0 */
29
+ gamma?: number;
30
+ /** L1 regularization (lasso). Encourages sparsity/feature selection. Default: 0 */
31
+ alpha?: number;
32
+ /** L2 regularization (ridge). Penalizes large weights to prevent overfitting. Default: 1 */
33
+ lambda?: number;
34
+ /** Stop training after N rounds without validation improvement. Prevents overfitting. */
35
+ early_stopping_rounds?: number;
36
+ /** Random seed for reproducibility. Default: 0 */
37
+ seed?: number;
38
+ /** Number of boosting rounds (trees to build). More rounds needed with lower eta. */
39
+ nrounds?: number;
40
+ /** Tree construction algorithm: 'auto', 'exact', 'approx', 'hist', 'gpu_hist'. Default: 'auto' */
41
+ tree_method?: string;
42
+ /** Tree growth policy: 'depthwise' (level-by-level) or 'lossguide' (leaf-by-leaf). Default: 'depthwise' */
43
+ grow_policy?: string;
44
+ /** Index signature for additional XGBoost parameters not explicitly typed */
45
+ [key: string]: any;
46
+ }
47
+ /**
48
+ * Options for training an XGBoost model.
49
+ */
50
+ export interface TrainModelOptions {
51
+ /** XGBoost parameters for model configuration */
52
+ xgbParams?: XGBoostParams;
53
+ /** Proportion of data to use for testing (default: 0.2) */
54
+ testSize?: number;
55
+ /** Specific feature columns to use for training */
56
+ featuresToUse: string[];
57
+ }
58
+ /**
59
+ * Options for making predictions with a trained model.
60
+ */
61
+ export interface PredictOptions {
62
+ /** Specific feature columns to use for prediction */
63
+ featuresToUse: string[];
64
+ }
65
+ /**
66
+ * Result of train/test data split.
67
+ */
68
+ export interface TrainTestSplit {
69
+ /** Training feature arrays */
70
+ trainFeatures: any[][];
71
+ /** Testing feature arrays */
72
+ testFeatures: any[][];
73
+ /** Training target values */
74
+ trainTarget: any[];
75
+ /** Testing target values */
76
+ testTarget: any[];
77
+ }
78
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/correlate/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qGAAqG;IACrG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uHAAuH;IACvH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8GAA8G;IAC9G,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sGAAsG;IACtG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iGAAiG;IACjG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qGAAqG;IACrG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0GAA0G;IAC1G,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,8GAA8G;IAC9G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4FAA4F;IAC5F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yFAAyF;IACzF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qFAAqF;IACrF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kGAAkG;IAClG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2GAA2G;IAC3G,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,iDAAiD;IACjD,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,8BAA8B;IAC9B,aAAa,EAAE,GAAG,EAAE,EAAE,CAAC;IACvB,6BAA6B;IAC7B,YAAY,EAAE,GAAG,EAAE,EAAE,CAAC;IACtB,6BAA6B;IAC7B,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,4BAA4B;IAC5B,UAAU,EAAE,GAAG,EAAE,CAAC;CACnB"}
@@ -0,0 +1,19 @@
1
+ import { PredictOptions } from './types';
2
+ /**
3
+ * Predicts target variable for future data using the trained XGBoost model
4
+ * @param futureData - Array of data objects for future dates
5
+ * @param options - Prediction options including features to use
6
+ * @returns Promise resolving to array of data objects with predictions
7
+ * @example
8
+ * let futureData = [
9
+ * { feature1: 10, feature2: 20 },
10
+ * { feature1: 15, feature2: 25 }
11
+ * ];
12
+ * let options = {
13
+ * featuresToUse: ['feature1', 'feature2']
14
+ * };
15
+ * let predictions = await predictFuture(futureData, options);
16
+ * console.log(predictions);
17
+ */
18
+ export declare function predictFuture(futureData: any[], options: PredictOptions): Promise<any[]>;
19
+ //# sourceMappingURL=xgboost-predictor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xgboost-predictor.d.ts","sourceRoot":"","sources":["../../src/correlate/xgboost-predictor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,GAAG,EAAE,EACjB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,GAAG,EAAE,CAAC,CA2BhB"}
@@ -0,0 +1,112 @@
1
+ import { TrainModelOptions, TrainTestSplit } from './types';
2
+ /**
3
+ * Trains an XGBoost model on preprocessed data and evaluates its performance.
4
+ *
5
+ * XGBoost (eXtreme Gradient Boosting) works by sequentially building decision trees
6
+ * where each new tree corrects errors made by the ensemble of previous trees.
7
+ * It uses gradient descent to minimize a loss function by adding trees that
8
+ * predict the residuals or errors of prior trees, then combining them through boosting.
9
+ * The algorithm employs regularization techniques to prevent overfitting and handles
10
+ * missing values effectively through its sparsity-aware split finding approach.
11
+ *
12
+ * @param fullData - Preprocessed training data as array of objects with numeric values only
13
+ * @param targetName - Name of the target variable column to predict
14
+ * @param options - Configuration options for model training
15
+ *
16
+ * // General Parameters
17
+ * @param options.xgbParams.verbosity - [default=1] Controls the verbosity of XGBoost's output
18
+ * 0: silent mode (no messages)
19
+ * 1: warnings only
20
+ * 2: info messages
21
+ * 3: debug messages
22
+ *
23
+ * // Tree Booster Parameters (Control tree structure)
24
+ * @param options.xgbParams.max_depth - [default=6] Maximum depth of each tree
25
+ * Controls model complexity. Higher values create more complex trees that may overfit.
26
+ * Reduced from 8 to 6 to limit tree complexity and prevent overfitting.
27
+ *
28
+ * @param options.xgbParams.eta - [default=0.3, alias: learning_rate] Step size shrinkage
29
+ * Controls how much weight is given to new trees in each boosting round.
30
+ * Smaller values (0.1) make the model more robust by shrinking feature weights.
31
+ * Set to 0.1 to allow more conservative boosting, requiring more trees but improving generalization.
32
+ *
33
+ * @param options.xgbParams.objective - Specifies the learning task and objective
34
+ * 'reg:squarederror': Regression with squared loss (minimize MSE)
35
+ * Options include classification objectives, ranking, and other regression metrics.
36
+ *
37
+ * @param options.xgbParams.nthread - Number of parallel threads used for training
38
+ * Set to 4 to utilize multi-core processing without overwhelming the system.
39
+ *
40
+ * @param options.xgbParams.subsample - [default=1] Fraction of training instances used per tree
41
+ * Values < 1 implement random sampling of the training data for each tree.
42
+ * Set to 0.9 to reduce overfitting by introducing randomness while using most of the data.
43
+ *
44
+ * @param options.xgbParams.colsample_bytree - [default=1] Fraction of features used per tree
45
+ * Controls feature sampling for each tree, similar to Random Forest.
46
+ * Set to 0.9 to reduce overfitting and create diverse trees.
47
+ *
48
+ * @param options.xgbParams.min_child_weight - [default=1] Minimum sum of instance weight in a child
49
+ * Controls the minimum number of instances needed in a leaf node.
50
+ * Set to 3 to prevent the model from creating overly specific rules based on few samples.
51
+ *
52
+ * @param options.xgbParams.gamma - [default=0, alias: min_split_loss] Minimum loss reduction for a split
53
+ * Controls the minimum reduction in the loss function required to make a split.
54
+ * Set to 0.1 to make splitting more conservative and reduce overfitting.
55
+ *
56
+ * // Regularization Parameters
57
+ * @param options.xgbParams.alpha - [default=0, alias: reg_alpha] L1 regularization on weights
58
+ * Encourages sparsity by penalizing non-zero weights (feature selection).
59
+ * Set to 0 as gamma is being used for regularization.
60
+ *
61
+ * @param options.xgbParams.lambda - [default=1, alias: reg_lambda] L2 regularization on weights
62
+ * Penalizes large weights to prevent overfitting (similar to Ridge regression).
63
+ * Default value of 1 provides moderate regularization.
64
+ *
65
+ * // Learning Control Parameters
66
+ * @param options.xgbParams.early_stopping_rounds - Stop training if performance doesn't improve
67
+ * Stops adding trees when the validation metric doesn't improve for specified rounds.
68
+ * Set to 20 to prevent overfitting by stopping when the model stops improving.
69
+ *
70
+ * @param options.xgbParams.seed - [default=0] Random number seed for reproducibility
71
+ * Set to 42 to ensure consistent results across training runs.
72
+ *
73
+ * @param options.xgbParams.nrounds - Number of boosting rounds (trees to build)
74
+ * Set to 1000 to compensate for the lower learning rate (eta),
75
+ * allowing the model to converge slowly but more accurately.
76
+ *
77
+ * @param options.testSize - Proportion of data to use for testing (default: 0.2)
78
+ * @param options.featuresToUse - Specific feature columns to use for training
79
+ * @see [XGBoost_parameters](https://xgboost.readthedocs.io/en/release_3.0.0/parameter.html)
80
+ * @author [vtempest](https://github.com/vtempest)
81
+ * @license MIT
82
+ * @returns R² value (coefficient of determination) indicating model accuracy
83
+ * @example
84
+ * let data = [
85
+ * {
86
+ * "feature1": 1,
87
+ * "feature2": 2,
88
+ * "target": 3
89
+ * }
90
+ * ];
91
+ * let options = {
92
+ * xgbParams: {
93
+ * verbosity: 0,
94
+ * max_depth: 7,
95
+ * eta: 0.07,
96
+ * objective: 'reg:squarederror',
97
+ * nthread: 4,
98
+ * }
99
+ * };
100
+ * let accuracy = await trainModels(data, 'target', options);
101
+ * console.log(accuracy);
102
+ */
103
+ export declare function trainModels(fullData: any[], targetName: string, options: TrainModelOptions): Promise<number>;
104
+ /**
105
+ * Splits data into training and testing sets
106
+ * @param features - Feature array
107
+ * @param target - Target array
108
+ * @param testSize - Proportion of data to use for testing
109
+ * @returns Split datasets
110
+ */
111
+ export declare function splitTrainTest(features: any[][], target: any[], testSize?: number): TrainTestSplit;
112
+ //# sourceMappingURL=xgboost-trainer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xgboost-trainer.d.ts","sourceRoot":"","sources":["../../src/correlate/xgboost-trainer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoGG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,GAAG,EAAE,EACf,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,MAAM,CAAC,CA4EjB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,GAAG,EAAE,EAAE,EACjB,MAAM,EAAE,GAAG,EAAE,EACb,QAAQ,GAAE,MAAY,GACrB,cAAc,CAsBhB"}
@@ -0,0 +1,10 @@
1
+ import { DetectionConfig, PriceWindow } from '../prediction/types';
2
+ export declare function getPool(): {
3
+ query: (text: string, params: any[]) => Promise<{
4
+ rows: never[];
5
+ }>;
6
+ };
7
+ export declare function getConfig(): Promise<DetectionConfig>;
8
+ export declare function getPriceWindowsBatch(tokenIds: string[], minutes: number): Promise<Map<string, PriceWindow>>;
9
+ export declare function getMarketsInCooldown(marketIds: string[], minutes: number): Promise<Set<string>>;
10
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/db/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGnE,wBAAgB,OAAO;kBAEC,MAAM,UAAU,GAAG,EAAE;;;EAK5C;AAED,wBAAsB,SAAS,IAAI,OAAO,CAAC,eAAe,CAAC,CAU1D;AAED,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAEnC;AAED,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EAAE,EACnB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAEtB"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Cloudflare D1 over the HTTP (REST) API.
3
+ *
4
+ * The app runs on Cloudflare Workers, where D1 is reached through the `DB`
5
+ * binding. Outside of workerd — maintenance scripts, one-off jobs, CI — there
6
+ * is no binding, so the *same* D1 database is reached through Cloudflare's
7
+ * REST API instead. This keeps a single database (Cloudflare D1) for every
8
+ * runtime: no libsql/Turso, no Postgres, no local sqlite file.
9
+ *
10
+ * Required environment variables outside Workers:
11
+ * CLOUDFLARE_ACCOUNT_ID Cloudflare account id
12
+ * CLOUDFLARE_DATABASE_ID D1 database id (defaults to the app's database)
13
+ * CLOUDFLARE_D1_TOKEN API token with D1 edit permission
14
+ */
15
+ /** Default D1 database id for this monorepo (`ai-broker-db`). */
16
+ export declare const DEFAULT_D1_DATABASE_ID = "37dbe79c-2687-4127-ad02-2372e15ac077";
17
+ export interface D1HttpCredentials {
18
+ accountId: string;
19
+ databaseId: string;
20
+ token: string;
21
+ }
22
+ /**
23
+ * Read D1 REST credentials from the environment.
24
+ * Returns null when the account id or API token is missing.
25
+ */
26
+ export declare function getD1HttpCredentials(): D1HttpCredentials | null;
27
+ /**
28
+ * Callback for `drizzle-orm/sqlite-proxy`.
29
+ *
30
+ * drizzle's proxy driver expects rows as positional value arrays, while the D1
31
+ * REST API returns row objects. Object key order matches the statement's
32
+ * column order, so `Object.values` restores the positional shape drizzle maps
33
+ * back onto the schema.
34
+ */
35
+ export declare function createD1HttpDriver(credentials: D1HttpCredentials): (sql: string, params: unknown[], method: "run" | "all" | "values" | "get") => Promise<{
36
+ rows: unknown[] | unknown[][];
37
+ }>;
38
+ //# sourceMappingURL=d1-http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d1-http.d.ts","sourceRoot":"","sources":["../../src/db/d1-http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,iEAAiE;AACjE,eAAO,MAAM,sBAAsB,yCAAyC,CAAC;AAE7E,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,GAAG,IAAI,CAe/D;AA6CD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,iBAAiB,IAE7D,KAAK,MAAM,EACX,QAAQ,OAAO,EAAE,EACjB,QAAQ,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,KACvC,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,EAAE,CAAA;CAAE,CAAC,CAQ9C"}