Skip to content

Commit

Permalink
Added yield getter to portfolio
Browse files Browse the repository at this point in the history
  • Loading branch information
SlashGordon committed Aug 29, 2021
1 parent 9314357 commit 96fb097
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions portfolio.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ func (p Portfolio) Value() float64 {
return value
}

// Yield return the yield value of the portfolio
func (p Portfolio) Yield() float64 {
return (p.Value()/p.initialCash - 1) * 100
}

// Holdings returns the holdings of the portfolio
func (p Portfolio) Holdings() map[string]Position {
return p.holdings
Expand Down

0 comments on commit 96fb097

Please sign in to comment.