17 using System.Collections.Generic;
37 throw new KeyNotFoundException($
"No position with symbol '{symbol}' exists in the group: {group}");
53 var positions =
template.ToArray(p => p.WithLots(groupQuantity));
56 if (groupQuantity < 0)
61 return new PositionGroup(
template.Key, groupQuantity, positions);
71 return template.WithQuantity(1, positionMananger);
81 return positionGroup.Count == 0;
94 return group.Count == other.Count
95 && group.All(position => Math.Sign(position.Quantity) == -Math.Sign(other.GetPosition(position.Symbol).
Quantity));
107 if (finalGroup.IsEmpty())
112 if (finalGroup.Count != initialGroup.Count)
120 finalGroup.All(position => initialGroup.
TryGetPosition(position.Symbol, out _)))
126 if (finalGroup.IsInvertedOf(initialGroup))
133 finalGroup.All(position => Math.Sign(position.Quantity) == Math.Sign(initialGroup.GetPosition(position.Symbol).
Quantity));
141 if (group.Count == 1)
143 return group.Single().Symbol.ToString();
146 return string.Join(
"|", group.Select(p => p.Symbol.ToString()));