cointop-sh / cointop

A fast and lightweight interactive terminal based UI application for tracking cryptocurrencies 🚀
https://cointop.sh
Apache License 2.0
3.98k stars 311 forks source link

Add support for purchase price/currency to portfolio #243

Closed lyricnz closed 2 years ago

lyricnz commented 2 years ago

Add support for declaring a BuyPrice and BuyCurrency in portfolio. eg: ["Algorand", "125.4", "0.8", "USD"]

Add optional (default off) columns to portfolio: "buy_price", "buy_currency", "profit", "profit_percent"

TODO:

lyricnz commented 2 years ago

With the following config

[portfolio]
  columns = ["rank", "name", "symbol", "price", "holdings", "balance", "1h_change", "24h_change", "7d_change", "percent_holdings", "last_updated"]
  compact_notation = false
  holdings = [["Algorand", "100", "1.95", "USD"], ["Binance Coin", "3.2", "401.45", "USD"], ["Bitcoin", "0.1", "34849.83", "USD"]]

The following output

Screen Shot 2021-10-21 at 11 14 08 am
lyricnz commented 2 years ago

Added "cost" and changed some of the formatting.

[portfolio]
  holdings = [["Algorand", "100", "1.95", "USD"], ["Binance Coin", "3.2", "401.45", "USD"], ["Bitcoin", "0.1", "34849.83", "USD"]]
  columns = ["rank", "name", "symbol", "price", "holdings", "balance", "buy_price", "buy_currency", "cost", "profit", "profit_percent"]
Screen Shot 2021-10-21 at 3 37 23 pm
matthiasbeyer commented 2 years ago

Nice! I Think in the next step it would also be interesting to add the date the purchase was made, so one can see the differences in performance over time - I don't think, though, that this should go in the same PR, should it? (Of course the maintainers have to decide!)

lyricnz commented 2 years ago

I don't know how to make new edit fields, and in fact are in the middle of a radical overhaul of color/keybinding in another PR. Can you test this PR, see if it works for you? (or help?) There are still some todo's here, in particular currency conversion.

lyricnz commented 2 years ago

There's still an issue with changing currency conversion - it takes a while for the table to update, so the numbers are wrong for a bit.

lyricnz commented 2 years ago

Priced in SATs

image

lyricnz commented 2 years ago

The slow-update is caused by #178 which has to do with updating all the pages of coins, one after another, before going back to the top. I think this PR is ready for review. Will raise feature-requests for pnl-alerts and pnl "cointop holdings" output.

lyricnz commented 2 years ago

Renamed and combined buy-price and buy-currency to "cost price".

With the following portfolio (cost in diverse currencies) and column configuration, and the currency set to GBP (British Pound).

[portfolio]
  columns = ["rank", "name", "symbol", "price", "holdings", "balance", "cost_price", "cost", "profit", "profit_percent"]
  holdings = [["Algorand", "100", "1.95", "USD"], ["Binance Coin", "3.2", "401.45", "USD"], ["Bitcoin", "0.1", "50100.83", "AUD"]]

it looks like this:

image

lyricnz commented 2 years ago

Oh! There's still no support for editing the cost price in the UI. I have no idea how to do this yet.

miguelmota commented 2 years ago

For consistency, I renamed 'profit' column keys to 'pnl'. I also added the cost and pnl columns to the default list of column but they'll only render if there's at least one portfolio entry with a specified cost basis. https://github.com/cointop-sh/cointop/commit/fe9400080e07f52af1d139247deee074f327b961

Overall it works great! nice job @lyricnz

lyricnz commented 2 years ago

Oops, I didn't notice your commits weren't in this branch/PR, but were in another! I tried to update your branch from but got all kinds of conflicts, so I create a new branch and cherry-picked the two commits above. Hope this is OK! #250

miguelmota commented 2 years ago

sorry about that! I didn't realize that it was in a different branch. The other PR looks good @lyricnz