From 8d2b195bc1d46227f6516dcb7a287a1a4a857a1f Mon Sep 17 00:00:00 2001 From: kevincolyer Date: Tue, 23 Aug 2022 19:36:58 +0100 Subject: [PATCH] finesse to report and output --- node-polo.demo.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/node-polo.demo.js b/node-polo.demo.js index 5eba8ad..03a7842 100644 --- a/node-polo.demo.js +++ b/node-polo.demo.js @@ -9,7 +9,8 @@ import { } from "module"; // construct the require method -const require = createRequire(import.meta.url); +const require = createRequire( + import.meta.url); const jsonfile = require('jsonfile') const url = 'https://api.poloniex.com' @@ -173,13 +174,14 @@ function post(url, path, param = {}) { -// email - sendmail via localhost +// email - nodemailer via localhost function sendEmailReport(report) { let message = { from: 'kevin@thecolyers.net', to: 'kevin@thecolyers.net ', subject: 'Poloniex Report', - text: report, + text: report + "\n", + html: "
" + report + "
", }; let transporter = nodemailer.createTransport({ @@ -238,7 +240,10 @@ function truncate(number) { } function moneydollar(number) { - return (+number).toFixed(2); + return (+number).toLocaleString('en-GB', { + "minimumFractionDigits": 2, + "maximumFractionDigits": 2 + }); } function moneybitcoin(number) { @@ -479,7 +484,8 @@ tableOfCoins.sort((a, b) => b[4] - a[4]); tableOfCoins.push(['', '', '', 'TOTALS', moneydollar(tot_usd), moneybitcoin(tot_btc)]); // output -var report = "MARKETS\n"; +var report = "POLONIEX ACTIVITY REPORT " + new Date().toUTCString() + "\n\n"; +report += "MARKETS\n"; report += tableOfMarkets.toString(); report += "\n\n\n"; report += "Orders\n";