@one_deploy/sdk 1.0.7 → 1.2.0

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 (106) hide show
  1. package/README.md +339 -0
  2. package/dist/ForexPoolDataGenerator--__twRwl.d.mts +76 -0
  3. package/dist/ForexPoolDataGenerator-eUgwsU_B.d.ts +76 -0
  4. package/dist/OneForexTradeHistory-TlKxjbFF.d.ts +250 -0
  5. package/dist/OneForexTradeHistory-iDySMcw0.d.mts +250 -0
  6. package/dist/components/index.d.mts +539 -0
  7. package/dist/components/index.d.ts +539 -0
  8. package/dist/components/index.js +7295 -0
  9. package/dist/components/index.js.map +1 -0
  10. package/dist/components/index.mjs +7243 -0
  11. package/dist/components/index.mjs.map +1 -0
  12. package/dist/config/index.d.mts +1 -0
  13. package/dist/config/index.d.ts +1 -0
  14. package/dist/console-BfTMA7ah.d.mts +504 -0
  15. package/dist/console-BfTMA7ah.d.ts +504 -0
  16. package/dist/hooks/index.d.mts +323 -1
  17. package/dist/hooks/index.d.ts +323 -1
  18. package/dist/hooks/index.js +3223 -0
  19. package/dist/hooks/index.js.map +1 -1
  20. package/dist/hooks/index.mjs +3204 -1
  21. package/dist/hooks/index.mjs.map +1 -1
  22. package/dist/index.d.mts +18 -352
  23. package/dist/index.d.ts +18 -352
  24. package/dist/index.js +8646 -574
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +8449 -432
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/providers/index.d.mts +31 -31
  29. package/dist/providers/index.d.ts +31 -31
  30. package/dist/providers/index.js +140 -153
  31. package/dist/providers/index.js.map +1 -1
  32. package/dist/providers/index.mjs +100 -109
  33. package/dist/providers/index.mjs.map +1 -1
  34. package/dist/react-native.d.mts +8 -144
  35. package/dist/react-native.d.ts +8 -144
  36. package/dist/react-native.js +2640 -689
  37. package/dist/react-native.js.map +1 -1
  38. package/dist/react-native.mjs +2610 -691
  39. package/dist/react-native.mjs.map +1 -1
  40. package/dist/services/index.d.mts +85 -4
  41. package/dist/services/index.d.ts +85 -4
  42. package/dist/services/index.js +1621 -0
  43. package/dist/services/index.js.map +1 -1
  44. package/dist/services/index.mjs +1619 -1
  45. package/dist/services/index.mjs.map +1 -1
  46. package/dist/types/index.d.mts +203 -1
  47. package/dist/types/index.d.ts +203 -1
  48. package/dist/types/index.js +275 -0
  49. package/dist/types/index.js.map +1 -1
  50. package/dist/types/index.mjs +251 -0
  51. package/dist/types/index.mjs.map +1 -1
  52. package/dist/useForexTrading-BleeSor8.d.mts +80 -0
  53. package/dist/useForexTrading-ZgW_G40Q.d.ts +80 -0
  54. package/package.json +9 -2
  55. package/src/components/OneConnectButton.tsx +24 -1
  56. package/src/components/OneNFTGallery.tsx +13 -7
  57. package/src/components/OneOfframpWidget.tsx +4 -3
  58. package/src/components/OnePayWidget.tsx +10 -1
  59. package/src/components/OneSendWidget.tsx +3 -3
  60. package/src/components/OneSwapWidget.tsx +4 -4
  61. package/src/components/OneTransactionButton.tsx +28 -3
  62. package/src/components/OneWalletBalance.tsx +1 -1
  63. package/src/components/ai/OneChainSelector.tsx +63 -336
  64. package/src/components/ai/OneForexCapitalSplit.tsx +112 -0
  65. package/src/components/ai/OneForexConsoleView.tsx +90 -0
  66. package/src/components/ai/OneForexPairSelector.tsx +101 -0
  67. package/src/components/ai/OneForexPoolCard.tsx +105 -0
  68. package/src/components/ai/OneForexTradeHistory.tsx +107 -0
  69. package/src/components/ai/OnePairSelector.tsx +77 -434
  70. package/src/components/ai/console/OneAIQuantConsole.tsx +423 -0
  71. package/src/components/ai/console/OneAgentCard.tsx +383 -0
  72. package/src/components/ai/console/OneAgentConsole.tsx +469 -0
  73. package/src/components/ai/console/OneDecisionTimeline.tsx +433 -0
  74. package/src/components/ai/console/OneMetricsDashboard.tsx +493 -0
  75. package/src/components/ai/console/OnePositionCard.tsx +406 -0
  76. package/src/components/ai/console/OnePositionDetail.tsx +600 -0
  77. package/src/components/ai/console/OneRiskIndicator.tsx +464 -0
  78. package/src/components/ai/console/OneTradingConsole.tsx +660 -0
  79. package/src/components/ai/console/index.ts +17 -0
  80. package/src/components/ai/index.ts +10 -0
  81. package/src/hooks/index.ts +46 -0
  82. package/src/hooks/useAIDecisions.ts +280 -0
  83. package/src/hooks/useAIPositions.ts +349 -0
  84. package/src/hooks/useAIQuantConsole.ts +283 -0
  85. package/src/hooks/useAIRiskStatus.ts +276 -0
  86. package/src/hooks/useAITrading.ts +190 -0
  87. package/src/hooks/useBotSimulation.ts +201 -0
  88. package/src/hooks/useForexTrading.ts +430 -0
  89. package/src/hooks/useTradingConsole.ts +243 -0
  90. package/src/index.ts +123 -5
  91. package/src/providers/OneProvider.tsx +181 -5
  92. package/src/providers/index.ts +22 -8
  93. package/src/react-native.ts +41 -0
  94. package/src/services/forex/BotSimulationEngine.ts +968 -0
  95. package/src/services/forex/ForexPoolDataGenerator.ts +542 -0
  96. package/src/services/forex/ForexSimulationEngine.ts +482 -0
  97. package/src/services/forex/index.ts +21 -0
  98. package/src/services/index.ts +16 -0
  99. package/src/types/aiTrading.ts +151 -0
  100. package/src/types/console.ts +380 -0
  101. package/src/types/forex.ts +282 -0
  102. package/src/types/index.ts +106 -0
  103. package/dist/price-CgqXPnT3.d.ts +0 -13
  104. package/dist/price-ClbLHHjv.d.mts +0 -13
  105. package/dist/supabase-BT0c7q9e.d.mts +0 -82
  106. package/dist/supabase-BT0c7q9e.d.ts +0 -82
@@ -0,0 +1,433 @@
1
+ /**
2
+ * OneDecisionTimeline - Displays AI decision history with reasoning
3
+ * Part of ONE Ecosystem SDK
4
+ */
5
+
6
+ import React from 'react';
7
+ import { View, Text, StyleSheet, ScrollView, ViewStyle, Platform, TouchableOpacity } from 'react-native';
8
+ import type { AIDecision, DecisionAction } from '../../../types/console';
9
+
10
+ const MONO = Platform.OS === 'ios' ? 'Courier New' : 'monospace';
11
+
12
+ const ACTION_COLORS: Record<DecisionAction, { color: string; bgColor: string; label: string }> = {
13
+ OPEN_LONG: { color: '#10B981', bgColor: '#D1FAE5', label: 'LONG' },
14
+ OPEN_SHORT: { color: '#EF4444', bgColor: '#FEE2E2', label: 'SHORT' },
15
+ CLOSE_LONG: { color: '#6366F1', bgColor: '#E0E7FF', label: 'CLOSE L' },
16
+ CLOSE_SHORT: { color: '#8B5CF6', bgColor: '#EDE9FE', label: 'CLOSE S' },
17
+ HOLD: { color: '#9CA3AF', bgColor: '#F3F4F6', label: 'HOLD' },
18
+ SKIP: { color: '#F59E0B', bgColor: '#FEF3C7', label: 'SKIP' },
19
+ };
20
+
21
+ export interface OneDecisionTimelineProps {
22
+ decisions: AIDecision[];
23
+ maxItems?: number;
24
+ showReasoning?: boolean;
25
+ showIndicators?: boolean;
26
+ showConfidence?: boolean;
27
+ onDecisionPress?: (decision: AIDecision) => void;
28
+ style?: ViewStyle;
29
+ height?: number;
30
+ dark?: boolean;
31
+ }
32
+
33
+ export const OneDecisionTimeline: React.FC<OneDecisionTimelineProps> = ({
34
+ decisions,
35
+ maxItems = 50,
36
+ showReasoning = true,
37
+ showIndicators = true,
38
+ showConfidence = true,
39
+ onDecisionPress,
40
+ style,
41
+ height = 400,
42
+ dark = true,
43
+ }) => {
44
+ const bg = dark ? '#0A0A0C' : '#ffffff';
45
+ const border = dark ? '#2A2A35' : '#E5E7EB';
46
+ const textPrimary = dark ? '#ffffff' : '#111827';
47
+ const textSecondary = dark ? '#9CA3AF' : '#6B7280';
48
+ const textMuted = dark ? '#555560' : '#9CA3AF';
49
+ const cardBg = dark ? '#111111' : '#F9FAFB';
50
+
51
+ const visibleDecisions = decisions.slice(0, maxItems);
52
+
53
+ const formatTime = (ts: number) => {
54
+ const d = new Date(ts);
55
+ const hours = d.getHours().toString().padStart(2, '0');
56
+ const mins = d.getMinutes().toString().padStart(2, '0');
57
+ const secs = d.getSeconds().toString().padStart(2, '0');
58
+ return `${hours}:${mins}:${secs}`;
59
+ };
60
+
61
+ const formatDate = (ts: number) => {
62
+ const d = new Date(ts);
63
+ const month = (d.getMonth() + 1).toString().padStart(2, '0');
64
+ const day = d.getDate().toString().padStart(2, '0');
65
+ return `${month}/${day}`;
66
+ };
67
+
68
+ const getConfidenceColor = (confidence: number): string => {
69
+ if (confidence >= 0.7) return '#10B981';
70
+ if (confidence >= 0.5) return '#F59E0B';
71
+ return '#EF4444';
72
+ };
73
+
74
+ const handlePress = (decision: AIDecision) => {
75
+ if (onDecisionPress) {
76
+ onDecisionPress(decision);
77
+ }
78
+ };
79
+
80
+ const DecisionItem = ({ decision }: { decision: AIDecision }) => {
81
+ const actionConfig = ACTION_COLORS[decision.action];
82
+
83
+ const itemContent = (
84
+ <>
85
+ {/* Timeline dot and line */}
86
+ <View style={styles.timelineColumn}>
87
+ <View style={[styles.timelineDot, { backgroundColor: actionConfig.color }]} />
88
+ <View style={[styles.timelineLine, { backgroundColor: border }]} />
89
+ </View>
90
+
91
+ {/* Content */}
92
+ <View style={styles.decisionContent}>
93
+ {/* Header */}
94
+ <View style={styles.decisionHeader}>
95
+ <View style={styles.decisionHeaderLeft}>
96
+ <View style={[styles.actionBadge, { backgroundColor: actionConfig.bgColor }]}>
97
+ <Text style={[styles.actionText, { color: actionConfig.color }]}>
98
+ {actionConfig.label}
99
+ </Text>
100
+ </View>
101
+ <Text style={[styles.pairText, { color: textPrimary }]}>{decision.pair}</Text>
102
+ </View>
103
+ <View style={styles.decisionHeaderRight}>
104
+ <Text style={[styles.timeText, { color: textMuted }]}>
105
+ {formatDate(decision.timestamp)} {formatTime(decision.timestamp)}
106
+ </Text>
107
+ </View>
108
+ </View>
109
+
110
+ {/* Strategy and Confidence */}
111
+ <View style={styles.metaRow}>
112
+ <Text style={[styles.strategyText, { color: textSecondary }]}>
113
+ {decision.strategyName}
114
+ </Text>
115
+ {showConfidence && (
116
+ <View style={styles.confidenceRow}>
117
+ <Text style={[styles.confidenceLabel, { color: textMuted }]}>Confidence:</Text>
118
+ <View style={[styles.confidenceBar, { backgroundColor: dark ? '#1A1A1F' : '#E5E7EB' }]}>
119
+ <View
120
+ style={[
121
+ styles.confidenceFill,
122
+ {
123
+ width: `${decision.confidence * 100}%`,
124
+ backgroundColor: getConfidenceColor(decision.confidence),
125
+ }
126
+ ]}
127
+ />
128
+ </View>
129
+ <Text style={[styles.confidenceValue, { color: getConfidenceColor(decision.confidence) }]}>
130
+ {(decision.confidence * 100).toFixed(0)}%
131
+ </Text>
132
+ </View>
133
+ )}
134
+ </View>
135
+
136
+ {/* Reasoning */}
137
+ {showReasoning && decision.reasoning && (
138
+ <View style={[styles.reasoningBox, { backgroundColor: dark ? '#1A1A1F' : '#F3F4F6' }]}>
139
+ <Text style={[styles.reasoningText, { color: textSecondary }]}>
140
+ {decision.reasoning}
141
+ </Text>
142
+ </View>
143
+ )}
144
+
145
+ {/* Indicators */}
146
+ {showIndicators && decision.indicators && Object.keys(decision.indicators).length > 0 && (
147
+ <View style={styles.indicatorsRow}>
148
+ {decision.indicators.rsi !== undefined && (
149
+ <View style={styles.indicatorItem}>
150
+ <Text style={[styles.indicatorLabel, { color: textMuted }]}>RSI</Text>
151
+ <Text style={[styles.indicatorValue, { color: textSecondary }]}>
152
+ {decision.indicators.rsi.toFixed(1)}
153
+ </Text>
154
+ </View>
155
+ )}
156
+ {decision.indicators.macd !== undefined && (
157
+ <View style={styles.indicatorItem}>
158
+ <Text style={[styles.indicatorLabel, { color: textMuted }]}>MACD</Text>
159
+ <Text style={[
160
+ styles.indicatorValue,
161
+ { color: decision.indicators.macd >= 0 ? '#10B981' : '#EF4444' }
162
+ ]}>
163
+ {decision.indicators.macd >= 0 ? '+' : ''}{decision.indicators.macd.toFixed(3)}
164
+ </Text>
165
+ </View>
166
+ )}
167
+ {decision.indicators.ema && (
168
+ <View style={styles.indicatorItem}>
169
+ <Text style={[styles.indicatorLabel, { color: textMuted }]}>EMA</Text>
170
+ <Text style={[
171
+ styles.indicatorValue,
172
+ { color: decision.indicators.ema === 'bullish' ? '#10B981' : '#EF4444' }
173
+ ]}>
174
+ {decision.indicators.ema}
175
+ </Text>
176
+ </View>
177
+ )}
178
+ {decision.indicators.volume !== undefined && (
179
+ <View style={styles.indicatorItem}>
180
+ <Text style={[styles.indicatorLabel, { color: textMuted }]}>Vol</Text>
181
+ <Text style={[styles.indicatorValue, { color: textSecondary }]}>
182
+ {decision.indicators.volume.toFixed(1)}x
183
+ </Text>
184
+ </View>
185
+ )}
186
+ </View>
187
+ )}
188
+
189
+ {/* Signals */}
190
+ {decision.signals && decision.signals.length > 0 && (
191
+ <View style={styles.signalsRow}>
192
+ {decision.signals.slice(0, 3).map((signal, index) => (
193
+ <View key={index} style={[styles.signalBadge, { backgroundColor: dark ? '#1A1A1F' : '#E5E7EB' }]}>
194
+ <Text style={[styles.signalText, { color: textSecondary }]}>{signal}</Text>
195
+ </View>
196
+ ))}
197
+ </View>
198
+ )}
199
+
200
+ {/* Execution Info */}
201
+ {decision.executed && (
202
+ <View style={[styles.executionRow, { borderTopColor: border }]}>
203
+ <View style={[styles.executedBadge, { backgroundColor: '#D1FAE5' }]}>
204
+ <Text style={styles.executedText}>EXECUTED</Text>
205
+ </View>
206
+ {decision.price && (
207
+ <Text style={[styles.executionDetail, { color: textSecondary }]}>
208
+ @ ${decision.price.toFixed(2)}
209
+ </Text>
210
+ )}
211
+ {decision.size && (
212
+ <Text style={[styles.executionDetail, { color: textSecondary }]}>
213
+ Size: ${decision.size}
214
+ </Text>
215
+ )}
216
+ {decision.leverage && (
217
+ <Text style={[styles.executionDetail, { color: textSecondary }]}>
218
+ {decision.leverage}x
219
+ </Text>
220
+ )}
221
+ </View>
222
+ )}
223
+ </View>
224
+ </>
225
+ );
226
+
227
+ if (onDecisionPress) {
228
+ return (
229
+ <TouchableOpacity
230
+ style={[styles.decisionItem, { backgroundColor: cardBg }]}
231
+ onPress={() => handlePress(decision)}
232
+ activeOpacity={0.7}
233
+ >
234
+ {itemContent}
235
+ </TouchableOpacity>
236
+ );
237
+ }
238
+
239
+ return (
240
+ <View style={[styles.decisionItem, { backgroundColor: cardBg }]}>
241
+ {itemContent}
242
+ </View>
243
+ );
244
+ };
245
+
246
+ return (
247
+ <View style={[styles.container, { backgroundColor: bg, borderColor: border, height }, style]}>
248
+ <ScrollView style={styles.scroll} contentContainerStyle={styles.scrollContent}>
249
+ {visibleDecisions.map((decision) => (
250
+ <DecisionItem key={decision.id} decision={decision} />
251
+ ))}
252
+ {visibleDecisions.length === 0 && (
253
+ <Text style={[styles.emptyText, { color: textMuted }]}>
254
+ No decisions recorded yet...
255
+ </Text>
256
+ )}
257
+ </ScrollView>
258
+ </View>
259
+ );
260
+ };
261
+
262
+ const styles = StyleSheet.create({
263
+ container: {
264
+ borderRadius: 8,
265
+ borderWidth: 1,
266
+ overflow: 'hidden',
267
+ },
268
+ scroll: {
269
+ flex: 1,
270
+ },
271
+ scrollContent: {
272
+ padding: 12,
273
+ gap: 8,
274
+ },
275
+ decisionItem: {
276
+ flexDirection: 'row',
277
+ borderRadius: 8,
278
+ overflow: 'hidden',
279
+ },
280
+ timelineColumn: {
281
+ width: 24,
282
+ alignItems: 'center',
283
+ paddingTop: 14,
284
+ },
285
+ timelineDot: {
286
+ width: 10,
287
+ height: 10,
288
+ borderRadius: 5,
289
+ },
290
+ timelineLine: {
291
+ width: 2,
292
+ flex: 1,
293
+ marginTop: 4,
294
+ },
295
+ decisionContent: {
296
+ flex: 1,
297
+ padding: 12,
298
+ gap: 8,
299
+ },
300
+ decisionHeader: {
301
+ flexDirection: 'row',
302
+ justifyContent: 'space-between',
303
+ alignItems: 'center',
304
+ },
305
+ decisionHeaderLeft: {
306
+ flexDirection: 'row',
307
+ alignItems: 'center',
308
+ gap: 8,
309
+ },
310
+ decisionHeaderRight: {
311
+ alignItems: 'flex-end',
312
+ },
313
+ actionBadge: {
314
+ paddingHorizontal: 8,
315
+ paddingVertical: 3,
316
+ borderRadius: 4,
317
+ },
318
+ actionText: {
319
+ fontFamily: MONO,
320
+ fontSize: 10,
321
+ fontWeight: '700',
322
+ },
323
+ pairText: {
324
+ fontSize: 14,
325
+ fontWeight: '600',
326
+ },
327
+ timeText: {
328
+ fontFamily: MONO,
329
+ fontSize: 10,
330
+ },
331
+ metaRow: {
332
+ flexDirection: 'row',
333
+ justifyContent: 'space-between',
334
+ alignItems: 'center',
335
+ },
336
+ strategyText: {
337
+ fontSize: 11,
338
+ },
339
+ confidenceRow: {
340
+ flexDirection: 'row',
341
+ alignItems: 'center',
342
+ gap: 6,
343
+ },
344
+ confidenceLabel: {
345
+ fontFamily: MONO,
346
+ fontSize: 9,
347
+ },
348
+ confidenceBar: {
349
+ width: 50,
350
+ height: 6,
351
+ borderRadius: 3,
352
+ overflow: 'hidden',
353
+ },
354
+ confidenceFill: {
355
+ height: '100%',
356
+ borderRadius: 3,
357
+ },
358
+ confidenceValue: {
359
+ fontFamily: MONO,
360
+ fontSize: 10,
361
+ fontWeight: '600',
362
+ },
363
+ reasoningBox: {
364
+ padding: 8,
365
+ borderRadius: 6,
366
+ },
367
+ reasoningText: {
368
+ fontSize: 11,
369
+ lineHeight: 16,
370
+ },
371
+ indicatorsRow: {
372
+ flexDirection: 'row',
373
+ flexWrap: 'wrap',
374
+ gap: 12,
375
+ },
376
+ indicatorItem: {
377
+ flexDirection: 'row',
378
+ alignItems: 'center',
379
+ gap: 4,
380
+ },
381
+ indicatorLabel: {
382
+ fontFamily: MONO,
383
+ fontSize: 9,
384
+ textTransform: 'uppercase',
385
+ },
386
+ indicatorValue: {
387
+ fontFamily: MONO,
388
+ fontSize: 11,
389
+ fontWeight: '600',
390
+ },
391
+ signalsRow: {
392
+ flexDirection: 'row',
393
+ flexWrap: 'wrap',
394
+ gap: 6,
395
+ },
396
+ signalBadge: {
397
+ paddingHorizontal: 6,
398
+ paddingVertical: 2,
399
+ borderRadius: 4,
400
+ },
401
+ signalText: {
402
+ fontFamily: MONO,
403
+ fontSize: 9,
404
+ },
405
+ executionRow: {
406
+ flexDirection: 'row',
407
+ alignItems: 'center',
408
+ gap: 10,
409
+ paddingTop: 8,
410
+ borderTopWidth: 1,
411
+ },
412
+ executedBadge: {
413
+ paddingHorizontal: 6,
414
+ paddingVertical: 2,
415
+ borderRadius: 4,
416
+ },
417
+ executedText: {
418
+ fontFamily: MONO,
419
+ fontSize: 9,
420
+ fontWeight: '700',
421
+ color: '#10B981',
422
+ },
423
+ executionDetail: {
424
+ fontFamily: MONO,
425
+ fontSize: 10,
426
+ },
427
+ emptyText: {
428
+ fontFamily: MONO,
429
+ fontSize: 11,
430
+ textAlign: 'center',
431
+ paddingVertical: 40,
432
+ },
433
+ });