EricSam commited on
Commit
4e0862d
Β·
verified Β·
1 Parent(s): 9342591

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +12 -12
index.html CHANGED
@@ -293,8 +293,8 @@
293
  });
294
 
295
  // API Configuration
296
- let API_KEY = localStorage.getItem('bingxApiKey') || ''; // Removed default hardcoded value
297
- let API_SECRET = localStorage.getItem('bingxApiSecret') || ''; // Removed default hardcoded value
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 apiKey in params
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/v1/account/balance');
358
- // Adjust parsing based on actual response structure
359
- return data.data.balance.find(b => b.asset === 'USDT').free;
360
  }
361
 
362
  async function fetchOpenPositions() {
363
- const data = await fetchFromAPI('/openApi/swap/v1/position');
364
- // Adjust parsing based on actual response structure
365
- return data.data;
366
  }
367
 
368
  async function fetchTradeHistory() {
369
- const data = await fetchFromAPI('/openApi/swap/v1/trade/history', { limit: 100 });
370
- // Adjust parsing based on actual response structure
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