Download server/utils/parser.js from algorembrant/mt5-analyzer: direct link, hf CLI and curl.
- Browser
- Download file 1.82 kB
-
https://huggingface.co/algorembrant/mt5-analyzer/resolve/main/server/utils/parser.js
- Command line
-
hf download hf://algorembrant/mt5-analyzer/server/utils/parser.js
-
curl -L -o parser.js https://huggingface.co/algorembrant/mt5-analyzer/resolve/main/server/utils/parser.js
1.82 kB
| const cheerio = require('cheerio'); | |
| const fs = require('fs'); | |
| const parseMT5Report = (filePath) => { | |
| const html = fs.readFileSync(filePath, 'utf8'); | |
| const $ = cheerio.load(html); | |
| const deals = []; | |
| // 1. Find the header "Deals" to locate the correct section | |
| // The user specified: <th colspan="13" ...>Deals</th> | |
| const dealsHeader = $('th:contains("Deals")'); | |
| if (dealsHeader.length > 0) { | |
| // Find the parent table of this header | |
| const table = dealsHeader.closest('table'); | |
| // Iterate through rows (skipping the header rows) | |
| // We look for rows that contain numeric data or standard deal attributes | |
| table.find('tr').each((i, row) => { | |
| const cols = $(row).find('td'); | |
| // Basic validation to ensure it's a data row (13 columns based on prompt) | |
| 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(), | |
| }; | |
| // Filter out header row repetitions if any exist by checking if 'balance' is a number | |
| if (!isNaN(rowData.balance)) { | |
| deals.push(rowData); | |
| } | |
| } | |
| }); | |
| } | |
| return deals; | |
| }; | |
| module.exports = { parseMT5Report }; |