| const cheerio = require('cheerio');
|
| const fs = require('fs');
|
|
|
| const parseMT5Report = (filePath) => {
|
| const html = fs.readFileSync(filePath, 'utf8');
|
| const $ = cheerio.load(html);
|
| const deals = [];
|
|
|
|
|
|
|
| const dealsHeader = $('th:contains("Deals")');
|
|
|
| if (dealsHeader.length > 0) {
|
|
|
| const table = dealsHeader.closest('table');
|
|
|
|
|
|
|
| table.find('tr').each((i, row) => {
|
| const cols = $(row).find('td');
|
|
|
|
|
| if (cols.length === 13) {
|
| const rowData = {
|
| time: $(cols[0]).text().trim(),
|
| deal: $(cols[1]).text().trim(),
|
| symbol: $(cols[2]).text().trim(),
|
| type: $(cols[3]).text().trim(),
|
| direction: $(cols[4]).text().trim(),
|
| volume: parseFloat($(cols[5]).text().trim()),
|
| price: parseFloat($(cols[6]).text().trim()),
|
| order: $(cols[7]).text().trim(),
|
| commission: parseFloat($(cols[8]).text().trim()),
|
| swap: parseFloat($(cols[9]).text().trim()),
|
| profit: parseFloat($(cols[10]).text().trim()),
|
| balance: parseFloat($(cols[11]).text().trim()),
|
| comment: $(cols[12]).text().trim(),
|
| };
|
|
|
|
|
| if (!isNaN(rowData.balance)) {
|
| deals.push(rowData);
|
| }
|
| }
|
| });
|
| }
|
| return deals;
|
| };
|
|
|
| module.exports = { parseMT5Report }; |