/*
* 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.Orders
{
///
/// Provides extension methods for the class and for the enumeration
///
public static class OrderExtensions
{
///
/// Determines if the specified status is in a closed state.
///
/// The status to check
/// True if the status is , , or
public static bool IsClosed(this OrderStatus status)
{
return status == OrderStatus.Filled
|| status == OrderStatus.Canceled
|| status == OrderStatus.Invalid;
}
///
/// Determines if the specified status is in an open state.
///
/// The status to check
/// True if the status is not , , or
public static bool IsOpen(this OrderStatus status)
{
return !status.IsClosed();
}
///
/// Determines if the specified status is a fill, that is,
/// order
///
/// The status to check
/// True if the status is or , false otherwise
public static bool IsFill(this OrderStatus status)
{
return status == OrderStatus.Filled || status == OrderStatus.PartiallyFilled;
}
///
/// Determines whether or not the specified order is a limit order
///
/// The order to check
/// True if the order is a limit order, false otherwise
public static bool IsLimitOrder(this OrderType orderType)
{
return orderType == OrderType.Limit
|| orderType == OrderType.StopLimit
|| orderType == OrderType.LimitIfTouched;
}
///
/// Determines whether or not the specified order is a stop order
///
/// The order to check
/// True if the order is a stop order, false otherwise
public static bool IsStopOrder(this OrderType orderType)
{
return orderType == OrderType.StopMarket || orderType == OrderType.StopLimit || orderType == OrderType.TrailingStop;
}
}
}