diff --git a/internal/position/position.go b/internal/position/position.go index c2acba6..56188cb 100644 --- a/internal/position/position.go +++ b/internal/position/position.go @@ -106,12 +106,14 @@ func GetPositions(ctx c.Context, aggregatedLots map[string]AggregatedLot) func([ positionsReduced := getPositionsReduced(ctx, aggregatedLots, quotes) + change := positionsReduced.positionSummaryBase.value - positionsReduced.positionSummaryBase.cost + positionSummary := PositionSummary{ Value: positionsReduced.positionSummaryBase.value, Cost: positionsReduced.positionSummaryBase.cost, Change: positionsReduced.positionSummaryBase.value - positionsReduced.positionSummaryBase.cost, DayChange: positionsReduced.positionSummaryBase.dayChange, - ChangePercent: (positionsReduced.positionSummaryBase.value / positionsReduced.positionSummaryBase.cost) * 100, + ChangePercent: (change / positionsReduced.positionSummaryBase.cost) * 100, DayChangePercent: (positionsReduced.positionSummaryBase.dayChange / positionsReduced.positionSummaryBase.value) * 100, } diff --git a/internal/position/position_test.go b/internal/position/position_test.go index 8cfaf1e..b5045bd 100644 --- a/internal/position/position_test.go +++ b/internal/position/position_test.go @@ -102,7 +102,7 @@ var _ = Describe("Position", func() { Cost: 4000, Change: 1450, DayChange: 625, - ChangePercent: 136.25, + ChangePercent: 36.25, DayChangePercent: 11.46788990825688, } Expect(outputPositions["ARKW"]).To(Equal(Position{