Skip to content

Commit

Permalink
finesse to report and output
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincolyer committed Aug 23, 2022
1 parent 3384f0d commit 8d2b195
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions node-polo.demo.js
Expand Up @@ -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'
Expand Down Expand Up @@ -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: "<pre>" + report + "</pre>",
};

let transporter = nodemailer.createTransport({
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 8d2b195

Please sign in to comment.