Spaces:
Runtime error
Runtime error
Update index.html
Browse files- index.html +12 -12
index.html
CHANGED
|
@@ -293,8 +293,8 @@
|
|
| 293 |
});
|
| 294 |
|
| 295 |
// API Configuration
|
| 296 |
-
let API_KEY = localStorage.getItem('bingxApiKey') || '';
|
| 297 |
-
let API_SECRET = localStorage.getItem('bingxApiSecret') || '';
|
| 298 |
const API_BASE_URL = 'https://open-api.bingx.com';
|
| 299 |
|
| 300 |
// Toggle API Form
|
|
@@ -340,7 +340,7 @@
|
|
| 340 |
}
|
| 341 |
params.timestamp = Date.now();
|
| 342 |
params.recvWindow = 5000; // Optional, check if needed
|
| 343 |
-
// Do not include
|
| 344 |
const signature = generateSignature(params);
|
| 345 |
params.signature = signature;
|
| 346 |
const url = `${API_BASE_URL}${endpoint}?${new URLSearchParams(params)}`;
|
|
@@ -354,21 +354,21 @@
|
|
| 354 |
|
| 355 |
// Fetch Specific Data
|
| 356 |
async function fetchBalance() {
|
| 357 |
-
const data = await fetchFromAPI('/openApi/swap/
|
| 358 |
-
//
|
| 359 |
-
return data.data.
|
| 360 |
}
|
| 361 |
|
| 362 |
async function fetchOpenPositions() {
|
| 363 |
-
const data = await fetchFromAPI('/openApi/swap/
|
| 364 |
-
//
|
| 365 |
-
return data.data;
|
| 366 |
}
|
| 367 |
|
| 368 |
async function fetchTradeHistory() {
|
| 369 |
-
const data = await fetchFromAPI('/openApi/swap/
|
| 370 |
-
//
|
| 371 |
-
return data.data;
|
| 372 |
}
|
| 373 |
|
| 374 |
// Helper Functions
|
|
|
|
| 293 |
});
|
| 294 |
|
| 295 |
// API Configuration
|
| 296 |
+
let API_KEY = localStorage.getItem('bingxApiKey') || '';
|
| 297 |
+
let API_SECRET = localStorage.getItem('bingxApiSecret') || '';
|
| 298 |
const API_BASE_URL = 'https://open-api.bingx.com';
|
| 299 |
|
| 300 |
// Toggle API Form
|
|
|
|
| 340 |
}
|
| 341 |
params.timestamp = Date.now();
|
| 342 |
params.recvWindow = 5000; // Optional, check if needed
|
| 343 |
+
// Do not include IP restriction parameters; assume disabled in API key settings
|
| 344 |
const signature = generateSignature(params);
|
| 345 |
params.signature = signature;
|
| 346 |
const url = `${API_BASE_URL}${endpoint}?${new URLSearchParams(params)}`;
|
|
|
|
| 354 |
|
| 355 |
// Fetch Specific Data
|
| 356 |
async function fetchBalance() {
|
| 357 |
+
const data = await fetchFromAPI('/openApi/swap/v2/account/balance');
|
| 358 |
+
// Updated parsing for V2 response structure
|
| 359 |
+
return data.data.assets.find(b => b.asset === 'USDT')?.walletBalance || 0;
|
| 360 |
}
|
| 361 |
|
| 362 |
async function fetchOpenPositions() {
|
| 363 |
+
const data = await fetchFromAPI('/openApi/swap/v2/position');
|
| 364 |
+
// Updated for V2 response structure
|
| 365 |
+
return data.data || [];
|
| 366 |
}
|
| 367 |
|
| 368 |
async function fetchTradeHistory() {
|
| 369 |
+
const data = await fetchFromAPI('/openApi/swap/v2/trade/history', { limit: 100 });
|
| 370 |
+
// Updated for V2 response structure
|
| 371 |
+
return data.data || [];
|
| 372 |
}
|
| 373 |
|
| 374 |
// Helper Functions
|