Skip to content

Commit

Permalink
print out weighted yield
Browse files Browse the repository at this point in the history
  • Loading branch information
AramKoorn committed Oct 3, 2021
1 parent 5502e1d commit 04dfea4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions tenbagger/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ def main():
print(port.df.drop(columns=['circulatingSupply', 'type']))

# Print passive income
print(f'\n Total passive income: {port.df.passive_income.sum()} {env["CURRENCY"]} \n')
print(f'\n Total value stonks: {port.df[port.df.sector != "Crypto"].value.sum()} {env["CURRENCY"]} \n')
print(f'\n Total value crypto: {port.df[port.df.sector == "Crypto"].value.sum()} {env["CURRENCY"]} \n')
print(f'Total passive income: {port.df.passive_income.sum()} {env["CURRENCY"]} \n')
print(f'Total value stonks: {port.df[port.df.sector != "Crypto"].value.sum()} {env["CURRENCY"]} \n')
print(f'Total value crypto: {port.df[port.df.sector == "Crypto"].value.sum()} {env["CURRENCY"]} \n')
print(f'Total dividend income: {port.df.dividends.sum()} {env["CURRENCY"]} \n')
print(f'Total staking rewards: {port.df.staking_rewards.sum()} {env["CURRENCY"]} \n')

# Print portfolio
by_sector = make_percentage(port.df.groupby('sector').value.sum().reset_index(), 'value', 'sector')
Expand All @@ -132,6 +134,15 @@ def main():
# Print total value
print(f'Total value of portfolio: {round(port.df.value.sum(), 2) } {env["CURRENCY"]}')

# Print out Dividend yield
fmt = lambda x: "{:.3f}".format(x)
df = port.df.copy()
print(
f'Weighted dividend yield: {fmt(df[df.sector != "Crypto"].dividends.sum() / df[df.sector != "Crypto"].value.sum() * 100)}%')
print(
f'Weighted staking rewards: {fmt(df[df.sector == "Crypto"].staking_rewards.sum() / df[df.sector == "Crypto"].value.sum() * 100)}%')
print(f'Weighted yield portfolio: {fmt(df.passive_income.sum() / df.value.sum() * 100)}%')

if args.tracker:
from tenbagger.src.dashboard.trackerdash import main
main()
Expand Down
2 changes: 1 addition & 1 deletion tenbagger/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.1"
__version__ = "0.4.2"

0 comments on commit 04dfea4

Please # to comment.