I’ve got MMM-Cryptocurrency up and running, but I want to display my current portfolio value too. Someone else has requested it as an option in the past, and there has been a solution posted.
I’m having a problem with arcangeloerrico’s wallet code from the issue listed here:
Wallet value issue
I’ve copied the code they posted for McNose, and it seems to be mostly working, but the wallet value is wrong, and it’s not consistent.
ETH is currently priced at £1,400 and Doge is currently £0.039. If I put 10 ETH and 10 Doge into the wallet section of config.js, my ETH shows as £14.00 and Doge shows as £390.00.
The first two coins I list are valued at 100 times lower than they should be, the next three are 100 times higher, the sixth coin is correct, then the next two are 100 times higher again. I can’t see any obvious reason for this.
I’ve put the edited code below, with my details removed.
I’d be very grateful if anyone could help me please :)
config.js
{
module: 'MMM-cryptocurrency',
disabled: false,
position: 'bottom_bar',
config: {
apikey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
currency: [
'bitcoin',
'ethereum',
'stellar',
'dogecoin',
'algorand',
'litecoin',
'cardano',
],
conversion: 'GBP',
maximumFractionDigits: 3,
headers: [
'change24h',
'change1h',
'change7d'
],
displayType: 'details',
wallet: [0.14,10.0,150.951,10.0,2.22,0.057,1.234],
showGraphs: true
}
},
MMM-Cryptocurrency.js Line 3 - 18
defaults: {
currency: ['bitcoin'],
conversion: 'USD',
displayLongNames: false,
headers: [],
displayType: 'detail',
showGraphs: false,
logoHeaderText: 'Crypto currency',
significantDigits: [2,4],
minimumFractionDigits: 2,
maximumFractionDigits: 5,
coloredLogos: true,
fontSize: 'xx-large',
limit: '100',
apiDelay: 300000,
},
MMM-Cryptocurrency.js Line 168 - 173
var tableHeaderValues = [
this.translate('CURRENCY'),
this.translate('PRICE'),
('Portfolio'),
('Asset')
]
MMM-Cryptocurrency.js Line 200 - 209
var myPrice=currentCurrency.price.replace("£","");
var myPrice=myPrice.replace(".", "").replace(",", ".");
var myWallet=(this.config.wallet[i]).toFixed(4);
var myValue='£' + (this.config.wallet[i]*myPrice).toFixed(2);
var tdValues = [
name,
currentCurrency.price,
myWallet,
myValue
]
MMM-Cryptocurrency.js Line 427 - 434
var cPrice = apiResult[j].price.replace("£", "");
var cPrice = cPrice.replace(".", "").replace(",", ".");
var myWallet = (this.config.wallet[j] * cPrice || 0).toFixed(2);
var priceWrapper = document.createElement('td')
var price = document.createElement('price')
price.style.fontSize = this.config.fontSize
price.innerHTML = cPrice + '£ x ' + this.config.wallet[j] + ' = ' + myWallet + '£';
price.innerHTML = apiResult[j].price.replace("GBP", "£")