dexbot 1.4.17 → 1.4.19

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 (247) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -0
  3. package/analysis/README.md +43 -43
  4. package/analysis/ama_fitting/README.md +8 -8
  5. package/analysis/ama_fitting/package.json +1 -1
  6. package/analysis/bot_fitting/README.md +4 -4
  7. package/analysis/bot_fitting/backtest_ama_sweep.ts +1 -1
  8. package/analysis/bot_usage/discover_bot_accounts.ts +11 -11
  9. package/analysis/tradingview/README.md +4 -4
  10. package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +2 -2
  11. package/analysis/trend_detection/SIGNAL_DOCUMENTATION.md +1 -1
  12. package/analysis/trend_detection/package.json +1 -1
  13. package/claw/README.md +45 -45
  14. package/claw/docs/AI_BOT_LIBRARY_API.md +6 -6
  15. package/claw/examples/short_mpa_bts_strategy.ts +3 -3
  16. package/claw/package.json +21 -21
  17. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  18. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  19. package/claw/scripts/claw_bridge.ts +2 -2
  20. package/claw/scripts/claw_skill_md.ts +1 -1
  21. package/claw/skills/launcher-ops/references/launcher-workflow.md +5 -5
  22. package/claw/skills/margin-trading/references/honest-asset-list.md +1 -1
  23. package/claw/skills/memu-memory/SKILL.md +3 -3
  24. package/claw/tests/test_claw_mcp_transport.ts +2 -2
  25. package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts +3 -0
  26. package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +1 -0
  27. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +148 -0
  28. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +1 -0
  29. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts +12 -0
  30. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +1 -0
  31. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +389 -0
  32. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +1 -0
  33. package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts +3 -0
  34. package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +1 -0
  35. package/dist/analysis/ama_fitting/calibrate_convergence_er.js +200 -0
  36. package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +1 -0
  37. package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts +3 -0
  38. package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +1 -0
  39. package/dist/analysis/ama_fitting/fetch_lp_candles.js +213 -0
  40. package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +1 -0
  41. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +25 -0
  42. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +1 -0
  43. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +247 -0
  44. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +1 -0
  45. package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts +35 -0
  46. package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +1 -0
  47. package/dist/analysis/ama_fitting/optimizer_high_resolution.js +782 -0
  48. package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +1 -0
  49. package/dist/analysis/analyze_derivatives.d.ts +86 -0
  50. package/dist/analysis/analyze_derivatives.d.ts.map +1 -0
  51. package/dist/analysis/analyze_derivatives.js +285 -0
  52. package/dist/analysis/analyze_derivatives.js.map +1 -0
  53. package/dist/analysis/analyze_dynamic_weight.d.ts +14 -0
  54. package/dist/analysis/analyze_dynamic_weight.d.ts.map +1 -0
  55. package/dist/analysis/analyze_dynamic_weight.js +197 -0
  56. package/dist/analysis/analyze_dynamic_weight.js.map +1 -0
  57. package/dist/analysis/analyze_kalman.d.ts +13 -0
  58. package/dist/analysis/analyze_kalman.d.ts.map +1 -0
  59. package/dist/analysis/analyze_kalman.js +118 -0
  60. package/dist/analysis/analyze_kalman.js.map +1 -0
  61. package/dist/analysis/analyze_regime.d.ts +20 -0
  62. package/dist/analysis/analyze_regime.d.ts.map +1 -0
  63. package/dist/analysis/analyze_regime.js +139 -0
  64. package/dist/analysis/analyze_regime.js.map +1 -0
  65. package/dist/analysis/analyze_regime_windows.d.ts +19 -0
  66. package/dist/analysis/analyze_regime_windows.d.ts.map +1 -0
  67. package/dist/analysis/analyze_regime_windows.js +414 -0
  68. package/dist/analysis/analyze_regime_windows.js.map +1 -0
  69. package/dist/analysis/analyze_risk_profile.d.ts +3 -0
  70. package/dist/analysis/analyze_risk_profile.d.ts.map +1 -0
  71. package/dist/analysis/analyze_risk_profile.js +186 -0
  72. package/dist/analysis/analyze_risk_profile.js.map +1 -0
  73. package/dist/analysis/analyze_trade_heatmap.d.ts +3 -0
  74. package/dist/analysis/analyze_trade_heatmap.d.ts.map +1 -0
  75. package/dist/analysis/analyze_trade_heatmap.js +358 -0
  76. package/dist/analysis/analyze_trade_heatmap.js.map +1 -0
  77. package/dist/analysis/analyze_volatility.d.ts +22 -0
  78. package/dist/analysis/analyze_volatility.d.ts.map +1 -0
  79. package/dist/analysis/analyze_volatility.js +165 -0
  80. package/dist/analysis/analyze_volatility.js.map +1 -0
  81. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +91 -0
  82. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +1 -0
  83. package/dist/analysis/bot_fitting/backtest_ama_sweep.js +792 -0
  84. package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +1 -0
  85. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +2 -0
  86. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +1 -0
  87. package/dist/analysis/bot_fitting/backtest_bot_fitting.js +380 -0
  88. package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +1 -0
  89. package/dist/analysis/bot_fitting/shared_utils.d.ts +26 -0
  90. package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -0
  91. package/dist/analysis/bot_fitting/shared_utils.js +42 -0
  92. package/dist/analysis/bot_fitting/shared_utils.js.map +1 -0
  93. package/dist/analysis/bot_key_utils.d.ts +11 -0
  94. package/dist/analysis/bot_key_utils.d.ts.map +1 -0
  95. package/dist/analysis/bot_key_utils.js +153 -0
  96. package/dist/analysis/bot_key_utils.js.map +1 -0
  97. package/dist/analysis/bot_usage/discover_bot_accounts.d.ts +3 -0
  98. package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +1 -0
  99. package/dist/analysis/bot_usage/discover_bot_accounts.js +499 -0
  100. package/dist/analysis/bot_usage/discover_bot_accounts.js.map +1 -0
  101. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +531 -0
  102. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -0
  103. package/dist/analysis/bot_usage/kibana_bot_queries.js +399 -0
  104. package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -0
  105. package/dist/analysis/chart_css.d.ts +17 -0
  106. package/dist/analysis/chart_css.d.ts.map +1 -0
  107. package/dist/analysis/chart_css.js +49 -0
  108. package/dist/analysis/chart_css.js.map +1 -0
  109. package/dist/analysis/chart_ui.d.ts +45 -0
  110. package/dist/analysis/chart_ui.d.ts.map +1 -0
  111. package/dist/analysis/chart_ui.js +97 -0
  112. package/dist/analysis/chart_ui.js.map +1 -0
  113. package/dist/analysis/chart_utils.d.ts +27 -0
  114. package/dist/analysis/chart_utils.d.ts.map +1 -0
  115. package/dist/analysis/chart_utils.js +153 -0
  116. package/dist/analysis/chart_utils.js.map +1 -0
  117. package/dist/analysis/derivative_chart_generator.d.ts +12 -0
  118. package/dist/analysis/derivative_chart_generator.d.ts.map +1 -0
  119. package/dist/analysis/derivative_chart_generator.js +891 -0
  120. package/dist/analysis/derivative_chart_generator.js.map +1 -0
  121. package/dist/analysis/math_utils.d.ts +22 -0
  122. package/dist/analysis/math_utils.d.ts.map +1 -0
  123. package/dist/analysis/math_utils.js +43 -0
  124. package/dist/analysis/math_utils.js.map +1 -0
  125. package/dist/analysis/price_sources.d.ts +40 -0
  126. package/dist/analysis/price_sources.d.ts.map +1 -0
  127. package/dist/analysis/price_sources.js +94 -0
  128. package/dist/analysis/price_sources.js.map +1 -0
  129. package/dist/analysis/resolve_source.d.ts +25 -0
  130. package/dist/analysis/resolve_source.d.ts.map +1 -0
  131. package/dist/analysis/resolve_source.js +69 -0
  132. package/dist/analysis/resolve_source.js.map +1 -0
  133. package/dist/analysis/trade_profitability.d.ts +115 -0
  134. package/dist/analysis/trade_profitability.d.ts.map +1 -0
  135. package/dist/analysis/trade_profitability.js +1240 -0
  136. package/dist/analysis/trade_profitability.js.map +1 -0
  137. package/dist/analysis/tradingview/analyze_tradingview.d.ts +31 -0
  138. package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +1 -0
  139. package/dist/analysis/tradingview/analyze_tradingview.js +146 -0
  140. package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -0
  141. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +5 -0
  142. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -0
  143. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +1714 -0
  144. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -0
  145. package/dist/analysis/trend_detection/derivative_analyzer.d.ts +247 -0
  146. package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +1 -0
  147. package/dist/analysis/trend_detection/derivative_analyzer.js +901 -0
  148. package/dist/analysis/trend_detection/derivative_analyzer.js.map +1 -0
  149. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts +3 -0
  150. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -0
  151. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +1361 -0
  152. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -0
  153. package/dist/analysis/trend_detection/hurst_analyzer.d.ts +6 -0
  154. package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +1 -0
  155. package/dist/analysis/trend_detection/hurst_analyzer.js +7 -0
  156. package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -0
  157. package/dist/analysis/trend_detection/kalman_chart_generator.d.ts +3 -0
  158. package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +1 -0
  159. package/dist/analysis/trend_detection/kalman_chart_generator.js +360 -0
  160. package/dist/analysis/trend_detection/kalman_chart_generator.js.map +1 -0
  161. package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts +8 -0
  162. package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +1 -0
  163. package/dist/analysis/trend_detection/kalman_trend_analyzer.js +8 -0
  164. package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +1 -0
  165. package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts +6 -0
  166. package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +1 -0
  167. package/dist/analysis/trend_detection/kalman_velocity_smoothing.js +7 -0
  168. package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +1 -0
  169. package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts +6 -0
  170. package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +1 -0
  171. package/dist/analysis/trend_detection/permutation_entropy_analyzer.js +7 -0
  172. package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +1 -0
  173. package/dist/analysis/trend_detection/regime_chart_generator.d.ts +3 -0
  174. package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +1 -0
  175. package/dist/analysis/trend_detection/regime_chart_generator.js +310 -0
  176. package/dist/analysis/trend_detection/regime_chart_generator.js.map +1 -0
  177. package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +2 -0
  178. package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +1 -0
  179. package/dist/analysis/trend_detection/tests/test_kalman_trend.js +128 -0
  180. package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +1 -0
  181. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +2 -0
  182. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +1 -0
  183. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +37 -0
  184. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +1 -0
  185. package/dist/analysis/trend_detection/volatility_chart_generator.d.ts +3 -0
  186. package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +1 -0
  187. package/dist/analysis/trend_detection/volatility_chart_generator.js +646 -0
  188. package/dist/analysis/trend_detection/volatility_chart_generator.js.map +1 -0
  189. package/dist/bot.js +1 -1
  190. package/dist/bot.js.map +1 -1
  191. package/dist/market_adapter/ama_signal_runner.js +1 -1
  192. package/dist/market_adapter/ama_signal_runner.js.map +1 -1
  193. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +1 -1
  194. package/dist/modules/account_bots.d.ts +1 -0
  195. package/dist/modules/account_bots.d.ts.map +1 -1
  196. package/dist/modules/account_bots.js +27 -5
  197. package/dist/modules/account_bots.js.map +1 -1
  198. package/dist/modules/constants.d.ts +1 -0
  199. package/dist/modules/constants.d.ts.map +1 -1
  200. package/dist/modules/constants.js +12 -3
  201. package/dist/modules/constants.js.map +1 -1
  202. package/dist/modules/dexbot_class.d.ts +22 -0
  203. package/dist/modules/dexbot_class.d.ts.map +1 -1
  204. package/dist/modules/dexbot_class.js +27 -1
  205. package/dist/modules/dexbot_class.js.map +1 -1
  206. package/dist/modules/dexbot_cow_runtime.d.ts +48 -1
  207. package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
  208. package/dist/modules/dexbot_cow_runtime.js +168 -4
  209. package/dist/modules/dexbot_cow_runtime.js.map +1 -1
  210. package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
  211. package/dist/modules/order/grid_reconcile_internal.js +6 -27
  212. package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
  213. package/dist/modules/order/strategy.d.ts.map +1 -1
  214. package/dist/modules/order/strategy.js +6 -15
  215. package/dist/modules/order/strategy.js.map +1 -1
  216. package/dist/modules/order/utils/math.d.ts +29 -1
  217. package/dist/modules/order/utils/math.d.ts.map +1 -1
  218. package/dist/modules/order/utils/math.js +46 -1
  219. package/dist/modules/order/utils/math.js.map +1 -1
  220. package/dist/modules/order/utils/system.d.ts +2 -0
  221. package/dist/modules/order/utils/system.d.ts.map +1 -1
  222. package/dist/modules/order/utils/system.js +30 -2
  223. package/dist/modules/order/utils/system.js.map +1 -1
  224. package/dist/modules/runtime_settings.d.ts +1 -0
  225. package/dist/modules/runtime_settings.d.ts.map +1 -1
  226. package/dist/modules/runtime_settings.js +13 -2
  227. package/dist/modules/runtime_settings.js.map +1 -1
  228. package/dist/scripts/generate_lp_chart.js +1 -1
  229. package/dist/scripts/test-credit-renewal.js +1 -1
  230. package/docs/DEXBOT_COMPARISON.md +3 -3
  231. package/docs/EVOLUTION.md +26 -95
  232. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
  233. package/docs/GRID_RECALCULATION.md +2 -2
  234. package/docs/LIFECYCLE.md +207 -0
  235. package/docs/README.md +9 -1
  236. package/docs/developer_guide.md +4 -3
  237. package/market_adapter/README.md +23 -23
  238. package/package.json +18 -21
  239. package/scripts/README.md +12 -12
  240. package/scripts/bots +5 -7
  241. package/scripts/clear-market-adapter.sh +1 -1
  242. package/scripts/dexbot +5 -7
  243. package/scripts/keys +5 -7
  244. package/scripts/pm2 +5 -7
  245. package/scripts/unlock +5 -7
  246. package/scripts/update.js +6 -7
  247. package/scripts/repo-stats.html +0 -480
@@ -0,0 +1,531 @@
1
+ /**
2
+ * KIBANA BOT QUERIES
3
+ *
4
+ * Elasticsearch query builders for analyzing DEXBot / DEXBot2 order activity
5
+ * on the BitShares blockchain via the public Kibana instance.
6
+ *
7
+ * Data source:
8
+ * https://kibana.bitshares.dev / bitshares-* index
9
+ * Time field: block_data.block_time
10
+ *
11
+ * BitShares operation types used here:
12
+ * 1 = limit_order_create (field: op_object.seller)
13
+ * 2 = limit_order_cancel (field: op_object.fee_paying_account)
14
+ * 4 = fill_order (field: op_object.account_id)
15
+ *
16
+ * Relevant ES field paths:
17
+ * limit_order_create:
18
+ * op_object.seller — account that placed the order
19
+ * op_object.amount_to_sell.amount — integer sell amount
20
+ * op_object.amount_to_sell.asset_id — sell asset ID (e.g. '1.3.0' = BTS)
21
+ * op_object.min_to_receive.amount — integer min-receive (= limit price numerator)
22
+ * op_object.min_to_receive.asset_id — receive asset ID
23
+ * op_object.expiration — ISO datetime
24
+ *
25
+ * fill_order:
26
+ * op_object.account_id — whose order was filled
27
+ * op_object.pays.amount / .asset_id — what was paid
28
+ * op_object.receives.amount / .asset_id — what was received
29
+ * op_object.order_id — the limit order that filled
30
+ *
31
+ * limit_order_cancel:
32
+ * op_object.fee_paying_account — account that cancelled
33
+ * op_object.order — the order ID cancelled
34
+ */
35
+ import { kibanaSearch } from '../../market_adapter/core/kibana_client.js';
36
+ declare const OP_LIMIT_ORDER_CREATE = 1;
37
+ declare const OP_LIMIT_ORDER_CANCEL = 2;
38
+ declare const OP_FILL_ORDER = 4;
39
+ declare const DEFAULT_CONFIG: {
40
+ timeout: number;
41
+ kibanaUrl: "https://kibana.bitshares.dev";
42
+ apiKey: null;
43
+ };
44
+ /**
45
+ * Time-bucketed count of limit_order_create ops for an account.
46
+ * Optionally filtered to orders selling a specific asset.
47
+ */
48
+ declare function buildOrderCreateQuery(accountId: string, lookbackHours: number, intervalSeconds?: number, sellAssetId?: string | null): {
49
+ size: number;
50
+ query: {
51
+ bool: {
52
+ filter: ({
53
+ term: {
54
+ operation_type: number;
55
+ 'operation_history.op_object.seller.keyword'?: undefined;
56
+ };
57
+ range?: undefined;
58
+ } | {
59
+ term: {
60
+ 'operation_history.op_object.seller.keyword': string;
61
+ operation_type?: undefined;
62
+ };
63
+ range?: undefined;
64
+ } | {
65
+ range: {
66
+ 'block_data.block_time': {
67
+ gte: string;
68
+ lte: string;
69
+ };
70
+ };
71
+ term?: undefined;
72
+ })[];
73
+ };
74
+ };
75
+ aggs: {
76
+ by_time: {
77
+ date_histogram: {
78
+ field: string;
79
+ fixed_interval: string;
80
+ min_doc_count: number;
81
+ };
82
+ };
83
+ total: {
84
+ value_count: {
85
+ field: string;
86
+ };
87
+ };
88
+ };
89
+ };
90
+ /**
91
+ * Time-bucketed count of fill_order ops for an account.
92
+ * Optionally filtered to fills where account pays a specific asset.
93
+ */
94
+ declare function buildFillOrderQuery(accountId: string, lookbackHours: number, intervalSeconds?: number, paysAssetId?: string | null): {
95
+ size: number;
96
+ query: {
97
+ bool: {
98
+ filter: ({
99
+ term: {
100
+ operation_type: number;
101
+ 'operation_history.op_object.account_id.keyword'?: undefined;
102
+ };
103
+ range?: undefined;
104
+ } | {
105
+ term: {
106
+ 'operation_history.op_object.account_id.keyword': string;
107
+ operation_type?: undefined;
108
+ };
109
+ range?: undefined;
110
+ } | {
111
+ range: {
112
+ 'block_data.block_time': {
113
+ gte: string;
114
+ lte: string;
115
+ };
116
+ };
117
+ term?: undefined;
118
+ })[];
119
+ };
120
+ };
121
+ aggs: {
122
+ by_time: {
123
+ date_histogram: {
124
+ field: string;
125
+ fixed_interval: string;
126
+ min_doc_count: number;
127
+ };
128
+ };
129
+ total: {
130
+ value_count: {
131
+ field: string;
132
+ };
133
+ };
134
+ };
135
+ };
136
+ /**
137
+ * Time-bucketed count of limit_order_cancel ops for an account.
138
+ */
139
+ declare function buildOrderCancelQuery(accountId: string, lookbackHours: number, intervalSeconds?: number): {
140
+ size: number;
141
+ query: {
142
+ bool: {
143
+ filter: ({
144
+ term: {
145
+ operation_type: number;
146
+ 'operation_history.op_object.fee_paying_account.keyword'?: undefined;
147
+ };
148
+ range?: undefined;
149
+ } | {
150
+ term: {
151
+ 'operation_history.op_object.fee_paying_account.keyword': string;
152
+ operation_type?: undefined;
153
+ };
154
+ range?: undefined;
155
+ } | {
156
+ range: {
157
+ 'block_data.block_time': {
158
+ gte: string;
159
+ lte: string;
160
+ };
161
+ };
162
+ term?: undefined;
163
+ })[];
164
+ };
165
+ };
166
+ aggs: {
167
+ by_time: {
168
+ date_histogram: {
169
+ field: string;
170
+ fixed_interval: string;
171
+ min_doc_count: number;
172
+ };
173
+ };
174
+ total: {
175
+ value_count: {
176
+ field: string;
177
+ };
178
+ };
179
+ };
180
+ };
181
+ /**
182
+ * Daily activity breakdown by operation type for an account.
183
+ * Merges creates (by seller), fills (by account_id), cancels (by fee_paying_account)
184
+ * into one aggregation using a filter per op type.
185
+ */
186
+ declare function buildDailyActivityQuery(accountId: string, lookbackHours: number): {
187
+ size: number;
188
+ query: {
189
+ bool: {
190
+ filter: {
191
+ range: {
192
+ 'block_data.block_time': {
193
+ gte: string;
194
+ lte: string;
195
+ };
196
+ };
197
+ }[];
198
+ };
199
+ };
200
+ aggs: {
201
+ creates: {
202
+ filter: {
203
+ bool: {
204
+ filter: ({
205
+ term: {
206
+ operation_type: number;
207
+ 'operation_history.op_object.seller.keyword'?: undefined;
208
+ };
209
+ } | {
210
+ term: {
211
+ 'operation_history.op_object.seller.keyword': string;
212
+ operation_type?: undefined;
213
+ };
214
+ })[];
215
+ };
216
+ };
217
+ aggs: {
218
+ by_day: {
219
+ date_histogram: {
220
+ field: string;
221
+ fixed_interval: string;
222
+ min_doc_count: number;
223
+ };
224
+ };
225
+ };
226
+ };
227
+ fills: {
228
+ filter: {
229
+ bool: {
230
+ filter: ({
231
+ term: {
232
+ operation_type: number;
233
+ 'operation_history.op_object.account_id.keyword'?: undefined;
234
+ };
235
+ } | {
236
+ term: {
237
+ 'operation_history.op_object.account_id.keyword': string;
238
+ operation_type?: undefined;
239
+ };
240
+ })[];
241
+ };
242
+ };
243
+ aggs: {
244
+ by_day: {
245
+ date_histogram: {
246
+ field: string;
247
+ fixed_interval: string;
248
+ min_doc_count: number;
249
+ };
250
+ };
251
+ };
252
+ };
253
+ cancels: {
254
+ filter: {
255
+ bool: {
256
+ filter: ({
257
+ term: {
258
+ operation_type: number;
259
+ 'operation_history.op_object.fee_paying_account.keyword'?: undefined;
260
+ };
261
+ } | {
262
+ term: {
263
+ 'operation_history.op_object.fee_paying_account.keyword': string;
264
+ operation_type?: undefined;
265
+ };
266
+ })[];
267
+ };
268
+ };
269
+ aggs: {
270
+ by_day: {
271
+ date_histogram: {
272
+ field: string;
273
+ fixed_interval: string;
274
+ min_doc_count: number;
275
+ };
276
+ };
277
+ };
278
+ };
279
+ };
280
+ };
281
+ /**
282
+ * Fetch raw limit_order_create documents for grid spacing analysis.
283
+ * Returns the price-relevant fields plus timestamps.
284
+ *
285
+ * @param {string} accountId
286
+ * @param {number} lookbackHours
287
+ * @param {string} [sellAssetId] - optional: filter to one sell-side asset
288
+ * @param {number} [maxResults]
289
+ * @returns {Object} Elasticsearch query object
290
+ */
291
+ declare function buildOrderPriceQuery(accountId: string, lookbackHours: number, sellAssetId?: string | null, maxResults?: number): {
292
+ size: number;
293
+ _source: string[];
294
+ query: {
295
+ bool: {
296
+ filter: ({
297
+ term: {
298
+ operation_type: number;
299
+ 'operation_history.op_object.seller.keyword'?: undefined;
300
+ };
301
+ range?: undefined;
302
+ } | {
303
+ term: {
304
+ 'operation_history.op_object.seller.keyword': string;
305
+ operation_type?: undefined;
306
+ };
307
+ range?: undefined;
308
+ } | {
309
+ range: {
310
+ 'block_data.block_time': {
311
+ gte: string;
312
+ lte: string;
313
+ };
314
+ };
315
+ term?: undefined;
316
+ })[];
317
+ };
318
+ };
319
+ sort: {
320
+ 'block_data.block_time': {
321
+ order: string;
322
+ };
323
+ }[];
324
+ };
325
+ /**
326
+ * Fetch raw fill_order documents for fill-price analysis.
327
+ *
328
+ * @param {string} accountId
329
+ * @param {number} lookbackHours
330
+ * @param {string} [paysAssetId]
331
+ * @param {number} [maxResults]
332
+ * @returns {Object} Elasticsearch query object
333
+ */
334
+ declare function buildFillPriceQuery(accountId: string, lookbackHours: number, paysAssetId?: string | null, maxResults?: number): {
335
+ size: number;
336
+ _source: string[];
337
+ query: {
338
+ bool: {
339
+ filter: ({
340
+ term: {
341
+ operation_type: number;
342
+ 'operation_history.op_object.account_id.keyword'?: undefined;
343
+ };
344
+ range?: undefined;
345
+ } | {
346
+ term: {
347
+ 'operation_history.op_object.account_id.keyword': string;
348
+ operation_type?: undefined;
349
+ };
350
+ range?: undefined;
351
+ } | {
352
+ range: {
353
+ 'block_data.block_time': {
354
+ gte: string;
355
+ lte: string;
356
+ };
357
+ };
358
+ term?: undefined;
359
+ })[];
360
+ };
361
+ };
362
+ sort: {
363
+ 'block_data.block_time': {
364
+ order: string;
365
+ };
366
+ }[];
367
+ };
368
+ /**
369
+ * Discover which asset pairs an account trades by aggregating the sell asset IDs.
370
+ * Returns top asset IDs by order count.
371
+ */
372
+ declare function buildAssetDiscoveryQuery(accountId: string, lookbackHours: number): {
373
+ size: number;
374
+ query: {
375
+ bool: {
376
+ filter: ({
377
+ term: {
378
+ operation_type: number;
379
+ 'operation_history.op_object.seller.keyword'?: undefined;
380
+ };
381
+ range?: undefined;
382
+ } | {
383
+ term: {
384
+ 'operation_history.op_object.seller.keyword': string;
385
+ operation_type?: undefined;
386
+ };
387
+ range?: undefined;
388
+ } | {
389
+ range: {
390
+ 'block_data.block_time': {
391
+ gte: string;
392
+ lte: string;
393
+ };
394
+ };
395
+ term?: undefined;
396
+ })[];
397
+ };
398
+ };
399
+ aggs: {
400
+ sell_assets: {
401
+ terms: {
402
+ field: string;
403
+ size: number;
404
+ };
405
+ };
406
+ recv_assets: {
407
+ terms: {
408
+ field: string;
409
+ size: number;
410
+ };
411
+ };
412
+ };
413
+ };
414
+ declare function fetchOrderCreate(accountId: string, lookbackHours: number, config?: any, sellAssetId?: string | null, intervalSeconds?: number): Promise<unknown>;
415
+ declare function fetchFillOrder(accountId: string, lookbackHours: number, config?: any, paysAssetId?: string | null, intervalSeconds?: number): Promise<unknown>;
416
+ declare function fetchOrderCancel(accountId: string, lookbackHours: number, config?: any, intervalSeconds?: number): Promise<unknown>;
417
+ declare function fetchOrderPrices(accountId: string, lookbackHours: number, config?: any, sellAssetId?: string | null, maxResults?: number): Promise<unknown>;
418
+ declare function fetchFillPrices(accountId: string, lookbackHours: number, config?: any, paysAssetId?: string | null, maxResults?: number): Promise<unknown>;
419
+ declare function fetchDailyActivity(accountId: string, lookbackHours: number, config?: any): Promise<unknown>;
420
+ declare function fetchAssetDiscovery(accountId: string, lookbackHours: number, config?: any): Promise<unknown>;
421
+ /**
422
+ * Top N accounts by limit_order_create count (seller field).
423
+ * Use this to discover the most active order-placing accounts.
424
+ */
425
+ declare function buildTopSellerAccountsQuery(lookbackHours: number, topN?: number, minCreates?: number): {
426
+ size: number;
427
+ query: {
428
+ bool: {
429
+ filter: ({
430
+ term: {
431
+ operation_type: number;
432
+ };
433
+ range?: undefined;
434
+ } | {
435
+ range: {
436
+ 'block_data.block_time': {
437
+ gte: string;
438
+ lte: string;
439
+ };
440
+ };
441
+ term?: undefined;
442
+ })[];
443
+ };
444
+ };
445
+ aggs: {
446
+ by_account: {
447
+ terms: {
448
+ field: string;
449
+ size: number;
450
+ min_doc_count: number;
451
+ order: {
452
+ _count: string;
453
+ };
454
+ };
455
+ };
456
+ };
457
+ };
458
+ /**
459
+ * Top N accounts by limit_order_cancel count (fee_paying_account field).
460
+ */
461
+ declare function buildTopCancellerAccountsQuery(lookbackHours: number, topN?: number, minCancels?: number): {
462
+ size: number;
463
+ query: {
464
+ bool: {
465
+ filter: ({
466
+ term: {
467
+ operation_type: number;
468
+ };
469
+ range?: undefined;
470
+ } | {
471
+ range: {
472
+ 'block_data.block_time': {
473
+ gte: string;
474
+ lte: string;
475
+ };
476
+ };
477
+ term?: undefined;
478
+ })[];
479
+ };
480
+ };
481
+ aggs: {
482
+ by_account: {
483
+ terms: {
484
+ field: string;
485
+ size: number;
486
+ min_doc_count: number;
487
+ order: {
488
+ _count: string;
489
+ };
490
+ };
491
+ };
492
+ };
493
+ };
494
+ /**
495
+ * Top N accounts by fill_order count (account_id field).
496
+ */
497
+ declare function buildTopFilledAccountsQuery(lookbackHours: number, topN?: number, minFills?: number): {
498
+ size: number;
499
+ query: {
500
+ bool: {
501
+ filter: ({
502
+ term: {
503
+ operation_type: number;
504
+ };
505
+ range?: undefined;
506
+ } | {
507
+ range: {
508
+ 'block_data.block_time': {
509
+ gte: string;
510
+ lte: string;
511
+ };
512
+ };
513
+ term?: undefined;
514
+ })[];
515
+ };
516
+ };
517
+ aggs: {
518
+ by_account: {
519
+ terms: {
520
+ field: string;
521
+ size: number;
522
+ min_doc_count: number;
523
+ order: {
524
+ _count: string;
525
+ };
526
+ };
527
+ };
528
+ };
529
+ };
530
+ export { OP_LIMIT_ORDER_CREATE, OP_LIMIT_ORDER_CANCEL, OP_FILL_ORDER, DEFAULT_CONFIG, kibanaSearch, buildOrderCreateQuery, buildFillOrderQuery, buildOrderCancelQuery, buildDailyActivityQuery, buildAssetDiscoveryQuery, buildOrderPriceQuery, buildFillPriceQuery, fetchOrderCreate, fetchFillOrder, fetchOrderCancel, fetchOrderPrices, fetchFillPrices, fetchDailyActivity, fetchAssetDiscovery, buildTopSellerAccountsQuery, buildTopCancellerAccountsQuery, buildTopFilledAccountsQuery };
531
+ //# sourceMappingURL=kibana_bot_queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kibana_bot_queries.d.ts","sourceRoot":"","sources":["../../../analysis/bot_usage/kibana_bot_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAIH,OAAO,EAAE,YAAY,EAAiC,MAAM,4CAA4C,CAAC;AAKzG,QAAA,MAAM,qBAAqB,IAAI,CAAC;AAChC,QAAA,MAAM,qBAAqB,IAAI,CAAC;AAChC,QAAA,MAAM,aAAa,IAAY,CAAC;AAEhC,QAAA,MAAM,cAAc;;;;CAGnB,CAAC;AAIF;;;GAGG;AACH,iBAAS,qBAA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