Spaces:
Runtime error

File size: 4,159 Bytes
56c0d82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
 * ═══════════════════════════════════════════════════════════════════════════════
 * πŸ” CHECK ACCOUNT PERMISSIONS - What can we trade?
 * ═══════════════════════════════════════════════════════════════════════════════
 */

import * as fs from 'fs';
import * as path from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const keysPath = path.join(__dirname, 'binanceKeys.json');
const { keys } = JSON.parse(fs.readFileSync(keysPath, 'utf-8'));

async function checkPermissions() {
  console.log(`\nπŸ” CHECKING ACCOUNT PERMISSIONS...\n`);
  
  const BinanceLib = await import('binance-api-node');
  const client = (BinanceLib as any).default({
    apiKey: keys[0].apiKey,
    apiSecret: keys[0].apiSecret,
  });

  // Get account info
  const account = await client.accountInfo();
  
  console.log(`πŸ“Š ACCOUNT STATUS:`);
  console.log(`   Can Trade: ${account.canTrade}`);
  console.log(`   Can Withdraw: ${account.canWithdraw}`);
  console.log(`   Can Deposit: ${account.canDeposit}`);
  console.log(`   Account Type: ${account.accountType}`);
  
  // Get balances with value
  console.log(`\nπŸ’° YOUR ASSETS:`);
  const assets = account.balances.filter((b: any) => parseFloat(b.free) > 0 || parseFloat(b.locked) > 0);
  for (const a of assets) {
    console.log(`   ${a.asset}: ${a.free} free, ${a.locked} locked`);
  }

  // Check API key permissions
  console.log(`\nπŸ”‘ API KEY PERMISSIONS:`);
  try {
    const apiPerms = await client.apiPermissions();
    console.log(`   IP Restrict: ${apiPerms.ipRestrict}`);
    console.log(`   Enable Spot: ${apiPerms.enableSpotAndMarginTrading}`);
    console.log(`   Enable Withdrawals: ${apiPerms.enableWithdrawals}`);
    console.log(`   Enable Internal Transfer: ${apiPerms.enableInternalTransfer}`);
    console.log(`   Enable Margin: ${apiPerms.enableMargin}`);
    console.log(`   Enable Futures: ${apiPerms.enableFutures}`);
  } catch (e: any) {
    console.log(`   Could not get API permissions: ${e.message}`);
  }

  // Try a test order to see what works
  console.log(`\nπŸ§ͺ TESTING TRADEABLE PAIRS...`);
  
  const testPairs = ['BTCUSDT', 'ETHUSDT', 'BNBUSDT', 'DOGEUSDT', 'ADAUSDT', 'DOTUSDT', 'XRPUSDT', 'SOLUSDT'];
  
  for (const symbol of testPairs) {
    try {
      // Try to get order book - if this works, we can trade it
      await client.book({ symbol, limit: 1 });
      
      // Check if we have balance
      const base = symbol.replace('USDT', '');
      const bal = assets.find((a: any) => a.asset === base);
      const hasBal = bal && parseFloat(bal.free) > 0;
      
      console.log(`   βœ… ${symbol} - Accessible ${hasBal ? `(Have ${bal.free} ${base})` : '(No balance)'}`);
    } catch (e: any) {
      console.log(`   ❌ ${symbol} - ${e.message.substring(0, 50)}`);
    }
  }

  // Check if it's a sub-account
  console.log(`\nπŸ“‹ CHECKING ACCOUNT TYPE...`);
  try {
    // This will fail if not a sub-account
    const subAccounts = await client.subAccountList();
    console.log(`   This is a MASTER account with ${subAccounts.subAccounts?.length || 0} sub-accounts`);
  } catch (e: any) {
    if (e.message.includes('not authorized')) {
      console.log(`   This appears to be a SUB-ACCOUNT (or no sub-account access)`);
    } else {
      console.log(`   ${e.message}`);
    }
  }

  console.log(`\n${'═'.repeat(60)}`);
  console.log(`\nπŸ’‘ RECOMMENDATION:`);
  console.log(`   If trading is blocked, you may need to:`);
  console.log(`   1. Enable Spot Trading in Binance API settings`);
  console.log(`   2. Complete identity verification (KYC)`);
  console.log(`   3. Check if your region has trading restrictions`);
  console.log(`   4. Check if this is a sub-account with limited permissions`);
}

checkPermissions().catch(console.error);