Spaces:
Running
Running
Deploy Aureon OS (deploy/selfhost stack: nginx edge + fusion API x2 + console + HNC organ + redis + postgres; paper mode) (part 19)
da0ce7b verified Download scripts/traders/checkPermissions.ts from GaryLeckey/aureon-os: direct link, hf CLI and curl.
- Browser
- Download file 4.26 kB
-
https://huggingface.co/spaces/GaryLeckey/aureon-os/resolve/main/scripts/traders/checkPermissions.ts
- Command line
-
hf download hf://spaces/GaryLeckey/aureon-os/scripts/traders/checkPermissions.ts
-
curl -L -o checkPermissions.ts https://huggingface.co/spaces/GaryLeckey/aureon-os/resolve/main/scripts/traders/checkPermissions.ts
4.26 kB
| /** | |
| * βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| * π 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); | |