/*
* 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 System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using QuantConnect.Data.Market;
using QuantConnect.Orders;
using QuantConnect.Orders.Fills;
using QuantConnect.Securities;
using static QuantConnect.StringExtensions;
namespace QuantConnect
{
///
/// Provides user-facing message construction methods and static messages for the namespace
///
public static partial class Messages
{
///
/// Provides user-facing messages for the class and its consumers or related classes
///
public static class FillModel
{
///
/// Returns a string message warning saying the order was filled at stale price
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string FilledAtStalePrice(Securities.Security security, Prices prices)
{
return Invariant($"Warning: fill at stale price ({prices.EndTime.ToStringInvariant()} {security.Exchange.TimeZone})");
}
///
/// Returns a string message saying the market never closes for the given symbol, and that an order of the given
/// type cannot be submitted
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string MarketNeverCloses(Securities.Security security, OrderType orderType)
{
return Invariant($"Market never closes for this symbol {security.Symbol}, can no submit a {nameof(orderType)} order.");
}
///
/// Returns a string message containing the given subscribedTypes
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static string SubscribedTypesToString(HashSet subscribedTypes)
{
return subscribedTypes == null
? string.Empty
: Invariant($" SubscribedTypes: [{string.Join(",", subscribedTypes.Select(type => type.Name))}]");
}
///
/// Returns a string message saying it was impossible to get ask price to perform the fill for the given security symbol because
/// no market data was found
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string NoMarketDataToGetAskPriceForFilling(Securities.Security security, HashSet subscribedTypes = null)
{
return Invariant($"Cannot get ask price to perform fill for {security.Symbol} because no market data was found.") +
SubscribedTypesToString(subscribedTypes);
}
///
/// Returns a string message saying it was impossible to get bid price to perform the fill for the given security symbol because
/// no market data was found
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string NoMarketDataToGetBidPriceForFilling(Securities.Security security, HashSet subscribedTypes = null)
{
return Invariant($"Cannot get bid price to perform fill for {security.Symbol} because no market data was found.") +
SubscribedTypesToString(subscribedTypes);
}
///
/// Returns a string message saying it was impossible to perform a fill for the given security symbol because
/// no data subscription was found
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string NoDataSubscriptionFoundForFilling(Securities.Security security)
{
return Invariant($"Cannot perform fill for {security.Symbol} because no data subscription were found.");
}
}
///
/// Provides user-facing messages for the class and its consumers or related classes
///
public static class EquityFillModel
{
///
/// String message saying: No trade with the OfficialOpen or OpeningPrints flag within the 1-minute timeout
///
public static string MarketOnOpenFillNoOfficialOpenOrOpeningPrintsWithinOneMinute =
"No trade with the OfficialOpen or OpeningPrints flag within the 1-minute timeout.";
///
/// String message saying: No trade with the OfficialClose or ClosingPrints flag within the 1-minute timeout
///
public static string MarketOnCloseFillNoOfficialCloseOrClosingPrintsWithinOneMinute =
"No trade with the OfficialClose or ClosingPrints flag within the 1-minute timeout.";
///
/// String message saying: No trade with the OfficialClose or ClosingPrints flag for data that does not include
/// extended market hours
///
public static string MarketOnCloseFillNoOfficialCloseOrClosingPrintsWithoutExtendedMarketHours =
"No trade with the OfficialClose or ClosingPrints flag for data that does not include extended market hours.";
///
/// Returns a string message saying the last data (of the given tick type) has been used to fill
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string FilledWithLastTickTypeData(Tick tick)
{
return Invariant($"Fill with last {tick.TickType} data.");
}
///
/// Returns a string message warnning the user that no trade information was available, so the order was filled
/// using quote data
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string FilledWithQuoteData(Securities.Security security)
{
return Invariant($@"Warning: No trade information available at {security.LocalTime.ToStringInvariant()} {
security.Exchange.TimeZone}, order filled using Quote data");
}
///
/// Returns a string message warning the user that the fill is at stale price and that the order will
/// be filled using quote tick data
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string FilledWithQuoteTickData(Securities.Security security, Tick quoteTick)
{
return Invariant($@"Warning: fill at stale price ({quoteTick.EndTime.ToStringInvariant()} {
security.Exchange.TimeZone}), using Quote Tick data.");
}
///
/// Returns a string message warning the user that no quote information was available, so the order
/// was filled using trade tick data
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string FilledWithTradeTickData(Securities.Security security, Tick tradeTick)
{
return Invariant($@"Warning: No quote information available at {tradeTick.EndTime.ToStringInvariant()} {
security.Exchange.TimeZone}, order filled using Trade Tick data");
}
///
/// Returns a string message warning the user that the fill was at stale price, so quote bar data
/// was used to fill the order
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string FilledWithQuoteBarData(Securities.Security security, QuoteBar quoteBar)
{
return Invariant($@"Warning: fill at stale price ({quoteBar.EndTime.ToStringInvariant()} {
security.Exchange.TimeZone}), using QuoteBar data.");
}
///
/// Returns a string message warning the user that no quote information was available, so that trade bar
/// data was used to fill the order
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string FilledWithTradeBarData(Securities.Security security, TradeBar tradeBar)
{
return Invariant($@"Warning: No quote information available at {tradeBar.EndTime.ToStringInvariant()} {
security.Exchange.TimeZone}, order filled using TradeBar data");
}
///
/// Returns a string message saying that the order was filled using the open price due to a favorable gap
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string FilledWithOpenDueToFavorableGap(Securities.Security security, TradeBar tradeBar)
{
return Invariant($@"Due to a favorable gap at {tradeBar.EndTime.ToStringInvariant()} {security.Exchange.TimeZone}, order filled using the open price ({tradeBar.Open})");
}
///
/// Returns a string message saying that the order was filled using the open price due to an unfavorable gap
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string FilledWithOpenDueToUnfavorableGap(Securities.Security security, TradeBar tradeBar)
{
return Invariant($@"Due to an unfavorable gap at {tradeBar.EndTime.ToStringInvariant()} {security.Exchange.TimeZone}, order filled using the open price ({tradeBar.Open})");
}
}
}
}