123456789101112131415161718192021222324252627282930313233343536 |
- package sentio
- type Portfolio interface {
- // Get returns Position of the symbol if exists in Portfolio
- Get(symbol string) (Position, bool)
- // Positions returns each Position we have in Portfolio
- Positions() []Position
- }
- type PortfolioStub []PositionStub
- func (p PortfolioStub) Get(symbol string) (Position, bool) {
- for _, stub := range p {
- if symbol == stub.Symbol {
- return stub, true
- }
- }
- return nil, false
- }
- func (p PortfolioStub) Positions() []Position {
- var positions []Position
- for _, stub := range p {
- positions = append(positions, stub)
- }
- return positions
- }
- func NewPortfolioStub(elem ...PositionStub) Portfolio {
- var p PortfolioStub
- p = append(p, elem...)
- return p
- }
|