(args: string[])
| 322 | const curr: string[] = []; |
| 323 | for (const t of tokens) { |
| 324 | const n = parseFloat(t); |
| 325 | if (!isNaN(n) && isFinite(n)) amount = n; else curr.push(t); |
| 326 | } |
| 327 | const base = curr[0] || 'btc'; |
| 328 | const quote = curr[1] || 'usd'; |
| 329 | return { base, quote, amount }; |
| 330 | } |
| 331 | |
| 332 | // (新) 获取币安价格 |
| 333 | private async fetchBinancePrice(symbol: string): Promise<number> { |
| 334 | try { |
| 335 | const url = `https://api.binance.com/api/v3/ticker/price?symbol=${symbol.toUpperCase()}`; |
| 336 | const { data } = await axios.get(url, { timeout: 5000 }); |
| 337 | if (data && data.price) { |
| 338 | return parseFloat(data.price); |
no test coverage detected