@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,469 @@
1
+ /**
2
+ * OneAgentConsole - Individual agent detail view
3
+ * Part of ONE Ecosystem SDK
4
+ */
5
+
6
+ import React, { useRef, useEffect } from 'react';
7
+ import { View, Text, StyleSheet, ScrollView, ViewStyle, Platform, TouchableOpacity } from 'react-native';
8
+ import type { BotLogEntry, BotState } from '../../../services/forex/BotSimulationEngine';
9
+ import type { AIPosition, AIDecision, AIAgent } from '../../../types/console';
10
+ import { AI_LOG_COLORS } from '../../../types/console';
11
+ import { OnePositionCard } from './OnePositionCard';
12
+ import { OneDecisionTimeline } from './OneDecisionTimeline';
13
+
14
+ const MONO = Platform.OS === 'ios' ? 'Courier New' : 'monospace';
15
+
16
+ export interface OneAgentConsoleProps {
17
+ agent?: AIAgent;
18
+ strategyId?: string;
19
+ strategyName?: string;
20
+ logs: BotLogEntry[];
21
+ botState?: BotState;
22
+ positions?: AIPosition[];
23
+ decisions?: AIDecision[];
24
+ showConsole?: boolean;
25
+ showPositions?: boolean;
26
+ showDecisions?: boolean;
27
+ showMetrics?: boolean;
28
+ maxLogs?: number;
29
+ autoScroll?: boolean;
30
+ consoleHeight?: number;
31
+ onPositionPress?: (position: AIPosition) => void;
32
+ onDecisionPress?: (decision: AIDecision) => void;
33
+ onClosePosition?: (positionId: string) => void;
34
+ style?: ViewStyle;
35
+ dark?: boolean;
36
+ }
37
+
38
+ export const OneAgentConsole: React.FC<OneAgentConsoleProps> = ({
39
+ agent,
40
+ strategyId,
41
+ strategyName,
42
+ logs,
43
+ botState,
44
+ positions = [],
45
+ decisions = [],
46
+ showConsole = true,
47
+ showPositions = true,
48
+ showDecisions = true,
49
+ showMetrics = true,
50
+ maxLogs = 100,
51
+ autoScroll = true,
52
+ consoleHeight = 300,
53
+ onPositionPress,
54
+ onDecisionPress,
55
+ onClosePosition,
56
+ style,
57
+ dark = true,
58
+ }) => {
59
+ const bg = dark ? '#111111' : '#ffffff';
60
+ const border = dark ? '#2A2A35' : '#E5E7EB';
61
+ const textPrimary = dark ? '#ffffff' : '#111827';
62
+ const textSecondary = dark ? '#9CA3AF' : '#6B7280';
63
+ const textMuted = dark ? '#555560' : '#9CA3AF';
64
+ const consoleBg = dark ? '#0A0A0C' : '#F9FAFB';
65
+
66
+ const scrollRef = useRef<ScrollView>(null);
67
+ const visibleLogs = logs.slice(-maxLogs);
68
+ const openPositions = positions.filter(p => p.status === 'open');
69
+
70
+ // Auto-scroll console
71
+ useEffect(() => {
72
+ if (autoScroll && scrollRef.current) {
73
+ setTimeout(() => scrollRef.current?.scrollToEnd({ animated: true }), 50);
74
+ }
75
+ }, [logs.length, autoScroll]);
76
+
77
+ const formatTime = (ts: number) => {
78
+ const d = new Date(ts);
79
+ return `${d.getHours().toString().padStart(2, '0')}:${d.getMinutes().toString().padStart(2, '0')}:${d.getSeconds().toString().padStart(2, '0')}`;
80
+ };
81
+
82
+ const displayName = agent?.name || strategyName || strategyId || 'Agent';
83
+ const displayColor = agent?.color || botState?.strategyName ? '#3B82F6' : '#9CA3AF';
84
+ const isActive = agent?.status === 'active' || botState?.isRunning;
85
+
86
+ return (
87
+ <View style={[styles.container, { backgroundColor: bg, borderColor: border }, style]}>
88
+ {/* Header */}
89
+ <View style={styles.header}>
90
+ <View style={styles.headerLeft}>
91
+ <View style={[styles.colorDot, { backgroundColor: displayColor }]} />
92
+ <Text style={[styles.agentName, { color: textPrimary }]}>{displayName}</Text>
93
+ <View style={[
94
+ styles.statusBadge,
95
+ { backgroundColor: isActive ? '#D1FAE5' : '#F3F4F6' }
96
+ ]}>
97
+ <View style={[
98
+ styles.statusDot,
99
+ { backgroundColor: isActive ? '#10B981' : '#9CA3AF' }
100
+ ]} />
101
+ <Text style={[
102
+ styles.statusText,
103
+ { color: isActive ? '#10B981' : '#9CA3AF' }
104
+ ]}>
105
+ {isActive ? 'Active' : 'Idle'}
106
+ </Text>
107
+ </View>
108
+ </View>
109
+ {botState && (
110
+ <View style={styles.headerRight}>
111
+ <Text style={[styles.currentPair, { color: textSecondary }]}>
112
+ {botState.currentPair}
113
+ </Text>
114
+ </View>
115
+ )}
116
+ </View>
117
+
118
+ {/* Quick Metrics */}
119
+ {showMetrics && (agent || botState) && (
120
+ <View style={[styles.metricsRow, { borderBottomColor: border }]}>
121
+ <View style={styles.metricItem}>
122
+ <Text style={[styles.metricLabel, { color: textMuted }]}>P&L</Text>
123
+ <Text style={[
124
+ styles.metricValue,
125
+ { color: (agent?.totalPnl ?? botState?.totalPnl ?? 0) >= 0 ? '#10B981' : '#EF4444' }
126
+ ]}>
127
+ {(agent?.totalPnl ?? botState?.totalPnl ?? 0) >= 0 ? '+' : ''}
128
+ ${(agent?.totalPnl ?? botState?.totalPnl ?? 0).toFixed(2)}
129
+ </Text>
130
+ </View>
131
+ <View style={styles.metricItem}>
132
+ <Text style={[styles.metricLabel, { color: textMuted }]}>Win Rate</Text>
133
+ <Text style={[styles.metricValue, { color: textPrimary }]}>
134
+ {((agent?.winRate ?? botState?.winRate ?? 0) * 100).toFixed(1)}%
135
+ </Text>
136
+ </View>
137
+ <View style={styles.metricItem}>
138
+ <Text style={[styles.metricLabel, { color: textMuted }]}>Trades</Text>
139
+ <Text style={[styles.metricValue, { color: textPrimary }]}>
140
+ {agent?.totalTrades ?? botState?.totalTrades ?? 0}
141
+ </Text>
142
+ </View>
143
+ <View style={styles.metricItem}>
144
+ <Text style={[styles.metricLabel, { color: textMuted }]}>Positions</Text>
145
+ <Text style={[styles.metricValue, { color: textPrimary }]}>
146
+ {openPositions.length}
147
+ </Text>
148
+ </View>
149
+ {botState?.lastSignal && botState.lastSignal !== 'HOLD' && (
150
+ <View style={styles.metricItem}>
151
+ <Text style={[styles.metricLabel, { color: textMuted }]}>Signal</Text>
152
+ <View style={[
153
+ styles.signalBadge,
154
+ { backgroundColor: botState.lastSignal === 'LONG' ? '#D1FAE5' : '#FEE2E2' }
155
+ ]}>
156
+ <Text style={[
157
+ styles.signalText,
158
+ { color: botState.lastSignal === 'LONG' ? '#10B981' : '#EF4444' }
159
+ ]}>
160
+ {botState.lastSignal}
161
+ </Text>
162
+ </View>
163
+ </View>
164
+ )}
165
+ </View>
166
+ )}
167
+
168
+ {/* Console Output */}
169
+ {showConsole && (
170
+ <View style={styles.section}>
171
+ <Text style={[styles.sectionTitle, { color: textMuted }]}>Console Output</Text>
172
+ <View style={[styles.consoleContainer, { backgroundColor: consoleBg, height: consoleHeight }]}>
173
+ <ScrollView
174
+ ref={scrollRef}
175
+ style={styles.consoleScroll}
176
+ contentContainerStyle={styles.consoleContent}
177
+ >
178
+ {visibleLogs.map((log) => (
179
+ <View key={log.id} style={styles.logRow}>
180
+ <Text style={[styles.logTime, { color: textMuted }]}>
181
+ {formatTime(log.timestamp)}
182
+ </Text>
183
+ <Text style={[
184
+ styles.logType,
185
+ { color: AI_LOG_COLORS[log.type as keyof typeof AI_LOG_COLORS] || textMuted }
186
+ ]}>
187
+ {log.type.padEnd(10)}
188
+ </Text>
189
+ <Text
190
+ style={[
191
+ styles.logMessage,
192
+ { color: log.importance === 'high' ? textPrimary : textSecondary },
193
+ log.importance === 'high' && styles.logMessageHigh,
194
+ ]}
195
+ numberOfLines={2}
196
+ >
197
+ {log.message}
198
+ </Text>
199
+ </View>
200
+ ))}
201
+ {visibleLogs.length === 0 && (
202
+ <Text style={[styles.emptyText, { color: textMuted }]}>
203
+ Waiting for activity...
204
+ </Text>
205
+ )}
206
+ </ScrollView>
207
+ </View>
208
+ </View>
209
+ )}
210
+
211
+ {/* Open Positions */}
212
+ {showPositions && openPositions.length > 0 && (
213
+ <View style={styles.section}>
214
+ <Text style={[styles.sectionTitle, { color: textMuted }]}>
215
+ Open Positions ({openPositions.length})
216
+ </Text>
217
+ <View style={styles.positionsList}>
218
+ {openPositions.map((position) => (
219
+ <OnePositionCard
220
+ key={position.id}
221
+ position={position}
222
+ onPress={onPositionPress}
223
+ onClose={onClosePosition}
224
+ compact={true}
225
+ dark={dark}
226
+ />
227
+ ))}
228
+ </View>
229
+ </View>
230
+ )}
231
+
232
+ {/* Recent Decisions */}
233
+ {showDecisions && decisions.length > 0 && (
234
+ <View style={styles.section}>
235
+ <Text style={[styles.sectionTitle, { color: textMuted }]}>
236
+ Recent Decisions ({decisions.length})
237
+ </Text>
238
+ <OneDecisionTimeline
239
+ decisions={decisions.slice(0, 5)}
240
+ showReasoning={true}
241
+ showIndicators={false}
242
+ showConfidence={true}
243
+ onDecisionPress={onDecisionPress}
244
+ height={250}
245
+ dark={dark}
246
+ />
247
+ </View>
248
+ )}
249
+
250
+ {/* Indicators (if bot state available) */}
251
+ {botState?.indicators && (
252
+ <View style={[styles.indicatorsSection, { borderTopColor: border }]}>
253
+ <Text style={[styles.sectionTitle, { color: textMuted }]}>Current Indicators</Text>
254
+ <View style={styles.indicatorsGrid}>
255
+ <View style={styles.indicatorItem}>
256
+ <Text style={[styles.indicatorLabel, { color: textMuted }]}>RSI</Text>
257
+ <Text style={[
258
+ styles.indicatorValue,
259
+ {
260
+ color: botState.indicators.rsi < 30 ? '#10B981' :
261
+ botState.indicators.rsi > 70 ? '#EF4444' : textPrimary
262
+ }
263
+ ]}>
264
+ {botState.indicators.rsi.toFixed(1)}
265
+ </Text>
266
+ </View>
267
+ <View style={styles.indicatorItem}>
268
+ <Text style={[styles.indicatorLabel, { color: textMuted }]}>MACD</Text>
269
+ <Text style={[
270
+ styles.indicatorValue,
271
+ { color: botState.indicators.macd.histogram >= 0 ? '#10B981' : '#EF4444' }
272
+ ]}>
273
+ {botState.indicators.macd.histogram >= 0 ? '+' : ''}
274
+ {botState.indicators.macd.histogram.toFixed(3)}
275
+ </Text>
276
+ </View>
277
+ <View style={styles.indicatorItem}>
278
+ <Text style={[styles.indicatorLabel, { color: textMuted }]}>EMA</Text>
279
+ <Text style={[
280
+ styles.indicatorValue,
281
+ { color: botState.indicators.ema.crossover === 'golden' ? '#10B981' :
282
+ botState.indicators.ema.crossover === 'death' ? '#EF4444' : textSecondary }
283
+ ]}>
284
+ {botState.indicators.ema.crossover !== 'none' ?
285
+ botState.indicators.ema.crossover.toUpperCase() : 'NEUTRAL'}
286
+ </Text>
287
+ </View>
288
+ <View style={styles.indicatorItem}>
289
+ <Text style={[styles.indicatorLabel, { color: textMuted }]}>Volume</Text>
290
+ <Text style={[styles.indicatorValue, { color: textPrimary }]}>
291
+ {botState.indicators.volume.ratio.toFixed(1)}x
292
+ </Text>
293
+ </View>
294
+ <View style={styles.indicatorItem}>
295
+ <Text style={[styles.indicatorLabel, { color: textMuted }]}>BB Pos</Text>
296
+ <Text style={[styles.indicatorValue, { color: textPrimary }]}>
297
+ {botState.indicators.bollinger.position.toFixed(0)}%
298
+ </Text>
299
+ </View>
300
+ </View>
301
+ </View>
302
+ )}
303
+ </View>
304
+ );
305
+ };
306
+
307
+ const styles = StyleSheet.create({
308
+ container: {
309
+ borderRadius: 12,
310
+ borderWidth: 1,
311
+ overflow: 'hidden',
312
+ },
313
+ header: {
314
+ flexDirection: 'row',
315
+ justifyContent: 'space-between',
316
+ alignItems: 'center',
317
+ padding: 14,
318
+ borderBottomWidth: 1,
319
+ borderBottomColor: '#2A2A35',
320
+ },
321
+ headerLeft: {
322
+ flexDirection: 'row',
323
+ alignItems: 'center',
324
+ gap: 10,
325
+ },
326
+ headerRight: {
327
+ alignItems: 'flex-end',
328
+ },
329
+ colorDot: {
330
+ width: 12,
331
+ height: 12,
332
+ borderRadius: 6,
333
+ },
334
+ agentName: {
335
+ fontSize: 16,
336
+ fontWeight: '600',
337
+ },
338
+ statusBadge: {
339
+ flexDirection: 'row',
340
+ alignItems: 'center',
341
+ paddingHorizontal: 8,
342
+ paddingVertical: 4,
343
+ borderRadius: 12,
344
+ gap: 4,
345
+ },
346
+ statusDot: {
347
+ width: 6,
348
+ height: 6,
349
+ borderRadius: 3,
350
+ },
351
+ statusText: {
352
+ fontSize: 11,
353
+ fontWeight: '600',
354
+ },
355
+ currentPair: {
356
+ fontFamily: MONO,
357
+ fontSize: 12,
358
+ },
359
+ metricsRow: {
360
+ flexDirection: 'row',
361
+ justifyContent: 'space-around',
362
+ paddingVertical: 12,
363
+ paddingHorizontal: 8,
364
+ borderBottomWidth: 1,
365
+ },
366
+ metricItem: {
367
+ alignItems: 'center',
368
+ gap: 2,
369
+ },
370
+ metricLabel: {
371
+ fontFamily: MONO,
372
+ fontSize: 9,
373
+ textTransform: 'uppercase',
374
+ },
375
+ metricValue: {
376
+ fontFamily: MONO,
377
+ fontSize: 14,
378
+ fontWeight: '600',
379
+ },
380
+ signalBadge: {
381
+ paddingHorizontal: 8,
382
+ paddingVertical: 2,
383
+ borderRadius: 4,
384
+ },
385
+ signalText: {
386
+ fontFamily: MONO,
387
+ fontSize: 10,
388
+ fontWeight: '700',
389
+ },
390
+ section: {
391
+ padding: 14,
392
+ gap: 10,
393
+ },
394
+ sectionTitle: {
395
+ fontFamily: MONO,
396
+ fontSize: 10,
397
+ textTransform: 'uppercase',
398
+ letterSpacing: 1,
399
+ },
400
+ consoleContainer: {
401
+ borderRadius: 8,
402
+ overflow: 'hidden',
403
+ },
404
+ consoleScroll: {
405
+ flex: 1,
406
+ },
407
+ consoleContent: {
408
+ padding: 8,
409
+ },
410
+ logRow: {
411
+ flexDirection: 'row',
412
+ paddingVertical: 2,
413
+ },
414
+ logTime: {
415
+ fontFamily: MONO,
416
+ fontSize: 10,
417
+ width: 60,
418
+ marginRight: 6,
419
+ },
420
+ logType: {
421
+ fontFamily: MONO,
422
+ fontSize: 10,
423
+ fontWeight: '700',
424
+ width: 75,
425
+ marginRight: 6,
426
+ },
427
+ logMessage: {
428
+ fontFamily: MONO,
429
+ fontSize: 10,
430
+ flex: 1,
431
+ },
432
+ logMessageHigh: {
433
+ fontWeight: '600',
434
+ },
435
+ emptyText: {
436
+ fontFamily: MONO,
437
+ fontSize: 11,
438
+ textAlign: 'center',
439
+ paddingVertical: 30,
440
+ },
441
+ positionsList: {
442
+ gap: 8,
443
+ },
444
+ indicatorsSection: {
445
+ padding: 14,
446
+ borderTopWidth: 1,
447
+ gap: 10,
448
+ },
449
+ indicatorsGrid: {
450
+ flexDirection: 'row',
451
+ flexWrap: 'wrap',
452
+ gap: 16,
453
+ },
454
+ indicatorItem: {
455
+ alignItems: 'center',
456
+ gap: 2,
457
+ minWidth: 60,
458
+ },
459
+ indicatorLabel: {
460
+ fontFamily: MONO,
461
+ fontSize: 9,
462
+ textTransform: 'uppercase',
463
+ },
464
+ indicatorValue: {
465
+ fontFamily: MONO,
466
+ fontSize: 13,
467
+ fontWeight: '600',
468
+ },
469
+ });