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
Comments
Hi, |
Hi Matteo |
Thank you, nice idea. |
I have got the solution
It is also necessary to get the alignment proper zo add this line
Only add the lines I have marked the other lines are just to identify where to add I hope Matteo add this soon to his module |
To add the total market cap of your portfolio you need to write a few lines as well
Then you need the add the data to the wrapper this is around line 240
It gives the total market cap but I didn't do any formatting |
Very nice :) Thank you very much This module is going to be one of the nicest and most intelligent ever. |
@lordvalium I am not sure what you mean. You can also write German if that's easier to explain. |
@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) |
@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 There you can add the wanted currencies |
@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 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: 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. |
@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: In the config.js you only need to add the line wallet:
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!):
Everything will be updated every single time when you call the API action automatically, i call it every 300000 ms (5m). |
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.
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. |
Just to be sure I deleted all rows and wrote them again. Still the same. Might it be a wrong editor? |
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. |
Ah, I see. Code:
|
Now add to the first row .remplace("€", "") and should work, I think. |
If not try ('€' , ''), but the sign need to go or the multiplicity operation didn't work |
Hey, I did it. 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. |
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? |
I will take a look next week when I'm back and have some free time in the work. I will try my best. |
No need to hurry. |
@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 ; ) First you need to change the option in the config.js in: 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):
('Portfolio'), // add this line (don't need the option this.translate)
and that is all if you don't have any problem ^^ 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. |
@arcangeloerrico Awesome work! And can you change the layout of the row "Asset" a bit? Like in "Preis". I don´t know how much work this is. But I am really impressed. |
I don't understand very well what you will do:
|
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. Concerning the layout, I just see that the row portfolio is 1234.56 as well. |
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. |
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. |
Great. The replacement in myWallet works. Thanks. |
@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,"."); 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 ; ) |
Well, I am even worse, so never mind not beeing a pro:-) |
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 : ( |
@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. |
Well, even if I´ll try, I am not smart enough:-) 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. |
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. |
So your BTC price is 15.000 as well? ETH 400? |
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.. |
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 |
I did not say, how much I spend in BTC;-) But the price is 15k a BTC right now. |
Sometimes it's so easy :-) Now everything works :-) If someone could help us with the totals line now, it would be a dream. |
@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:
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
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 |
@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 ^^ |
@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 :) ) |
Would you like to make a pull request for that work? |
@Tippon yeah i know i didnt start my Pi since last month but i will do a Backup for sure. |
@Tippon : Great that it works for you as well now. And thanks for the hint concerning the update of the module;-) 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. |
@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 ^^ |
@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 😄 |
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. |
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
The text was updated successfully, but these errors were encountered: