Repository navigation
Expand file tree
/
Copy pathtest-benchmarks.js
More file actions
62 lines (51 loc) · 1.89 KB
/
Copy pathtest-benchmarks.js
File metadata and controls
62 lines (51 loc) · 1.89 KB
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
import axios from 'axios';
import dotenv from 'dotenv';
dotenv.config();
// Test various ticker formats for S&P 500 ETF and Bitcoin
async function testBenchmarks() {
const apiKey = process.env.EODHD_API_KEY;
if (!apiKey) {
console.error('No API key found for EODHD');
return;
}
console.log('Testing S&P 500 ETF formats');
await testTicker('SPY');
await testTicker('SPY.US');
console.log('\nTesting Bitcoin formats');
await testTicker('BTC-USD');
await testTicker('BTC-USD.CC');
await testTicker('BTCUSD');
await testTicker('BTC.CC');
await testTicker('BTCUSD.CC');
console.log('\nTesting other crypto formats (ETH)');
await testTicker('ETH-USD.CC');
await testTicker('ETH.CC');
}
async function testTicker(ticker) {
const apiKey = process.env.EODHD_API_KEY;
const baseUrl = 'https://eodhistoricaldata.com/api';
try {
console.log(`\nTesting ticker: ${ticker}`);
// Try real-time endpoint
const realtimeUrl = `${baseUrl}/real-time/${ticker}?api_token=${apiKey}&fmt=json`;
console.log(`Testing real-time endpoint: ${realtimeUrl}`);
try {
const realtimeResponse = await axios.get(realtimeUrl);
console.log('✅ Real-time data:', JSON.stringify(realtimeResponse.data).substring(0, 300) + '...');
} catch (error) {
console.log('❌ Real-time data failed:', error.message);
}
// Try EOD (end of day) endpoint
const eodUrl = `${baseUrl}/eod/${ticker}?api_token=${apiKey}&fmt=json&limit=5`;
console.log(`Testing EOD endpoint: ${eodUrl}`);
try {
const eodResponse = await axios.get(eodUrl);
console.log('✅ EOD data:', JSON.stringify(eodResponse.data).substring(0, 300) + '...');
} catch (error) {
console.log('❌ EOD data failed:', error.message);
}
} catch (error) {
console.error(`Error testing ${ticker}:`, error.message);
}
}
testBenchmarks().catch(console.error);