import Alpaca from '@alpacahq/alpaca-trade-api'; import * as dotenv from 'dotenv'; dotenv.config(); async function test() { const alpaca = new (Alpaca as any)({ keyId: process.env.ALPACA_API_KEY, secretKey: process.env.ALPACA_API_SECRET, paper: true, }); const combinations = [ { m: 'getBarsV2', s: 'BTCUSD' }, { m: 'getBarsV2', s: 'BTC/USD' }, { m: 'getCryptoBars', s: 'BTCUSD' }, { m: 'getCryptoBars', s: 'BTC/USD' }, ]; for (const item of combinations) { console.log(`--- Testing ${item.m} with ${item.s} ---`); try { const bars = (alpaca as any)[item.m](item.s, { timeframe: '1Min', limit: 5, start: new Date(Date.now() - 3600000 * 48).toISOString() }); let count = 0; for await (const b of bars) { count++; } console.log(`Success! Found ${count} bars.`); } catch (e: any) { console.log(`Failed: ${e.message}`); } } } test();