@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
package/dist/types/index.js
CHANGED
|
@@ -1,4 +1,279 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// src/types/forex.ts
|
|
4
|
+
var FOREX_CAPITAL_SPLIT = {
|
|
5
|
+
poolReserves: 0.5,
|
|
6
|
+
tradingCapital: 0.5
|
|
7
|
+
};
|
|
8
|
+
function computePoolAllocations(amount) {
|
|
9
|
+
const totalPoolReserves = amount * FOREX_CAPITAL_SPLIT.poolReserves;
|
|
10
|
+
const tradingCapital = amount * FOREX_CAPITAL_SPLIT.tradingCapital;
|
|
11
|
+
return {
|
|
12
|
+
tradingCapital,
|
|
13
|
+
totalPoolReserves,
|
|
14
|
+
clearing: totalPoolReserves * 0.5,
|
|
15
|
+
hedging: totalPoolReserves * 0.3,
|
|
16
|
+
insurance: totalPoolReserves * 0.2
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
var FOREX_CYCLE_OPTIONS = [
|
|
20
|
+
{ days: 30, feeRate: 0.1, commissionRate: 0.6, label: "30D" },
|
|
21
|
+
{ days: 60, feeRate: 0.08, commissionRate: 0.7, label: "60D" },
|
|
22
|
+
{ days: 90, feeRate: 0.07, commissionRate: 0.75, label: "90D" },
|
|
23
|
+
{ days: 180, feeRate: 0.05, commissionRate: 0.85, label: "180D" },
|
|
24
|
+
{ days: 360, feeRate: 0.03, commissionRate: 0.9, label: "360D" }
|
|
25
|
+
];
|
|
26
|
+
var FOREX_CURRENCY_PAIRS = [
|
|
27
|
+
{ id: "USDC_EURC", base: "USDC", quote: "EURC", symbol: "USDC/EURC", flag: "\u{1F1EA}\u{1F1FA}", name: "Euro", basePrice: 0.923, pipSize: 1e-4, spreadPips: 1.2 },
|
|
28
|
+
{ id: "USDC_GBPC", base: "USDC", quote: "GBPC", symbol: "USDC/GBPC", flag: "\u{1F1EC}\u{1F1E7}", name: "British Pound", basePrice: 0.789, pipSize: 1e-4, spreadPips: 1.5 },
|
|
29
|
+
{ id: "USDC_JPYC", base: "USDC", quote: "JPYC", symbol: "USDC/JPYC", flag: "\u{1F1EF}\u{1F1F5}", name: "Japanese Yen", basePrice: 154.5, pipSize: 0.01, spreadPips: 1 },
|
|
30
|
+
{ id: "USDC_AUDC", base: "USDC", quote: "AUDC", symbol: "USDC/AUDC", flag: "\u{1F1E6}\u{1F1FA}", name: "Australian Dollar", basePrice: 1.538, pipSize: 1e-4, spreadPips: 1.8 },
|
|
31
|
+
{ id: "USDC_CADC", base: "USDC", quote: "CADC", symbol: "USDC/CADC", flag: "\u{1F1E8}\u{1F1E6}", name: "Canadian Dollar", basePrice: 1.364, pipSize: 1e-4, spreadPips: 1.5 },
|
|
32
|
+
{ id: "USDC_CHFC", base: "USDC", quote: "CHFC", symbol: "USDC/CHFC", flag: "\u{1F1E8}\u{1F1ED}", name: "Swiss Franc", basePrice: 0.875, pipSize: 1e-4, spreadPips: 1.3 }
|
|
33
|
+
];
|
|
34
|
+
var FOREX_POOL_DEFAULTS = [
|
|
35
|
+
{ id: "clearing", nameKey: "forex.pool_clearing", descriptionKey: "forex.pool_clearing_desc", allocation: 0.5, totalSize: 125e5, utilization: 0.78, color: "#3B82F6", apy7d: 12.8, apy30d: 11.5, netFlow24h: 185e3, txCount24h: 42, txCountTotal: 12840, totalDeposits: 452e5, totalWithdrawals: 327e5, profitDistributed: 185e4, lastUpdated: Date.now() },
|
|
36
|
+
{ id: "hedging", nameKey: "forex.pool_hedging", descriptionKey: "forex.pool_hedging_desc", allocation: 0.3, totalSize: 75e5, utilization: 0.65, color: "#F59E0B", apy7d: 8.1, apy30d: 7.6, netFlow24h: 72e3, txCount24h: 24, txCountTotal: 7620, totalDeposits: 285e5, totalWithdrawals: 21e6, profitDistributed: 98e4, lastUpdated: Date.now() },
|
|
37
|
+
{ id: "insurance", nameKey: "forex.pool_insurance", descriptionKey: "forex.pool_insurance_desc", allocation: 0.2, totalSize: 5e6, utilization: 0.42, color: "#10B981", apy7d: 4.8, apy30d: 4.5, netFlow24h: 35e3, txCount24h: 14, txCountTotal: 4280, totalDeposits: 158e5, totalWithdrawals: 108e5, profitDistributed: 52e4, lastUpdated: Date.now() }
|
|
38
|
+
];
|
|
39
|
+
var FOREX_AGENT = {
|
|
40
|
+
id: "stablefx-01",
|
|
41
|
+
nameKey: "forex.agent_name",
|
|
42
|
+
descriptionKey: "forex.agent_description",
|
|
43
|
+
icon: "\u{1F4B1}",
|
|
44
|
+
color: "#0EA5E9",
|
|
45
|
+
supportedPairs: FOREX_CURRENCY_PAIRS.map((p) => p.id),
|
|
46
|
+
dailyRoiMin: 2e-3,
|
|
47
|
+
dailyRoiMax: 5e-3,
|
|
48
|
+
totalManaged: 25e6,
|
|
49
|
+
totalUsers: 3847,
|
|
50
|
+
winRate: 72.5
|
|
51
|
+
};
|
|
52
|
+
function calculateForexNetProfit(grossProfit, cycleOption) {
|
|
53
|
+
const feeAmount = grossProfit * cycleOption.feeRate;
|
|
54
|
+
const postFeeProfit = grossProfit - feeAmount;
|
|
55
|
+
const netProfit = postFeeProfit * cycleOption.commissionRate;
|
|
56
|
+
return { feeAmount, postFeeProfit, netProfit };
|
|
57
|
+
}
|
|
58
|
+
function estimateForexProfit(amount, cycleDays, agent = FOREX_AGENT) {
|
|
59
|
+
const cycleOption = FOREX_CYCLE_OPTIONS.find((c) => c.days === cycleDays) || FOREX_CYCLE_OPTIONS[0];
|
|
60
|
+
const estimatedApy = (agent.dailyRoiMin + agent.dailyRoiMax) / 2 * 365 * 100;
|
|
61
|
+
const dailyRate = estimatedApy / 100 / 365;
|
|
62
|
+
const grossProfit = amount * dailyRate * cycleDays;
|
|
63
|
+
const { feeAmount, netProfit } = calculateForexNetProfit(grossProfit, cycleOption);
|
|
64
|
+
return { grossProfit, feeAmount, netProfit, dailyRate };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/types/aiTrading.ts
|
|
68
|
+
var PENALTY_TIERS = [
|
|
69
|
+
{ minProgress: 0.75, maxProgress: 1, rate: 0.5, label: "50%" },
|
|
70
|
+
{ minProgress: 0.5, maxProgress: 0.75, rate: 0.6, label: "60%" },
|
|
71
|
+
{ minProgress: 0.25, maxProgress: 0.5, rate: 0.7, label: "70%" },
|
|
72
|
+
{ minProgress: 0, maxProgress: 0.25, rate: 0.8, label: "80%" }
|
|
73
|
+
];
|
|
74
|
+
function calculateEarlyWithdrawalPenalty(investedAmount, profit, lockProgress) {
|
|
75
|
+
const totalValue = investedAmount + profit;
|
|
76
|
+
const isEarlyWithdrawal = lockProgress < 1;
|
|
77
|
+
let penaltyRate = 0;
|
|
78
|
+
if (isEarlyWithdrawal) {
|
|
79
|
+
if (lockProgress >= 0.75) penaltyRate = 0.5;
|
|
80
|
+
else if (lockProgress >= 0.5) penaltyRate = 0.6;
|
|
81
|
+
else if (lockProgress >= 0.25) penaltyRate = 0.7;
|
|
82
|
+
else penaltyRate = 0.8;
|
|
83
|
+
}
|
|
84
|
+
const estimatedPenalty = totalValue * penaltyRate;
|
|
85
|
+
const estimatedRedemption = totalValue - estimatedPenalty;
|
|
86
|
+
return { completionRate: lockProgress, penaltyRate, estimatedPenalty, estimatedRedemption, isEarlyWithdrawal };
|
|
87
|
+
}
|
|
88
|
+
var STRATEGY_CATEGORIES = {
|
|
89
|
+
conservative: { labelKey: "ai.category_conservative", color: "#10B981", icon: "\u{1F6E1}\uFE0F" },
|
|
90
|
+
balanced: { labelKey: "ai.category_balanced", color: "#3B82F6", icon: "\u2696\uFE0F" },
|
|
91
|
+
aggressive: { labelKey: "ai.category_aggressive", color: "#EF4444", icon: "\u{1F680}" },
|
|
92
|
+
hedge: { labelKey: "ai.category_hedge", color: "#8B5CF6", icon: "\u{1F512}" },
|
|
93
|
+
arbitrage: { labelKey: "ai.category_arbitrage", color: "#F59E0B", icon: "\u26A1" },
|
|
94
|
+
trend: { labelKey: "ai.category_trend", color: "#EC4899", icon: "\u{1F4C8}" },
|
|
95
|
+
grid: { labelKey: "ai.category_grid", color: "#6366F1", icon: "\u25A6" },
|
|
96
|
+
dca: { labelKey: "ai.category_dca", color: "#14B8A6", icon: "\u{1F4CA}" }
|
|
97
|
+
};
|
|
98
|
+
var RISK_LEVELS = {
|
|
99
|
+
1: { labelKey: "ai.risk_very_low", color: "#10B981", bgColor: "#D1FAE5" },
|
|
100
|
+
2: { labelKey: "ai.risk_low", color: "#22C55E", bgColor: "#DCFCE7" },
|
|
101
|
+
3: { labelKey: "ai.risk_medium", color: "#F59E0B", bgColor: "#FEF3C7" },
|
|
102
|
+
4: { labelKey: "ai.risk_high", color: "#F97316", bgColor: "#FFEDD5" },
|
|
103
|
+
5: { labelKey: "ai.risk_very_high", color: "#EF4444", bgColor: "#FEE2E2" }
|
|
104
|
+
};
|
|
105
|
+
var ORDER_STATUS_CONFIG = {
|
|
106
|
+
pending: { labelKey: "ai.status_pending", color: "#F59E0B", bgColor: "#FEF3C7" },
|
|
107
|
+
active: { labelKey: "ai.status_active", color: "#10B981", bgColor: "#D1FAE5" },
|
|
108
|
+
paused: { labelKey: "ai.status_paused", color: "#6B7280", bgColor: "#F3F4F6" },
|
|
109
|
+
completed: { labelKey: "ai.status_completed", color: "#3B82F6", bgColor: "#DBEAFE" },
|
|
110
|
+
cancelled: { labelKey: "ai.status_cancelled", color: "#EF4444", bgColor: "#FEE2E2" },
|
|
111
|
+
pending_redemption: { labelKey: "ai.status_pending_redemption", color: "#8B5CF6", bgColor: "#EDE9FE" },
|
|
112
|
+
redeemed: { labelKey: "ai.status_redeemed", color: "#14B8A6", bgColor: "#CCFBF1" }
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/types/console.ts
|
|
116
|
+
var AI_LOG_COLORS = {
|
|
117
|
+
SCAN: "#06B6D4",
|
|
118
|
+
// Cyan
|
|
119
|
+
THINKING: "#A855F7",
|
|
120
|
+
// Purple
|
|
121
|
+
INDICATOR: "#3B82F6",
|
|
122
|
+
// Blue
|
|
123
|
+
ANALYSIS: "#6366F1",
|
|
124
|
+
// Indigo
|
|
125
|
+
SIGNAL: "#F59E0B",
|
|
126
|
+
// Amber
|
|
127
|
+
STRATEGY: "#D946EF",
|
|
128
|
+
// Fuchsia
|
|
129
|
+
DECISION: "#F97316",
|
|
130
|
+
// Orange
|
|
131
|
+
ORDER: "#EC4899",
|
|
132
|
+
// Pink
|
|
133
|
+
FILLED: "#10B981",
|
|
134
|
+
// Green
|
|
135
|
+
PNL: "#22C55E",
|
|
136
|
+
// Emerald
|
|
137
|
+
RISK: "#EF4444",
|
|
138
|
+
// Red
|
|
139
|
+
NEWS: "#14B8A6",
|
|
140
|
+
// Teal
|
|
141
|
+
SYSTEM: "#9CA3AF"
|
|
142
|
+
// Gray
|
|
143
|
+
};
|
|
144
|
+
var FOREX_LOG_COLORS = {
|
|
145
|
+
RFQ: "#06B6D4",
|
|
146
|
+
// Cyan
|
|
147
|
+
QUOTE: "#8B5CF6",
|
|
148
|
+
// Purple
|
|
149
|
+
MATCH: "#10B981",
|
|
150
|
+
// Green
|
|
151
|
+
SETTLE: "#F59E0B",
|
|
152
|
+
// Amber
|
|
153
|
+
PVP: "#3B82F6",
|
|
154
|
+
// Blue
|
|
155
|
+
HEDGE: "#EC4899",
|
|
156
|
+
// Pink
|
|
157
|
+
CLEAR: "#14B8A6",
|
|
158
|
+
// Teal
|
|
159
|
+
POSITION: "#6366F1",
|
|
160
|
+
// Indigo
|
|
161
|
+
PNL: "#22C55E",
|
|
162
|
+
// Emerald
|
|
163
|
+
SYSTEM: "#9CA3AF"
|
|
164
|
+
// Gray
|
|
165
|
+
};
|
|
166
|
+
var RISK_LEVEL_COLORS = {
|
|
167
|
+
low: { color: "#10B981", bgColor: "#D1FAE5" },
|
|
168
|
+
medium: { color: "#F59E0B", bgColor: "#FEF3C7" },
|
|
169
|
+
high: { color: "#F97316", bgColor: "#FFEDD5" },
|
|
170
|
+
critical: { color: "#EF4444", bgColor: "#FEE2E2" }
|
|
171
|
+
};
|
|
172
|
+
var TRADING_STATUS_COLORS = {
|
|
173
|
+
active: { color: "#10B981", bgColor: "#D1FAE5" },
|
|
174
|
+
paused: { color: "#F59E0B", bgColor: "#FEF3C7" },
|
|
175
|
+
stopped: { color: "#EF4444", bgColor: "#FEE2E2" },
|
|
176
|
+
cooldown: { color: "#6366F1", bgColor: "#E0E7FF" }
|
|
177
|
+
};
|
|
178
|
+
var AGENT_STATUS_COLORS = {
|
|
179
|
+
active: { color: "#10B981", bgColor: "#D1FAE5", label: "Active" },
|
|
180
|
+
paused: { color: "#F59E0B", bgColor: "#FEF3C7", label: "Paused" },
|
|
181
|
+
idle: { color: "#6B7280", bgColor: "#F3F4F6", label: "Idle" },
|
|
182
|
+
error: { color: "#EF4444", bgColor: "#FEE2E2", label: "Error" },
|
|
183
|
+
initializing: { color: "#3B82F6", bgColor: "#DBEAFE", label: "Starting" }
|
|
184
|
+
};
|
|
185
|
+
var DEFAULT_CONSOLE_OPTIONS = {
|
|
186
|
+
simulation: true,
|
|
187
|
+
pollInterval: 5e3,
|
|
188
|
+
maxLogs: 500,
|
|
189
|
+
autoStart: false
|
|
190
|
+
};
|
|
191
|
+
var DEFAULT_RISK_STATUS = {
|
|
192
|
+
timestamp: Date.now(),
|
|
193
|
+
totalExposure: 0,
|
|
194
|
+
maxExposure: 1e5,
|
|
195
|
+
exposurePercent: 0,
|
|
196
|
+
dailyPnl: 0,
|
|
197
|
+
dailyPnlLimit: 5e3,
|
|
198
|
+
dailyPnlPercent: 0,
|
|
199
|
+
dailyTradeCount: 0,
|
|
200
|
+
dailyTradeLimit: 50,
|
|
201
|
+
currentDrawdown: 0,
|
|
202
|
+
maxDrawdown: 15,
|
|
203
|
+
drawdownPercent: 0,
|
|
204
|
+
openPositions: 0,
|
|
205
|
+
maxPositions: 10,
|
|
206
|
+
riskLevel: "low",
|
|
207
|
+
tradingStatus: "active",
|
|
208
|
+
warnings: []
|
|
209
|
+
};
|
|
210
|
+
var DEFAULT_CONSOLE_METRICS = {
|
|
211
|
+
nav: 0,
|
|
212
|
+
navChange24h: 0,
|
|
213
|
+
navChangePercent24h: 0,
|
|
214
|
+
totalPnl: 0,
|
|
215
|
+
realizedPnl: 0,
|
|
216
|
+
unrealizedPnl: 0,
|
|
217
|
+
pnlToday: 0,
|
|
218
|
+
pnl7d: 0,
|
|
219
|
+
pnl30d: 0,
|
|
220
|
+
totalTrades: 0,
|
|
221
|
+
tradesToday: 0,
|
|
222
|
+
winRate: 0,
|
|
223
|
+
winCount: 0,
|
|
224
|
+
lossCount: 0,
|
|
225
|
+
avgWin: 0,
|
|
226
|
+
avgLoss: 0,
|
|
227
|
+
profitFactor: 0,
|
|
228
|
+
openPositions: 0,
|
|
229
|
+
totalExposure: 0,
|
|
230
|
+
avgLeverage: 0
|
|
231
|
+
};
|
|
232
|
+
function calculateRiskLevel(exposurePercent, drawdownPercent, dailyPnlPercent) {
|
|
233
|
+
const worstMetric = Math.max(exposurePercent, drawdownPercent, Math.abs(dailyPnlPercent));
|
|
234
|
+
if (worstMetric >= 90) return "critical";
|
|
235
|
+
if (worstMetric >= 70) return "high";
|
|
236
|
+
if (worstMetric >= 40) return "medium";
|
|
237
|
+
return "low";
|
|
238
|
+
}
|
|
239
|
+
function formatPnl(pnl) {
|
|
240
|
+
const sign = pnl >= 0 ? "+" : "";
|
|
241
|
+
if (Math.abs(pnl) >= 1e6) {
|
|
242
|
+
return `${sign}$${(pnl / 1e6).toFixed(2)}M`;
|
|
243
|
+
}
|
|
244
|
+
if (Math.abs(pnl) >= 1e3) {
|
|
245
|
+
return `${sign}$${(pnl / 1e3).toFixed(2)}K`;
|
|
246
|
+
}
|
|
247
|
+
return `${sign}$${pnl.toFixed(2)}`;
|
|
248
|
+
}
|
|
249
|
+
function formatPercent(value, showSign = true) {
|
|
250
|
+
const sign = showSign && value >= 0 ? "+" : "";
|
|
251
|
+
return `${sign}${value.toFixed(2)}%`;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
exports.AGENT_STATUS_COLORS = AGENT_STATUS_COLORS;
|
|
255
|
+
exports.AI_LOG_COLORS = AI_LOG_COLORS;
|
|
256
|
+
exports.DEFAULT_CONSOLE_METRICS = DEFAULT_CONSOLE_METRICS;
|
|
257
|
+
exports.DEFAULT_CONSOLE_OPTIONS = DEFAULT_CONSOLE_OPTIONS;
|
|
258
|
+
exports.DEFAULT_RISK_STATUS = DEFAULT_RISK_STATUS;
|
|
259
|
+
exports.FOREX_AGENT = FOREX_AGENT;
|
|
260
|
+
exports.FOREX_CAPITAL_SPLIT = FOREX_CAPITAL_SPLIT;
|
|
261
|
+
exports.FOREX_CURRENCY_PAIRS = FOREX_CURRENCY_PAIRS;
|
|
262
|
+
exports.FOREX_CYCLE_OPTIONS = FOREX_CYCLE_OPTIONS;
|
|
263
|
+
exports.FOREX_LOG_COLORS = FOREX_LOG_COLORS;
|
|
264
|
+
exports.FOREX_POOL_DEFAULTS = FOREX_POOL_DEFAULTS;
|
|
265
|
+
exports.ORDER_STATUS_CONFIG = ORDER_STATUS_CONFIG;
|
|
266
|
+
exports.PENALTY_TIERS = PENALTY_TIERS;
|
|
267
|
+
exports.RISK_LEVELS = RISK_LEVELS;
|
|
268
|
+
exports.RISK_LEVEL_COLORS = RISK_LEVEL_COLORS;
|
|
269
|
+
exports.STRATEGY_CATEGORIES = STRATEGY_CATEGORIES;
|
|
270
|
+
exports.TRADING_STATUS_COLORS = TRADING_STATUS_COLORS;
|
|
271
|
+
exports.calculateEarlyWithdrawalPenalty = calculateEarlyWithdrawalPenalty;
|
|
272
|
+
exports.calculateForexNetProfit = calculateForexNetProfit;
|
|
273
|
+
exports.calculateRiskLevel = calculateRiskLevel;
|
|
274
|
+
exports.computePoolAllocations = computePoolAllocations;
|
|
275
|
+
exports.estimateForexProfit = estimateForexProfit;
|
|
276
|
+
exports.formatPercent = formatPercent;
|
|
277
|
+
exports.formatPnl = formatPnl;
|
|
3
278
|
//# sourceMappingURL=index.js.map
|
|
4
279
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/types/forex.ts","../../src/types/aiTrading.ts","../../src/types/console.ts"],"names":[],"mappings":";;;AAOO,IAAM,mBAAA,GAAsB;AAAA,EACjC,YAAA,EAAc,GAAA;AAAA,EACd,cAAA,EAAgB;AAClB;AAEO,SAAS,uBAAuB,MAAA,EAMrC;AACA,EAAA,MAAM,iBAAA,GAAoB,SAAS,mBAAA,CAAoB,YAAA;AACvD,EAAA,MAAM,cAAA,GAAiB,SAAS,mBAAA,CAAoB,cAAA;AACpD,EAAA,OAAO;AAAA,IACL,cAAA;AAAA,IACA,iBAAA;AAAA,IACA,UAAU,iBAAA,GAAoB,GAAA;AAAA,IAC9B,SAAS,iBAAA,GAAoB,GAAA;AAAA,IAC7B,WAAW,iBAAA,GAAoB;AAAA,GACjC;AACF;AAWO,IAAM,mBAAA,GAA0C;AAAA,EACrD,EAAE,MAAM,EAAA,EAAK,OAAA,EAAS,KAAM,cAAA,EAAgB,GAAA,E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AA,CAAA,EAAA,CAAK,MAAM,GAAA,EAAM,OAAA,CAAQ,CAAC,CAAC,CAAA,CAAA,CAAA;AAAA,EAC3C;AACA,EAAA,OAAO,GAAG,IAAI,CAAA,CAAA,EAAI,GAAA,CAAI,OAAA,CAAQ,CAAC,CAAC,CAAA,CAAA;AAClC;AAEO,SAAS,aAAA,CAAc,KAAA,EAAe,QAAA,GAAW,IAAA,EAAc;AACpE,EAAA,MAAM,IAAA,GAAO,QAAA,IAAY,KAAA,IAAS,CAAA,GAAI,GAAA,GAAM,EAAA;AAC5C,EAAA,OAAO,GAAG,IAAI,CAAA,EAAG,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAC,CAAA,CAAA,CAAA;AACnC","file":"index.js","sourcesContent":["// ══════════════════════════════════════════════════════════════════════════════\n// ONE SDK - StableFX On-Chain Forex Types & Constants\n// Shared types for stablecoin foreign exchange pool trading\n// ══════════════════════════════════════════════════════════════════════════════\n\n// ── Capital Split ────────────────────────────────────────────────────────────\n\nexport const FOREX_CAPITAL_SPLIT = {\n poolReserves: 0.50,\n tradingCapital: 0.50,\n} as const;\n\nexport function computePoolAllocations(amount: number): {\n tradingCapital: number;\n totalPoolReserves: number;\n clearing: number;\n hedging: number;\n insurance: number;\n} {\n const totalPoolReserves = amount * FOREX_CAPITAL_SPLIT.poolReserves;\n const tradingCapital = amount * FOREX_CAPITAL_SPLIT.tradingCapital;\n return {\n tradingCapital,\n totalPoolReserves,\n clearing: totalPoolReserves * 0.50,\n hedging: totalPoolReserves * 0.30,\n insurance: totalPoolReserves * 0.20,\n };\n}\n\n// ── Cycle Options ────────────────────────────────────────────────────────────\n\nexport interface ForexCycleOption {\n days: number;\n feeRate: number;\n commissionRate: number;\n label: string;\n}\n\nexport const FOREX_CYCLE_OPTIONS: ForexCycleOption[] = [\n { days: 30, feeRate: 0.10, commissionRate: 0.60, label: '30D' },\n { days: 60, feeRate: 0.08, commissionRate: 0.70, label: '60D' },\n { days: 90, feeRate: 0.07, commissionRate: 0.75, label: '90D' },\n { days: 180, feeRate: 0.05, commissionRate: 0.85, label: '180D' },\n { days: 360, feeRate: 0.03, commissionRate: 0.90, label: '360D' },\n];\n\n// ── Currency Pairs ───────────────────────────────────────────────────────────\n\nexport interface ForexCurrencyPair {\n id: string;\n base: string;\n quote: string;\n symbol: string;\n flag: string;\n name: string;\n basePrice: number;\n pipSize: number;\n spreadPips: number;\n}\n\nexport const FOREX_CURRENCY_PAIRS: ForexCurrencyPair[] = [\n { id: 'USDC_EURC', base: 'USDC', quote: 'EURC', symbol: 'USDC/EURC', flag: '\\u{1F1EA}\\u{1F1FA}', name: 'Euro', basePrice: 0.9230, pipSize: 0.0001, spreadPips: 1.2 },\n { id: 'USDC_GBPC', base: 'USDC', quote: 'GBPC', symbol: 'USDC/GBPC', flag: '\\u{1F1EC}\\u{1F1E7}', name: 'British Pound', basePrice: 0.7890, pipSize: 0.0001, spreadPips: 1.5 },\n { id: 'USDC_JPYC', base: 'USDC', quote: 'JPYC', symbol: 'USDC/JPYC', flag: '\\u{1F1EF}\\u{1F1F5}', name: 'Japanese Yen', basePrice: 154.50, pipSize: 0.01, spreadPips: 1.0 },\n { id: 'USDC_AUDC', base: 'USDC', quote: 'AUDC', symbol: 'USDC/AUDC', flag: '\\u{1F1E6}\\u{1F1FA}', name: 'Australian Dollar', basePrice: 1.5380, pipSize: 0.0001, spreadPips: 1.8 },\n { id: 'USDC_CADC', base: 'USDC', quote: 'CADC', symbol: 'USDC/CADC', flag: '\\u{1F1E8}\\u{1F1E6}', name: 'Canadian Dollar', basePrice: 1.3640, pipSize: 0.0001, spreadPips: 1.5 },\n { id: 'USDC_CHFC', base: 'USDC', quote: 'CHFC', symbol: 'USDC/CHFC', flag: '\\u{1F1E8}\\u{1F1ED}', name: 'Swiss Franc', basePrice: 0.8750, pipSize: 0.0001, spreadPips: 1.3 },\n];\n\n// ── Pools ────────────────────────────────────────────────────────────────────\n\nexport type ForexPoolType = 'clearing' | 'hedging' | 'insurance';\n\nexport interface ForexPool {\n id: ForexPoolType;\n nameKey: string;\n descriptionKey: string;\n allocation: number;\n totalSize: number;\n utilization: number;\n color: string;\n apy7d: number;\n apy30d: number;\n netFlow24h: number;\n txCount24h: number;\n txCountTotal: number;\n totalDeposits: number;\n totalWithdrawals: number;\n profitDistributed: number;\n lastUpdated: number;\n}\n\nexport const FOREX_POOL_DEFAULTS: ForexPool[] = [\n { id: 'clearing', nameKey: 'forex.pool_clearing', descriptionKey: 'forex.pool_clearing_desc', allocation: 0.50, totalSize: 12500000, utilization: 0.78, color: '#3B82F6', apy7d: 12.8, apy30d: 11.5, netFlow24h: 185000, txCount24h: 42, txCountTotal: 12840, totalDeposits: 45200000, totalWithdrawals: 32700000, profitDistributed: 1850000, lastUpdated: Date.now() },\n { id: 'hedging', nameKey: 'forex.pool_hedging', descriptionKey: 'forex.pool_hedging_desc', allocation: 0.30, totalSize: 7500000, utilization: 0.65, color: '#F59E0B', apy7d: 8.1, apy30d: 7.6, netFlow24h: 72000, txCount24h: 24, txCountTotal: 7620, totalDeposits: 28500000, totalWithdrawals: 21000000, profitDistributed: 980000, lastUpdated: Date.now() },\n { id: 'insurance', nameKey: 'forex.pool_insurance', descriptionKey: 'forex.pool_insurance_desc', allocation: 0.20, totalSize: 5000000, utilization: 0.42, color: '#10B981', apy7d: 4.8, apy30d: 4.5, netFlow24h: 35000, txCount24h: 14, txCountTotal: 4280, totalDeposits: 15800000, totalWithdrawals: 10800000, profitDistributed: 520000, lastUpdated: Date.now() },\n];\n\n// ── Pool Transactions ────────────────────────────────────────────────────────\n\nexport type ForexPoolTransactionType =\n | 'deposit' | 'withdrawal' | 'profit_distribution'\n | 'loss_absorption' | 'inter_pool_transfer' | 'fee_collection' | 'reserve_rebalance';\n\nexport interface ForexPoolTransaction {\n id: string;\n poolId: ForexPoolType;\n type: ForexPoolTransactionType;\n amount: number;\n balanceBefore: number;\n balanceAfter: number;\n txHash: string;\n blockNumber: number;\n timestamp: number;\n description: string;\n}\n\n// ── Pool Daily Snapshots ────────────────────────────────────────────────────\n\nexport interface ForexPoolDailySnapshot {\n poolId: ForexPoolType;\n date: string;\n openBalance: number;\n closeBalance: number;\n deposits: number;\n withdrawals: number;\n netFlow: number;\n dailyPnl: number;\n dailyPnlPct: number;\n cumulativePnl: number;\n utilization: number;\n txCount: number;\n activeUsers: number;\n}\n\n// ── Positions ────────────────────────────────────────────────────────────────\n\nexport interface ForexPosition {\n id: string;\n pairId: string;\n side: 'BUY' | 'SELL';\n lots: number;\n pips: number;\n entryPrice: number;\n currentPrice: number;\n pnl: number;\n openTime: number;\n}\n\n// ── Investment ───────────────────────────────────────────────────────────────\n\nexport interface ForexInvestment {\n id: string;\n userId?: string;\n amount: number;\n currentValue: number;\n profit: number;\n status: 'active' | 'completed' | 'pending' | 'redeemed' | 'cancelled';\n selectedPairs: string[];\n cycleDays: number;\n cycleOption: ForexCycleOption;\n feeRate?: number;\n commissionRate?: number;\n startDate: string;\n endDate: string;\n tradingCapital: number;\n totalPoolReserves: number;\n poolAllocations: {\n clearing: number;\n hedging: number;\n insurance: number;\n };\n tradeWeight: number;\n totalLots: number;\n totalPips: number;\n totalTrades: number;\n positions: ForexPosition[];\n tradeHistory: ForexTradeRecord[];\n redeemedAt?: string;\n createdAt?: string;\n updatedAt?: string;\n}\n\n// ── Trade Records ────────────────────────────────────────────────────────────\n\nexport type ForexTradeStatus = 'RFQ' | 'QUOTED' | 'MATCHED' | 'SETTLED' | 'FAILED';\n\nexport interface ForexTradeRecord {\n id: string;\n timestamp: number;\n pairId: string;\n pairSymbol: string;\n side: 'BUY' | 'SELL';\n rfqPrice: number;\n quotePrice: number;\n matchPrice: number;\n settlePrice: number;\n lots: number;\n pips: number;\n pnl: number;\n status: ForexTradeStatus;\n pvpSettled: boolean;\n clearingFee?: number;\n hedgingCost?: number;\n insuranceReserve?: number;\n txHash?: string;\n blockNumber?: number;\n cycleDay?: number;\n cumulativePnl?: number;\n}\n\n// ── Console Log Types ────────────────────────────────────────────────────────\n\nexport type ForexLogType =\n | 'RFQ' | 'QUOTE' | 'MATCH' | 'SETTLE' | 'PVP'\n | 'HEDGE' | 'CLEAR' | 'POSITION' | 'PNL' | 'SYSTEM';\n\nexport interface ForexLogEntry {\n id: string;\n timestamp: number;\n type: ForexLogType;\n message: string;\n data?: Record<string, any>;\n importance: 'low' | 'medium' | 'high';\n pairId?: string;\n}\n\n// ── Agent ────────────────────────────────────────────────────────────────────\n\nexport interface ForexAgent {\n id: string;\n nameKey: string;\n descriptionKey: string;\n icon: string;\n color: string;\n supportedPairs: string[];\n dailyRoiMin: number;\n dailyRoiMax: number;\n totalManaged: number;\n totalUsers: number;\n winRate: number;\n}\n\nexport const FOREX_AGENT: ForexAgent = {\n id: 'stablefx-01',\n nameKey: 'forex.agent_name',\n descriptionKey: 'forex.agent_description',\n icon: '\\u{1F4B1}',\n color: '#0EA5E9',\n supportedPairs: FOREX_CURRENCY_PAIRS.map(p => p.id),\n dailyRoiMin: 0.002,\n dailyRoiMax: 0.005,\n totalManaged: 25000000,\n totalUsers: 3847,\n winRate: 72.5,\n};\n\n// ── Profit Calculation ───────────────────────────────────────────────────────\n\nexport function calculateForexNetProfit(\n grossProfit: number,\n cycleOption: ForexCycleOption,\n): { feeAmount: number; postFeeProfit: number; netProfit: number } {\n const feeAmount = grossProfit * cycleOption.feeRate;\n const postFeeProfit = grossProfit - feeAmount;\n const netProfit = postFeeProfit * cycleOption.commissionRate;\n return { feeAmount, postFeeProfit, netProfit };\n}\n\nexport function estimateForexProfit(\n amount: number,\n cycleDays: number,\n agent: ForexAgent = FOREX_AGENT,\n): { grossProfit: number; feeAmount: number; netProfit: number; dailyRate: number } {\n const cycleOption = FOREX_CYCLE_OPTIONS.find(c => c.days === cycleDays) || FOREX_CYCLE_OPTIONS[0];\n const estimatedApy = ((agent.dailyRoiMin + agent.dailyRoiMax) / 2) * 365 * 100;\n const dailyRate = estimatedApy / 100 / 365;\n const grossProfit = amount * dailyRate * cycleDays;\n const { feeAmount, netProfit } = calculateForexNetProfit(grossProfit, cycleOption);\n return { grossProfit, feeAmount, netProfit, dailyRate };\n}\n","// ══════════════════════════════════════════════════════════════════════════════\n// ONE SDK - AI Trading Types & Constants\n// Shared types for AI-powered crypto trading strategies\n// ══════════════════════════════════════════════════════════════════════════════\n\nexport type StrategyCategory = 'conservative' | 'balanced' | 'aggressive' | 'hedge' | 'arbitrage' | 'trend' | 'grid' | 'dca';\nexport type OrderStatus = 'pending' | 'active' | 'paused' | 'completed' | 'cancelled' | 'pending_redemption' | 'redeemed';\nexport type TradeAction = 'buy' | 'sell' | 'long' | 'short' | 'close_long' | 'close_short';\nexport type TradeStatus = 'open' | 'closed' | 'liquidated' | 'cancelled';\nexport type FeeType = 'management' | 'performance' | 'withdrawal' | 'early_redemption_penalty';\nexport type OrderEventType = 'created' | 'activated' | 'paused' | 'resumed' | 'redemption_requested' | 'redeemed' | 'cancelled' | 'fee_deducted' | 'profit_realized';\n\nexport interface AIStrategyConfig {\n id: string;\n name: string;\n description: string | null;\n category: StrategyCategory;\n riskLevel: 1 | 2 | 3 | 4 | 5;\n minInvestment: number;\n maxInvestment: number | null;\n lockPeriodDays: number;\n expectedApyMin: number | null;\n expectedApyMax: number | null;\n managementFeeRate: number;\n performanceFeeRate: number;\n supportedPairs: string[];\n supportedChains: string[];\n supportedCurrencies: string[];\n leverageMin: number;\n leverageMax: number;\n isActive: boolean;\n}\n\nexport interface AIOrderCreateInput {\n strategyId: string;\n amount: number;\n currency: string;\n chain: string;\n lockPeriodDays: number;\n}\n\nexport interface AIOrderSummary {\n orderId: string;\n strategyId: string;\n strategyName: string;\n amount: number;\n currentValue: number;\n profit: number;\n profitPercent: number;\n status: OrderStatus;\n daysRemaining: number;\n lockProgress: number;\n}\n\nexport interface AIPortfolioSummary {\n totalInvested: number;\n totalValue: number;\n totalProfit: number;\n totalProfitPercent: number;\n activeOrders: number;\n totalTrades: number;\n profitToday: number;\n profit7d: number;\n profit30d: number;\n}\n\nexport interface AITradeLog {\n id: string;\n timestamp: string;\n action: TradeAction;\n pair: string;\n entryPrice: number;\n exitPrice: number | null;\n amount: number;\n pnl: number;\n pnlPercent: number;\n leverage: number;\n status: TradeStatus;\n aiConfidence: number | null;\n aiReasoning: string | null;\n}\n\nexport interface AIPenaltyCalculation {\n completionRate: number;\n penaltyRate: number;\n estimatedPenalty: number;\n estimatedRedemption: number;\n isEarlyWithdrawal: boolean;\n}\n\nexport interface AIPerformanceChart {\n date: string;\n nav: number;\n dailyPnl: number;\n cumulativePnl: number;\n}\n\nexport const PENALTY_TIERS = [\n { minProgress: 0.75, maxProgress: 1.0, rate: 0.50, label: '50%' },\n { minProgress: 0.50, maxProgress: 0.75, rate: 0.60, label: '60%' },\n { minProgress: 0.25, maxProgress: 0.50, rate: 0.70, label: '70%' },\n { minProgress: 0.00, maxProgress: 0.25, rate: 0.80, label: '80%' },\n] as const;\n\nexport function calculateEarlyWithdrawalPenalty(\n investedAmount: number,\n profit: number,\n lockProgress: number,\n): AIPenaltyCalculation {\n const totalValue = investedAmount + profit;\n const isEarlyWithdrawal = lockProgress < 1.0;\n let penaltyRate = 0;\n if (isEarlyWithdrawal) {\n if (lockProgress >= 0.75) penaltyRate = 0.50;\n else if (lockProgress >= 0.50) penaltyRate = 0.60;\n else if (lockProgress >= 0.25) penaltyRate = 0.70;\n else penaltyRate = 0.80;\n }\n const estimatedPenalty = totalValue * penaltyRate;\n const estimatedRedemption = totalValue - estimatedPenalty;\n return { completionRate: lockProgress, penaltyRate, estimatedPenalty, estimatedRedemption, isEarlyWithdrawal };\n}\n\nexport const STRATEGY_CATEGORIES: Record<StrategyCategory, { labelKey: string; color: string; icon: string }> = {\n conservative: { labelKey: 'ai.category_conservative', color: '#10B981', icon: '\\u{1F6E1}\\u{FE0F}' },\n balanced: { labelKey: 'ai.category_balanced', color: '#3B82F6', icon: '\\u{2696}\\u{FE0F}' },\n aggressive: { labelKey: 'ai.category_aggressive', color: '#EF4444', icon: '\\u{1F680}' },\n hedge: { labelKey: 'ai.category_hedge', color: '#8B5CF6', icon: '\\u{1F512}' },\n arbitrage: { labelKey: 'ai.category_arbitrage', color: '#F59E0B', icon: '\\u{26A1}' },\n trend: { labelKey: 'ai.category_trend', color: '#EC4899', icon: '\\u{1F4C8}' },\n grid: { labelKey: 'ai.category_grid', color: '#6366F1', icon: '\\u{25A6}' },\n dca: { labelKey: 'ai.category_dca', color: '#14B8A6', icon: '\\u{1F4CA}' },\n};\n\nexport const RISK_LEVELS: Record<number, { labelKey: string; color: string; bgColor: string }> = {\n 1: { labelKey: 'ai.risk_very_low', color: '#10B981', bgColor: '#D1FAE5' },\n 2: { labelKey: 'ai.risk_low', color: '#22C55E', bgColor: '#DCFCE7' },\n 3: { labelKey: 'ai.risk_medium', color: '#F59E0B', bgColor: '#FEF3C7' },\n 4: { labelKey: 'ai.risk_high', color: '#F97316', bgColor: '#FFEDD5' },\n 5: { labelKey: 'ai.risk_very_high', color: '#EF4444', bgColor: '#FEE2E2' },\n};\n\nexport const ORDER_STATUS_CONFIG: Record<OrderStatus, { labelKey: string; color: string; bgColor: string }> = {\n pending: { labelKey: 'ai.status_pending', color: '#F59E0B', bgColor: '#FEF3C7' },\n active: { labelKey: 'ai.status_active', color: '#10B981', bgColor: '#D1FAE5' },\n paused: { labelKey: 'ai.status_paused', color: '#6B7280', bgColor: '#F3F4F6' },\n completed: { labelKey: 'ai.status_completed', color: '#3B82F6', bgColor: '#DBEAFE' },\n cancelled: { labelKey: 'ai.status_cancelled', color: '#EF4444', bgColor: '#FEE2E2' },\n pending_redemption: { labelKey: 'ai.status_pending_redemption', color: '#8B5CF6', bgColor: '#EDE9FE' },\n redeemed: { labelKey: 'ai.status_redeemed', color: '#14B8A6', bgColor: '#CCFBF1' },\n};\n","// ══════════════════════════════════════════════════════════════════════════════\n// ONE SDK - Trading Console Types & Constants\n// Shared types for real-time trading console components\n// ══════════════════════════════════════════════════════════════════════════════\n\nimport type { BotLogEntry, BotState, StrategyPersonality } from '../services/forex/BotSimulationEngine';\nimport type { ForexLogEntry, ForexPoolTransaction, ForexLogType } from './forex';\n\n// ── Re-exports for convenience ────────────────────────────────────────────────\n\nexport type { BotLogEntry, BotLogType, BotState, IndicatorSnapshot, StrategyPersonality } from '../services/forex/BotSimulationEngine';\n\n// ── Console Log Types ─────────────────────────────────────────────────────────\n\nexport type AILogType =\n | 'SCAN' | 'THINKING' | 'INDICATOR' | 'ANALYSIS' | 'SIGNAL'\n | 'STRATEGY' | 'DECISION' | 'ORDER' | 'FILLED' | 'PNL'\n | 'RISK' | 'NEWS' | 'SYSTEM';\n\nexport const AI_LOG_COLORS: Record<AILogType, string> = {\n SCAN: '#06B6D4', // Cyan\n THINKING: '#A855F7', // Purple\n INDICATOR: '#3B82F6', // Blue\n ANALYSIS: '#6366F1', // Indigo\n SIGNAL: '#F59E0B', // Amber\n STRATEGY: '#D946EF', // Fuchsia\n DECISION: '#F97316', // Orange\n ORDER: '#EC4899', // Pink\n FILLED: '#10B981', // Green\n PNL: '#22C55E', // Emerald\n RISK: '#EF4444', // Red\n NEWS: '#14B8A6', // Teal\n SYSTEM: '#9CA3AF', // Gray\n};\n\n// Forex log type colors (for ForexSimulationEngine logs)\nexport const FOREX_LOG_COLORS: Record<ForexLogType, string> = {\n RFQ: '#06B6D4', // Cyan\n QUOTE: '#8B5CF6', // Purple\n MATCH: '#10B981', // Green\n SETTLE: '#F59E0B', // Amber\n PVP: '#3B82F6', // Blue\n HEDGE: '#EC4899', // Pink\n CLEAR: '#14B8A6', // Teal\n POSITION: '#6366F1', // Indigo\n PNL: '#22C55E', // Emerald\n SYSTEM: '#9CA3AF', // Gray\n};\n\n// ── AI Position Types ─────────────────────────────────────────────────────────\n\nexport type PositionSide = 'LONG' | 'SHORT';\nexport type PositionStatus = 'open' | 'closed' | 'liquidated' | 'pending';\n\nexport interface AIPosition {\n id: string;\n strategyId: string;\n strategyName: string;\n pair: string;\n side: PositionSide;\n entryPrice: number;\n currentPrice: number;\n size: number;\n leverage: number;\n margin: number;\n pnl: number;\n pnlPercent: number;\n status: PositionStatus;\n stopLoss?: number;\n takeProfit?: number;\n liquidationPrice?: number;\n openTime: number;\n closeTime?: number;\n chain?: string;\n orderId?: string;\n aiConfidence?: number;\n aiReasoning?: string;\n}\n\n// ── AI Decision Types ─────────────────────────────────────────────────────────\n\nexport type DecisionAction = 'OPEN_LONG' | 'OPEN_SHORT' | 'CLOSE_LONG' | 'CLOSE_SHORT' | 'HOLD' | 'SKIP';\n\nexport interface AIDecision {\n id: string;\n timestamp: number;\n strategyId: string;\n strategyName: string;\n pair: string;\n action: DecisionAction;\n confidence: number;\n reasoning: string;\n indicators: {\n rsi?: number;\n macd?: number;\n ema?: string;\n volume?: number;\n bollinger?: string;\n };\n signals: string[];\n executed: boolean;\n positionId?: string;\n price?: number;\n size?: number;\n leverage?: number;\n}\n\n// ── Risk Status Types ─────────────────────────────────────────────────────────\n\nexport type RiskLevel = 'low' | 'medium' | 'high' | 'critical';\nexport type TradingStatus = 'active' | 'paused' | 'stopped' | 'cooldown';\n\nexport interface RiskStatus {\n timestamp: number;\n // Portfolio exposure\n totalExposure: number;\n maxExposure: number;\n exposurePercent: number;\n // Daily limits\n dailyPnl: number;\n dailyPnlLimit: number;\n dailyPnlPercent: number;\n dailyTradeCount: number;\n dailyTradeLimit: number;\n // Drawdown\n currentDrawdown: number;\n maxDrawdown: number;\n drawdownPercent: number;\n // Position limits\n openPositions: number;\n maxPositions: number;\n // Risk assessment\n riskLevel: RiskLevel;\n tradingStatus: TradingStatus;\n warnings: string[];\n // Per-strategy risk\n strategyRisks?: Record<string, {\n exposure: number;\n drawdown: number;\n riskLevel: RiskLevel;\n }>;\n}\n\nexport const RISK_LEVEL_COLORS: Record<RiskLevel, { color: string; bgColor: string }> = {\n low: { color: '#10B981', bgColor: '#D1FAE5' },\n medium: { color: '#F59E0B', bgColor: '#FEF3C7' },\n high: { color: '#F97316', bgColor: '#FFEDD5' },\n critical: { color: '#EF4444', bgColor: '#FEE2E2' },\n};\n\nexport const TRADING_STATUS_COLORS: Record<TradingStatus, { color: string; bgColor: string }> = {\n active: { color: '#10B981', bgColor: '#D1FAE5' },\n paused: { color: '#F59E0B', bgColor: '#FEF3C7' },\n stopped: { color: '#EF4444', bgColor: '#FEE2E2' },\n cooldown: { color: '#6366F1', bgColor: '#E0E7FF' },\n};\n\n// ── Console Metrics Types ─────────────────────────────────────────────────────\n\nexport interface ConsoleMetrics {\n // NAV & Performance\n nav: number;\n navChange24h: number;\n navChangePercent24h: number;\n // P&L\n totalPnl: number;\n realizedPnl: number;\n unrealizedPnl: number;\n pnlToday: number;\n pnl7d: number;\n pnl30d: number;\n // Trading stats\n totalTrades: number;\n tradesToday: number;\n winRate: number;\n winCount: number;\n lossCount: number;\n avgWin: number;\n avgLoss: number;\n profitFactor: number;\n // Position stats\n openPositions: number;\n totalExposure: number;\n avgLeverage: number;\n // By strategy\n strategyMetrics?: Record<string, {\n pnl: number;\n trades: number;\n winRate: number;\n exposure: number;\n }>;\n}\n\n// ── Agent Types ───────────────────────────────────────────────────────────────\n\nexport type AgentStatus = 'active' | 'paused' | 'idle' | 'error' | 'initializing';\n\nexport interface AIAgent {\n id: string;\n strategyId: string;\n name: string;\n shortName: string;\n color: string;\n status: AgentStatus;\n // Performance\n totalPnl: number;\n pnlToday: number;\n winRate: number;\n totalTrades: number;\n tradesToday: number;\n // Current state\n currentPair?: string;\n currentPrice?: number;\n lastSignal?: string;\n lastSignalConfidence?: number;\n lastActivity?: number;\n // Positions\n openPositions: number;\n totalExposure: number;\n // Risk\n riskLevel: RiskLevel;\n drawdown: number;\n // Config\n riskTolerance: 'low' | 'medium' | 'high';\n primaryIndicators: string[];\n preferredPairs: string[];\n leverageRange: [number, number];\n}\n\nexport const AGENT_STATUS_COLORS: Record<AgentStatus, { color: string; bgColor: string; label: string }> = {\n active: { color: '#10B981', bgColor: '#D1FAE5', label: 'Active' },\n paused: { color: '#F59E0B', bgColor: '#FEF3C7', label: 'Paused' },\n idle: { color: '#6B7280', bgColor: '#F3F4F6', label: 'Idle' },\n error: { color: '#EF4444', bgColor: '#FEE2E2', label: 'Error' },\n initializing: { color: '#3B82F6', bgColor: '#DBEAFE', label: 'Starting' },\n};\n\n// ── Combined Console State ────────────────────────────────────────────────────\n\nexport interface CombinedLogEntry {\n id: string;\n timestamp: number;\n source: 'ai' | 'forex';\n strategyId?: string;\n strategyName?: string;\n type: string;\n message: string;\n data?: Record<string, any>;\n importance: 'low' | 'medium' | 'high';\n}\n\nexport interface TradingConsoleState {\n ai: {\n strategies: StrategyPersonality[];\n agents: AIAgent[];\n positions: AIPosition[];\n decisions: AIDecision[];\n riskStatus: RiskStatus | null;\n simulationLogs: BotLogEntry[];\n botStates: Map<string, BotState>;\n };\n forex: {\n logs: ForexLogEntry[];\n poolTransactions: ForexPoolTransaction[];\n stats: {\n totalPnl: number;\n totalTrades: number;\n totalPips: number;\n totalLots: number;\n };\n };\n metrics: ConsoleMetrics;\n combinedLogs: CombinedLogEntry[];\n}\n\n// ── Hook Options ──────────────────────────────────────────────────────────────\n\nexport interface TradingConsoleOptions {\n simulation?: boolean;\n pollInterval?: number;\n maxLogs?: number;\n strategyIds?: string[];\n autoStart?: boolean;\n}\n\nexport interface AIQuantConsoleOptions {\n strategyIds?: string[];\n pollInterval?: number;\n simulation?: boolean;\n maxLogs?: number;\n}\n\nexport interface AgentConsoleOptions {\n strategyId: string;\n pollInterval?: number;\n simulation?: boolean;\n maxLogs?: number;\n}\n\n// ── Default Values ────────────────────────────────────────────────────────────\n\nexport const DEFAULT_CONSOLE_OPTIONS: TradingConsoleOptions = {\n simulation: true,\n pollInterval: 5000,\n maxLogs: 500,\n autoStart: false,\n};\n\nexport const DEFAULT_RISK_STATUS: RiskStatus = {\n timestamp: Date.now(),\n totalExposure: 0,\n maxExposure: 100000,\n exposurePercent: 0,\n dailyPnl: 0,\n dailyPnlLimit: 5000,\n dailyPnlPercent: 0,\n dailyTradeCount: 0,\n dailyTradeLimit: 50,\n currentDrawdown: 0,\n maxDrawdown: 15,\n drawdownPercent: 0,\n openPositions: 0,\n maxPositions: 10,\n riskLevel: 'low',\n tradingStatus: 'active',\n warnings: [],\n};\n\nexport const DEFAULT_CONSOLE_METRICS: ConsoleMetrics = {\n nav: 0,\n navChange24h: 0,\n navChangePercent24h: 0,\n totalPnl: 0,\n realizedPnl: 0,\n unrealizedPnl: 0,\n pnlToday: 0,\n pnl7d: 0,\n pnl30d: 0,\n totalTrades: 0,\n tradesToday: 0,\n winRate: 0,\n winCount: 0,\n lossCount: 0,\n avgWin: 0,\n avgLoss: 0,\n profitFactor: 0,\n openPositions: 0,\n totalExposure: 0,\n avgLeverage: 0,\n};\n\n// ── Utility Functions ─────────────────────────────────────────────────────────\n\nexport function calculateRiskLevel(\n exposurePercent: number,\n drawdownPercent: number,\n dailyPnlPercent: number\n): RiskLevel {\n const worstMetric = Math.max(exposurePercent, drawdownPercent, Math.abs(dailyPnlPercent));\n if (worstMetric >= 90) return 'critical';\n if (worstMetric >= 70) return 'high';\n if (worstMetric >= 40) return 'medium';\n return 'low';\n}\n\nexport function formatPnl(pnl: number): string {\n const sign = pnl >= 0 ? '+' : '';\n if (Math.abs(pnl) >= 1000000) {\n return `${sign}$${(pnl / 1000000).toFixed(2)}M`;\n }\n if (Math.abs(pnl) >= 1000) {\n return `${sign}$${(pnl / 1000).toFixed(2)}K`;\n }\n return `${sign}$${pnl.toFixed(2)}`;\n}\n\nexport function formatPercent(value: number, showSign = true): string {\n const sign = showSign && value >= 0 ? '+' : '';\n return `${sign}${value.toFixed(2)}%`;\n}\n"]}
|
package/dist/types/index.mjs
CHANGED
|
@@ -1,3 +1,254 @@
|
|
|
1
|
+
// src/types/forex.ts
|
|
2
|
+
var FOREX_CAPITAL_SPLIT = {
|
|
3
|
+
poolReserves: 0.5,
|
|
4
|
+
tradingCapital: 0.5
|
|
5
|
+
};
|
|
6
|
+
function computePoolAllocations(amount) {
|
|
7
|
+
const totalPoolReserves = amount * FOREX_CAPITAL_SPLIT.poolReserves;
|
|
8
|
+
const tradingCapital = amount * FOREX_CAPITAL_SPLIT.tradingCapital;
|
|
9
|
+
return {
|
|
10
|
+
tradingCapital,
|
|
11
|
+
totalPoolReserves,
|
|
12
|
+
clearing: totalPoolReserves * 0.5,
|
|
13
|
+
hedging: totalPoolReserves * 0.3,
|
|
14
|
+
insurance: totalPoolReserves * 0.2
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
var FOREX_CYCLE_OPTIONS = [
|
|
18
|
+
{ days: 30, feeRate: 0.1, commissionRate: 0.6, label: "30D" },
|
|
19
|
+
{ days: 60, feeRate: 0.08, commissionRate: 0.7, label: "60D" },
|
|
20
|
+
{ days: 90, feeRate: 0.07, commissionRate: 0.75, label: "90D" },
|
|
21
|
+
{ days: 180, feeRate: 0.05, commissionRate: 0.85, label: "180D" },
|
|
22
|
+
{ days: 360, feeRate: 0.03, commissionRate: 0.9, label: "360D" }
|
|
23
|
+
];
|
|
24
|
+
var FOREX_CURRENCY_PAIRS = [
|
|
25
|
+
{ id: "USDC_EURC", base: "USDC", quote: "EURC", symbol: "USDC/EURC", flag: "\u{1F1EA}\u{1F1FA}", name: "Euro", basePrice: 0.923, pipSize: 1e-4, spreadPips: 1.2 },
|
|
26
|
+
{ id: "USDC_GBPC", base: "USDC", quote: "GBPC", symbol: "USDC/GBPC", flag: "\u{1F1EC}\u{1F1E7}", name: "British Pound", basePrice: 0.789, pipSize: 1e-4, spreadPips: 1.5 },
|
|
27
|
+
{ id: "USDC_JPYC", base: "USDC", quote: "JPYC", symbol: "USDC/JPYC", flag: "\u{1F1EF}\u{1F1F5}", name: "Japanese Yen", basePrice: 154.5, pipSize: 0.01, spreadPips: 1 },
|
|
28
|
+
{ id: "USDC_AUDC", base: "USDC", quote: "AUDC", symbol: "USDC/AUDC", flag: "\u{1F1E6}\u{1F1FA}", name: "Australian Dollar", basePrice: 1.538, pipSize: 1e-4, spreadPips: 1.8 },
|
|
29
|
+
{ id: "USDC_CADC", base: "USDC", quote: "CADC", symbol: "USDC/CADC", flag: "\u{1F1E8}\u{1F1E6}", name: "Canadian Dollar", basePrice: 1.364, pipSize: 1e-4, spreadPips: 1.5 },
|
|
30
|
+
{ id: "USDC_CHFC", base: "USDC", quote: "CHFC", symbol: "USDC/CHFC", flag: "\u{1F1E8}\u{1F1ED}", name: "Swiss Franc", basePrice: 0.875, pipSize: 1e-4, spreadPips: 1.3 }
|
|
31
|
+
];
|
|
32
|
+
var FOREX_POOL_DEFAULTS = [
|
|
33
|
+
{ id: "clearing", nameKey: "forex.pool_clearing", descriptionKey: "forex.pool_clearing_desc", allocation: 0.5, totalSize: 125e5, utilization: 0.78, color: "#3B82F6", apy7d: 12.8, apy30d: 11.5, netFlow24h: 185e3, txCount24h: 42, txCountTotal: 12840, totalDeposits: 452e5, totalWithdrawals: 327e5, profitDistributed: 185e4, lastUpdated: Date.now() },
|
|
34
|
+
{ id: "hedging", nameKey: "forex.pool_hedging", descriptionKey: "forex.pool_hedging_desc", allocation: 0.3, totalSize: 75e5, utilization: 0.65, color: "#F59E0B", apy7d: 8.1, apy30d: 7.6, netFlow24h: 72e3, txCount24h: 24, txCountTotal: 7620, totalDeposits: 285e5, totalWithdrawals: 21e6, profitDistributed: 98e4, lastUpdated: Date.now() },
|
|
35
|
+
{ id: "insurance", nameKey: "forex.pool_insurance", descriptionKey: "forex.pool_insurance_desc", allocation: 0.2, totalSize: 5e6, utilization: 0.42, color: "#10B981", apy7d: 4.8, apy30d: 4.5, netFlow24h: 35e3, txCount24h: 14, txCountTotal: 4280, totalDeposits: 158e5, totalWithdrawals: 108e5, profitDistributed: 52e4, lastUpdated: Date.now() }
|
|
36
|
+
];
|
|
37
|
+
var FOREX_AGENT = {
|
|
38
|
+
id: "stablefx-01",
|
|
39
|
+
nameKey: "forex.agent_name",
|
|
40
|
+
descriptionKey: "forex.agent_description",
|
|
41
|
+
icon: "\u{1F4B1}",
|
|
42
|
+
color: "#0EA5E9",
|
|
43
|
+
supportedPairs: FOREX_CURRENCY_PAIRS.map((p) => p.id),
|
|
44
|
+
dailyRoiMin: 2e-3,
|
|
45
|
+
dailyRoiMax: 5e-3,
|
|
46
|
+
totalManaged: 25e6,
|
|
47
|
+
totalUsers: 3847,
|
|
48
|
+
winRate: 72.5
|
|
49
|
+
};
|
|
50
|
+
function calculateForexNetProfit(grossProfit, cycleOption) {
|
|
51
|
+
const feeAmount = grossProfit * cycleOption.feeRate;
|
|
52
|
+
const postFeeProfit = grossProfit - feeAmount;
|
|
53
|
+
const netProfit = postFeeProfit * cycleOption.commissionRate;
|
|
54
|
+
return { feeAmount, postFeeProfit, netProfit };
|
|
55
|
+
}
|
|
56
|
+
function estimateForexProfit(amount, cycleDays, agent = FOREX_AGENT) {
|
|
57
|
+
const cycleOption = FOREX_CYCLE_OPTIONS.find((c) => c.days === cycleDays) || FOREX_CYCLE_OPTIONS[0];
|
|
58
|
+
const estimatedApy = (agent.dailyRoiMin + agent.dailyRoiMax) / 2 * 365 * 100;
|
|
59
|
+
const dailyRate = estimatedApy / 100 / 365;
|
|
60
|
+
const grossProfit = amount * dailyRate * cycleDays;
|
|
61
|
+
const { feeAmount, netProfit } = calculateForexNetProfit(grossProfit, cycleOption);
|
|
62
|
+
return { grossProfit, feeAmount, netProfit, dailyRate };
|
|
63
|
+
}
|
|
1
64
|
|
|
65
|
+
// src/types/aiTrading.ts
|
|
66
|
+
var PENALTY_TIERS = [
|
|
67
|
+
{ minProgress: 0.75, maxProgress: 1, rate: 0.5, label: "50%" },
|
|
68
|
+
{ minProgress: 0.5, maxProgress: 0.75, rate: 0.6, label: "60%" },
|
|
69
|
+
{ minProgress: 0.25, maxProgress: 0.5, rate: 0.7, label: "70%" },
|
|
70
|
+
{ minProgress: 0, maxProgress: 0.25, rate: 0.8, label: "80%" }
|
|
71
|
+
];
|
|
72
|
+
function calculateEarlyWithdrawalPenalty(investedAmount, profit, lockProgress) {
|
|
73
|
+
const totalValue = investedAmount + profit;
|
|
74
|
+
const isEarlyWithdrawal = lockProgress < 1;
|
|
75
|
+
let penaltyRate = 0;
|
|
76
|
+
if (isEarlyWithdrawal) {
|
|
77
|
+
if (lockProgress >= 0.75) penaltyRate = 0.5;
|
|
78
|
+
else if (lockProgress >= 0.5) penaltyRate = 0.6;
|
|
79
|
+
else if (lockProgress >= 0.25) penaltyRate = 0.7;
|
|
80
|
+
else penaltyRate = 0.8;
|
|
81
|
+
}
|
|
82
|
+
const estimatedPenalty = totalValue * penaltyRate;
|
|
83
|
+
const estimatedRedemption = totalValue - estimatedPenalty;
|
|
84
|
+
return { completionRate: lockProgress, penaltyRate, estimatedPenalty, estimatedRedemption, isEarlyWithdrawal };
|
|
85
|
+
}
|
|
86
|
+
var STRATEGY_CATEGORIES = {
|
|
87
|
+
conservative: { labelKey: "ai.category_conservative", color: "#10B981", icon: "\u{1F6E1}\uFE0F" },
|
|
88
|
+
balanced: { labelKey: "ai.category_balanced", color: "#3B82F6", icon: "\u2696\uFE0F" },
|
|
89
|
+
aggressive: { labelKey: "ai.category_aggressive", color: "#EF4444", icon: "\u{1F680}" },
|
|
90
|
+
hedge: { labelKey: "ai.category_hedge", color: "#8B5CF6", icon: "\u{1F512}" },
|
|
91
|
+
arbitrage: { labelKey: "ai.category_arbitrage", color: "#F59E0B", icon: "\u26A1" },
|
|
92
|
+
trend: { labelKey: "ai.category_trend", color: "#EC4899", icon: "\u{1F4C8}" },
|
|
93
|
+
grid: { labelKey: "ai.category_grid", color: "#6366F1", icon: "\u25A6" },
|
|
94
|
+
dca: { labelKey: "ai.category_dca", color: "#14B8A6", icon: "\u{1F4CA}" }
|
|
95
|
+
};
|
|
96
|
+
var RISK_LEVELS = {
|
|
97
|
+
1: { labelKey: "ai.risk_very_low", color: "#10B981", bgColor: "#D1FAE5" },
|
|
98
|
+
2: { labelKey: "ai.risk_low", color: "#22C55E", bgColor: "#DCFCE7" },
|
|
99
|
+
3: { labelKey: "ai.risk_medium", color: "#F59E0B", bgColor: "#FEF3C7" },
|
|
100
|
+
4: { labelKey: "ai.risk_high", color: "#F97316", bgColor: "#FFEDD5" },
|
|
101
|
+
5: { labelKey: "ai.risk_very_high", color: "#EF4444", bgColor: "#FEE2E2" }
|
|
102
|
+
};
|
|
103
|
+
var ORDER_STATUS_CONFIG = {
|
|
104
|
+
pending: { labelKey: "ai.status_pending", color: "#F59E0B", bgColor: "#FEF3C7" },
|
|
105
|
+
active: { labelKey: "ai.status_active", color: "#10B981", bgColor: "#D1FAE5" },
|
|
106
|
+
paused: { labelKey: "ai.status_paused", color: "#6B7280", bgColor: "#F3F4F6" },
|
|
107
|
+
completed: { labelKey: "ai.status_completed", color: "#3B82F6", bgColor: "#DBEAFE" },
|
|
108
|
+
cancelled: { labelKey: "ai.status_cancelled", color: "#EF4444", bgColor: "#FEE2E2" },
|
|
109
|
+
pending_redemption: { labelKey: "ai.status_pending_redemption", color: "#8B5CF6", bgColor: "#EDE9FE" },
|
|
110
|
+
redeemed: { labelKey: "ai.status_redeemed", color: "#14B8A6", bgColor: "#CCFBF1" }
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// src/types/console.ts
|
|
114
|
+
var AI_LOG_COLORS = {
|
|
115
|
+
SCAN: "#06B6D4",
|
|
116
|
+
// Cyan
|
|
117
|
+
THINKING: "#A855F7",
|
|
118
|
+
// Purple
|
|
119
|
+
INDICATOR: "#3B82F6",
|
|
120
|
+
// Blue
|
|
121
|
+
ANALYSIS: "#6366F1",
|
|
122
|
+
// Indigo
|
|
123
|
+
SIGNAL: "#F59E0B",
|
|
124
|
+
// Amber
|
|
125
|
+
STRATEGY: "#D946EF",
|
|
126
|
+
// Fuchsia
|
|
127
|
+
DECISION: "#F97316",
|
|
128
|
+
// Orange
|
|
129
|
+
ORDER: "#EC4899",
|
|
130
|
+
// Pink
|
|
131
|
+
FILLED: "#10B981",
|
|
132
|
+
// Green
|
|
133
|
+
PNL: "#22C55E",
|
|
134
|
+
// Emerald
|
|
135
|
+
RISK: "#EF4444",
|
|
136
|
+
// Red
|
|
137
|
+
NEWS: "#14B8A6",
|
|
138
|
+
// Teal
|
|
139
|
+
SYSTEM: "#9CA3AF"
|
|
140
|
+
// Gray
|
|
141
|
+
};
|
|
142
|
+
var FOREX_LOG_COLORS = {
|
|
143
|
+
RFQ: "#06B6D4",
|
|
144
|
+
// Cyan
|
|
145
|
+
QUOTE: "#8B5CF6",
|
|
146
|
+
// Purple
|
|
147
|
+
MATCH: "#10B981",
|
|
148
|
+
// Green
|
|
149
|
+
SETTLE: "#F59E0B",
|
|
150
|
+
// Amber
|
|
151
|
+
PVP: "#3B82F6",
|
|
152
|
+
// Blue
|
|
153
|
+
HEDGE: "#EC4899",
|
|
154
|
+
// Pink
|
|
155
|
+
CLEAR: "#14B8A6",
|
|
156
|
+
// Teal
|
|
157
|
+
POSITION: "#6366F1",
|
|
158
|
+
// Indigo
|
|
159
|
+
PNL: "#22C55E",
|
|
160
|
+
// Emerald
|
|
161
|
+
SYSTEM: "#9CA3AF"
|
|
162
|
+
// Gray
|
|
163
|
+
};
|
|
164
|
+
var RISK_LEVEL_COLORS = {
|
|
165
|
+
low: { color: "#10B981", bgColor: "#D1FAE5" },
|
|
166
|
+
medium: { color: "#F59E0B", bgColor: "#FEF3C7" },
|
|
167
|
+
high: { color: "#F97316", bgColor: "#FFEDD5" },
|
|
168
|
+
critical: { color: "#EF4444", bgColor: "#FEE2E2" }
|
|
169
|
+
};
|
|
170
|
+
var TRADING_STATUS_COLORS = {
|
|
171
|
+
active: { color: "#10B981", bgColor: "#D1FAE5" },
|
|
172
|
+
paused: { color: "#F59E0B", bgColor: "#FEF3C7" },
|
|
173
|
+
stopped: { color: "#EF4444", bgColor: "#FEE2E2" },
|
|
174
|
+
cooldown: { color: "#6366F1", bgColor: "#E0E7FF" }
|
|
175
|
+
};
|
|
176
|
+
var AGENT_STATUS_COLORS = {
|
|
177
|
+
active: { color: "#10B981", bgColor: "#D1FAE5", label: "Active" },
|
|
178
|
+
paused: { color: "#F59E0B", bgColor: "#FEF3C7", label: "Paused" },
|
|
179
|
+
idle: { color: "#6B7280", bgColor: "#F3F4F6", label: "Idle" },
|
|
180
|
+
error: { color: "#EF4444", bgColor: "#FEE2E2", label: "Error" },
|
|
181
|
+
initializing: { color: "#3B82F6", bgColor: "#DBEAFE", label: "Starting" }
|
|
182
|
+
};
|
|
183
|
+
var DEFAULT_CONSOLE_OPTIONS = {
|
|
184
|
+
simulation: true,
|
|
185
|
+
pollInterval: 5e3,
|
|
186
|
+
maxLogs: 500,
|
|
187
|
+
autoStart: false
|
|
188
|
+
};
|
|
189
|
+
var DEFAULT_RISK_STATUS = {
|
|
190
|
+
timestamp: Date.now(),
|
|
191
|
+
totalExposure: 0,
|
|
192
|
+
maxExposure: 1e5,
|
|
193
|
+
exposurePercent: 0,
|
|
194
|
+
dailyPnl: 0,
|
|
195
|
+
dailyPnlLimit: 5e3,
|
|
196
|
+
dailyPnlPercent: 0,
|
|
197
|
+
dailyTradeCount: 0,
|
|
198
|
+
dailyTradeLimit: 50,
|
|
199
|
+
currentDrawdown: 0,
|
|
200
|
+
maxDrawdown: 15,
|
|
201
|
+
drawdownPercent: 0,
|
|
202
|
+
openPositions: 0,
|
|
203
|
+
maxPositions: 10,
|
|
204
|
+
riskLevel: "low",
|
|
205
|
+
tradingStatus: "active",
|
|
206
|
+
warnings: []
|
|
207
|
+
};
|
|
208
|
+
var DEFAULT_CONSOLE_METRICS = {
|
|
209
|
+
nav: 0,
|
|
210
|
+
navChange24h: 0,
|
|
211
|
+
navChangePercent24h: 0,
|
|
212
|
+
totalPnl: 0,
|
|
213
|
+
realizedPnl: 0,
|
|
214
|
+
unrealizedPnl: 0,
|
|
215
|
+
pnlToday: 0,
|
|
216
|
+
pnl7d: 0,
|
|
217
|
+
pnl30d: 0,
|
|
218
|
+
totalTrades: 0,
|
|
219
|
+
tradesToday: 0,
|
|
220
|
+
winRate: 0,
|
|
221
|
+
winCount: 0,
|
|
222
|
+
lossCount: 0,
|
|
223
|
+
avgWin: 0,
|
|
224
|
+
avgLoss: 0,
|
|
225
|
+
profitFactor: 0,
|
|
226
|
+
openPositions: 0,
|
|
227
|
+
totalExposure: 0,
|
|
228
|
+
avgLeverage: 0
|
|
229
|
+
};
|
|
230
|
+
function calculateRiskLevel(exposurePercent, drawdownPercent, dailyPnlPercent) {
|
|
231
|
+
const worstMetric = Math.max(exposurePercent, drawdownPercent, Math.abs(dailyPnlPercent));
|
|
232
|
+
if (worstMetric >= 90) return "critical";
|
|
233
|
+
if (worstMetric >= 70) return "high";
|
|
234
|
+
if (worstMetric >= 40) return "medium";
|
|
235
|
+
return "low";
|
|
236
|
+
}
|
|
237
|
+
function formatPnl(pnl) {
|
|
238
|
+
const sign = pnl >= 0 ? "+" : "";
|
|
239
|
+
if (Math.abs(pnl) >= 1e6) {
|
|
240
|
+
return `${sign}$${(pnl / 1e6).toFixed(2)}M`;
|
|
241
|
+
}
|
|
242
|
+
if (Math.abs(pnl) >= 1e3) {
|
|
243
|
+
return `${sign}$${(pnl / 1e3).toFixed(2)}K`;
|
|
244
|
+
}
|
|
245
|
+
return `${sign}$${pnl.toFixed(2)}`;
|
|
246
|
+
}
|
|
247
|
+
function formatPercent(value, showSign = true) {
|
|
248
|
+
const sign = showSign && value >= 0 ? "+" : "";
|
|
249
|
+
return `${sign}${value.toFixed(2)}%`;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export { AGENT_STATUS_COLORS, AI_LOG_COLORS, DEFAULT_CONSOLE_METRICS, DEFAULT_CONSOLE_OPTIONS, DEFAULT_RISK_STATUS, FOREX_AGENT, FOREX_CAPITAL_SPLIT, FOREX_CURRENCY_PAIRS, FOREX_CYCLE_OPTIONS, FOREX_LOG_COLORS, FOREX_POOL_DEFAULTS, ORDER_STATUS_CONFIG, PENALTY_TIERS, RISK_LEVELS, RISK_LEVEL_COLORS, STRATEGY_CATEGORIES, TRADING_STATUS_COLORS, calculateEarlyWithdrawalPenalty, calculateForexNetProfit, calculateRiskLevel, computePoolAllocations, estimateForexProfit, formatPercent, formatPnl };
|
|
2
253
|
//# sourceMappingURL=index.mjs.map
|
|
3
254
|
//# sourceMappingURL=index.mjs.map
|