diff --git a/helper/skip.go b/helper/skip.go index 69dcbd5..bec5f90 100644 --- a/helper/skip.go +++ b/helper/skip.go @@ -17,7 +17,10 @@ func Skip[T any](c <-chan T, count int) <-chan T { go func() { for i := 0; i < count; i++ { - <-c + _, ok := <-c + if !ok { + break + } } Pipe(c, result) diff --git a/strategy/strategy.go b/strategy/strategy.go index cb26887..d4257b5 100644 --- a/strategy/strategy.go +++ b/strategy/strategy.go @@ -43,16 +43,11 @@ func ComputeWithOutcome(s Strategy, c <-chan *asset.Snapshot) (<-chan Action, <- snapshots := helper.Duplicate(c, 2) actions := helper.Duplicate(s.Compute(snapshots[0]), 2) + closings := asset.SnapshotsAsClosings(snapshots[1]) - openings := helper.Skip(asset.SnapshotsAsOpenings(snapshots[1]), 1) + outcomes := Outcome(closings, actions[1]) - outcomes := helper.Echo( - Outcome(openings, actions[0]), - 1, - 1, - ) - - return actions[1], outcomes + return actions[0], outcomes } // AllStrategies returns a slice containing references to all available base strategies.