@microcosmmoney/portal-react 3.13.5 → 3.13.6
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/dist/main-portal/components/auctions/AuctionsPage.js +2 -2
- package/dist/main-portal/components/income/ManagerIncomePage.js +1 -16
- package/dist/main-portal/components/layout/AppSidebar.js +1 -1
- package/dist/main-portal/components/layout/TerminalSidebar.js +1 -1
- package/dist/main-portal/components/profile/ProfilePage.js +2 -2
- package/dist/main-portal/components/queue/QueueStatusPage.js +2 -71
- package/dist/main-portal/components/stations/StationDetailPage.js +1 -3
- package/dist/main-portal/components/stations/StationListPage.js +2 -4
- package/dist/main-portal/components/stations/StationsPage.js +2 -5
- package/dist/main-portal/config/menu-config.d.ts +0 -2
- package/dist/main-portal/config/menu-config.js +14 -67
- package/dist/main-portal/hooks/useAuth.d.ts +1 -2
- package/dist/main-portal/hooks/useAuth.js +0 -2
- package/dist/main-portal/lib/api/blockchain.d.ts +0 -44
- package/dist/main-portal/lib/api/blockchain.js +0 -195
- package/dist/main-portal/lib/api/services/index.d.ts +0 -1
- package/dist/main-portal/lib/api/services/index.js +0 -1
- package/dist/main-portal/lib/api/services/organization.d.ts +1 -6
- package/dist/main-portal/lib/api/services/organization.js +0 -12
- package/dist/main-portal/lib/oauth-config.js +3 -3
- package/dist/main-portal/lib/types/common.types.d.ts +0 -32
- package/dist/main-portal/lib/types/user.types.d.ts +1 -33
- package/package.json +1 -1
- package/dist/main-portal/hooks/useStrategies.d.ts +0 -134
- package/dist/main-portal/hooks/useStrategies.js +0 -28
- package/dist/main-portal/lib/api/services/ai.d.ts +0 -139
- package/dist/main-portal/lib/api/services/ai.js +0 -214
- package/dist/main-portal/lib/order-id-generator.d.ts +0 -19
- package/dist/main-portal/lib/order-id-generator.js +0 -97
- package/dist/main-portal/lib/strategy/defaults.d.ts +0 -2
- package/dist/main-portal/lib/strategy/defaults.js +0 -58
- package/dist/main-portal/lib/strategy/index.d.ts +0 -3
- package/dist/main-portal/lib/strategy/index.js +0 -20
- package/dist/main-portal/lib/strategy/tooltips.d.ts +0 -1
- package/dist/main-portal/lib/strategy/tooltips.js +0 -50
- package/dist/main-portal/lib/strategy/types.d.ts +0 -74
- package/dist/main-portal/lib/strategy/types.js +0 -2
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
interface PositionData {
|
|
2
|
-
amount?: number;
|
|
3
|
-
entryPrice?: number;
|
|
4
|
-
}
|
|
5
|
-
interface PowerStartCheck {
|
|
6
|
-
profit_check?: {
|
|
7
|
-
passed: boolean;
|
|
8
|
-
current: number;
|
|
9
|
-
threshold: number;
|
|
10
|
-
};
|
|
11
|
-
gap_check?: {
|
|
12
|
-
passed: boolean;
|
|
13
|
-
current: number;
|
|
14
|
-
threshold: number;
|
|
15
|
-
};
|
|
16
|
-
thickness_check?: {
|
|
17
|
-
passed: boolean;
|
|
18
|
-
thickness_pct: number;
|
|
19
|
-
};
|
|
20
|
-
orders_check?: {
|
|
21
|
-
passed: boolean;
|
|
22
|
-
long_count: number;
|
|
23
|
-
short_count: number;
|
|
24
|
-
max_orders: number;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export interface LiveState {
|
|
28
|
-
total_unrealized_pnl?: number;
|
|
29
|
-
energy_unrealized_pnl?: number;
|
|
30
|
-
price_gap_pct?: number;
|
|
31
|
-
price_gap_abs?: number;
|
|
32
|
-
current_drawdown_pct?: number;
|
|
33
|
-
current_price?: number;
|
|
34
|
-
wallet_balance?: number;
|
|
35
|
-
total_long_pos_amount?: number;
|
|
36
|
-
total_short_pos_amount?: number;
|
|
37
|
-
power_open_orders_long?: number;
|
|
38
|
-
power_open_orders_short?: number;
|
|
39
|
-
power_tp_orders_long?: number;
|
|
40
|
-
power_tp_orders_short?: number;
|
|
41
|
-
power_total_realized_pnl?: number;
|
|
42
|
-
power_closed_trades_long?: number;
|
|
43
|
-
power_closed_trades_short?: number;
|
|
44
|
-
energy_realized_pnl?: number;
|
|
45
|
-
user_manual_long_position?: number;
|
|
46
|
-
user_manual_short_position?: number;
|
|
47
|
-
user_manual_realized_pnl?: number;
|
|
48
|
-
power_start_mode?: string;
|
|
49
|
-
power_start_check?: PowerStartCheck;
|
|
50
|
-
positions?: {
|
|
51
|
-
energy?: {
|
|
52
|
-
LONG?: PositionData;
|
|
53
|
-
SHORT?: PositionData;
|
|
54
|
-
};
|
|
55
|
-
power?: {
|
|
56
|
-
LONG?: {
|
|
57
|
-
amount?: number;
|
|
58
|
-
open_orders?: number;
|
|
59
|
-
tp_orders?: number;
|
|
60
|
-
};
|
|
61
|
-
SHORT?: {
|
|
62
|
-
amount?: number;
|
|
63
|
-
open_orders?: number;
|
|
64
|
-
tp_orders?: number;
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
total_long?: PositionData;
|
|
68
|
-
total_short?: PositionData;
|
|
69
|
-
};
|
|
70
|
-
raw_snapshot?: {
|
|
71
|
-
positions?: Array<{
|
|
72
|
-
positionSide: 'LONG' | 'SHORT';
|
|
73
|
-
unRealizedProfit: string;
|
|
74
|
-
positionAmt: string;
|
|
75
|
-
entryPrice: string;
|
|
76
|
-
markPrice: string;
|
|
77
|
-
}>;
|
|
78
|
-
};
|
|
79
|
-
start_time?: string;
|
|
80
|
-
duration?: string;
|
|
81
|
-
power_today_realized_pnl?: number;
|
|
82
|
-
energy_today_realized_pnl?: number;
|
|
83
|
-
power_win_rate?: number;
|
|
84
|
-
power_profit_factor?: number;
|
|
85
|
-
energy_win_rate?: number;
|
|
86
|
-
energy_profit_factor?: number;
|
|
87
|
-
energy_hedge_count?: number;
|
|
88
|
-
energy_sync_hedge_count?: number;
|
|
89
|
-
energy_tp_form_a_count?: number;
|
|
90
|
-
energy_tp_form_b_count?: number;
|
|
91
|
-
power_stale_converted_count?: number;
|
|
92
|
-
power_avg_holding_duration?: number;
|
|
93
|
-
power_longest_stale_duration?: number;
|
|
94
|
-
power_avg_stale_duration?: number;
|
|
95
|
-
power_stale_cleanup_count?: number;
|
|
96
|
-
power_protection_trigger_count?: number;
|
|
97
|
-
power_total_fees?: number;
|
|
98
|
-
energy_total_fees?: number;
|
|
99
|
-
power_today_fees?: number;
|
|
100
|
-
energy_today_fees?: number;
|
|
101
|
-
power_month_fees?: number;
|
|
102
|
-
energy_month_fees?: number;
|
|
103
|
-
manual_open_count?: number;
|
|
104
|
-
manual_close_count?: number;
|
|
105
|
-
manual_chase_count?: number;
|
|
106
|
-
manual_cancel_count?: number;
|
|
107
|
-
}
|
|
108
|
-
export interface PowerParams {
|
|
109
|
-
start_price_gap_pct?: number;
|
|
110
|
-
open_pos_quantity?: number;
|
|
111
|
-
start_pos_thickness_pct?: number;
|
|
112
|
-
max_open_orders?: number;
|
|
113
|
-
start_energy_profit_pct?: number;
|
|
114
|
-
}
|
|
115
|
-
export interface Strategy {
|
|
116
|
-
id: string;
|
|
117
|
-
name?: string;
|
|
118
|
-
strategy_name?: string;
|
|
119
|
-
symbol?: string;
|
|
120
|
-
is_active: boolean;
|
|
121
|
-
base?: {
|
|
122
|
-
symbol?: string;
|
|
123
|
-
};
|
|
124
|
-
power?: PowerParams;
|
|
125
|
-
params?: {
|
|
126
|
-
power?: PowerParams;
|
|
127
|
-
};
|
|
128
|
-
live_state?: LiveState;
|
|
129
|
-
created_at?: string;
|
|
130
|
-
updated_at?: string;
|
|
131
|
-
}
|
|
132
|
-
export declare function useStrategies(refreshInterval?: number): import("swr").SWRResponse<Strategy[], any, import("swr").SWRConfiguration<Strategy[], any, import("swr").BareFetcher<Strategy[]>> | undefined>;
|
|
133
|
-
export declare function useStrategyDetails(strategyId: string | null, refreshInterval?: number): import("swr").SWRResponse<Strategy, any, import("swr").SWRConfiguration<Strategy, any, import("swr").BareFetcher<Strategy>> | undefined>;
|
|
134
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// AI-generated · AI-managed · AI-maintained
|
|
3
|
-
'use client';
|
|
4
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.useStrategies = useStrategies;
|
|
9
|
-
exports.useStrategyDetails = useStrategyDetails;
|
|
10
|
-
const swr_1 = __importDefault(require("swr"));
|
|
11
|
-
const api_service_1 = require("../lib/api-service");
|
|
12
|
-
const fetcher = async (url) => (0, api_service_1.fetchApi)(url);
|
|
13
|
-
function useStrategies(refreshInterval = 15000) {
|
|
14
|
-
return (0, swr_1.default)('/strategies', fetcher, {
|
|
15
|
-
refreshInterval,
|
|
16
|
-
revalidateOnFocus: true,
|
|
17
|
-
dedupingInterval: 5000,
|
|
18
|
-
errorRetryCount: 3,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
function useStrategyDetails(strategyId, refreshInterval = 15000) {
|
|
22
|
-
return (0, swr_1.default)(strategyId ? `/strategies/${strategyId}` : null, fetcher, {
|
|
23
|
-
refreshInterval,
|
|
24
|
-
revalidateOnFocus: true,
|
|
25
|
-
dedupingInterval: 5000,
|
|
26
|
-
errorRetryCount: 3,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import type { APIResponse, AIProductsResponse, AIProductDetailResponse, AIRequestsResponse, AIRequestDetailResponse, SubmitAIRequestResponse, AIChatResponse, StrategyConfig, BinanceOrderResponse, BinanceCancelResponse } from '../../types/api';
|
|
2
|
-
export declare function getAIProducts(params?: {
|
|
3
|
-
status?: 'active' | 'all';
|
|
4
|
-
risk_level?: 'low' | 'medium' | 'high' | 'all';
|
|
5
|
-
sort?: 'risk' | 'return' | 'popularity';
|
|
6
|
-
}): Promise<AIProductsResponse>;
|
|
7
|
-
export declare function getAIProductDetail(productId: string): Promise<AIProductDetailResponse>;
|
|
8
|
-
export declare function submitAIRequest(data: {
|
|
9
|
-
ai_product_id: string;
|
|
10
|
-
exchange: string;
|
|
11
|
-
amount: number;
|
|
12
|
-
}): Promise<SubmitAIRequestResponse>;
|
|
13
|
-
export declare function getUserAIRequests(status?: string): Promise<AIRequestsResponse>;
|
|
14
|
-
export declare function getAIRequestDetail(requestId: string): Promise<AIRequestDetailResponse>;
|
|
15
|
-
export declare function cancelAIRequest(requestId: string): Promise<APIResponse<void>>;
|
|
16
|
-
export declare function stopAIStrategy(requestId: string, reason?: string): Promise<APIResponse<void>>;
|
|
17
|
-
export declare function getPendingAIRequests(): Promise<AIRequestsResponse>;
|
|
18
|
-
export declare function acceptAIRequest(requestId: string): Promise<APIResponse<void>>;
|
|
19
|
-
export declare function configureAIStrategy(requestId: string, config: StrategyConfig): Promise<APIResponse<void>>;
|
|
20
|
-
export declare function startAIStrategy(requestId: string): Promise<APIResponse<void>>;
|
|
21
|
-
export declare function rejectAIRequest(requestId: string, reason: string): Promise<APIResponse<void>>;
|
|
22
|
-
export declare function chatWithAIProduct(data: {
|
|
23
|
-
product_id: string;
|
|
24
|
-
product_info: Record<string, unknown>;
|
|
25
|
-
message: string;
|
|
26
|
-
history?: Array<{
|
|
27
|
-
role: string;
|
|
28
|
-
content: string;
|
|
29
|
-
}>;
|
|
30
|
-
}): Promise<AIChatResponse>;
|
|
31
|
-
export declare function getMyAIRequests(status?: string): Promise<AIRequestsResponse>;
|
|
32
|
-
export interface AISuggestion {
|
|
33
|
-
suggestion_id: string;
|
|
34
|
-
strategy_id: string;
|
|
35
|
-
symbol: string;
|
|
36
|
-
uid: string;
|
|
37
|
-
status: 'pending' | 'approved' | 'rejected' | 'modified' | 'executed' | 'expired';
|
|
38
|
-
suggestions: Array<{
|
|
39
|
-
param_name: string;
|
|
40
|
-
current_value: number;
|
|
41
|
-
suggested_value: number;
|
|
42
|
-
change_pct: number;
|
|
43
|
-
reason: string;
|
|
44
|
-
}>;
|
|
45
|
-
market_analysis: {
|
|
46
|
-
market_state: string;
|
|
47
|
-
trend_direction: string;
|
|
48
|
-
atr_pct: number;
|
|
49
|
-
adx: number;
|
|
50
|
-
plus_di: number;
|
|
51
|
-
minus_di: number;
|
|
52
|
-
volatility: number;
|
|
53
|
-
snapshot_time: string;
|
|
54
|
-
analysis_reason: string;
|
|
55
|
-
};
|
|
56
|
-
expected_outcomes: {
|
|
57
|
-
risk_change: string;
|
|
58
|
-
profit_impact?: string;
|
|
59
|
-
confidence: number;
|
|
60
|
-
};
|
|
61
|
-
trader_feedback?: string;
|
|
62
|
-
trader_modified_values?: Record<string, number>;
|
|
63
|
-
created_at: string;
|
|
64
|
-
reviewed_at?: string;
|
|
65
|
-
executed_at?: string;
|
|
66
|
-
expires_at: string;
|
|
67
|
-
reviewed_by?: string;
|
|
68
|
-
strategy_name?: string;
|
|
69
|
-
current_params?: Record<string, unknown>;
|
|
70
|
-
}
|
|
71
|
-
export interface AISuggestionsResponse {
|
|
72
|
-
success: boolean;
|
|
73
|
-
count: number;
|
|
74
|
-
suggestions: AISuggestion[];
|
|
75
|
-
error?: string;
|
|
76
|
-
}
|
|
77
|
-
export interface AISuggestionDetailResponse {
|
|
78
|
-
success: boolean;
|
|
79
|
-
suggestion: AISuggestion;
|
|
80
|
-
error?: string;
|
|
81
|
-
}
|
|
82
|
-
export interface AISuggestionStatsResponse {
|
|
83
|
-
success: boolean;
|
|
84
|
-
period: string;
|
|
85
|
-
stats: Record<string, {
|
|
86
|
-
count: number;
|
|
87
|
-
strategies: number;
|
|
88
|
-
symbols: number;
|
|
89
|
-
}>;
|
|
90
|
-
error?: string;
|
|
91
|
-
}
|
|
92
|
-
export declare function getAISuggestions(params?: {
|
|
93
|
-
trader_uid?: string;
|
|
94
|
-
status?: string;
|
|
95
|
-
limit?: number;
|
|
96
|
-
}): Promise<AISuggestionsResponse>;
|
|
97
|
-
export declare function getAISuggestionDetail(suggestionId: string): Promise<AISuggestionDetailResponse>;
|
|
98
|
-
export declare function approveAISuggestion(suggestionId: string, reviewer: string, modifiedValues?: Record<string, number>): Promise<APIResponse<void>>;
|
|
99
|
-
export declare function rejectAISuggestion(suggestionId: string, reviewer: string, feedback: string): Promise<APIResponse<void>>;
|
|
100
|
-
export declare function generateAISuggestions(timeframe?: string): Promise<APIResponse<{
|
|
101
|
-
total: number;
|
|
102
|
-
generated: number;
|
|
103
|
-
skipped: number;
|
|
104
|
-
errors: number;
|
|
105
|
-
}>>;
|
|
106
|
-
export declare function getAISuggestionStats(trader_uid?: string): Promise<AISuggestionStatsResponse>;
|
|
107
|
-
export declare function getMarketState(symbol: string, timeframe?: string, refresh?: boolean): Promise<APIResponse<{
|
|
108
|
-
symbol: string;
|
|
109
|
-
timeframe: string;
|
|
110
|
-
market_state: string;
|
|
111
|
-
trend_direction: string;
|
|
112
|
-
indicators: {
|
|
113
|
-
atr: number;
|
|
114
|
-
atr_pct: number;
|
|
115
|
-
adx: number;
|
|
116
|
-
plus_di: number;
|
|
117
|
-
minus_di: number;
|
|
118
|
-
volatility: number;
|
|
119
|
-
};
|
|
120
|
-
suggestion: {
|
|
121
|
-
risk_level: string;
|
|
122
|
-
adjustments: Record<string, {
|
|
123
|
-
direction: string;
|
|
124
|
-
range: string;
|
|
125
|
-
}>;
|
|
126
|
-
reason: string;
|
|
127
|
-
};
|
|
128
|
-
}>>;
|
|
129
|
-
export declare function cancelBinanceOrder(symbol: string, clientOrderId: string): Promise<BinanceCancelResponse>;
|
|
130
|
-
export declare function placeBinanceOrder(data: {
|
|
131
|
-
symbol: string;
|
|
132
|
-
side: string;
|
|
133
|
-
positionSide: string;
|
|
134
|
-
quantity: number;
|
|
135
|
-
orderType?: string;
|
|
136
|
-
price?: number;
|
|
137
|
-
clientOrderId?: string;
|
|
138
|
-
}): Promise<BinanceOrderResponse>;
|
|
139
|
-
export declare function modifyBinanceOrder(symbol: string, clientOrderId: string, newPrice: number): Promise<BinanceOrderResponse>;
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAIProducts = getAIProducts;
|
|
4
|
-
exports.getAIProductDetail = getAIProductDetail;
|
|
5
|
-
exports.submitAIRequest = submitAIRequest;
|
|
6
|
-
exports.getUserAIRequests = getUserAIRequests;
|
|
7
|
-
exports.getAIRequestDetail = getAIRequestDetail;
|
|
8
|
-
exports.cancelAIRequest = cancelAIRequest;
|
|
9
|
-
exports.stopAIStrategy = stopAIStrategy;
|
|
10
|
-
exports.getPendingAIRequests = getPendingAIRequests;
|
|
11
|
-
exports.acceptAIRequest = acceptAIRequest;
|
|
12
|
-
exports.configureAIStrategy = configureAIStrategy;
|
|
13
|
-
exports.startAIStrategy = startAIStrategy;
|
|
14
|
-
exports.rejectAIRequest = rejectAIRequest;
|
|
15
|
-
exports.chatWithAIProduct = chatWithAIProduct;
|
|
16
|
-
exports.getMyAIRequests = getMyAIRequests;
|
|
17
|
-
exports.getAISuggestions = getAISuggestions;
|
|
18
|
-
exports.getAISuggestionDetail = getAISuggestionDetail;
|
|
19
|
-
exports.approveAISuggestion = approveAISuggestion;
|
|
20
|
-
exports.rejectAISuggestion = rejectAISuggestion;
|
|
21
|
-
exports.generateAISuggestions = generateAISuggestions;
|
|
22
|
-
exports.getAISuggestionStats = getAISuggestionStats;
|
|
23
|
-
exports.getMarketState = getMarketState;
|
|
24
|
-
exports.cancelBinanceOrder = cancelBinanceOrder;
|
|
25
|
-
exports.placeBinanceOrder = placeBinanceOrder;
|
|
26
|
-
exports.modifyBinanceOrder = modifyBinanceOrder;
|
|
27
|
-
const core_1 = require("../core");
|
|
28
|
-
const auth_service_1 = require("../../auth-service");
|
|
29
|
-
async function getAIProducts(params) {
|
|
30
|
-
const queryParams = new URLSearchParams();
|
|
31
|
-
if (params?.status)
|
|
32
|
-
queryParams.append('status', params.status);
|
|
33
|
-
if (params?.risk_level)
|
|
34
|
-
queryParams.append('risk_level', params.risk_level);
|
|
35
|
-
if (params?.sort)
|
|
36
|
-
queryParams.append('sort', params.sort);
|
|
37
|
-
const queryString = queryParams.toString();
|
|
38
|
-
const url = `/api/ai-products${queryString ? `?${queryString}` : ''}`;
|
|
39
|
-
const response = await fetch(url);
|
|
40
|
-
return response.json();
|
|
41
|
-
}
|
|
42
|
-
async function getAIProductDetail(productId) {
|
|
43
|
-
const response = await fetch(`/api/ai-products/${productId}`);
|
|
44
|
-
return response.json();
|
|
45
|
-
}
|
|
46
|
-
async function submitAIRequest(data) {
|
|
47
|
-
return (0, core_1.fetchApi)('/user/ai-requests', {
|
|
48
|
-
method: 'POST',
|
|
49
|
-
body: JSON.stringify(data)
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
async function getUserAIRequests(status) {
|
|
53
|
-
const token = await (0, core_1.getCurrentUserToken)();
|
|
54
|
-
const url = status
|
|
55
|
-
? `/api/user/ai-requests?status=${status}`
|
|
56
|
-
: '/api/user/ai-requests';
|
|
57
|
-
const response = await fetch(url, {
|
|
58
|
-
headers: { 'Authorization': `Bearer ${token}` }
|
|
59
|
-
});
|
|
60
|
-
(0, auth_service_1.guardAuthResponse)(response);
|
|
61
|
-
return response.json();
|
|
62
|
-
}
|
|
63
|
-
async function getAIRequestDetail(requestId) {
|
|
64
|
-
const token = await (0, core_1.getCurrentUserToken)();
|
|
65
|
-
const response = await fetch(`/api/user/ai-requests/${requestId}`, {
|
|
66
|
-
headers: { 'Authorization': `Bearer ${token}` }
|
|
67
|
-
});
|
|
68
|
-
(0, auth_service_1.guardAuthResponse)(response);
|
|
69
|
-
return response.json();
|
|
70
|
-
}
|
|
71
|
-
async function cancelAIRequest(requestId) {
|
|
72
|
-
const token = await (0, core_1.getCurrentUserToken)();
|
|
73
|
-
const response = await fetch(`/api/user/ai-requests/${requestId}`, {
|
|
74
|
-
method: 'DELETE',
|
|
75
|
-
headers: { 'Authorization': `Bearer ${token}` }
|
|
76
|
-
});
|
|
77
|
-
(0, auth_service_1.guardAuthResponse)(response);
|
|
78
|
-
return response.json();
|
|
79
|
-
}
|
|
80
|
-
async function stopAIStrategy(requestId, reason) {
|
|
81
|
-
const token = await (0, core_1.getCurrentUserToken)();
|
|
82
|
-
const response = await fetch(`/api/user/ai-requests/${requestId}/stop`, {
|
|
83
|
-
method: 'POST',
|
|
84
|
-
headers: {
|
|
85
|
-
'Content-Type': 'application/json',
|
|
86
|
-
'Authorization': `Bearer ${token}`
|
|
87
|
-
},
|
|
88
|
-
body: JSON.stringify({ reason })
|
|
89
|
-
});
|
|
90
|
-
(0, auth_service_1.guardAuthResponse)(response);
|
|
91
|
-
return response.json();
|
|
92
|
-
}
|
|
93
|
-
async function getPendingAIRequests() {
|
|
94
|
-
return (0, core_1.fetchApi)('/trader/ai-requests/pending');
|
|
95
|
-
}
|
|
96
|
-
async function acceptAIRequest(requestId) {
|
|
97
|
-
return (0, core_1.fetchApi)(`/trader/ai-requests/${requestId}/accept`, { method: 'POST' });
|
|
98
|
-
}
|
|
99
|
-
async function configureAIStrategy(requestId, config) {
|
|
100
|
-
return (0, core_1.fetchApi)(`/trader/ai-requests/${requestId}/configure`, {
|
|
101
|
-
method: 'POST',
|
|
102
|
-
body: JSON.stringify(config)
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
async function startAIStrategy(requestId) {
|
|
106
|
-
return (0, core_1.fetchApi)(`/trader/ai-requests/${requestId}/start`, { method: 'POST' });
|
|
107
|
-
}
|
|
108
|
-
async function rejectAIRequest(requestId, reason) {
|
|
109
|
-
return (0, core_1.fetchApi)(`/trader/ai-requests/${requestId}/reject`, {
|
|
110
|
-
method: 'POST',
|
|
111
|
-
body: JSON.stringify({ reason })
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
async function chatWithAIProduct(data) {
|
|
115
|
-
const response = await fetch('/api/ai-product-chat', {
|
|
116
|
-
method: 'POST',
|
|
117
|
-
headers: { 'Content-Type': 'application/json' },
|
|
118
|
-
body: JSON.stringify(data)
|
|
119
|
-
});
|
|
120
|
-
return response.json();
|
|
121
|
-
}
|
|
122
|
-
async function getMyAIRequests(status) {
|
|
123
|
-
const url = status
|
|
124
|
-
? `/trader/ai-requests/my-requests?status=${status}`
|
|
125
|
-
: '/trader/ai-requests/my-requests';
|
|
126
|
-
return (0, core_1.fetchApi)(url);
|
|
127
|
-
}
|
|
128
|
-
async function getAISuggestions(params) {
|
|
129
|
-
const queryParams = new URLSearchParams();
|
|
130
|
-
if (params?.trader_uid)
|
|
131
|
-
queryParams.append('trader_uid', params.trader_uid);
|
|
132
|
-
if (params?.status)
|
|
133
|
-
queryParams.append('status', params.status);
|
|
134
|
-
if (params?.limit)
|
|
135
|
-
queryParams.append('limit', params.limit.toString());
|
|
136
|
-
const queryString = queryParams.toString();
|
|
137
|
-
return (0, core_1.fetchApi)(`/data-service/indicators/suggestions${queryString ? `?${queryString}` : ''}`);
|
|
138
|
-
}
|
|
139
|
-
async function getAISuggestionDetail(suggestionId) {
|
|
140
|
-
return (0, core_1.fetchApi)(`/data-service/indicators/suggestions/${suggestionId}`);
|
|
141
|
-
}
|
|
142
|
-
async function approveAISuggestion(suggestionId, reviewer, modifiedValues) {
|
|
143
|
-
return (0, core_1.fetchApi)(`/data-service/indicators/suggestions/${suggestionId}/approve`, {
|
|
144
|
-
method: 'POST',
|
|
145
|
-
body: JSON.stringify({ reviewer, modified_values: modifiedValues })
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
async function rejectAISuggestion(suggestionId, reviewer, feedback) {
|
|
149
|
-
return (0, core_1.fetchApi)(`/data-service/indicators/suggestions/${suggestionId}/reject`, {
|
|
150
|
-
method: 'POST',
|
|
151
|
-
body: JSON.stringify({ reviewer, feedback })
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
async function generateAISuggestions(timeframe) {
|
|
155
|
-
return (0, core_1.fetchApi)('/data-service/indicators/suggestions/generate', {
|
|
156
|
-
method: 'POST',
|
|
157
|
-
body: JSON.stringify({ timeframe: timeframe || '4h' })
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
async function getAISuggestionStats(trader_uid) {
|
|
161
|
-
const params = new URLSearchParams();
|
|
162
|
-
if (trader_uid)
|
|
163
|
-
params.append('trader_uid', trader_uid);
|
|
164
|
-
const queryString = params.toString();
|
|
165
|
-
return (0, core_1.fetchApi)(`/data-service/indicators/suggestions/stats${queryString ? `?${queryString}` : ''}`);
|
|
166
|
-
}
|
|
167
|
-
async function getMarketState(symbol, timeframe, refresh) {
|
|
168
|
-
const params = new URLSearchParams();
|
|
169
|
-
if (timeframe)
|
|
170
|
-
params.append('timeframe', timeframe);
|
|
171
|
-
if (refresh)
|
|
172
|
-
params.append('refresh', 'true');
|
|
173
|
-
const queryString = params.toString();
|
|
174
|
-
return (0, core_1.fetchApi)(`/data-service/indicators/market-state/${symbol}${queryString ? `?${queryString}` : ''}`);
|
|
175
|
-
}
|
|
176
|
-
async function cancelBinanceOrder(symbol, clientOrderId) {
|
|
177
|
-
const token = await (0, core_1.getCurrentUserToken)();
|
|
178
|
-
const response = await fetch('/api/trading/binance/cancel-order', {
|
|
179
|
-
method: 'POST',
|
|
180
|
-
headers: {
|
|
181
|
-
'Content-Type': 'application/json',
|
|
182
|
-
'Authorization': `Bearer ${token}`
|
|
183
|
-
},
|
|
184
|
-
body: JSON.stringify({ symbol, clientOrderId })
|
|
185
|
-
});
|
|
186
|
-
(0, auth_service_1.guardAuthResponse)(response);
|
|
187
|
-
return response.json();
|
|
188
|
-
}
|
|
189
|
-
async function placeBinanceOrder(data) {
|
|
190
|
-
const token = await (0, core_1.getCurrentUserToken)();
|
|
191
|
-
const response = await fetch('/api/trading/binance/place-order', {
|
|
192
|
-
method: 'POST',
|
|
193
|
-
headers: {
|
|
194
|
-
'Content-Type': 'application/json',
|
|
195
|
-
'Authorization': `Bearer ${token}`
|
|
196
|
-
},
|
|
197
|
-
body: JSON.stringify(data)
|
|
198
|
-
});
|
|
199
|
-
(0, auth_service_1.guardAuthResponse)(response);
|
|
200
|
-
return response.json();
|
|
201
|
-
}
|
|
202
|
-
async function modifyBinanceOrder(symbol, clientOrderId, newPrice) {
|
|
203
|
-
const token = await (0, core_1.getCurrentUserToken)();
|
|
204
|
-
const response = await fetch('/api/trading/binance/modify-order', {
|
|
205
|
-
method: 'POST',
|
|
206
|
-
headers: {
|
|
207
|
-
'Content-Type': 'application/json',
|
|
208
|
-
'Authorization': `Bearer ${token}`
|
|
209
|
-
},
|
|
210
|
-
body: JSON.stringify({ symbol, clientOrderId, newPrice })
|
|
211
|
-
});
|
|
212
|
-
(0, auth_service_1.guardAuthResponse)(response);
|
|
213
|
-
return response.json();
|
|
214
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type Platform = 'web' | 'android' | 'ios';
|
|
2
|
-
export type UserOrderAction = 'open' | 'close' | 'modify' | 'cancel' | 'add';
|
|
3
|
-
export declare class OrderIDGenerator {
|
|
4
|
-
static generateUserOrderId(platform: Platform, action: UserOrderAction): string;
|
|
5
|
-
static parseOrderSource(clientOrderId: string): {
|
|
6
|
-
source: 'bot' | 'user' | 'unknown';
|
|
7
|
-
strategy: 'energy' | 'power' | 'claude' | null;
|
|
8
|
-
platform: Platform | null;
|
|
9
|
-
action: string | null;
|
|
10
|
-
};
|
|
11
|
-
static isBotOrder(clientOrderId: string): boolean;
|
|
12
|
-
static isUserOrder(clientOrderId: string): boolean;
|
|
13
|
-
static getOrderSourceText(clientOrderId: string): string;
|
|
14
|
-
}
|
|
15
|
-
export declare const generateUserOrderId: typeof OrderIDGenerator.generateUserOrderId;
|
|
16
|
-
export declare const parseOrderSource: typeof OrderIDGenerator.parseOrderSource;
|
|
17
|
-
export declare const isBotOrder: typeof OrderIDGenerator.isBotOrder;
|
|
18
|
-
export declare const isUserOrder: typeof OrderIDGenerator.isUserOrder;
|
|
19
|
-
export declare const getOrderSourceText: typeof OrderIDGenerator.getOrderSourceText;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOrderSourceText = exports.isUserOrder = exports.isBotOrder = exports.parseOrderSource = exports.generateUserOrderId = exports.OrderIDGenerator = void 0;
|
|
4
|
-
class OrderIDGenerator {
|
|
5
|
-
static generateUserOrderId(platform, action) {
|
|
6
|
-
const timestamp = Date.now();
|
|
7
|
-
const clientOrderId = `user-${platform}-${action}-${timestamp}`;
|
|
8
|
-
if (clientOrderId.length > 32) {
|
|
9
|
-
throw new Error(`生成的订单ID长度超过32字符: ${clientOrderId} (${clientOrderId.length}字符)`);
|
|
10
|
-
}
|
|
11
|
-
return clientOrderId;
|
|
12
|
-
}
|
|
13
|
-
static parseOrderSource(clientOrderId) {
|
|
14
|
-
const parts = clientOrderId.split('-');
|
|
15
|
-
if (parts[0] === 'energy') {
|
|
16
|
-
return {
|
|
17
|
-
source: 'bot',
|
|
18
|
-
strategy: 'energy',
|
|
19
|
-
platform: null,
|
|
20
|
-
action: parts[1] || null
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
if (parts[0] === 'power') {
|
|
24
|
-
return {
|
|
25
|
-
source: 'bot',
|
|
26
|
-
strategy: 'power',
|
|
27
|
-
platform: null,
|
|
28
|
-
action: parts[1] || null
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
if (parts[0] === 'claude') {
|
|
32
|
-
return {
|
|
33
|
-
source: 'bot',
|
|
34
|
-
strategy: 'claude',
|
|
35
|
-
platform: null,
|
|
36
|
-
action: parts[1] || null
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
if (parts[0] === 'user') {
|
|
40
|
-
return {
|
|
41
|
-
source: 'user',
|
|
42
|
-
strategy: null,
|
|
43
|
-
platform: parts[1] || null,
|
|
44
|
-
action: parts[2] || null
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
source: 'unknown',
|
|
49
|
-
strategy: null,
|
|
50
|
-
platform: null,
|
|
51
|
-
action: null
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
static isBotOrder(clientOrderId) {
|
|
55
|
-
const { source } = this.parseOrderSource(clientOrderId);
|
|
56
|
-
return source === 'bot';
|
|
57
|
-
}
|
|
58
|
-
static isUserOrder(clientOrderId) {
|
|
59
|
-
const { source } = this.parseOrderSource(clientOrderId);
|
|
60
|
-
return source === 'user';
|
|
61
|
-
}
|
|
62
|
-
static getOrderSourceText(clientOrderId) {
|
|
63
|
-
const info = this.parseOrderSource(clientOrderId);
|
|
64
|
-
if (info.source === 'bot') {
|
|
65
|
-
const strategyNames = {
|
|
66
|
-
energy: 'Energy策略',
|
|
67
|
-
power: 'Power策略',
|
|
68
|
-
claude: 'Claude AI策略'
|
|
69
|
-
};
|
|
70
|
-
return strategyNames[info.strategy || ''] || 'Bot策略';
|
|
71
|
-
}
|
|
72
|
-
if (info.source === 'user') {
|
|
73
|
-
const platformNames = {
|
|
74
|
-
web: '网页',
|
|
75
|
-
android: 'Android',
|
|
76
|
-
ios: 'iOS'
|
|
77
|
-
};
|
|
78
|
-
const platform = platformNames[info.platform || 'web'] || '未知平台';
|
|
79
|
-
const actionNames = {
|
|
80
|
-
open: '开仓',
|
|
81
|
-
close: '平仓',
|
|
82
|
-
add: '加仓',
|
|
83
|
-
modify: '修改',
|
|
84
|
-
cancel: '取消'
|
|
85
|
-
};
|
|
86
|
-
const action = actionNames[info.action || ''] || '操作';
|
|
87
|
-
return `${platform} - ${action}`;
|
|
88
|
-
}
|
|
89
|
-
return '未知来源';
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.OrderIDGenerator = OrderIDGenerator;
|
|
93
|
-
exports.generateUserOrderId = OrderIDGenerator.generateUserOrderId.bind(OrderIDGenerator);
|
|
94
|
-
exports.parseOrderSource = OrderIDGenerator.parseOrderSource.bind(OrderIDGenerator);
|
|
95
|
-
exports.isBotOrder = OrderIDGenerator.isBotOrder.bind(OrderIDGenerator);
|
|
96
|
-
exports.isUserOrder = OrderIDGenerator.isUserOrder.bind(OrderIDGenerator);
|
|
97
|
-
exports.getOrderSourceText = OrderIDGenerator.getOrderSourceText.bind(OrderIDGenerator);
|