/* * 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; using QuantConnect.Orders; using QuantConnect.Interfaces; namespace QuantConnect.Tests.Brokerages; /// /// Represents test parameters for a market-on-close order. /// public class MarketOnCloseOrderTestParameters : MarketOrderTestParameters { /// /// Initializes a new instance of the class. /// /// The trading symbol associated with the order. /// Optional order properties. /// Optional order submission data. public MarketOnCloseOrderTestParameters(Symbol symbol, IOrderProperties properties = null, OrderSubmissionData orderSubmissionData = null) : base(symbol, properties, orderSubmissionData) { } /// /// Creates a short market-on-close order. /// /// The quantity to sell (must be a positive value). /// A new representing a short order. public override Order CreateShortOrder(decimal quantity) { return new MarketOnCloseOrder(Symbol, -Math.Abs(quantity), DateTime.UtcNow, properties: Properties) { OrderSubmissionData = OrderSubmissionData, PriceCurrency = GetSymbolProperties(Symbol).QuoteCurrency }; } /// /// Creates a long market-on-close order. /// /// The quantity to buy (must be a positive value). /// A new representing a long order. public override Order CreateLongOrder(decimal quantity) { return new MarketOnCloseOrder(Symbol, Math.Abs(quantity), DateTime.UtcNow, properties: Properties) { OrderSubmissionData = OrderSubmissionData, PriceCurrency = GetSymbolProperties(Symbol).QuoteCurrency }; } /// /// Gets the expected status of the market-on-close order during testing. /// /// /// Returns because this order type is tested /// when the market is open, meaning it remains in the submitted state until market close. /// public override OrderStatus ExpectedStatus => OrderStatus.Submitted; /// /// Gets a value indicating whether cancellation is expected for this order type. /// /// /// Always returns true because market-on-close orders can be canceled before execution. /// public override bool ExpectedCancellationResult => true; }