import React from 'react';
import { useEffect, useState } from 'react';
const GulfCanadianTable = () => {
const [data, setData] = useState([]);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState(null);
const averageVolume = 2.07; // المتوسط العام للحجم التداولي
useEffect(() => {
const loadData = async () => {
try {
const response = await window.fs.readFile('historical_data-Gulf_Canadian_RE_Inv_Co.csv', { encoding: 'utf8' });
// Parse CSV
const rows = response.split('\n')
.filter(line => line.trim().length > 0)
.map(line => line.split(','));
// Remove the summary line at the end
const dataRows = rows.filter(row => !row[0].includes('Open :'));
setData(dataRows);
setIsLoading(false);
} catch (err) {
console.error('Error loading data:', err);
setError('Failed to load data');
setIsLoading(false);
}
};
loadData();
}, []);
if (isLoading) return
);
};
export default GulfCanadianTable;
جاري تحميل البيانات...
;
if (error) return {error}
;
return (
شركة الخليج الكندية للاستثمار العقاري - بيانات تاريخية
| {header === 'Date' ? 'التاريخ' : header === 'Price' ? 'السعر' : header === 'Open' ? 'الافتتاح' : header === 'High' ? 'الأعلى' : header === 'Low' ? 'الأدنى' : header === 'Vol.' ? 'الحجم' : header === 'Chg. %' ? 'نسبة التغيير %' : header} | ))}نسبة الحجم للمتوسط | |
|---|---|---|
| {cell} | ); })} {/* Add volume ratio column */} {(() => { // Calculate volume ratio compared to average const volumeIndex = data[0].findIndex(h => h === 'Vol.'); const volumeStr = row[volumeIndex]; if (volumeStr && volumeStr.includes('M')) { const volume = parseFloat(volumeStr); const averageVolume = 2.07; const ratio = volume / averageVolume; const ratioFormatted = ratio.toFixed(2) + 'x'; // Style based on ratio value let ratioStyle = 'text-gray-700'; if (ratio > 1.1) ratioStyle = 'text-green-600'; else if (ratio < 0.9) ratioStyle = 'text-red-600'; else ratioStyle = 'text-blue-600'; // Near average return ({ratioFormatted} | ); } return- | ; })()}
ملخص الفترة:
الافتتاح: 4.02
الأعلى: 4.90
الأدنى: 3.95
نسبة التغيير: 15.42%
المتوسط العام للحجم: 2.07 مليون