Skip to content

Commit

Permalink
Improved general market prices part of report
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Colyer committed Sep 23, 2022
1 parent 09dea77 commit 1a52d59
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
43 changes: 33 additions & 10 deletions node-polo.demo.js
Expand Up @@ -242,8 +242,9 @@ function put(url, path, param = {}, apiKey, secretKey) {
/////////////////////////////////////////////
// helper function for number formatting
function percent(number) {

return (truncate(number * 10000) / 100).toFixed(0);
var val=(truncate(number * 10000) / 100).toFixed(0);
if (val>0) {val='+'+val}
return val;
}

// helper function for number formatting
Expand Down Expand Up @@ -406,28 +407,50 @@ var tableOfMarkets = new Table({
'padding-left': 0,
'padding-right': 0
},
head: ['Market', 'Price', 'Changed Daily %'],
colWidths: [20, 20, 20],
colAligns: ['left', 'right', 'right']
head: ['Market', 'USDTPrice', 'Changed Daily %', 'BTC Price'],
colWidths: [12, 12, 16,16],
colAligns: ['left', 'right', 'right','right']
});


var interestingMarkets = new Set();
interestingMarkets.add("BTC_USDT")
interestingMarkets.add("ETH_USDT");
//interestingMarkets.add("BTC_USDT")
//interestingMarkets.add("ETH_USDT");
for (const order of myOrders) {
interestingMarkets.add(order.symbol);
}

for (const symbol of interestingMarkets) {

var market = marketsPriceHash[symbol];
var priceInBTC;
var priceInUSDT;
if (symbol.endsWith('BTC')) {
priceInBTC= market.price;
priceInUSDT = parseFloat(market.price) * myBTC_USDTPrice
}
if (symbol.endsWith('USDT')) {
priceInBTC = parseFloat(market.price)/myBTC_USDTPrice;
priceInUSDT = market.price;
}


// table is an Array, so you can `push`, `unshift`, `splice` and friends
tableOfMarkets.push(
[market.symbol, market.price, percent(market.dailyChange)]
[market.symbol, moneydollar(priceInUSDT), percent(market.dailyChange), moneybitcoin(priceInBTC)]
);

}
tableOfMarkets.sort();
var market= marketsPriceHash["ETH_USDT"];
tableOfMarkets.unshift(
[market.symbol, moneydollar(market.price), percent(market.dailyChange),moneydollar(parseFloat(market.price)/myBTC_USDTPrice)]
);
market= marketsPriceHash["BTC_USDT"];
tableOfMarkets.unshift(
[market.symbol, moneydollar(market.price), percent(market.dailyChange),'n/a']
);



//////////////////////////////////////////////
Expand Down Expand Up @@ -455,7 +478,7 @@ var tableOfOrders = new Table({
'padding-right': 0
},
head: ['Order', 'Prox %', '24hrs %', 'Type', 'Rate', 'Amount', 'Value'],
colWidths: [13, 12, 10, 6, 15, 15, 15],
colWidths: [12, 12, 10, 6, 15, 15, 15],
colAligns: ['left', 'right', 'right', 'right', 'right', 'right', 'right']
});

Expand Down Expand Up @@ -506,7 +529,7 @@ var tableOfCoins = new Table({
'padding-right': 0
},
head: ['Coin', 'Avail', 'Hold', 'Total', 'Value USD', 'Value BTC'],
colWidths: [10, 18, 18, 18, 15, 15],
colWidths: [12, 18, 18, 18, 15, 15],
colAligns: ['left', 'right', 'right', 'right', 'right', 'right']
});

Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -3,6 +3,7 @@
"axios": "^0.27.2",
"cli-table": "^0.3.11",
"crypto-js": "^4.1.1",
"js-beautify": "^1.14.6",
"jsonfile": "^6.1.0",
"nodemailer": "^6.7.8",
"poloniex-node-api": "^5.0.2"
Expand Down

0 comments on commit 1a52d59

Please sign in to comment.