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

[Feature]: capital gain display in addition to the account variation in percent #8647

Open
mdedonno1337 opened this issue Dec 9, 2024 · 0 comments
Labels
libraries Impacts the Libraries triage In need of triage

Comments

@mdedonno1337
Copy link

mdedonno1337 commented Dec 9, 2024

Describe your feature request

Hi,

Currently, in the Ledger Live application, the variation in percent of the value is displayed.
This value is computed using the current value of the account, and not capital gain ; this implies that, for example, if I add tokens in the account (get or buy tokens), the value of the account get up, hence drive the percent up, even if no real gain has been done.
As an example, if I have 100$, then buy 100$ more, and the value for one token get down 50%, 0% variation will be displayed for that account, even if I've spent 200$ and have a value of 100$ now.

It would be interesting to add (in addition, or as option) the capital gain computed with the data already stored in the transaction history (with the "transaction date" value and the "Current value" fields).

At the moment, I do the computation as follow in R :

library(readr)
library(dplyr)
library(reshape2)
library(magrittr)

options("scipen" = 100, "digits" = 4)

raw <- read_csv("ledgerlive-operations.csv", show_col_types = FALSE) %>%
  filter(`Operation Type` %in% c("IN", "OUT")) %>%
  mutate(
    name = `Currency Ticker`,
    fac = ifelse(`Operation Type` == "IN", 1, -1),
    value_date = `Countervalue at Operation Date` * fac,
    value_now = `Countervalue at CSV Export` * fac,
    amount = `Operation Amount` * fac,
  )

data <- raw %>%
  select(c("name", "value_date", "value_now", "amount")) %>%
  na.omit() %>%
  melt(id = c("name")) %>%
  dcast(name ~ variable, sum) %>%
  mutate(
    mean_price = value_date / amount,
    gain = value_now - value_date,
    gain_percent = gain / value_date * 100
  ) %>%
  arrange(-gain_percent) %>%
  filter(value_now > 1)

data
data %>%
  summarise(
    value_date = sum(value_date),
    value_now = sum(value_now),
    gain = sum(gain),
  ) %>%
  mutate(gain_percent = gain / value_date * 100)
@mdedonno1337 mdedonno1337 added libraries Impacts the Libraries triage In need of triage labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libraries Impacts the Libraries triage In need of triage
Projects
None yet
Development

No branches or pull requests

1 participant