@@ -33,6 +33,7 @@ func (h Holding) TotalSharesString() string {
33
33
return h .TotalShares
34
34
}
35
35
36
+ // check if holdings account has a currency by symbol name
36
37
func (h Holdings ) HasCurrencySymbolName (symbol string ) bool {
37
38
for _ , v := range h {
38
39
if strings .ToLower (symbol ) == strings .ToLower (v .SymbolName ) {
@@ -42,6 +43,7 @@ func (h Holdings) HasCurrencySymbolName(symbol string) bool {
42
43
return false
43
44
}
44
45
46
+ // check if holdings account has a currency by name
45
47
func (h Holdings ) HasCurrencyName (name string ) bool {
46
48
for _ , v := range h {
47
49
if strings .ToLower (name ) == strings .ToLower (v .FullName ) {
@@ -51,6 +53,7 @@ func (h Holdings) HasCurrencyName(name string) bool {
51
53
return false
52
54
}
53
55
56
+ // MapReduce will return Holdings that have been summed across the same SymbolName
54
57
func (h Holdings ) MapReduce () (final Holdings ) {
55
58
rHolds := make (map [string ]Holdings )
56
59
for i , holding := range h {
@@ -87,23 +90,28 @@ func (h Holdings) MapReduce() (final Holdings) {
87
90
return final
88
91
}
89
92
93
+ // HasInfo contains positioning information about holdings in two accounts
90
94
type HasInfo struct {
91
95
LPos int
92
96
RPos int
93
97
}
94
98
99
+ // FoundBoth when both are not -1
95
100
func (hi HasInfo ) FoundBoth () bool {
96
101
return hi .LPos != - 1 && hi .RPos != - 1
97
102
}
98
103
104
+ // LeftOnly when holding found in the Left Account
99
105
func (hi HasInfo ) LeftOnly () bool {
100
106
return hi .LPos != - 1 && hi .RPos == - 1
101
107
}
102
108
109
+ // RightOnly when holding found in the Right Account
103
110
func (hi HasInfo ) RightOnly () bool {
104
111
return hi .LPos == - 1 && hi .RPos != - 1
105
112
}
106
113
114
+ // HasCurrencyMap compares holdings with another Holdings account to check for existence
107
115
func (h Holdings ) HasCurrencyMap (left func (l IHolding ) string , right func (r IHolding ) string , ih ... IHolding ) map [string ]HasInfo {
108
116
mb := make (map [string ]HasInfo , len (h ))
109
117
for index , v := range h {
@@ -136,10 +144,14 @@ func (h Holdings) SearchByPattern(pattern regexp.Regexp) []int {
136
144
panic ("implement me" )
137
145
}
138
146
147
+ // Interface to providing holding across different third party accounts
139
148
type Account interface {
149
+ // GetHoldings returns all holdings that is has
140
150
GetHoldings () (Holdings , error )
141
151
}
142
152
153
+ // Interface to providing pricing data
143
154
type Price interface {
155
+ // GetExchange gets the value of currency1 in currency2
144
156
GetExchange (currency1 , currency2 string ) (string , error )
145
157
}
0 commit comments