Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column for own portfolio #32

Open
lordvalium opened this issue Feb 1, 2018 · 53 comments
Open

Column for own portfolio #32

lordvalium opened this issue Feb 1, 2018 · 53 comments

Comments

@lordvalium
Copy link

Hi,
could it be possible to add a new column (e.g. in detail mode), right after 7d forecast, in which i could paste my number of coins i have in the specific currency?
Thank you

@matteodanelli
Copy link
Owner

Hi,
sure. I'll add it as a future work!

@lordvalium
Copy link
Author

Hi Matteo
that would be amazing !

@SpoturDeal
Copy link

SpoturDeal commented Feb 9, 2018

Hello Mateo,

I have made my own portfolio and changed a few lines of your code.
around line 354 I have added and edit some lines

          var cPrice= apiResult[j].price.replace("€", "");
           cPrice= cPrice.replace(",",".");
           var myWallet=(this.config.wallet[j] * cPrice).toFixed(2);
           var priceWrapper = document.createElement('td')
           var price = document.createElement('price')
           price.style.fontSize = this.config.fontSize
           price.innerHTML = this.config.wallet[j] + ' @ ' + apiResult[j].price.replace("EUR", "€") + ' = € ' + myWallet;

Then I have added in the config.js

	    {
			module: "MMM-cryptocurrency",
			position: "top_left",
			config: {
				currency: ['ripple', 'litecoin'],
				wallet: [251.688014,0.0382885],   // Added this line
                                conversion: 'EUR',
         ......

The wallet in config must be the same order as the currency above.
It looks like this
newset

@lordvalium
Copy link
Author

Thank you, nice idea.
And in detail view?
Meantime I Favorite Detail more because of
The large portfolio.
Nice idea to show the market cap with your
Number of assets

@SpoturDeal
Copy link

SpoturDeal commented Feb 11, 2018

@lordvalium

I have got the solution

           var cPrice= currentCurrency.price.replace("€", "").trim();            //add this line around line 207
           cPrice= parseFloat(cPrice.replace(",","."));            // add this line
           var myWallet='€ '+(this.config.wallet[i] * cPrice ).toFixed(2);     // add this line
           
           var tdValues = [
               name,
               currentCurrency.price,
               myWallet                 //add this line
           ]

It is also necessary to get the alignment proper zo add this line

            for (var j = 0; j < tdValues.length; j++) {
                var tdWrapper = document.createElement('td')
                let currValue = tdValues[j]
                // If I am showing value then set color
                if (currValue.includes('%')) {
                    tdWrapper.style.color = this.colorizeChange(currValue.slice(0,-1))
                }
                tdWrapper.style.textAlign=(j>0?"right":"left");  //add this line
                tdWrapper.innerHTML = currValue
                trWrapper.appendChild(tdWrapper)                              
            }
            wrapper.appendChild(trWrapper)

Only add the lines I have marked the other lines are just to identify where to add
This is how it will look

detail

I hope Matteo add this soon to his module

@SpoturDeal
Copy link

@lordvalium

To add the total market cap of your portfolio you need to write a few lines as well

        tableHeader.style.textAlign="right";        // add this line for layout purpose
        wrapper.appendChild(tableHeader)    
        var marketCapMyWallet=0;                   // add this line  around line 197
        for (i = 0; i < data.length; i++) {
            marketCapMyWallet += parseFloat(currentCurrency.market_cap_eur);    //add this line
            var currentCurrency = data[i]

Then you need the add the data to the wrapper this is around line 240

     wrapper.appendChild(trWrapper)
        }
        var tableCaption = document.createElement('caption');                             // add this line
        tableCaption.innerHTML = "Total market cap: " + marketCapMyWallet;    // add this line
        wrapper.appendChild(tableCaption);       //add this line
        return wrapper

witcap

It gives the total market cap but I didn't do any formatting

@lordvalium
Copy link
Author

Very nice :) Thank you very much

This module is going to be one of the nicest and most intelligent ever.
As other modules only take information from the internet, this one gets very interactive and is now heavily customizeable from the MM owner :)

@SpoturDeal
Copy link

@lordvalium I am not sure what you mean. You can also write German if that's easier to explain.

@lordvalium
Copy link
Author

@SpoturDeal i think Matteo can better follow in English, but thank you!

You had the monetary amount in your code (# of assets * price per asset)
The raw number of assets would be nice (or even selectable) what do you think?

@SpoturDeal
Copy link

@lordvalium I think I know what you need.

Not to mess up Matteos great module I have added my own module based on Matteo's work
you can find it at https://github.com/spoturdeal/MMM-crypto-portfolio

There you can add the wanted currencies
logowithassets
and how much you have in your wallet.
In the config you can choose to show your assets and your portfolio.

@jinjirosan
Copy link

jinjirosan commented Mar 26, 2018

@SpoturDeal I've added your portfolio code. I do not have a certain coin but I do want to see its value change-over-time. In this case the portfolio value would be zero, the coin value would show correctly but the math results in the display of "€ NaN".

I made the following change by adding: ||0
var myWallet=(this.config.wallet[j] * cPrice || 0).toFixed(2);

as my column width is narrower and the graph width I use is only 150px, you'd also have to change to a smaller font:
price.style.fontSize = 'small'

Now it shows zero. Code can stay the same for all coins/portfolios but IMHO it looks more consistent.
:-)

edit: weird though, looking at your feb 9 comment, you have zero ETH and it shows zero. On my mirror it showed up as NaN... anyhow, it works now.

@arcangeloerrico
Copy link

arcangeloerrico commented Nov 12, 2020

@matteodanelli @SpoturDeal , great modul and great custom code. I just wanted to have my wallet stats and value in the same module so i take the code from @SpoturDeal and try to fix it in this module. I need to say i never have done anything like this so if this can be done better i would appreciate it. if you can tell me and this awesome community. This is what i have and for me is enough. I don't want to see more info or data.

Now you can see Crypto Prices, Portfolio amount and how much worth they are:
MM

In the config.js you only need to add the line wallet:

	{
	module: "MMM-cryptocurrency",
	position: "top_left",
	config: {
		apikey: 'xxxx-xxxx-x-x-x-x--x-xxx',
		currency: ['bitcoin', 'ethereum'],
		conversion: 'EUR',
		logoHeaderText: 'Kryptobörse',
		significantDigits: '5',
		fontSize: 'x-large',
		headers: 'none',
		displayType: 'logo',
		wallet: [0.01951150,0.19834263],  //add this line!
		showGraphs: true
		},
	},

In the MMM-cryptocurrency.js add this lines to line 414 (maybe not every time the same line if someone have do changes before in the same .js!):

    //add this to line 414
        var cPrice = apiResult[j].price.replace("€", ""); //add this line
        var cPrice = cPrice.replace(".", "").replace(",", "."); //add this line
        var myWallet = (this.config.wallet[j] * cPrice || 0).toFixed(2); //add this line ((2) change this number if you want to see more decimals)
        var priceWrapper = document.createElement('td') //don't touch this!
        var price = document.createElement('price') //don't touch this!
        price.style.fontSize = this.config.fontSize //don't touch this!
        price.innerHTML = cPrice + '€ x ' + this.config.wallet[j] + ' = ' + myWallet + '€'; //Modify this line for custom view

Everything will be updated every single time when you call the API action automatically, i call it every 300000 ms (5m).

@McNose
Copy link

McNose commented Nov 12, 2020

Hi @arcangeloerrico,

what a coincidence. I've been trying to implement @SpoturDeal 's code for a few hours, especially in the detail view. But I am not good enough.

I resetet my coding and just added your code in line 414 and also adjusted the config.js.
Unfortunately it doesn't work for me.
I get the following picture when I use your code:

//add this to line 414
         var cPrice = apiResult[j].price.replace("€", ""); //add this line
         var cPrice = cPrice.replace(".", "").replace(",", "."); //add this line
         var myWallet = (this.config.wallet[j] * cPrice || 0).toFixed(2); //add this line ((2) change this number if you want to see more decimals)
         var priceWrapper = document.createElement('td') //don't touch this!
         var price = document.createElement('price') //don't touch this!
         price.style.fontSize = this.config.fontSize //don't touch this!
         price.innerHTML = cPrice + '€ x ' + this.config.wallet[j] + ' = ' + myWallet + '€'; //Modify this line for custom view

grafik

Any idea?

Thank you.

@arcangeloerrico
Copy link

Hi @arcangeloerrico,

what a coincidence. I've been trying to implement @SpoturDeal 's code for a few hours, especially in the detail view. But I am not good enough.

I resetet my coding and just added your code in line 414 and also adjusted the config.js.
Unfortunately it doesn't work for me.
I get the following picture when I use your code:

//add this to line 414
         var cPrice = apiResult[j].price.replace("€", ""); //add this line
         var cPrice = cPrice.replace(".", "").replace(",", "."); //add this line
         var myWallet = (this.config.wallet[j] * cPrice || 0).toFixed(2); //add this line ((2) change this number if you want to see more decimals)
         var priceWrapper = document.createElement('td') //don't touch this!
         var price = document.createElement('price') //don't touch this!
         price.style.fontSize = this.config.fontSize //don't touch this!
         price.innerHTML = cPrice + '€ x ' + this.config.wallet[j] + ' = ' + myWallet + '€'; //Modify this line for custom view

grafik

Any idea?

Thank you.

Hi, maybe just delete the first and last row and write it again (don't copy it) maybe it's a copy error while the problem seems to be in the "€" encoding. The correct amount a the end will be correct when you resolve this Problem with the "€" encoding.

@McNose
Copy link

McNose commented Nov 12, 2020

Just to be sure I deleted all rows and wrote them again. Still the same. Might it be a wrong editor?
I changed the € to EUR and than it works (except the replacing of the first €, which is clear).
But anyway it does not bulid the sum as well. It remains 0.00.

@arcangeloerrico
Copy link

Just to be sure I deleted all rows and wrote them again. Still the same. Might it be a wrong editor?
I changed the € to EUR and than it works (except the replacing of the first €, which is clear).
But anyway it does not bulid the sum as well. It remains 0.00.

Trow away the remplace on the first row and let my see what do you see then. I can't test it while I'm on Trip right now.

@McNose
Copy link

McNose commented Nov 12, 2020

If I commend the first row out, the module stays empty.
So I just let it remain.
Here is what I see:
grafik

This is the code I use:

var cPrice = apiResult[j].price.replace("€", ""); 
var cPrice = cPrice.replace(".", "").replace(",", "."); 
var myWallet = (this.config.wallet[j] * cPrice || 0).toFixed(2); //add this line ((2) change this number if you want to see more decimals)
var priceWrapper = document.createElement('td')
var price = document.createElement('price')
price.style.fontSize = this.config.fontSize
price.innerHTML = cPrice + 'EUR x ' + this.config.wallet[j] + ' = ' + myWallet + 'EUR'; //Modify this line for custom view

@arcangeloerrico
Copy link

If I commend the first row out, the module stays empty.
So I just let it remain.
Here is what I see:
grafik

This is the code I use:

var cPrice = apiResult[j].price.replace("€", ""); 
var cPrice = cPrice.replace(".", "").replace(",", "."); 
var myWallet = (this.config.wallet[j] * cPrice || 0).toFixed(2); //add this line ((2) change this number if you want to see more decimals)
var priceWrapper = document.createElement('td')
var price = document.createElement('price')
price.style.fontSize = this.config.fontSize
price.innerHTML = cPrice + 'EUR x ' + this.config.wallet[j] + ' = ' + myWallet + 'EUR'; //Modify this line for custom view

Yeah, the first row is important while you need the price from the API, this can't be deleted. Your problem ist that he didn't remplace the sign, when he can't remplace the sign the multiplicity operation didn't work. Delete from the first lane only (.remplace...) until the end and on innerHTML delete EUR and let me show the result please.

@McNose
Copy link

McNose commented Nov 12, 2020

Ah, I see.

But still no luck
grafik

Code:

var cPrice = apiResult[j].price; 
var cPrice = cPrice.replace(".", "").replace(",", "."); 
var myWallet = (this.config.wallet[j] * cPrice || 0).toFixed(2); //add this line ((2) change this number if you want to see more decimals)
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 + ' '; //Modify this line for custom view

@arcangeloerrico
Copy link

Ah, I see.

But still no luck
grafik

Code:

var cPrice = apiResult[j].price; 
var cPrice = cPrice.replace(".", "").replace(",", "."); 
var myWallet = (this.config.wallet[j] * cPrice || 0).toFixed(2); //add this line ((2) change this number if you want to see more decimals)
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 + ' '; //Modify this line for custom view

Now add to the first row .remplace("€", "") and should work, I think.

@arcangeloerrico
Copy link

If not try ('€' , ''), but the sign need to go or the multiplicity operation didn't work

@McNose
Copy link

McNose commented Nov 12, 2020

Hey, I did it.
And I am really sorry. It was so simple. I just changed the editor and tried your code again. Now everything works.
Really sorry. This is the first time my other editor did not work.

grafik

I hardly dare to ask, but did you also implement that for the detailed view?

I had already tried the @SpoturDeal code described above. In the wrong editor of course, but I'm not sure if it really still works.

Thank you for your perseverance.

@arcangeloerrico
Copy link

Yeah! I just do it for this view a the moment but I can try to implement it in the detailed view, what do you want to have? Just the same information but in the detailed view?

@McNose
Copy link

McNose commented Nov 12, 2020

Great! Thanks a lot.
Yes, actually it is the same information. Like in the picure above:
grafik

Maybe I would change the order of the rows, so it matches your view.
Instead of price-asset-portfolio ----> price-portfolio-asset would fit better.
And please don´t forget the total sum;-)

Awesome.

@arcangeloerrico
Copy link

I will take a look next week when I'm back and have some free time in the work. I will try my best.

@McNose
Copy link

McNose commented Nov 12, 2020

No need to hurry.
Until then you made my day:-)

@arcangeloerrico
Copy link

@McNose Done!

I will try to tell you the changes that i do from my first post so you can do it quickly and without any problem because you have the same content like i do befor. And this time use the correct editor ; )

crypto_detailed

First you need to change the option in the config.js in:
{
module: "MMM-cryptocurrency",
position: "top_center",
config: {
apikey: 'xxxx',
currency: ['bitcoin', 'ethereum'],
conversion: 'EUR',
logoHeaderText: 'Kryptobörse',
significantDigits: '5',
fontSize: 'x-large',
headers: 'none',
headers: ['change24h', 'change1h', 'change7d'], // need this
displayType: 'details', // need this
wallet: [0.01951150,0.19834263],
},
},

Second in MMM-cryptocurrency.js add the following lines (delete all the lines from SpoturDeal code to be sure you only use my code). Search for var tableHeaderValues [] and add the lines (line 162 for me):

    var tableHeaderValues = [
        this.translate('CURRENCY'),
        this.translate('PRICE'),

('Portfolio'), // add this line (don't need the option this.translate)
('Asset'), // add this line (don't need the option this.translate)
]
then add the following code to var tdValues [] (line 195 for me, just after the for (xxx){} function):

	var myPrice=currentCurrency.price.replace("€","");				// add this line
	var myPrice=myPrice.replace(".", "").replace(",", ".");			// add this line
	var myWallet=(this.config.wallet[i]).toFixed(5);				// add this line 
	var myValue=(this.config.wallet[i]*myPrice).toFixed(2) + ' € ';	// add this line
	var tdValues = [
		name,
		 currentCurrency.price,
		myWallet,
		myValue
	];

and that is all if you don't have any problem ^^
Let me know if its work for your!

PD: the .toFixed(5) option is there while when I take it out no info will display. I think that is because I have the option significantDigits: '5' activated maybe if this option is deleted you don't need to put a number in .toFixed() but i didn't try this while I dont need to see more than 5 digit for my Portfolio and 2 Digits for the portfolio total value.

@McNose
Copy link

McNose commented Nov 19, 2020

@arcangeloerrico Awesome work!
I used the correct editor and it works;-)
I don´t use the "significantDigits" option, but let toFixed(5) untouched. Anyway it shows my 9 currencies.
Do you think it is possible to add a "total" line and the end? It would be interessting to know which sum I own at the moment. Specially as btc explodes:-)

And can you change the layout of the row "Asset" a bit? Like in "Preis".
In Preis it is 1.234,56€, but in "Asset" it is 1234.56€.

I don´t know how much work this is. But I am really impressed.
Thank you.

@arcangeloerrico
Copy link

@arcangeloerrico Awesome work!
I used the correct editor and it works;-)
I don´t use the "significantDigits" option, but let toFixed(5) untouched. Anyway it shows my 9 currencies.
Do you think it is possible to add a "total" line and the end? It would be interessting to know which sum I own at the moment. Specially as btc explodes:-)

And can you change the layout of the row "Asset" a bit? Like in "Preis".
In Preis it is 1.234,56€, but in "Asset" it is 1234.56€.

I don't know how much work this is. But I am really impressed.
Thank you.

I don't understand very well what you will do:

  • Do you want a total line that sum every Cryptocoin?
  • Change layout --> I can try that, maybe just need to convert back again. I need to convert "." and "," to null for the multiplication or this didn't work. I will give a check to this.
  • toFixed(5) problem --> can't tell you much to this is a commando and he should do it. Maybe a syntax error? it shows your the (2) good? or are both wrong?

@McNose
Copy link

McNose commented Nov 19, 2020

I just see that I misunderstood the toFixed Option. I changed it to two and I am fine now:-)

Yes, a total line that sums the Euro would be great. Like, if i have got BTC worth 20€ and ETH worth 40€ the line at the end should show "total 60€". My total portfolio sum.
If you got more then two or three currencies it is hard to build the sum by taking a short look.

Concerning the layout, I just see that the row portfolio is 1234.56 as well.

@arcangeloerrico
Copy link

The total line will need more time i think, im not such a pro ; ) (maybe i need to add a completely new table under the detailed view to add this, i will check this).

for the row portfolio you can just use the function .replace(".",",") a the end of .toFixed in var myWallet.

@arcangeloerrico
Copy link

but i just watching if i can do this be like --> if the number has more than 5 numbers use dot or something so. Just give me some time i will reply you for sure.

@McNose
Copy link

McNose commented Nov 19, 2020

Great. The replacement in myWallet works. Thanks.
Concerning the total line, maybe you want to have a look at https://github.com/spoturdeal/MMM-crypto-portfolio.
Because of the api-key the module is not working anymore, but the total line is implemented. Worked for me until the api-change.

@arcangeloerrico
Copy link

@McNose the problem with dot and comma --> Done! (Maybe not the best way to do it but i'm not a Pro and don't ask me what the hell that do I just fund it online and tested it. Its work and that is all you need to know ; ) hahaaha )

var myWallet=(this.config.wallet[i]).toFixed(5).replace(".", ",").replace(/\B(?=(\d{5})+(?!\d))/g,".");
var myValue=(this.config.wallet[i]*myPrice).toFixed(2).replace(".", ",").replace(/\B(?=(\d{3})+(?!\d))/g,".") + ' € ';

PD: You can change the number in the last .replace() from 5 to X and he will put a dot every X number you put there. i let the first one to 5 while when you put 3 he will start to put it on the right while this a string is. In the second one is different this is a number and he will start every time at the decimal dot or comma forward then. I hope you can understand what i try to say : /

Now I will give a try to the Total line ; )

@McNose
Copy link

McNose commented Nov 19, 2020

Well, I am even worse, so never mind not beeing a pro:-)
It works! Great again.
I changed the first replace 5 to 3, and that´s it for me.
I understand it:-)
Nice.

@arcangeloerrico
Copy link

Well, I am even worse, so never mind not beeing a pro:-)
It works! Great again.
I changed the rist replace 5 to 3, and that´s it for me.
I understand it:-)
Nice.

Nice! Nice! i will give a try to the Total line but need some time, maybe late night or next Week while im going to work right now : (

@arcangeloerrico
Copy link

arcangeloerrico commented Nov 19, 2020

@McNose I tried and failed. I cant let my show a fuc* line more in this module. It's not about the module i just don't have enough JS knowledgment or i think so : /. I looked at https://github.com/spoturdeal/MMM-crypto-portfolio but he changed the entery Array { }. I don't want do this because then i need to adapt everything to his module : /.

Maybe can someone else help?!

I tried to create a Table or a td more after the Array and take the infos from the Asset but no success. I didn't get a normal String like "Hi" showing up in a extra table or something like that, nothing :'. I see the module working or i don't see nothing...

Maybe can someone explain me why i can add a table or a td more to the Array and let my show this info. but alone i can't help you more, sorry.

@McNose
Copy link

McNose commented Nov 19, 2020

Well, even if I´ll try, I am not smart enough:-)
But thanks for trying! You already helped me a lot.
Maybe sone else can help us.

By the way: Might be a silly question, but my BTC Price did not change until 3.30pm when I started to watch. Is that right? It stays at 15.000 Euro. The percentage changes every few minutes. Some other currencies did not change as well. Others did.
Is there a rule like "only change the prices when it moves more than xy percentage?

@arcangeloerrico
Copy link

Well, even if I´ll try, I am not smart enough:-)
But thanks for trying! You already helped me a lot.
Maybe sone else can help us.

By the way: Might be a silly question, but my BTC Price did not change until 3.30pm when I started to watch. Is that right? It stays at 15.000 Euro. The percentage changes every few minutes. Some other currencies did not change as well. Others did.
Is there a rule like "only change the prices when it moves more than xy percentage?

You can only put the time in ms that he need to update the Infos. If that happen to you then you maybe have a problem while when you update the array do the whole job for every single one you have added in the list. Maybe the Infos are not update from API server sites and this don't is your problem but I can tell you more. I only have BTC and ETH and I think both update good until now.

@McNose
Copy link

McNose commented Nov 19, 2020

So your BTC price is 15.000 as well? ETH 400?
Or do you mean my list might be too long?
I did not change anything at the time. However the percentage do change.

@arcangeloerrico
Copy link

So your BTC price is 15.000 as well? ETH 400?
Or do you mean my list might be too long?
I did not change anything at the time. However the percentage do change.

No, my BTC and ETH price is another. You need to change the amount you have in the config.js under wallet. First number under wallet match the first input under currency and the second one the second and so continued. If you don't have one you need to erase it from currency or put a 0 in it, I think. I wish I will have 15k in BTC right now 😅, just started at 9800€ to invest and just a small amount. I will wait to pass the hype to get back in, maybe if he goes back..

@arcangeloerrico
Copy link

Maybe is the list to long, what I don't think. You can try it with only 2, them 4 and so continue until you can see it's didn't work and give feedback

@McNose
Copy link

McNose commented Nov 19, 2020

I did not say, how much I spend in BTC;-) But the price is 15k a BTC right now.
It is really strange. Each currency has an amount, the way you described it.
I will try it tomorrow to start with 2 , 4 etc currencies and give you feedback.

@McNose
Copy link

McNose commented Nov 20, 2020

Sometimes it's so easy :-)
I set the digits too small. Therefore, he always rounded the BTC price down to 15k.

Now everything works :-)

If someone could help us with the totals line now, it would be a dream.
If it is to difficult to build an extra line, a total sum somewhere at the top would do it also.

@Tippon
Copy link

Tippon commented Mar 31, 2021

@arcangeloerrico I hope you don't mind me asking you for help, but I'm having a problem with your wallet code. I've copied the code you posted for @McNose, and it seems to be 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 in 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 1000 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'd be very grateful if you could help me please :)

EDIT: I think I've cracked it with some very kind help from a member of the Magic Mirror Forum. As GBP uses commas as separators rather than dots, this line was changing the amounts obtained from the API:

var myPrice=myPrice.replace(".", "").replace(",", ".");

Changing it so that the decimal point wasn't removed and the thousands separator wasn't changed to a decimal point seems to have fixed it. For GBP, that line should be

var myPrice=myPrice.replace(",", "");

So just removing the thousands separator. The thread is here for anyone who wants to read further:

https://forum.magicmirror.builders/topic/14864/mmm-cryptocurrency

@arcangeloerrico
Copy link

@Tippon I'm glad you find it out. I just can't answer before, sorry about that but thanks to work further on the not Pro code that i just do for fun ^^

@Tippon
Copy link

Tippon commented Apr 13, 2021

@arcangeloerrico @McNose Make sure that you back up your MMM-cryptocurrency.js before updating the module. The update removes the changes that you worked so hard for (and that I'm very grateful for :) )

@matteodanelli
Copy link
Owner

Would you like to make a pull request for that work?
We can officially integrate :)

@arcangeloerrico
Copy link

@Tippon yeah i know i didnt start my Pi since last month but i will do a Backup for sure.
@matteodanelli i dont be such a Pro and right now i dont have time : ( like i said its like a month or maybe more that i dont start the Pi and do some work on it.

@McNose
Copy link

McNose commented Apr 13, 2021

@Tippon : Great that it works for you as well now. And thanks for the hint concerning the update of the module;-)
@matteodanelli @arcangeloerrico : A pull request is a good idea. It still works fine and i am really glad about it.

Just as an idea: If somebody is able to code a total sum of the portfolio, that would be the the icing on the cake.

@arcangeloerrico
Copy link

@McNose that with the total sum was my next step but i don't have time right now but i will try this when i just done with all the things i need to do befor ^^

@Tippon
Copy link

Tippon commented Apr 13, 2021

@matteodanelli In all honesty, I wouldn't know where to start. I copied @arcangeloerrico 's homework and got some help from the forum to adapt it 😁

I'm very happy with the module and the modifications though. I used them to impress my brother earlier 😄

@paper111
Copy link

paper111 commented Mar 7, 2024

@matteodanelli @SpoturDeal , great modul and great custom code. I just wanted to have my wallet stats and value in the same module so i take the code from @SpoturDeal and try to fix it in this module. I need to say i never have done anything like this so if this can be done better i would appreciate it. if you can tell me and this awesome community. This is what i have and for me is enough. I don't want to see more info or data.

Now you can see Crypto Prices, Portfolio amount and how much worth they are: MM

In the config.js you only need to add the line wallet:

	{
	module: "MMM-cryptocurrency",
	position: "top_left",
	config: {
		apikey: 'xxxx-xxxx-x-x-x-x--x-xxx',
		currency: ['bitcoin', 'ethereum'],
		conversion: 'EUR',
		logoHeaderText: 'Kryptobörse',
		significantDigits: '5',
		fontSize: 'x-large',
		headers: 'none',
		displayType: 'logo',
		wallet: [0.01951150,0.19834263],  //add this line!
		showGraphs: true
		},
	},

In the MMM-cryptocurrency.js add this lines to line 414 (maybe not every time the same line if someone have do changes before in the same .js!):

    //add this to line 414
        var cPrice = apiResult[j].price.replace("€", ""); //add this line
        var cPrice = cPrice.replace(".", "").replace(",", "."); //add this line
        var myWallet = (this.config.wallet[j] * cPrice || 0).toFixed(2); //add this line ((2) change this number if you want to see more decimals)
        var priceWrapper = document.createElement('td') //don't touch this!
        var price = document.createElement('price') //don't touch this!
        price.style.fontSize = this.config.fontSize //don't touch this!
        price.innerHTML = cPrice + '€ x ' + this.config.wallet[j] + ' = ' + myWallet + '€'; //Modify this line for custom view

Everything will be updated every single time when you call the API action automatically, i call it every 300000 ms (5m).

Hi everyone, I've just tried integrating my portfolio into the module but failed. I must admit I'm quite new to editing .js files. After implementing the lines, only the module's title loads. Could someone help me out? Thanks and have a great evening.
Screenshot_1
Screenshot_2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants