export function formatPrice(price: number): string {
	if (price >= 1000) {
		return price.toLocaleString('ko-KR', { maximumFractionDigits: 0 });
	}
	if (price >= 1) {
		return price.toLocaleString('ko-KR', { maximumFractionDigits: 2 });
	}
	if (price >= 0.01) {
		return price.toLocaleString('ko-KR', { maximumFractionDigits: 4 });
	}
	return price.toLocaleString('ko-KR', { maximumFractionDigits: 8 });
}

export function formatChangeRate(rate: number): string {
	const pct = (rate * 100).toFixed(2);
	return rate >= 0 ? `+${pct}%` : `${pct}%`;
}

export function getChangeClass(change: string): string {
	if (change === 'RISE') return 'up';
	if (change === 'FALL') return 'down';
	return 'neutral';
}

export function formatVolumeMillions(volume: number): string {
	const millions = Math.floor(volume / 1_000_000);
	return millions.toLocaleString('ko-KR') + '백만';
}