This commit is contained in:
Juergen Kunz
2025-07-11 09:09:13 +00:00
parent daeff1ce93
commit a29a50e825

View File

@@ -157,18 +157,29 @@ tap.test('should fetch major market indicators', async () => {
}
const marketIndicators = [
// Indices
{ ticker: '^GSPC', name: 'S&P 500' },
{ ticker: '^IXIC', name: 'NASDAQ' },
{ ticker: '^DJI', name: 'DOW Jones' },
// Tech Stocks
{ ticker: 'AAPL', name: 'Apple' },
{ ticker: 'AMZN', name: 'Amazon' },
{ ticker: 'GOOGL', name: 'Google' },
{ ticker: 'META', name: 'Meta' },
{ ticker: 'MSFT', name: 'Microsoft' },
{ ticker: 'PLTR', name: 'Palantir' },
// Crypto
{ ticker: 'BTC-USD', name: 'Bitcoin' },
{ ticker: 'ETH-USD', name: 'Ethereum' },
{ ticker: 'ADA-USD', name: 'Cardano' },
// Forex & Commodities
{ ticker: 'EURUSD=X', name: 'EUR/USD' },
{ ticker: 'GC=F', name: 'Gold Futures' },
{ ticker: 'CL=F', name: 'Crude Oil Futures' }
];
console.log('\n📊 Current Market Values:');
console.log('═'.repeat(60));
console.log('═'.repeat(65));
// Fetch all prices in batch for better performance
try {
@@ -199,8 +210,28 @@ tap.test('should fetch major market indicators', async () => {
}
}
// Display all results
// Display all results with section headers
let lastSection = '';
for (const indicator of marketIndicators) {
// Add section headers
if (indicator.ticker.startsWith('^') && lastSection !== 'indices') {
console.log('\n📈 Market Indices');
console.log('─'.repeat(65));
lastSection = 'indices';
} else if (['AAPL', 'AMZN', 'GOOGL', 'META', 'MSFT', 'PLTR'].includes(indicator.ticker) && lastSection !== 'stocks') {
console.log('\n💻 Tech Stocks');
console.log('─'.repeat(65));
lastSection = 'stocks';
} else if (indicator.ticker.includes('-USD') && lastSection !== 'crypto') {
console.log('\n🪙 Cryptocurrencies');
console.log('─'.repeat(65));
lastSection = 'crypto';
} else if ((indicator.ticker.includes('=') || indicator.ticker.includes('=F')) && lastSection !== 'forex') {
console.log('\n💱 Forex & Commodities');
console.log('─'.repeat(65));
lastSection = 'forex';
}
const price = priceMap.get(indicator.ticker);
if (price) {
const changeSymbol = price.change >= 0 ? '↑' : '↓';
@@ -210,7 +241,7 @@ tap.test('should fetch major market indicators', async () => {
console.log(
`${indicator.name.padEnd(20)} ${price.price.toLocaleString('en-US', {
minimumFractionDigits: 2,
maximumFractionDigits: indicator.name.includes('coin') || indicator.name.includes('EUR') ? 4 : 2
maximumFractionDigits: indicator.name.includes('coin') || indicator.name.includes('EUR') || indicator.name === 'Cardano' ? 4 : 2
}).padStart(12)} ${changeColor}${changeSymbol} ${price.change >= 0 ? '+' : ''}${price.change.toFixed(2)} (${price.changePercent >= 0 ? '+' : ''}${price.changePercent.toFixed(2)}%)${resetColor}`
);
} else {
@@ -230,7 +261,7 @@ tap.test('should fetch major market indicators', async () => {
console.log(
`${indicator.name.padEnd(20)} ${price.price.toLocaleString('en-US', {
minimumFractionDigits: 2,
maximumFractionDigits: indicator.name.includes('coin') || indicator.name.includes('EUR') ? 4 : 2
maximumFractionDigits: indicator.name.includes('coin') || indicator.name.includes('EUR') || indicator.name === 'Cardano' ? 4 : 2
}).padStart(12)} ${changeColor}${changeSymbol} ${price.change >= 0 ? '+' : ''}${price.change.toFixed(2)} (${price.changePercent >= 0 ? '+' : ''}${price.changePercent.toFixed(2)}%)${resetColor}`
);
} catch (error) {
@@ -239,7 +270,7 @@ tap.test('should fetch major market indicators', async () => {
}
}
console.log('═'.repeat(60));
console.log('═'.repeat(65));
console.log(`Last updated: ${new Date().toLocaleString()}\n`);
// Test passes if we successfully fetch at least some indicators