Skip to content

Commit 786ecc9

Browse files
committed
docs: update comments
1 parent 3b04d64 commit 786ecc9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

internal/holdings/account.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func (h Holding) TotalSharesString() string {
3333
return h.TotalShares
3434
}
3535

36+
// check if holdings account has a currency by symbol name
3637
func (h Holdings) HasCurrencySymbolName(symbol string) bool {
3738
for _, v := range h {
3839
if strings.ToLower(symbol) == strings.ToLower(v.SymbolName) {
@@ -42,6 +43,7 @@ func (h Holdings) HasCurrencySymbolName(symbol string) bool {
4243
return false
4344
}
4445

46+
// check if holdings account has a currency by name
4547
func (h Holdings) HasCurrencyName(name string) bool {
4648
for _, v := range h {
4749
if strings.ToLower(name) == strings.ToLower(v.FullName) {
@@ -51,6 +53,7 @@ func (h Holdings) HasCurrencyName(name string) bool {
5153
return false
5254
}
5355

56+
// MapReduce will return Holdings that have been summed across the same SymbolName
5457
func (h Holdings) MapReduce() (final Holdings) {
5558
rHolds := make(map[string]Holdings)
5659
for i, holding := range h {
@@ -87,23 +90,28 @@ func (h Holdings) MapReduce() (final Holdings) {
8790
return final
8891
}
8992

93+
// HasInfo contains positioning information about holdings in two accounts
9094
type HasInfo struct {
9195
LPos int
9296
RPos int
9397
}
9498

99+
// FoundBoth when both are not -1
95100
func (hi HasInfo) FoundBoth() bool {
96101
return hi.LPos != -1 && hi.RPos != -1
97102
}
98103

104+
// LeftOnly when holding found in the Left Account
99105
func (hi HasInfo) LeftOnly() bool {
100106
return hi.LPos != -1 && hi.RPos == -1
101107
}
102108

109+
// RightOnly when holding found in the Right Account
103110
func (hi HasInfo) RightOnly() bool {
104111
return hi.LPos == -1 && hi.RPos != -1
105112
}
106113

114+
// HasCurrencyMap compares holdings with another Holdings account to check for existence
107115
func (h Holdings) HasCurrencyMap(left func(l IHolding) string, right func(r IHolding) string, ih ...IHolding) map[string]HasInfo {
108116
mb := make(map[string]HasInfo, len(h))
109117
for index, v := range h {
@@ -136,10 +144,14 @@ func (h Holdings) SearchByPattern(pattern regexp.Regexp) []int {
136144
panic("implement me")
137145
}
138146

147+
// Interface to providing holding across different third party accounts
139148
type Account interface {
149+
// GetHoldings returns all holdings that is has
140150
GetHoldings() (Holdings, error)
141151
}
142152

153+
// Interface to providing pricing data
143154
type Price interface {
155+
// GetExchange gets the value of currency1 in currency2
144156
GetExchange(currency1, currency2 string) (string, error)
145157
}

0 commit comments

Comments
 (0)