Open jjc6676 opened 6 years ago
@cryptoeax I'd like to work on this; do you have thoughts on how this should be implemented in the UI?
Yes, thanks for your interest! I think we should extend the wallets and charts UI with some new information for this purpose. Here is the plan that I had in mind for this. It should be enough for you to be able to put together a PR for this. :-)
rate
field which is the latest price for the altcoin in BTC
that we have received from the exchange. So the balance of the coin in BTC is easy to compute. You should add a line after https://github.com/cryptoeax/arbbot/blob/18dfb6b838e59b2c3b511957cc4f9f329a121639/web/WebDB.php#L297 to add an entry to the array for the balance of each alyou tcoin in BTC. (Be careful to handle the special case of BTC
there!)
to "------- TOTAL PORTFOLIO -------
------------ IN BTC -----------
and then calculate the overall portfolio in balance in BTC, and then print it out in here. It woo uld be nice if you can break out the part up to here into one separate PR.
The graph part is quite similar. The server side is here: https://github.com/cryptoeax/arbbot/blob/18dfb6b838e59b2c3b511957cc4f9f329a121639/web/WebDB.php#L85 Each graph has three parameters, mode (0 for balance, 1 for rate and 2 for desired balance), coin and exchange. I think we should add a fourth mode (3 for total balance) where coin will be set to BTC, and exchange will be set to "0". The SQL query for this mode is simular to 0, except that you need to take the rate
into account, similar to the above. This function returns a JSON of the full history of the total balance amounts across exchanges.
The client side of this code has two parts. The links to the graphs will be generated on top of your previous PR with a convention like https://github.com/cryptoeax/arbbot/blob/production/web/ui.js#L757. The graph itself should basically draw itself with little changes to the drawing code but you may need to adapt it a bit to make it work with the added new mode and make it work with the new JSON schema (but I suggest you keep the JSON schema similar to mode=0).
The graph drawing happens in this function: https://github.com/cryptoeax/arbbot/blob/18dfb6b838e59b2c3b511957cc4f9f329a121639/web/ui.js#L144 Look for occurrences of graphMode
for places you would probably need to modify.
Hope this helps!
@cryptoeax Hm, it seems like we're writing a lot of edge cases for BTC when we store the amount of BTC as it's own value. Thoughts on setting RATE for BTC to be 1 for all values?
If not, I'm basically confused on writing the SQL query.
As far as the first PR goes, see #56.
@cryptoeax Hm, it seems like we're writing a lot of edge cases for BTC when we store the amount of BTC as it's own value. Thoughts on setting RATE for BTC to be 1 for all values?
If that makes your life simpler, that's fine. I prefer if you did that as a separate PR for easier t reviewing and merging. Thanks!
Note that you would need to handle the existing data in the user's database. We have had similar changes to the database before, and they're quite simple to make. For example, see this call in the beginning of main.php
. We upgrade the database if necessary: https://github.com/cryptoeax/arbbot/blob/7c8028da95d244d6c22747deddbe7c922ed88e53/bot/Database.php#L418
You would need to do something similar, with a query like UPDATE snapshot SET rate = '1.00000000' WHERE coin = 'BTC';
.
Sorry for being so AFK; I've been traveling with family! Just to give you a heads up, can probably work on this around next week. My apologies for any troubles it may have caused!
Not a problem, thanks for the heads up. Enjoy the time spent with family. :-)
Can we add another TOTAL BTC to the chart and Wallets section that adds the TOTAL BTC + TOTAL ALTCOINS? So TOTAL BTC+ALT = XXX