18 using System.Collections.Generic;
44 public IReadOnlyList<OptionStrategyLegDefinitionMatch>
Legs {
get; }
51 IReadOnlyList<OptionStrategyLegDefinitionMatch> legs,
65 var optionPositions =
Legs.Select(leg => leg.CreateOptionPosition(
Multiplier));
68 optionPositions = optionPositions.Concat(
new[]
81 var legs =
Legs.Select(leg => leg.CreateOptionStrategyLeg(
Multiplier));
84 Underlying =
Legs[0].Position.Underlying
87 foreach (var optionLeg
in legs)
89 optionLeg.Invoke(strategy.UnderlyingLegs.Add, strategy.OptionLegs.Add);
108 if (ReferenceEquals(
null, other))
113 if (ReferenceEquals(
this, other))
124 var positions = other.
Legs.ToDictionary(leg => leg.Position, leg => leg.Multiplier);
125 foreach (var leg
in other.Legs)
128 if (!positions.TryGetValue(leg.Position, out multiplier))
133 if (leg.Multiplier != multiplier)
147 if (ReferenceEquals(
null, obj))
152 if (ReferenceEquals(
this, obj))
157 if (obj.GetType() != GetType())
176 var arr =
new int[
Legs.Count];
177 for (
int i = 0; i <
Legs.Count; i++)
179 arr[i] =
Legs[i].GetHashCode();
184 for (
int i = 0; i < arr.Length; i++)
186 hashCode = (hashCode * 397) ^ arr[i];
197 return $
"{Definition.Name}: {string.Join("|
", Legs.Select(leg => leg.Position))}";
206 return Equals(left, right);
215 return !
Equals(left, right);