Skip to content

Commit

Permalink
Include total value in cost basis
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Feb 10, 2024
1 parent dfa4b53 commit 1929765
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2007,13 +2007,17 @@ async fn process_account_cost_basis(

for (amount, price) in lots {
total_amount += amount;
total_price += Decimal::from_u64(amount).unwrap() * price;
total_price += Decimal::from_f64(token.ui_amount(amount)).unwrap() * price;
}
println!(
" {:>7}: {:<20} at ${:.2}",
" {:>7}: {:<20} at ${} ; ${:.2} per {}",
token.to_string(),
token.format_amount(total_amount),
total_price / Decimal::from_u64(total_amount).unwrap()
TryInto::<f64>::try_into(total_price)
.unwrap()
.separated_string_with_fixed_place(2),
total_price / Decimal::from_f64(token.ui_amount(total_amount)).unwrap(),
token.name()
);
}
Ok(())
Expand Down

0 comments on commit 1929765

Please sign in to comment.