@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,464 @@
1
+ /**
2
+ * OneRiskIndicator - Displays risk status with visual indicators
3
+ * Part of ONE Ecosystem SDK
4
+ */
5
+
6
+ import React from 'react';
7
+ import { View, Text, StyleSheet, ViewStyle, Platform } from 'react-native';
8
+ import type { RiskStatus, RiskLevel, TradingStatus } from '../../../types/console';
9
+ import { RISK_LEVEL_COLORS, TRADING_STATUS_COLORS } from '../../../types/console';
10
+
11
+ const MONO = Platform.OS === 'ios' ? 'Courier New' : 'monospace';
12
+
13
+ export interface OneRiskIndicatorProps {
14
+ riskStatus: RiskStatus;
15
+ showDetails?: boolean;
16
+ showWarnings?: boolean;
17
+ showLimits?: boolean;
18
+ compact?: boolean;
19
+ style?: ViewStyle;
20
+ dark?: boolean;
21
+ }
22
+
23
+ export const OneRiskIndicator: React.FC<OneRiskIndicatorProps> = ({
24
+ riskStatus,
25
+ showDetails = true,
26
+ showWarnings = true,
27
+ showLimits = true,
28
+ compact = false,
29
+ style,
30
+ dark = true,
31
+ }) => {
32
+ const bg = dark ? '#111111' : '#ffffff';
33
+ const border = dark ? '#2A2A35' : '#E5E7EB';
34
+ const textPrimary = dark ? '#ffffff' : '#111827';
35
+ const textSecondary = dark ? '#9CA3AF' : '#6B7280';
36
+ const textMuted = dark ? '#555560' : '#9CA3AF';
37
+
38
+ const riskConfig = RISK_LEVEL_COLORS[riskStatus.riskLevel];
39
+ const statusConfig = TRADING_STATUS_COLORS[riskStatus.tradingStatus];
40
+
41
+ // Progress bar component
42
+ const ProgressBar = ({
43
+ value,
44
+ max,
45
+ color,
46
+ label,
47
+ showValue = true,
48
+ }: {
49
+ value: number;
50
+ max: number;
51
+ color: string;
52
+ label: string;
53
+ showValue?: boolean;
54
+ }) => {
55
+ const percent = Math.min((value / max) * 100, 100);
56
+ const barColor = percent > 80 ? '#EF4444' : percent > 60 ? '#F59E0B' : color;
57
+
58
+ return (
59
+ <View style={styles.progressItem}>
60
+ <View style={styles.progressHeader}>
61
+ <Text style={[styles.progressLabel, { color: textMuted }]}>{label}</Text>
62
+ {showValue && (
63
+ <Text style={[styles.progressValue, { color: textSecondary }]}>
64
+ {value.toFixed(0)} / {max.toFixed(0)}
65
+ </Text>
66
+ )}
67
+ </View>
68
+ <View style={[styles.progressTrack, { backgroundColor: dark ? '#1A1A1F' : '#E5E7EB' }]}>
69
+ <View
70
+ style={[
71
+ styles.progressFill,
72
+ { width: `${percent}%`, backgroundColor: barColor }
73
+ ]}
74
+ />
75
+ </View>
76
+ <Text style={[styles.progressPercent, { color: barColor }]}>
77
+ {percent.toFixed(1)}%
78
+ </Text>
79
+ </View>
80
+ );
81
+ };
82
+
83
+ if (compact) {
84
+ return (
85
+ <View style={[styles.compactContainer, { backgroundColor: bg, borderColor: border }, style]}>
86
+ <View style={[styles.riskBadge, { backgroundColor: riskConfig.bgColor }]}>
87
+ <View style={[styles.riskDot, { backgroundColor: riskConfig.color }]} />
88
+ <Text style={[styles.riskText, { color: riskConfig.color }]}>
89
+ {riskStatus.riskLevel.toUpperCase()}
90
+ </Text>
91
+ </View>
92
+ <View style={[styles.statusBadge, { backgroundColor: statusConfig.bgColor }]}>
93
+ <Text style={[styles.statusText, { color: statusConfig.color }]}>
94
+ {riskStatus.tradingStatus.toUpperCase()}
95
+ </Text>
96
+ </View>
97
+ <Text style={[styles.compactExposure, { color: textSecondary }]}>
98
+ Exp: {riskStatus.exposurePercent.toFixed(0)}%
99
+ </Text>
100
+ <Text style={[
101
+ styles.compactPnl,
102
+ { color: riskStatus.dailyPnl >= 0 ? '#10B981' : '#EF4444' }
103
+ ]}>
104
+ {riskStatus.dailyPnl >= 0 ? '+' : ''}{riskStatus.dailyPnl.toFixed(0)}
105
+ </Text>
106
+ </View>
107
+ );
108
+ }
109
+
110
+ return (
111
+ <View style={[styles.container, { backgroundColor: bg, borderColor: border }, style]}>
112
+ {/* Header */}
113
+ <View style={styles.header}>
114
+ <View style={styles.headerLeft}>
115
+ <Text style={[styles.title, { color: textPrimary }]}>Risk Status</Text>
116
+ <View style={[styles.riskBadgeLarge, { backgroundColor: riskConfig.bgColor }]}>
117
+ <View style={[styles.riskDotLarge, { backgroundColor: riskConfig.color }]} />
118
+ <Text style={[styles.riskTextLarge, { color: riskConfig.color }]}>
119
+ {riskStatus.riskLevel.toUpperCase()}
120
+ </Text>
121
+ </View>
122
+ </View>
123
+ <View style={[styles.tradingStatusBadge, { backgroundColor: statusConfig.bgColor }]}>
124
+ <View style={[styles.statusIndicator, { backgroundColor: statusConfig.color }]} />
125
+ <Text style={[styles.tradingStatusText, { color: statusConfig.color }]}>
126
+ {riskStatus.tradingStatus === 'active' ? 'Trading Active' :
127
+ riskStatus.tradingStatus === 'paused' ? 'Trading Paused' :
128
+ riskStatus.tradingStatus === 'stopped' ? 'Trading Stopped' : 'Cooldown'}
129
+ </Text>
130
+ </View>
131
+ </View>
132
+
133
+ {/* Progress Bars */}
134
+ {showLimits && (
135
+ <View style={styles.progressSection}>
136
+ <ProgressBar
137
+ value={riskStatus.totalExposure}
138
+ max={riskStatus.maxExposure}
139
+ color="#3B82F6"
140
+ label="Portfolio Exposure"
141
+ />
142
+ <ProgressBar
143
+ value={riskStatus.currentDrawdown}
144
+ max={riskStatus.maxDrawdown}
145
+ color="#8B5CF6"
146
+ label="Drawdown"
147
+ showValue={false}
148
+ />
149
+ <ProgressBar
150
+ value={Math.abs(riskStatus.dailyPnl)}
151
+ max={riskStatus.dailyPnlLimit}
152
+ color={riskStatus.dailyPnl >= 0 ? '#10B981' : '#EF4444'}
153
+ label="Daily P&L Limit"
154
+ />
155
+ <ProgressBar
156
+ value={riskStatus.openPositions}
157
+ max={riskStatus.maxPositions}
158
+ color="#F59E0B"
159
+ label="Open Positions"
160
+ />
161
+ </View>
162
+ )}
163
+
164
+ {/* Details Grid */}
165
+ {showDetails && (
166
+ <View style={styles.detailsGrid}>
167
+ <View style={styles.detailItem}>
168
+ <Text style={[styles.detailLabel, { color: textMuted }]}>Exposure</Text>
169
+ <Text style={[styles.detailValue, { color: textPrimary }]}>
170
+ ${riskStatus.totalExposure.toFixed(0)}
171
+ </Text>
172
+ </View>
173
+ <View style={styles.detailItem}>
174
+ <Text style={[styles.detailLabel, { color: textMuted }]}>Daily P&L</Text>
175
+ <Text style={[
176
+ styles.detailValue,
177
+ { color: riskStatus.dailyPnl >= 0 ? '#10B981' : '#EF4444' }
178
+ ]}>
179
+ {riskStatus.dailyPnl >= 0 ? '+' : ''}${riskStatus.dailyPnl.toFixed(0)}
180
+ </Text>
181
+ </View>
182
+ <View style={styles.detailItem}>
183
+ <Text style={[styles.detailLabel, { color: textMuted }]}>Drawdown</Text>
184
+ <Text style={[styles.detailValue, { color: textPrimary }]}>
185
+ {riskStatus.currentDrawdown.toFixed(2)}%
186
+ </Text>
187
+ </View>
188
+ <View style={styles.detailItem}>
189
+ <Text style={[styles.detailLabel, { color: textMuted }]}>Trades Today</Text>
190
+ <Text style={[styles.detailValue, { color: textPrimary }]}>
191
+ {riskStatus.dailyTradeCount} / {riskStatus.dailyTradeLimit}
192
+ </Text>
193
+ </View>
194
+ </View>
195
+ )}
196
+
197
+ {/* Warnings */}
198
+ {showWarnings && riskStatus.warnings.length > 0 && (
199
+ <View style={[styles.warningsSection, { backgroundColor: dark ? '#1A1A1F' : '#FEF3C7' }]}>
200
+ <Text style={[styles.warningsTitle, { color: '#F59E0B' }]}>Warnings</Text>
201
+ {riskStatus.warnings.map((warning, index) => (
202
+ <View key={index} style={styles.warningItem}>
203
+ <Text style={styles.warningIcon}>!</Text>
204
+ <Text style={[styles.warningText, { color: textSecondary }]}>{warning}</Text>
205
+ </View>
206
+ ))}
207
+ </View>
208
+ )}
209
+
210
+ {/* Strategy Risks */}
211
+ {riskStatus.strategyRisks && Object.keys(riskStatus.strategyRisks).length > 0 && (
212
+ <View style={styles.strategyRisksSection}>
213
+ <Text style={[styles.sectionTitle, { color: textMuted }]}>Strategy Risk Breakdown</Text>
214
+ {Object.entries(riskStatus.strategyRisks).map(([strategyId, risk]) => {
215
+ const strategyRiskConfig = RISK_LEVEL_COLORS[risk.riskLevel];
216
+ return (
217
+ <View key={strategyId} style={styles.strategyRiskItem}>
218
+ <Text style={[styles.strategyName, { color: textSecondary }]}>
219
+ {strategyId.replace('-01', '')}
220
+ </Text>
221
+ <View style={[styles.strategyRiskBadge, { backgroundColor: strategyRiskConfig.bgColor }]}>
222
+ <Text style={[styles.strategyRiskText, { color: strategyRiskConfig.color }]}>
223
+ {risk.riskLevel.toUpperCase()}
224
+ </Text>
225
+ </View>
226
+ <Text style={[styles.strategyExposure, { color: textMuted }]}>
227
+ ${risk.exposure.toFixed(0)}
228
+ </Text>
229
+ </View>
230
+ );
231
+ })}
232
+ </View>
233
+ )}
234
+ </View>
235
+ );
236
+ };
237
+
238
+ const styles = StyleSheet.create({
239
+ container: {
240
+ borderRadius: 12,
241
+ borderWidth: 1,
242
+ padding: 14,
243
+ gap: 14,
244
+ },
245
+ compactContainer: {
246
+ flexDirection: 'row',
247
+ alignItems: 'center',
248
+ borderRadius: 8,
249
+ borderWidth: 1,
250
+ paddingHorizontal: 12,
251
+ paddingVertical: 8,
252
+ gap: 10,
253
+ },
254
+ header: {
255
+ flexDirection: 'row',
256
+ justifyContent: 'space-between',
257
+ alignItems: 'flex-start',
258
+ },
259
+ headerLeft: {
260
+ flexDirection: 'row',
261
+ alignItems: 'center',
262
+ gap: 10,
263
+ },
264
+ title: {
265
+ fontSize: 15,
266
+ fontWeight: '600',
267
+ },
268
+ riskBadge: {
269
+ flexDirection: 'row',
270
+ alignItems: 'center',
271
+ paddingHorizontal: 8,
272
+ paddingVertical: 4,
273
+ borderRadius: 12,
274
+ gap: 4,
275
+ },
276
+ riskBadgeLarge: {
277
+ flexDirection: 'row',
278
+ alignItems: 'center',
279
+ paddingHorizontal: 10,
280
+ paddingVertical: 5,
281
+ borderRadius: 12,
282
+ gap: 5,
283
+ },
284
+ riskDot: {
285
+ width: 6,
286
+ height: 6,
287
+ borderRadius: 3,
288
+ },
289
+ riskDotLarge: {
290
+ width: 8,
291
+ height: 8,
292
+ borderRadius: 4,
293
+ },
294
+ riskText: {
295
+ fontFamily: MONO,
296
+ fontSize: 10,
297
+ fontWeight: '700',
298
+ },
299
+ riskTextLarge: {
300
+ fontFamily: MONO,
301
+ fontSize: 11,
302
+ fontWeight: '700',
303
+ },
304
+ statusBadge: {
305
+ paddingHorizontal: 8,
306
+ paddingVertical: 4,
307
+ borderRadius: 12,
308
+ },
309
+ statusText: {
310
+ fontFamily: MONO,
311
+ fontSize: 9,
312
+ fontWeight: '700',
313
+ },
314
+ tradingStatusBadge: {
315
+ flexDirection: 'row',
316
+ alignItems: 'center',
317
+ paddingHorizontal: 10,
318
+ paddingVertical: 5,
319
+ borderRadius: 12,
320
+ gap: 5,
321
+ },
322
+ statusIndicator: {
323
+ width: 6,
324
+ height: 6,
325
+ borderRadius: 3,
326
+ },
327
+ tradingStatusText: {
328
+ fontSize: 11,
329
+ fontWeight: '600',
330
+ },
331
+ compactExposure: {
332
+ fontFamily: MONO,
333
+ fontSize: 11,
334
+ flex: 1,
335
+ },
336
+ compactPnl: {
337
+ fontFamily: MONO,
338
+ fontSize: 12,
339
+ fontWeight: '600',
340
+ },
341
+ progressSection: {
342
+ gap: 10,
343
+ },
344
+ progressItem: {
345
+ gap: 4,
346
+ },
347
+ progressHeader: {
348
+ flexDirection: 'row',
349
+ justifyContent: 'space-between',
350
+ alignItems: 'center',
351
+ },
352
+ progressLabel: {
353
+ fontFamily: MONO,
354
+ fontSize: 10,
355
+ textTransform: 'uppercase',
356
+ },
357
+ progressValue: {
358
+ fontFamily: MONO,
359
+ fontSize: 10,
360
+ },
361
+ progressTrack: {
362
+ height: 6,
363
+ borderRadius: 3,
364
+ overflow: 'hidden',
365
+ },
366
+ progressFill: {
367
+ height: '100%',
368
+ borderRadius: 3,
369
+ },
370
+ progressPercent: {
371
+ fontFamily: MONO,
372
+ fontSize: 10,
373
+ textAlign: 'right',
374
+ },
375
+ detailsGrid: {
376
+ flexDirection: 'row',
377
+ flexWrap: 'wrap',
378
+ gap: 10,
379
+ },
380
+ detailItem: {
381
+ width: '48%',
382
+ gap: 2,
383
+ },
384
+ detailLabel: {
385
+ fontFamily: MONO,
386
+ fontSize: 9,
387
+ textTransform: 'uppercase',
388
+ },
389
+ detailValue: {
390
+ fontFamily: MONO,
391
+ fontSize: 14,
392
+ fontWeight: '600',
393
+ },
394
+ warningsSection: {
395
+ padding: 10,
396
+ borderRadius: 8,
397
+ gap: 6,
398
+ },
399
+ warningsTitle: {
400
+ fontFamily: MONO,
401
+ fontSize: 10,
402
+ fontWeight: '700',
403
+ textTransform: 'uppercase',
404
+ },
405
+ warningItem: {
406
+ flexDirection: 'row',
407
+ alignItems: 'center',
408
+ gap: 8,
409
+ },
410
+ warningIcon: {
411
+ width: 16,
412
+ height: 16,
413
+ backgroundColor: '#F59E0B',
414
+ color: '#ffffff',
415
+ textAlign: 'center',
416
+ lineHeight: 16,
417
+ fontSize: 12,
418
+ fontWeight: '700',
419
+ borderRadius: 8,
420
+ overflow: 'hidden',
421
+ },
422
+ warningText: {
423
+ fontSize: 12,
424
+ flex: 1,
425
+ },
426
+ strategyRisksSection: {
427
+ gap: 8,
428
+ paddingTop: 10,
429
+ borderTopWidth: 1,
430
+ borderTopColor: '#2A2A35',
431
+ },
432
+ sectionTitle: {
433
+ fontFamily: MONO,
434
+ fontSize: 10,
435
+ textTransform: 'uppercase',
436
+ },
437
+ strategyRiskItem: {
438
+ flexDirection: 'row',
439
+ alignItems: 'center',
440
+ gap: 10,
441
+ },
442
+ strategyName: {
443
+ fontFamily: MONO,
444
+ fontSize: 11,
445
+ flex: 1,
446
+ textTransform: 'capitalize',
447
+ },
448
+ strategyRiskBadge: {
449
+ paddingHorizontal: 6,
450
+ paddingVertical: 2,
451
+ borderRadius: 4,
452
+ },
453
+ strategyRiskText: {
454
+ fontFamily: MONO,
455
+ fontSize: 9,
456
+ fontWeight: '700',
457
+ },
458
+ strategyExposure: {
459
+ fontFamily: MONO,
460
+ fontSize: 10,
461
+ width: 60,
462
+ textAlign: 'right',
463
+ },
464
+ });