17 using System.Collections.Generic;
40 private readonly
double _percent;
53 double percent = 0.03)
54 : this(rebalancingDateRules.ToFunc(), portfolioBias, percent)
70 double percent = 0.03)
71 : base(rebalancingFunc)
73 _portfolioBias = portfolioBias;
74 _percent = Math.Abs(percent);
88 double percent = 0.03)
89 : this(rebalancingFunc != null ? (Func<DateTime, DateTime?>)(timeUtc => rebalancingFunc(timeUtc)) : null,
111 double percent = 0.03)
112 : this((Func<DateTime, DateTime?>)null,
129 double percent = 0.03)
130 : this(dt => dt.Add(timeSpan), portfolioBias, percent)
144 double percent = 0.03)
145 : this(resolution.ToTimeSpan(), portfolioBias, percent)
156 .OrderBy(insight => insight.GeneratedTimeUtc)
167 var percentPerSymbol =
new Dictionary<Symbol, double>();
169 foreach (var insight
in activeInsights)
171 double targetPercent;
172 if (percentPerSymbol.TryGetValue(insight.Symbol, out targetPercent))
178 if (Math.Abs(targetPercent) < _percent)
185 targetPercent += (targetPercent > 0 ? -_percent : _percent);
189 targetPercent += _percent * (int)insight.Direction;
193 && Math.Sign(targetPercent) != (int)_portfolioBias)
198 percentPerSymbol[insight.Symbol] = targetPercent;
201 return activeInsights.DistinctBy(insight => insight.Symbol)
202 .ToDictionary(insight => insight, insight => percentPerSymbol[insight.Symbol]);