/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System.Collections.Generic;
namespace QuantConnect.Securities.Positions
{
///
/// Resolves position groups from a collection of positions.
///
public interface IPositionGroupResolver
{
///
/// Attempts to group the specified positions into a new using an
/// appropriate for position groups created via this
/// resolver.
///
/// The positions to be grouped
/// The currently grouped positions
/// The grouped positions when this resolver is able to, otherwise null
/// True if this resolver can group the specified positions, otherwise false
bool TryGroup(IReadOnlyCollection newPositions, PositionGroupCollection currentPositions, out IPositionGroup group);
///
/// Resolves the position groups that exist within the specified collection of positions.
///
/// The collection of positions
/// An enumerable of position groups
PositionGroupCollection Resolve(PositionCollection positions);
///
/// Determines the position groups that would be evaluated for grouping of the specified
/// positions were passed into the method.
///
///
/// This function allows us to determine a set of impacted groups and run the resolver on just
/// those groups in order to support what-if analysis
///
/// The existing position groups
/// The positions being changed
/// An enumerable containing the position groups that could be impacted by the specified position changes
IEnumerable GetImpactedGroups(
PositionGroupCollection groups,
IReadOnlyCollection positions
);
}
}