|
@@ -1,7 +1,5 @@
|
|
|
package sentio
|
|
|
|
|
|
-import "github.com/samber/lo"
|
|
|
-
|
|
|
type Portfolio interface {
|
|
|
// Get returns Position of the symbol if exists in Portfolio
|
|
|
Get(symbol string) (Position, bool)
|
|
@@ -13,15 +11,22 @@ type Portfolio interface {
|
|
|
type PortfolioStub []PositionStub
|
|
|
|
|
|
func (p PortfolioStub) Get(symbol string) (Position, bool) {
|
|
|
- return lo.Find(p, func(item PositionStub) bool {
|
|
|
- return item.Symbol == symbol
|
|
|
- })
|
|
|
+ for _, stub := range p {
|
|
|
+ if symbol == stub.Symbol {
|
|
|
+ return stub, true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil, false
|
|
|
}
|
|
|
|
|
|
func (p PortfolioStub) Positions() []Position {
|
|
|
- return lo.Map(p, func(item PositionStub, _ int) Position {
|
|
|
- return item
|
|
|
- })
|
|
|
+ var positions []Position
|
|
|
+ for _, stub := range p {
|
|
|
+ positions = append(positions, stub)
|
|
|
+ }
|
|
|
+
|
|
|
+ return positions
|
|
|
}
|
|
|
|
|
|
func NewPortfolioStub(elem ...PositionStub) Portfolio {
|