Lean  $LEAN_TAG$
Messages.Commands.cs
1 /*
2  * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3  * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 using System.Runtime.CompilerServices;
18 using QuantConnect.Orders;
19 
20 using static QuantConnect.StringExtensions;
21 
22 namespace QuantConnect
23 {
24  /// <summary>
25  /// Provides user-facing message construction methods and static messages for the <see cref="Commands"/> namespace
26  /// </summary>
27  public static partial class Messages
28  {
29  /// <summary>
30  /// Provides user-facing messages for the <see cref="Commands.BaseCommand"/> class and its consumers or related classes
31  /// </summary>
32  public static class BaseCommand
33  {
34  /// <summary>
35  /// Returns a string message saying: Please provide values for: Ticker, Market and SecurityType
36  /// </summary>
37  public static string MissingValuesToGetSymbol = "Please provide values for: Ticker, Market & SecurityType";
38  }
39 
40  /// <summary>
41  /// Provides user-facing messages for the <see cref="Commands.BaseCommandHandler"/> class and its consumers or related classes
42  /// </summary>
43  public static class BaseCommandHandler
44  {
45  /// <summary>
46  /// Returns a string with the given command
47  /// </summary>
48  [MethodImpl(MethodImplOptions.AggressiveInlining)]
49  public static string ExecutingCommand(ICommand command)
50  {
51  return $"Executing {command}";
52  }
53  }
54 
55  /// <summary>
56  /// Provides user-facing messages for the <see cref="Commands.FileCommandHandler"/> class and its consumers or related classes
57  /// </summary>
58  public static class FileCommandHandler
59  {
60  /// <summary>
61  /// Returns a string message saying: Command Id is null or empty, will skip writing result file
62  /// </summary>
63  public static string NullOrEmptyCommandId = "Command Id is null or empty, will skip writing result file";
64 
65  /// <summary>
66  /// Returns a string message saying the given commandFilePath is being read
67  /// </summary>
68  [MethodImpl(MethodImplOptions.AggressiveInlining)]
69  public static string ReadingCommandFile(string commandFilePath)
70  {
71  return $"Reading command file {commandFilePath}";
72  }
73 
74  /// <summary>
75  /// Returns a string message saying the given commandFilePath does not exists
76  /// </summary>
77  [MethodImpl(MethodImplOptions.AggressiveInlining)]
78  public static string CommandFileDoesNotExist(string commandFilePath)
79  {
80  return $"File {commandFilePath} does not exists";
81  }
82  }
83 
84  /// <summary>
85  /// Provides user-facing messages for the <see cref="Commands.OrderCommand"/> class and its consumers or related classes
86  /// </summary>
87  public static class OrderCommand
88  {
89  /// <summary>
90  /// Returns a string message with basic information about a command, such us:
91  /// order type, symbol, quantity and response
92  /// </summary>
93  [MethodImpl(MethodImplOptions.AggressiveInlining)]
94  public static string CommandInfo(OrderType orderType, QuantConnect.Symbol symbol, decimal quantity, Orders.OrderResponse response)
95  {
96  return Invariant($"{orderType} for {quantity} units of {symbol}: {response}");
97  }
98  }
99  }
100 }