@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.
- package/README.md +339 -0
- package/dist/ForexPoolDataGenerator--__twRwl.d.mts +76 -0
- package/dist/ForexPoolDataGenerator-eUgwsU_B.d.ts +76 -0
- package/dist/OneForexTradeHistory-TlKxjbFF.d.ts +250 -0
- package/dist/OneForexTradeHistory-iDySMcw0.d.mts +250 -0
- package/dist/components/index.d.mts +539 -0
- package/dist/components/index.d.ts +539 -0
- package/dist/components/index.js +7295 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +7243 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/config/index.d.mts +1 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/console-BfTMA7ah.d.mts +504 -0
- package/dist/console-BfTMA7ah.d.ts +504 -0
- package/dist/hooks/index.d.mts +323 -1
- package/dist/hooks/index.d.ts +323 -1
- package/dist/hooks/index.js +3223 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +3204 -1
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +18 -352
- package/dist/index.d.ts +18 -352
- package/dist/index.js +8646 -574
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8449 -432
- package/dist/index.mjs.map +1 -1
- package/dist/providers/index.d.mts +31 -31
- package/dist/providers/index.d.ts +31 -31
- package/dist/providers/index.js +140 -153
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/index.mjs +100 -109
- package/dist/providers/index.mjs.map +1 -1
- package/dist/react-native.d.mts +8 -144
- package/dist/react-native.d.ts +8 -144
- package/dist/react-native.js +2640 -689
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +2610 -691
- package/dist/react-native.mjs.map +1 -1
- package/dist/services/index.d.mts +85 -4
- package/dist/services/index.d.ts +85 -4
- package/dist/services/index.js +1621 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +1619 -1
- package/dist/services/index.mjs.map +1 -1
- package/dist/types/index.d.mts +203 -1
- package/dist/types/index.d.ts +203 -1
- package/dist/types/index.js +275 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +251 -0
- package/dist/types/index.mjs.map +1 -1
- package/dist/useForexTrading-BleeSor8.d.mts +80 -0
- package/dist/useForexTrading-ZgW_G40Q.d.ts +80 -0
- package/package.json +9 -2
- package/src/components/OneConnectButton.tsx +24 -1
- package/src/components/OneNFTGallery.tsx +13 -7
- package/src/components/OneOfframpWidget.tsx +4 -3
- package/src/components/OnePayWidget.tsx +10 -1
- package/src/components/OneSendWidget.tsx +3 -3
- package/src/components/OneSwapWidget.tsx +4 -4
- package/src/components/OneTransactionButton.tsx +28 -3
- package/src/components/OneWalletBalance.tsx +1 -1
- package/src/components/ai/OneChainSelector.tsx +63 -336
- package/src/components/ai/OneForexCapitalSplit.tsx +112 -0
- package/src/components/ai/OneForexConsoleView.tsx +90 -0
- package/src/components/ai/OneForexPairSelector.tsx +101 -0
- package/src/components/ai/OneForexPoolCard.tsx +105 -0
- package/src/components/ai/OneForexTradeHistory.tsx +107 -0
- package/src/components/ai/OnePairSelector.tsx +77 -434
- package/src/components/ai/console/OneAIQuantConsole.tsx +423 -0
- package/src/components/ai/console/OneAgentCard.tsx +383 -0
- package/src/components/ai/console/OneAgentConsole.tsx +469 -0
- package/src/components/ai/console/OneDecisionTimeline.tsx +433 -0
- package/src/components/ai/console/OneMetricsDashboard.tsx +493 -0
- package/src/components/ai/console/OnePositionCard.tsx +406 -0
- package/src/components/ai/console/OnePositionDetail.tsx +600 -0
- package/src/components/ai/console/OneRiskIndicator.tsx +464 -0
- package/src/components/ai/console/OneTradingConsole.tsx +660 -0
- package/src/components/ai/console/index.ts +17 -0
- package/src/components/ai/index.ts +10 -0
- package/src/hooks/index.ts +46 -0
- package/src/hooks/useAIDecisions.ts +280 -0
- package/src/hooks/useAIPositions.ts +349 -0
- package/src/hooks/useAIQuantConsole.ts +283 -0
- package/src/hooks/useAIRiskStatus.ts +276 -0
- package/src/hooks/useAITrading.ts +190 -0
- package/src/hooks/useBotSimulation.ts +201 -0
- package/src/hooks/useForexTrading.ts +430 -0
- package/src/hooks/useTradingConsole.ts +243 -0
- package/src/index.ts +123 -5
- package/src/providers/OneProvider.tsx +181 -5
- package/src/providers/index.ts +22 -8
- package/src/react-native.ts +41 -0
- package/src/services/forex/BotSimulationEngine.ts +968 -0
- package/src/services/forex/ForexPoolDataGenerator.ts +542 -0
- package/src/services/forex/ForexSimulationEngine.ts +482 -0
- package/src/services/forex/index.ts +21 -0
- package/src/services/index.ts +16 -0
- package/src/types/aiTrading.ts +151 -0
- package/src/types/console.ts +380 -0
- package/src/types/forex.ts +282 -0
- package/src/types/index.ts +106 -0
- package/dist/price-CgqXPnT3.d.ts +0 -13
- package/dist/price-ClbLHHjv.d.mts +0 -13
- package/dist/supabase-BT0c7q9e.d.mts +0 -82
- package/dist/supabase-BT0c7q9e.d.ts +0 -82
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OnePositionDetail - Detailed position tracking view
|
|
3
|
+
* Part of ONE Ecosystem SDK
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
7
|
+
import { View, Text, StyleSheet, ScrollView, ViewStyle, Platform, TouchableOpacity, Animated } from 'react-native';
|
|
8
|
+
import type { AIPosition } from '../../../types/console';
|
|
9
|
+
import { formatPnl, formatPercent } from '../../../types/console';
|
|
10
|
+
|
|
11
|
+
const MONO = Platform.OS === 'ios' ? 'Courier New' : 'monospace';
|
|
12
|
+
|
|
13
|
+
export interface OnePositionDetailProps {
|
|
14
|
+
position: AIPosition;
|
|
15
|
+
showTimeline?: boolean;
|
|
16
|
+
showReasoning?: boolean;
|
|
17
|
+
showRiskLevels?: boolean;
|
|
18
|
+
showHistory?: boolean;
|
|
19
|
+
priceUpdateInterval?: number;
|
|
20
|
+
onClose?: (positionId: string) => void;
|
|
21
|
+
onUpdateStopLoss?: (positionId: string, stopLoss: number) => void;
|
|
22
|
+
onUpdateTakeProfit?: (positionId: string, takeProfit: number) => void;
|
|
23
|
+
style?: ViewStyle;
|
|
24
|
+
dark?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const OnePositionDetail: React.FC<OnePositionDetailProps> = ({
|
|
28
|
+
position,
|
|
29
|
+
showTimeline = true,
|
|
30
|
+
showReasoning = true,
|
|
31
|
+
showRiskLevels = true,
|
|
32
|
+
showHistory = true,
|
|
33
|
+
priceUpdateInterval = 5000,
|
|
34
|
+
onClose,
|
|
35
|
+
onUpdateStopLoss,
|
|
36
|
+
onUpdateTakeProfit,
|
|
37
|
+
style,
|
|
38
|
+
dark = true,
|
|
39
|
+
}) => {
|
|
40
|
+
const bg = dark ? '#0A0A0C' : '#ffffff';
|
|
41
|
+
const cardBg = dark ? '#111111' : '#F9FAFB';
|
|
42
|
+
const border = dark ? '#2A2A35' : '#E5E7EB';
|
|
43
|
+
const textPrimary = dark ? '#ffffff' : '#111827';
|
|
44
|
+
const textSecondary = dark ? '#9CA3AF' : '#6B7280';
|
|
45
|
+
const textMuted = dark ? '#555560' : '#9CA3AF';
|
|
46
|
+
|
|
47
|
+
const isLong = position.side === 'LONG';
|
|
48
|
+
const sideColor = isLong ? '#10B981' : '#EF4444';
|
|
49
|
+
const sideBgColor = isLong ? '#D1FAE5' : '#FEE2E2';
|
|
50
|
+
const pnlColor = position.pnl >= 0 ? '#10B981' : '#EF4444';
|
|
51
|
+
|
|
52
|
+
// Animated values for P&L updates
|
|
53
|
+
const pnlAnim = useRef(new Animated.Value(0)).current;
|
|
54
|
+
const [prevPnl, setPrevPnl] = useState(position.pnl);
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (position.pnl !== prevPnl) {
|
|
58
|
+
Animated.sequence([
|
|
59
|
+
Animated.timing(pnlAnim, { toValue: 1, duration: 200, useNativeDriver: false }),
|
|
60
|
+
Animated.timing(pnlAnim, { toValue: 0, duration: 400, useNativeDriver: false }),
|
|
61
|
+
]).start();
|
|
62
|
+
setPrevPnl(position.pnl);
|
|
63
|
+
}
|
|
64
|
+
}, [position.pnl, prevPnl, pnlAnim]);
|
|
65
|
+
|
|
66
|
+
const pnlBgColor = pnlAnim.interpolate({
|
|
67
|
+
inputRange: [0, 1],
|
|
68
|
+
outputRange: [cardBg, position.pnl >= 0 ? '#134E4A' : '#7F1D1D'],
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const formatPrice = (price: number): string => {
|
|
72
|
+
if (price >= 1000) return price.toFixed(2);
|
|
73
|
+
if (price >= 1) return price.toFixed(4);
|
|
74
|
+
return price.toFixed(6);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const formatDuration = (openTime: number, closeTime?: number): string => {
|
|
78
|
+
const end = closeTime || Date.now();
|
|
79
|
+
const duration = end - openTime;
|
|
80
|
+
const hours = Math.floor(duration / 3600000);
|
|
81
|
+
const minutes = Math.floor((duration % 3600000) / 60000);
|
|
82
|
+
const seconds = Math.floor((duration % 60000) / 1000);
|
|
83
|
+
|
|
84
|
+
if (hours > 0) return `${hours}h ${minutes}m`;
|
|
85
|
+
if (minutes > 0) return `${minutes}m ${seconds}s`;
|
|
86
|
+
return `${seconds}s`;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const formatTimestamp = (ts: number): string => {
|
|
90
|
+
const d = new Date(ts);
|
|
91
|
+
return d.toLocaleString('en-US', {
|
|
92
|
+
month: 'short',
|
|
93
|
+
day: 'numeric',
|
|
94
|
+
hour: '2-digit',
|
|
95
|
+
minute: '2-digit',
|
|
96
|
+
second: '2-digit',
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Calculate distance to liquidation
|
|
101
|
+
const distanceToLiquidation = position.liquidationPrice
|
|
102
|
+
? Math.abs((position.currentPrice - position.liquidationPrice) / position.currentPrice * 100)
|
|
103
|
+
: null;
|
|
104
|
+
|
|
105
|
+
// Calculate P&L at TP and SL
|
|
106
|
+
const pnlAtTP = position.takeProfit
|
|
107
|
+
? ((isLong
|
|
108
|
+
? (position.takeProfit - position.entryPrice)
|
|
109
|
+
: (position.entryPrice - position.takeProfit)) / position.entryPrice) * position.leverage * position.size
|
|
110
|
+
: null;
|
|
111
|
+
|
|
112
|
+
const pnlAtSL = position.stopLoss
|
|
113
|
+
? ((isLong
|
|
114
|
+
? (position.stopLoss - position.entryPrice)
|
|
115
|
+
: (position.entryPrice - position.stopLoss)) / position.entryPrice) * position.leverage * position.size
|
|
116
|
+
: null;
|
|
117
|
+
|
|
118
|
+
const handleClose = () => {
|
|
119
|
+
if (onClose) {
|
|
120
|
+
onClose(position.id);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<ScrollView style={[styles.container, { backgroundColor: bg }, style]}>
|
|
126
|
+
{/* Header */}
|
|
127
|
+
<View style={[styles.header, { backgroundColor: cardBg, borderBottomColor: border }]}>
|
|
128
|
+
<View style={styles.headerTop}>
|
|
129
|
+
<View style={styles.headerLeft}>
|
|
130
|
+
<View style={[styles.sideBadge, { backgroundColor: sideBgColor }]}>
|
|
131
|
+
<Text style={[styles.sideText, { color: sideColor }]}>{position.side}</Text>
|
|
132
|
+
</View>
|
|
133
|
+
<Text style={[styles.pair, { color: textPrimary }]}>{position.pair}</Text>
|
|
134
|
+
<Text style={[styles.leverage, { color: textSecondary }]}>{position.leverage}x</Text>
|
|
135
|
+
</View>
|
|
136
|
+
<View style={[
|
|
137
|
+
styles.statusBadge,
|
|
138
|
+
{ backgroundColor: position.status === 'open' ? '#D1FAE5' : '#F3F4F6' }
|
|
139
|
+
]}>
|
|
140
|
+
<Text style={[
|
|
141
|
+
styles.statusText,
|
|
142
|
+
{ color: position.status === 'open' ? '#10B981' : '#9CA3AF' }
|
|
143
|
+
]}>
|
|
144
|
+
{position.status.toUpperCase()}
|
|
145
|
+
</Text>
|
|
146
|
+
</View>
|
|
147
|
+
</View>
|
|
148
|
+
|
|
149
|
+
{/* Main P&L Display */}
|
|
150
|
+
<Animated.View style={[styles.pnlSection, { backgroundColor: pnlBgColor }]}>
|
|
151
|
+
<View style={styles.pnlMain}>
|
|
152
|
+
<Text style={[styles.pnlValue, { color: pnlColor }]}>
|
|
153
|
+
{formatPnl(position.pnl)}
|
|
154
|
+
</Text>
|
|
155
|
+
<Text style={[styles.pnlPercent, { color: pnlColor }]}>
|
|
156
|
+
{formatPercent(position.pnlPercent)}
|
|
157
|
+
</Text>
|
|
158
|
+
</View>
|
|
159
|
+
<Text style={[styles.pnlLabel, { color: textMuted }]}>Unrealized P&L</Text>
|
|
160
|
+
</Animated.View>
|
|
161
|
+
</View>
|
|
162
|
+
|
|
163
|
+
{/* Price Information */}
|
|
164
|
+
<View style={[styles.section, { backgroundColor: cardBg }]}>
|
|
165
|
+
<Text style={[styles.sectionTitle, { color: textMuted }]}>Price Information</Text>
|
|
166
|
+
<View style={styles.priceGrid}>
|
|
167
|
+
<View style={styles.priceItem}>
|
|
168
|
+
<Text style={[styles.priceLabel, { color: textMuted }]}>Entry Price</Text>
|
|
169
|
+
<Text style={[styles.priceValue, { color: textPrimary }]}>
|
|
170
|
+
${formatPrice(position.entryPrice)}
|
|
171
|
+
</Text>
|
|
172
|
+
</View>
|
|
173
|
+
<View style={styles.priceItem}>
|
|
174
|
+
<Text style={[styles.priceLabel, { color: textMuted }]}>Current Price</Text>
|
|
175
|
+
<Text style={[styles.priceValue, { color: textPrimary }]}>
|
|
176
|
+
${formatPrice(position.currentPrice)}
|
|
177
|
+
</Text>
|
|
178
|
+
</View>
|
|
179
|
+
<View style={styles.priceItem}>
|
|
180
|
+
<Text style={[styles.priceLabel, { color: textMuted }]}>Price Change</Text>
|
|
181
|
+
<Text style={[
|
|
182
|
+
styles.priceValue,
|
|
183
|
+
{ color: (position.currentPrice - position.entryPrice) * (isLong ? 1 : -1) >= 0 ? '#10B981' : '#EF4444' }
|
|
184
|
+
]}>
|
|
185
|
+
{((position.currentPrice - position.entryPrice) / position.entryPrice * 100) >= 0 ? '+' : ''}
|
|
186
|
+
{((position.currentPrice - position.entryPrice) / position.entryPrice * 100).toFixed(4)}%
|
|
187
|
+
</Text>
|
|
188
|
+
</View>
|
|
189
|
+
</View>
|
|
190
|
+
</View>
|
|
191
|
+
|
|
192
|
+
{/* Position Details */}
|
|
193
|
+
<View style={[styles.section, { backgroundColor: cardBg }]}>
|
|
194
|
+
<Text style={[styles.sectionTitle, { color: textMuted }]}>Position Details</Text>
|
|
195
|
+
<View style={styles.detailsGrid}>
|
|
196
|
+
<View style={styles.detailRow}>
|
|
197
|
+
<Text style={[styles.detailLabel, { color: textSecondary }]}>Size</Text>
|
|
198
|
+
<Text style={[styles.detailValue, { color: textPrimary }]}>
|
|
199
|
+
${position.size.toLocaleString()}
|
|
200
|
+
</Text>
|
|
201
|
+
</View>
|
|
202
|
+
<View style={styles.detailRow}>
|
|
203
|
+
<Text style={[styles.detailLabel, { color: textSecondary }]}>Margin</Text>
|
|
204
|
+
<Text style={[styles.detailValue, { color: textPrimary }]}>
|
|
205
|
+
${position.margin.toFixed(2)}
|
|
206
|
+
</Text>
|
|
207
|
+
</View>
|
|
208
|
+
<View style={styles.detailRow}>
|
|
209
|
+
<Text style={[styles.detailLabel, { color: textSecondary }]}>Leverage</Text>
|
|
210
|
+
<Text style={[styles.detailValue, { color: textPrimary }]}>
|
|
211
|
+
{position.leverage}x
|
|
212
|
+
</Text>
|
|
213
|
+
</View>
|
|
214
|
+
<View style={styles.detailRow}>
|
|
215
|
+
<Text style={[styles.detailLabel, { color: textSecondary }]}>Strategy</Text>
|
|
216
|
+
<Text style={[styles.detailValue, { color: textPrimary }]}>
|
|
217
|
+
{position.strategyName}
|
|
218
|
+
</Text>
|
|
219
|
+
</View>
|
|
220
|
+
{position.chain && (
|
|
221
|
+
<View style={styles.detailRow}>
|
|
222
|
+
<Text style={[styles.detailLabel, { color: textSecondary }]}>Chain</Text>
|
|
223
|
+
<Text style={[styles.detailValue, { color: textPrimary }]}>
|
|
224
|
+
{position.chain}
|
|
225
|
+
</Text>
|
|
226
|
+
</View>
|
|
227
|
+
)}
|
|
228
|
+
<View style={styles.detailRow}>
|
|
229
|
+
<Text style={[styles.detailLabel, { color: textSecondary }]}>Duration</Text>
|
|
230
|
+
<Text style={[styles.detailValue, { color: textPrimary }]}>
|
|
231
|
+
{formatDuration(position.openTime, position.closeTime)}
|
|
232
|
+
</Text>
|
|
233
|
+
</View>
|
|
234
|
+
</View>
|
|
235
|
+
</View>
|
|
236
|
+
|
|
237
|
+
{/* Risk Levels */}
|
|
238
|
+
{showRiskLevels && (
|
|
239
|
+
<View style={[styles.section, { backgroundColor: cardBg }]}>
|
|
240
|
+
<Text style={[styles.sectionTitle, { color: textMuted }]}>Risk Management</Text>
|
|
241
|
+
<View style={styles.riskGrid}>
|
|
242
|
+
{position.stopLoss && (
|
|
243
|
+
<View style={[styles.riskCard, { borderColor: '#EF4444' }]}>
|
|
244
|
+
<Text style={[styles.riskCardLabel, { color: '#EF4444' }]}>Stop Loss</Text>
|
|
245
|
+
<Text style={[styles.riskCardPrice, { color: textPrimary }]}>
|
|
246
|
+
${formatPrice(position.stopLoss)}
|
|
247
|
+
</Text>
|
|
248
|
+
{pnlAtSL !== null && (
|
|
249
|
+
<Text style={[styles.riskCardPnl, { color: '#EF4444' }]}>
|
|
250
|
+
{formatPnl(pnlAtSL)}
|
|
251
|
+
</Text>
|
|
252
|
+
)}
|
|
253
|
+
</View>
|
|
254
|
+
)}
|
|
255
|
+
{position.takeProfit && (
|
|
256
|
+
<View style={[styles.riskCard, { borderColor: '#10B981' }]}>
|
|
257
|
+
<Text style={[styles.riskCardLabel, { color: '#10B981' }]}>Take Profit</Text>
|
|
258
|
+
<Text style={[styles.riskCardPrice, { color: textPrimary }]}>
|
|
259
|
+
${formatPrice(position.takeProfit)}
|
|
260
|
+
</Text>
|
|
261
|
+
{pnlAtTP !== null && (
|
|
262
|
+
<Text style={[styles.riskCardPnl, { color: '#10B981' }]}>
|
|
263
|
+
{formatPnl(pnlAtTP)}
|
|
264
|
+
</Text>
|
|
265
|
+
)}
|
|
266
|
+
</View>
|
|
267
|
+
)}
|
|
268
|
+
{position.liquidationPrice && (
|
|
269
|
+
<View style={[styles.riskCard, { borderColor: '#F59E0B' }]}>
|
|
270
|
+
<Text style={[styles.riskCardLabel, { color: '#F59E0B' }]}>Liquidation</Text>
|
|
271
|
+
<Text style={[styles.riskCardPrice, { color: textPrimary }]}>
|
|
272
|
+
${formatPrice(position.liquidationPrice)}
|
|
273
|
+
</Text>
|
|
274
|
+
{distanceToLiquidation !== null && (
|
|
275
|
+
<Text style={[styles.riskCardDistance, { color: textMuted }]}>
|
|
276
|
+
{distanceToLiquidation.toFixed(2)}% away
|
|
277
|
+
</Text>
|
|
278
|
+
)}
|
|
279
|
+
</View>
|
|
280
|
+
)}
|
|
281
|
+
</View>
|
|
282
|
+
</View>
|
|
283
|
+
)}
|
|
284
|
+
|
|
285
|
+
{/* AI Reasoning */}
|
|
286
|
+
{showReasoning && position.aiReasoning && (
|
|
287
|
+
<View style={[styles.section, { backgroundColor: cardBg }]}>
|
|
288
|
+
<Text style={[styles.sectionTitle, { color: textMuted }]}>AI Analysis</Text>
|
|
289
|
+
<View style={[styles.reasoningBox, { backgroundColor: dark ? '#1A1A1F' : '#F3F4F6' }]}>
|
|
290
|
+
<Text style={[styles.reasoningText, { color: textSecondary }]}>
|
|
291
|
+
{position.aiReasoning}
|
|
292
|
+
</Text>
|
|
293
|
+
</View>
|
|
294
|
+
{position.aiConfidence && (
|
|
295
|
+
<View style={styles.confidenceRow}>
|
|
296
|
+
<Text style={[styles.confidenceLabel, { color: textMuted }]}>Confidence</Text>
|
|
297
|
+
<View style={[styles.confidenceBar, { backgroundColor: dark ? '#1A1A1F' : '#E5E7EB' }]}>
|
|
298
|
+
<View
|
|
299
|
+
style={[
|
|
300
|
+
styles.confidenceFill,
|
|
301
|
+
{
|
|
302
|
+
width: `${position.aiConfidence * 100}%`,
|
|
303
|
+
backgroundColor: position.aiConfidence >= 0.7 ? '#10B981' :
|
|
304
|
+
position.aiConfidence >= 0.5 ? '#F59E0B' : '#EF4444',
|
|
305
|
+
}
|
|
306
|
+
]}
|
|
307
|
+
/>
|
|
308
|
+
</View>
|
|
309
|
+
<Text style={[styles.confidenceValue, { color: textPrimary }]}>
|
|
310
|
+
{(position.aiConfidence * 100).toFixed(0)}%
|
|
311
|
+
</Text>
|
|
312
|
+
</View>
|
|
313
|
+
)}
|
|
314
|
+
</View>
|
|
315
|
+
)}
|
|
316
|
+
|
|
317
|
+
{/* Timeline */}
|
|
318
|
+
{showTimeline && (
|
|
319
|
+
<View style={[styles.section, { backgroundColor: cardBg }]}>
|
|
320
|
+
<Text style={[styles.sectionTitle, { color: textMuted }]}>Timeline</Text>
|
|
321
|
+
<View style={styles.timeline}>
|
|
322
|
+
<View style={styles.timelineItem}>
|
|
323
|
+
<View style={[styles.timelineDot, { backgroundColor: '#10B981' }]} />
|
|
324
|
+
<View style={styles.timelineContent}>
|
|
325
|
+
<Text style={[styles.timelineLabel, { color: textSecondary }]}>Position Opened</Text>
|
|
326
|
+
<Text style={[styles.timelineTime, { color: textMuted }]}>
|
|
327
|
+
{formatTimestamp(position.openTime)}
|
|
328
|
+
</Text>
|
|
329
|
+
<Text style={[styles.timelineDetail, { color: textMuted }]}>
|
|
330
|
+
@ ${formatPrice(position.entryPrice)}
|
|
331
|
+
</Text>
|
|
332
|
+
</View>
|
|
333
|
+
</View>
|
|
334
|
+
{position.closeTime && (
|
|
335
|
+
<View style={styles.timelineItem}>
|
|
336
|
+
<View style={[styles.timelineDot, { backgroundColor: '#EF4444' }]} />
|
|
337
|
+
<View style={styles.timelineContent}>
|
|
338
|
+
<Text style={[styles.timelineLabel, { color: textSecondary }]}>Position Closed</Text>
|
|
339
|
+
<Text style={[styles.timelineTime, { color: textMuted }]}>
|
|
340
|
+
{formatTimestamp(position.closeTime)}
|
|
341
|
+
</Text>
|
|
342
|
+
<Text style={[styles.timelineDetail, { color: textMuted }]}>
|
|
343
|
+
@ ${formatPrice(position.currentPrice)}
|
|
344
|
+
</Text>
|
|
345
|
+
</View>
|
|
346
|
+
</View>
|
|
347
|
+
)}
|
|
348
|
+
</View>
|
|
349
|
+
</View>
|
|
350
|
+
)}
|
|
351
|
+
|
|
352
|
+
{/* Action Buttons */}
|
|
353
|
+
{position.status === 'open' && onClose && (
|
|
354
|
+
<View style={styles.actionsSection}>
|
|
355
|
+
<TouchableOpacity
|
|
356
|
+
style={styles.closeButton}
|
|
357
|
+
onPress={handleClose}
|
|
358
|
+
activeOpacity={0.7}
|
|
359
|
+
>
|
|
360
|
+
<Text style={styles.closeButtonText}>Close Position</Text>
|
|
361
|
+
</TouchableOpacity>
|
|
362
|
+
</View>
|
|
363
|
+
)}
|
|
364
|
+
</ScrollView>
|
|
365
|
+
);
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
const styles = StyleSheet.create({
|
|
369
|
+
container: {
|
|
370
|
+
flex: 1,
|
|
371
|
+
},
|
|
372
|
+
header: {
|
|
373
|
+
padding: 16,
|
|
374
|
+
borderBottomWidth: 1,
|
|
375
|
+
gap: 16,
|
|
376
|
+
},
|
|
377
|
+
headerTop: {
|
|
378
|
+
flexDirection: 'row',
|
|
379
|
+
justifyContent: 'space-between',
|
|
380
|
+
alignItems: 'center',
|
|
381
|
+
},
|
|
382
|
+
headerLeft: {
|
|
383
|
+
flexDirection: 'row',
|
|
384
|
+
alignItems: 'center',
|
|
385
|
+
gap: 10,
|
|
386
|
+
},
|
|
387
|
+
sideBadge: {
|
|
388
|
+
paddingHorizontal: 10,
|
|
389
|
+
paddingVertical: 4,
|
|
390
|
+
borderRadius: 6,
|
|
391
|
+
},
|
|
392
|
+
sideText: {
|
|
393
|
+
fontFamily: MONO,
|
|
394
|
+
fontSize: 12,
|
|
395
|
+
fontWeight: '700',
|
|
396
|
+
},
|
|
397
|
+
pair: {
|
|
398
|
+
fontSize: 20,
|
|
399
|
+
fontWeight: '700',
|
|
400
|
+
},
|
|
401
|
+
leverage: {
|
|
402
|
+
fontFamily: MONO,
|
|
403
|
+
fontSize: 14,
|
|
404
|
+
},
|
|
405
|
+
statusBadge: {
|
|
406
|
+
paddingHorizontal: 10,
|
|
407
|
+
paddingVertical: 4,
|
|
408
|
+
borderRadius: 6,
|
|
409
|
+
},
|
|
410
|
+
statusText: {
|
|
411
|
+
fontSize: 11,
|
|
412
|
+
fontWeight: '700',
|
|
413
|
+
},
|
|
414
|
+
pnlSection: {
|
|
415
|
+
padding: 16,
|
|
416
|
+
borderRadius: 12,
|
|
417
|
+
alignItems: 'center',
|
|
418
|
+
gap: 4,
|
|
419
|
+
},
|
|
420
|
+
pnlMain: {
|
|
421
|
+
flexDirection: 'row',
|
|
422
|
+
alignItems: 'baseline',
|
|
423
|
+
gap: 10,
|
|
424
|
+
},
|
|
425
|
+
pnlValue: {
|
|
426
|
+
fontFamily: MONO,
|
|
427
|
+
fontSize: 32,
|
|
428
|
+
fontWeight: '700',
|
|
429
|
+
},
|
|
430
|
+
pnlPercent: {
|
|
431
|
+
fontFamily: MONO,
|
|
432
|
+
fontSize: 18,
|
|
433
|
+
fontWeight: '600',
|
|
434
|
+
},
|
|
435
|
+
pnlLabel: {
|
|
436
|
+
fontFamily: MONO,
|
|
437
|
+
fontSize: 10,
|
|
438
|
+
textTransform: 'uppercase',
|
|
439
|
+
},
|
|
440
|
+
section: {
|
|
441
|
+
margin: 12,
|
|
442
|
+
marginTop: 0,
|
|
443
|
+
padding: 16,
|
|
444
|
+
borderRadius: 12,
|
|
445
|
+
gap: 12,
|
|
446
|
+
},
|
|
447
|
+
sectionTitle: {
|
|
448
|
+
fontFamily: MONO,
|
|
449
|
+
fontSize: 10,
|
|
450
|
+
textTransform: 'uppercase',
|
|
451
|
+
letterSpacing: 1,
|
|
452
|
+
},
|
|
453
|
+
priceGrid: {
|
|
454
|
+
flexDirection: 'row',
|
|
455
|
+
justifyContent: 'space-between',
|
|
456
|
+
},
|
|
457
|
+
priceItem: {
|
|
458
|
+
alignItems: 'center',
|
|
459
|
+
gap: 4,
|
|
460
|
+
},
|
|
461
|
+
priceLabel: {
|
|
462
|
+
fontFamily: MONO,
|
|
463
|
+
fontSize: 9,
|
|
464
|
+
textTransform: 'uppercase',
|
|
465
|
+
},
|
|
466
|
+
priceValue: {
|
|
467
|
+
fontFamily: MONO,
|
|
468
|
+
fontSize: 14,
|
|
469
|
+
fontWeight: '600',
|
|
470
|
+
},
|
|
471
|
+
detailsGrid: {
|
|
472
|
+
gap: 8,
|
|
473
|
+
},
|
|
474
|
+
detailRow: {
|
|
475
|
+
flexDirection: 'row',
|
|
476
|
+
justifyContent: 'space-between',
|
|
477
|
+
alignItems: 'center',
|
|
478
|
+
paddingVertical: 6,
|
|
479
|
+
borderBottomWidth: 1,
|
|
480
|
+
borderBottomColor: '#1A1A1F',
|
|
481
|
+
},
|
|
482
|
+
detailLabel: {
|
|
483
|
+
fontSize: 13,
|
|
484
|
+
},
|
|
485
|
+
detailValue: {
|
|
486
|
+
fontFamily: MONO,
|
|
487
|
+
fontSize: 13,
|
|
488
|
+
fontWeight: '600',
|
|
489
|
+
},
|
|
490
|
+
riskGrid: {
|
|
491
|
+
flexDirection: 'row',
|
|
492
|
+
gap: 10,
|
|
493
|
+
},
|
|
494
|
+
riskCard: {
|
|
495
|
+
flex: 1,
|
|
496
|
+
padding: 12,
|
|
497
|
+
borderRadius: 8,
|
|
498
|
+
borderWidth: 1,
|
|
499
|
+
alignItems: 'center',
|
|
500
|
+
gap: 4,
|
|
501
|
+
},
|
|
502
|
+
riskCardLabel: {
|
|
503
|
+
fontFamily: MONO,
|
|
504
|
+
fontSize: 9,
|
|
505
|
+
fontWeight: '700',
|
|
506
|
+
textTransform: 'uppercase',
|
|
507
|
+
},
|
|
508
|
+
riskCardPrice: {
|
|
509
|
+
fontFamily: MONO,
|
|
510
|
+
fontSize: 13,
|
|
511
|
+
fontWeight: '600',
|
|
512
|
+
},
|
|
513
|
+
riskCardPnl: {
|
|
514
|
+
fontFamily: MONO,
|
|
515
|
+
fontSize: 11,
|
|
516
|
+
},
|
|
517
|
+
riskCardDistance: {
|
|
518
|
+
fontFamily: MONO,
|
|
519
|
+
fontSize: 10,
|
|
520
|
+
},
|
|
521
|
+
reasoningBox: {
|
|
522
|
+
padding: 12,
|
|
523
|
+
borderRadius: 8,
|
|
524
|
+
},
|
|
525
|
+
reasoningText: {
|
|
526
|
+
fontSize: 13,
|
|
527
|
+
lineHeight: 20,
|
|
528
|
+
},
|
|
529
|
+
confidenceRow: {
|
|
530
|
+
flexDirection: 'row',
|
|
531
|
+
alignItems: 'center',
|
|
532
|
+
gap: 10,
|
|
533
|
+
},
|
|
534
|
+
confidenceLabel: {
|
|
535
|
+
fontFamily: MONO,
|
|
536
|
+
fontSize: 10,
|
|
537
|
+
textTransform: 'uppercase',
|
|
538
|
+
},
|
|
539
|
+
confidenceBar: {
|
|
540
|
+
flex: 1,
|
|
541
|
+
height: 8,
|
|
542
|
+
borderRadius: 4,
|
|
543
|
+
overflow: 'hidden',
|
|
544
|
+
},
|
|
545
|
+
confidenceFill: {
|
|
546
|
+
height: '100%',
|
|
547
|
+
borderRadius: 4,
|
|
548
|
+
},
|
|
549
|
+
confidenceValue: {
|
|
550
|
+
fontFamily: MONO,
|
|
551
|
+
fontSize: 12,
|
|
552
|
+
fontWeight: '600',
|
|
553
|
+
width: 35,
|
|
554
|
+
},
|
|
555
|
+
timeline: {
|
|
556
|
+
gap: 16,
|
|
557
|
+
paddingLeft: 8,
|
|
558
|
+
},
|
|
559
|
+
timelineItem: {
|
|
560
|
+
flexDirection: 'row',
|
|
561
|
+
gap: 12,
|
|
562
|
+
},
|
|
563
|
+
timelineDot: {
|
|
564
|
+
width: 12,
|
|
565
|
+
height: 12,
|
|
566
|
+
borderRadius: 6,
|
|
567
|
+
marginTop: 3,
|
|
568
|
+
},
|
|
569
|
+
timelineContent: {
|
|
570
|
+
flex: 1,
|
|
571
|
+
gap: 2,
|
|
572
|
+
},
|
|
573
|
+
timelineLabel: {
|
|
574
|
+
fontSize: 13,
|
|
575
|
+
fontWeight: '500',
|
|
576
|
+
},
|
|
577
|
+
timelineTime: {
|
|
578
|
+
fontFamily: MONO,
|
|
579
|
+
fontSize: 11,
|
|
580
|
+
},
|
|
581
|
+
timelineDetail: {
|
|
582
|
+
fontFamily: MONO,
|
|
583
|
+
fontSize: 11,
|
|
584
|
+
},
|
|
585
|
+
actionsSection: {
|
|
586
|
+
padding: 16,
|
|
587
|
+
gap: 10,
|
|
588
|
+
},
|
|
589
|
+
closeButton: {
|
|
590
|
+
backgroundColor: '#EF4444',
|
|
591
|
+
paddingVertical: 14,
|
|
592
|
+
borderRadius: 10,
|
|
593
|
+
alignItems: 'center',
|
|
594
|
+
},
|
|
595
|
+
closeButtonText: {
|
|
596
|
+
color: '#ffffff',
|
|
597
|
+
fontSize: 16,
|
|
598
|
+
fontWeight: '600',
|
|
599
|
+
},
|
|
600
|
+
});
|