/*
* 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.
*/
namespace QuantConnect.Securities.Positions
{
///
/// Defines the parameters for
///
public class GetMaximumLotsForDeltaBuyingPowerParameters
{
///
/// Gets the algorithm's portfolio manager
///
public SecurityPortfolioManager Portfolio { get; }
///
/// Gets the position group
///
public IPositionGroup PositionGroup { get; }
///
/// The delta buying power.
///
/// Sign defines the position side to apply the delta, positive long, negative short side.
public decimal DeltaBuyingPower { get; }
///
/// True enables the to skip setting
/// for non error situations, for performance
///
public bool SilenceNonErrorReasons { get; }
///
/// Configurable minimum order margin portfolio percentage to ignore bad orders, orders with unrealistic small sizes
///
/// Default value is 0. This setting is useful to avoid small trading noise when using SetHoldings
public decimal MinimumOrderMarginPortfolioPercentage { get; }
///
/// Initializes a new instance of the class
///
/// The algorithm's portfolio manager
/// The position group
/// The delta buying power to apply. Sign defines the position side to apply the delta
/// Configurable minimum order margin portfolio percentage to ignore orders with unrealistic small sizes
/// True will not return
/// set for non error situation, this is for performance
public GetMaximumLotsForDeltaBuyingPowerParameters(
SecurityPortfolioManager portfolio,
IPositionGroup positionGroup,
decimal deltaBuyingPower,
decimal minimumOrderMarginPortfolioPercentage,
bool silenceNonErrorReasons = false
)
{
Portfolio = portfolio;
PositionGroup = positionGroup;
DeltaBuyingPower = deltaBuyingPower;
SilenceNonErrorReasons = silenceNonErrorReasons;
MinimumOrderMarginPortfolioPercentage = minimumOrderMarginPortfolioPercentage;
}
///
/// Creates a new with zero quantity and an error message.
///
public GetMaximumLotsResult Error(string reason)
{
return new GetMaximumLotsResult(0, reason, true);
}
///
/// Creates a new with zero quantity and no message.
///
public GetMaximumLotsResult Zero()
{
return new GetMaximumLotsResult(0, string.Empty, false);
}
///
/// Creates a new with zero quantity and an info message.
///
public GetMaximumLotsResult Zero(string reason)
{
return new GetMaximumLotsResult(0, reason, false);
}
///
/// Creates a new for the specified quantity and no message.
///
public GetMaximumLotsResult Result(decimal quantity)
{
return new GetMaximumLotsResult(quantity, string.Empty, false);
}
}
}