Lean  $LEAN_TAG$
Global.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;
17 using Newtonsoft.Json;
19 using System.Collections.Generic;
20 using Newtonsoft.Json.Converters;
21 using System.Runtime.Serialization;
22 using System.Runtime.CompilerServices;
23 
24 namespace QuantConnect
25 {
26  /// <summary>
27  /// Shortcut date format strings
28  /// </summary>
29  public static class DateFormat
30  {
31  /// Year-Month-Date 6 Character Date Representation
32  public const string SixCharacter = "yyMMdd";
33  /// YYYY-MM-DD Eight Character Date Representation
34  public const string EightCharacter = "yyyyMMdd";
35  /// Daily and hourly time format
36  public const string TwelveCharacter = "yyyyMMdd HH:mm";
37  /// JSON Format Date Representation
38  public static string JsonFormat = "yyyy-MM-ddTHH:mm:ss";
39  /// MySQL Format Date Representation
40  public const string DB = "yyyy-MM-dd HH:mm:ss";
41  /// QuantConnect UX Date Representation
42  public const string UI = "yyyy-MM-dd HH:mm:ss";
43  /// en-US Short Date and Time Pattern
44  public const string USShort = "M/d/yy h:mm tt";
45  /// en-US Short Date Pattern
46  public const string USShortDateOnly = "M/d/yy";
47  /// en-US format
48  public const string US = "M/d/yyyy h:mm:ss tt";
49  /// en-US Date format
50  public const string USDateOnly = "M/d/yyyy";
51  /// Date format of QC forex data
52  public const string Forex = "yyyyMMdd HH:mm:ss.ffff";
53  /// Date format of FIX Protocol UTC Timestamp without milliseconds
54  public const string FIX = "yyyyMMdd-HH:mm:ss";
55  /// Date format of FIX Protocol UTC Timestamp with milliseconds
56  public const string FIXWithMillisecond = "yyyyMMdd-HH:mm:ss.fff";
57  /// YYYYMM Year and Month Character Date Representation (used for futures)
58  public const string YearMonth = "yyyyMM";
59  }
60 
61  /// <summary>
62  /// Singular holding of assets from backend live nodes:
63  /// </summary>
64  [JsonObject]
65  public class Holding
66  {
67  /// Symbol of the Holding:
69 
70  /// Type of the security
71  [JsonIgnore]
73 
74  /// The currency symbol of the holding, such as $
75  public string CurrencySymbol;
76 
77  /// Average Price of our Holding in the currency the symbol is traded in
78  [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
79  public decimal AveragePrice;
80 
81  /// Quantity of Symbol We Hold.
82  [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
83  public decimal Quantity;
84 
85  /// Current Market Price of the Asset in the currency the symbol is traded in
86  [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
87  public decimal MarketPrice;
88 
89  /// Current market conversion rate into the account currency
90  [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
91  public decimal? ConversionRate;
92 
93  /// Current market value of the holding
94  [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
95  public decimal MarketValue;
96 
97  /// Current unrealized P/L of the holding
98  [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
99  public decimal UnrealizedPnL;
100 
101  /// Current unrealized P/L % of the holding
102  [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
103  public decimal UnrealizedPnLPercent;
104 
105  /// Create a new default holding:
106  public Holding()
107  {
108  CurrencySymbol = "$";
109  }
110 
111  /// <summary>
112  /// Create a simple JSON holdings from a Security holding class.
113  /// </summary>
114  /// <param name="security">The security instance</param>
115  public Holding(Security security)
116  : this()
117  {
118  var holding = security.Holdings;
119 
120  Symbol = holding.Symbol;
121  Quantity = holding.Quantity;
122  MarketValue = holding.HoldingsValue;
125 
126  var rounding = security.SymbolProperties.MinimumPriceVariation.GetDecimalPlaces();
127 
128  AveragePrice = Math.Round(holding.AveragePrice, rounding);
129  MarketPrice = Math.Round(holding.Price, rounding);
130  UnrealizedPnL = Math.Round(holding.UnrealizedProfit, 2);
131  UnrealizedPnLPercent = Math.Round(holding.UnrealizedProfitPercent * 100, 2);
132  }
133 
134  /// <summary>
135  /// Clones this instance
136  /// </summary>
137  /// <returns>A new Holding object with the same values as this one</returns>
138  public Holding Clone()
139  {
140  return new Holding
141  {
143  Symbol = Symbol,
144  Quantity = Quantity,
151  };
152  }
153 
154  /// <summary>
155  /// Writes out the properties of this instance to string
156  /// </summary>
157  public override string ToString()
158  {
159  return Messages.Holding.ToString(this);
160  }
161  }
162 
163  /// <summary>
164  /// Represents the types of environments supported by brokerages for trading
165  /// </summary>
166  [JsonConverter(typeof(StringEnumConverter))]
168  {
169  /// <summary>
170  /// Live trading (0)
171  /// </summary>
172  [EnumMember(Value = "live")]
173  Live,
174 
175  /// <summary>
176  /// Paper trading (1)
177  /// </summary>
178  [EnumMember(Value = "paper")]
179  Paper
180  }
181 
182  /// <summary>
183  /// Multilanguage support enum: which language is this project for the interop bridge converter.
184  /// </summary>
185  [JsonConverter(typeof(StringEnumConverter))]
186  public enum Language
187  {
188  /// <summary>
189  /// C# Language Project (0)
190  /// </summary>
191  [EnumMember(Value = "C#")]
192  CSharp,
193 
194  /// <summary>
195  /// FSharp Project (1)
196  /// </summary>
197  [EnumMember(Value = "F#")]
198  FSharp,
199 
200  /// <summary>
201  /// Visual Basic Project (2)
202  /// </summary>
203  [EnumMember(Value = "VB")]
204  VisualBasic,
205 
206  /// <summary>
207  /// Java Language Project (3)
208  /// </summary>
209  [EnumMember(Value = "Ja")]
210  Java,
211 
212  /// <summary>
213  /// Python Language Project (4)
214  /// </summary>
215  [EnumMember(Value = "Py")]
216  Python
217  }
218 
219  /// <summary>
220  /// Live server types available through the web IDE. / QC deployment.
221  /// </summary>
222  public enum ServerType
223  {
224  /// <summary>
225  /// Additional server (0)
226  /// </summary>
227  Server512,
228 
229  /// <summary>
230  /// Upgraded server (1)
231  /// </summary>
232  Server1024,
233 
234  /// <summary>
235  /// Server with 2048 MB Ram (2)
236  /// </summary>
237  Server2048
238  }
239 
240  /// <summary>
241  /// Type of tradable security / underlying asset
242  /// </summary>
243  public enum SecurityType
244  {
245  /// <summary>
246  /// Base class for all security types (0)
247  /// </summary>
248  Base,
249 
250  /// <summary>
251  /// US Equity Security (1)
252  /// </summary>
253  Equity,
254 
255  /// <summary>
256  /// Option Security Type (2)
257  /// </summary>
258  Option,
259 
260  /// <summary>
261  /// Commodity Security Type (3)
262  /// </summary>
263  Commodity,
264 
265  /// <summary>
266  /// FOREX Security (4)
267  /// </summary>
268  Forex,
269 
270  /// <summary>
271  /// Future Security Type (5)
272  /// </summary>
273  Future,
274 
275  /// <summary>
276  /// Contract For a Difference Security Type (6)
277  /// </summary>
278  Cfd,
279 
280  /// <summary>
281  /// Cryptocurrency Security Type (7)
282  /// </summary>
283  Crypto,
284 
285  /// <summary>
286  /// Futures Options Security Type (8)
287  /// </summary>
288  /// <remarks>
289  /// Futures options function similar to equity options, but with a few key differences.
290  /// Firstly, the contract unit of trade is 1x, rather than 100x. This means that each
291  /// option represents the right to buy or sell 1 future contract at expiry/exercise.
292  /// The contract multiplier for Futures Options plays a big part in determining the premium
293  /// of the option, which can also differ from the underlying future's multiplier.
294  /// </remarks>
295  FutureOption,
296 
297  /// <summary>
298  /// Index Security Type (9)
299  /// </summary>
300  Index,
301 
302  /// <summary>
303  /// Index Option Security Type (10)
304  /// </summary>
305  /// <remarks>
306  /// For index options traded on American markets, they tend to be European-style options and are Cash-settled.
307  /// </remarks>
308  IndexOption,
309 
310  /// <summary>
311  /// Crypto Future Type (11)
312  /// </summary>
313  CryptoFuture,
314  }
315 
316  /// <summary>
317  /// Account type: margin or cash
318  /// </summary>
319  public enum AccountType
320  {
321  /// <summary>
322  /// Margin account type (0)
323  /// </summary>
324  Margin,
325 
326  /// <summary>
327  /// Cash account type (1)
328  /// </summary>
329  Cash
330  }
331 
332  /// <summary>
333  /// Market data style: is the market data a summary (OHLC style) bar, or is it a time-price value.
334  /// </summary>
335  public enum MarketDataType
336  {
337  /// Base market data type (0)
338  Base,
339  /// TradeBar market data type (OHLC summary bar) (1)
340  TradeBar,
341  /// Tick market data type (price-time pair) (2)
342  Tick,
343  /// Data associated with an instrument (3)
344  Auxiliary,
345  /// QuoteBar market data type (4) [Bid(OHLC), Ask(OHLC) and Mid(OHLC) summary bar]
346  QuoteBar,
347  /// Option chain data (5)
348  OptionChain,
349  /// Futures chain data (6)
351  }
352 
353  /// <summary>
354  /// Datafeed enum options for selecting the source of the datafeed.
355  /// </summary>
356  public enum DataFeedEndpoint
357  {
358  /// Backtesting Datafeed Endpoint (0)
359  Backtesting,
360  /// Loading files off the local system (1)
361  FileSystem,
362  /// Getting datafeed from a QC-Live-Cloud (2)
363  LiveTrading,
364  /// Database (3)
365  Database
366  }
367 
368  /// <summary>
369  /// Cloud storage permission options.
370  /// </summary>
371  public enum StoragePermissions
372  {
373  /// Public Storage Permissions (0)
374  Public,
375 
376  /// Authenticated Read Storage Permissions (1)
378  }
379 
380  /// <summary>
381  /// Types of tick data
382  /// </summary>
383  /// <remarks>QuantConnect currently only has trade, quote, open interest tick data.</remarks>
384  public enum TickType
385  {
386  /// Trade type tick object (0)
387  Trade ,
388  /// Quote type tick object (1)
389  Quote,
390  /// Open Interest type tick object (for options, futures) (2)
392  }
393 
394  /// <summary>
395  /// Specifies the type of <see cref="QuantConnect.Data.Market.Delisting"/> data
396  /// </summary>
397  public enum DelistingType
398  {
399  /// <summary>
400  /// Specifies a warning of an imminent delisting (0)
401  /// </summary>
402  Warning = 0,
403 
404  /// <summary>
405  /// Specifies the symbol has been delisted (1)
406  /// </summary>
407  Delisted = 1
408  }
409 
410  /// <summary>
411  /// Specifies the type of <see cref="QuantConnect.Data.Market.Split"/> data
412  /// </summary>
413  public enum SplitType
414  {
415  /// <summary>
416  /// Specifies a warning of an imminent split event (0)
417  /// </summary>
418  Warning = 0,
419 
420  /// <summary>
421  /// Specifies the symbol has been split (1)
422  /// </summary>
423  SplitOccurred = 1
424  }
425 
426  /// <summary>
427  /// Resolution of data requested.
428  /// </summary>
429  /// <remarks>Always sort the enum from the smallest to largest resolution</remarks>
430  public enum Resolution
431  {
432  /// Tick Resolution (0)
433  Tick,
434  /// Second Resolution (1)
435  Second,
436  /// Minute Resolution (2)
437  Minute,
438  /// Hour Resolution (3)
439  Hour,
440  /// Daily Resolution (4)
441  Daily
442  }
443 
444  /// <summary>
445  /// Specifies what side a position is on, long/short
446  /// </summary>
447  public enum PositionSide
448  {
449  /// <summary>
450  /// A short position, quantity less than zero (-1)
451  /// </summary>
452  Short = -1,
453 
454  /// <summary>
455  /// No position, quantity equals zero (0)
456  /// </summary>
457  None = 0,
458 
459  /// <summary>
460  /// A long position, quantity greater than zero (1)
461  /// </summary>
462  Long = 1
463  }
464 
465  /// <summary>
466  /// Specifies the different types of options
467  /// </summary>
468  public enum OptionRight
469  {
470  /// <summary>
471  /// A call option, the right to buy at the strike price (0)
472  /// </summary>
473  Call,
474 
475  /// <summary>
476  /// A put option, the right to sell at the strike price (1)
477  /// </summary>
478  Put
479  }
480 
481  /// <summary>
482  /// Specifies the style of an option
483  /// </summary>
484  public enum OptionStyle
485  {
486  /// <summary>
487  /// American style options are able to be exercised at any time on or before the expiration date (0)
488  /// </summary>
489  American,
490 
491  /// <summary>
492  /// European style options are able to be exercised on the expiration date only (1)
493  /// </summary>
494  European
495  }
496 
497  /// <summary>
498  /// Specifies the type of settlement in derivative deals
499  /// </summary>
500  public enum SettlementType
501  {
502  /// <summary>
503  /// Physical delivery of the underlying security (0)
504  /// </summary>
506 
507  /// <summary>
508  /// Cash is paid/received on settlement (1)
509  /// </summary>
510  Cash
511  }
512 
513  /// <summary>
514  /// Wrapper for algorithm status enum to include the charting subscription.
515  /// </summary>
516  public class AlgorithmControl
517  {
518  /// <summary>
519  /// Default initializer for algorithm control class.
520  /// </summary>
522  {
523  // default to true, API can override
524  Initialized = false;
525  HasSubscribers = true;
526  Status = AlgorithmStatus.Running;
527  ChartSubscription = Messages.AlgorithmControl.ChartSubscription;
528  }
529 
530  /// <summary>
531  /// Register this control packet as not defaults.
532  /// </summary>
533  public bool Initialized;
534 
535  /// <summary>
536  /// Current run status of the algorithm id.
537  /// </summary>
539 
540  /// <summary>
541  /// Currently requested chart.
542  /// </summary>
543  public string ChartSubscription;
544 
545  /// <summary>
546  /// True if there's subscribers on the channel
547  /// </summary>
548  public bool HasSubscribers;
549  }
550 
551  /// <summary>
552  /// States of a live deployment.
553  /// </summary>
554  public enum AlgorithmStatus
555  {
556  /// Error compiling algorithm at start (0)
557  DeployError,
558  /// Waiting for a server (1)
559  InQueue,
560  /// Running algorithm (2)
561  Running,
562  /// Stopped algorithm or exited with runtime errors (3)
563  Stopped,
564  /// Liquidated algorithm (4)
565  Liquidated,
566  /// Algorithm has been deleted (5)
567  Deleted,
568  /// Algorithm completed running (6)
569  Completed,
570  /// Runtime Error Stoped Algorithm (7)
571  RuntimeError,
572  /// Error in the algorithm id (not used) (8)
573  Invalid,
574  /// The algorithm is logging into the brokerage (9)
575  LoggingIn,
576  /// The algorithm is initializing (10)
577  Initializing,
578  /// History status update (11)
579  History
580  }
581 
582  /// <summary>
583  /// Specifies where a subscription's data comes from
584  /// </summary>
586  {
587  /// <summary>
588  /// The subscription's data comes from disk (0)
589  /// </summary>
590  LocalFile,
591 
592  /// <summary>
593  /// The subscription's data is downloaded from a remote source (1)
594  /// </summary>
595  RemoteFile,
596 
597  /// <summary>
598  /// The subscription's data comes from a rest call that is polled and returns a single line/data point of information (2)
599  /// </summary>
600  Rest,
601 
602  /// <summary>
603  /// The subscription's data is streamed (3)
604  /// </summary>
605  Streaming,
606 
607  /// <summary>
608  /// The subscription's data comes from the object store (4)
609  /// </summary>
611  }
612 
613  /// <summary>
614  /// Used by the <see cref="Data.LeanDataWriter"/> to determine which merge write policy should be applied
615  /// </summary>
616  public enum WritePolicy
617  {
618  /// <summary>
619  /// Will overwrite any existing file or zip entry with the new content (0)
620  /// </summary>
621  Overwrite = 0,
622 
623  /// <summary>
624  /// Will inject and merge new content with the existings file content (1)
625  /// </summary>
626  Merge,
627 
628  /// <summary>
629  /// Will append new data to the end of the file or zip entry (2)
630  /// </summary>
631  Append
632  }
633 
634  /// <summary>
635  /// enum Period - Enum of all the analysis periods, AS integers. Reference "Period" Array to access the values
636  /// </summary>
637  public enum Period
638  {
639  /// Period Short Codes - 10
640  TenSeconds = 10,
641  /// Period Short Codes - 30 Second
642  ThirtySeconds = 30,
643  /// Period Short Codes - 60 Second
644  OneMinute = 60,
645  /// Period Short Codes - 120 Second
646  TwoMinutes = 120,
647  /// Period Short Codes - 180 Second
648  ThreeMinutes = 180,
649  /// Period Short Codes - 300 Second
650  FiveMinutes = 300,
651  /// Period Short Codes - 600 Second
652  TenMinutes = 600,
653  /// Period Short Codes - 900 Second
654  FifteenMinutes = 900,
655  /// Period Short Codes - 1200 Second
656  TwentyMinutes = 1200,
657  /// Period Short Codes - 1800 Second
658  ThirtyMinutes = 1800,
659  /// Period Short Codes - 3600 Second
660  OneHour = 3600,
661  /// Period Short Codes - 7200 Second
662  TwoHours = 7200,
663  /// Period Short Codes - 14400 Second
664  FourHours = 14400,
665  /// Period Short Codes - 21600 Second
666  SixHours = 21600
667  }
668 
669  /// <summary>
670  /// Specifies how data is normalized before being sent into an algorithm
671  /// </summary>
673  {
674  /// <summary>
675  /// No modifications to the asset price at all. For Equities, dividends are paid in cash and splits are applied directly to your portfolio quantity. (0)
676  /// </summary>
677  Raw,
678  /// <summary>
679  /// Splits and dividends are backward-adjusted into the price of the asset. The price today is identical to the current market price. (1)
680  /// </summary>
681  Adjusted,
682  /// <summary>
683  /// Equity splits are applied to the price adjustment but dividends are paid in cash to your portfolio. This normalization mode allows you to manage dividend payments (e.g. reinvestment) while still giving a smooth time series of prices for indicators. (2)
684  /// </summary>
686  /// <summary>
687  /// Equity splits are applied to the price adjustment and the value of all future dividend payments is added to the initial asset price. (3)
688  /// </summary>
689  TotalReturn,
690  /// <summary>
691  /// Eliminates price jumps between two consecutive contracts, adding a factor based on the difference of their prices. The first contract has the true price. Factor 0. (4)
692  /// </summary>
693  /// <remarks>First contract is the true one, factor 0</remarks>
695  /// <summary>
696  /// Eliminates price jumps between two consecutive contracts, adding a factor based on the difference of their prices. The last contract has the true price. Factor 0. (5)
697  /// </summary>
698  /// <remarks>Last contract is the true one, factor 0</remarks>
700  /// <summary>
701  /// Eliminates price jumps between two consecutive contracts, multiplying the prices by their ratio. The last contract has the true price. Factor 1. (6)
702  /// </summary>
703  /// <remarks>Last contract is the true one, factor 1</remarks>
705  /// <summary>
706  /// Splits and dividends are adjusted into the prices in a given date. Only for history requests. (7)
707  /// </summary>
708  ScaledRaw,
709  }
710 
711  /// <summary>
712  /// Continuous contracts mapping modes
713  /// </summary>
714  public enum DataMappingMode
715  {
716  /// <summary>
717  /// The contract maps on the previous day of expiration of the front month (0)
718  /// </summary>
720  /// <summary>
721  /// The contract maps on the first date of the delivery month of the front month. If the contract expires prior to this date,
722  /// then it rolls on the contract's last trading date instead (1)
723  /// </summary>
724  /// <remarks>For example, the Crude Oil WTI (CL) 'DEC 2021 CLZ1' contract expires on November, 19 2021, so the mapping date will be its expiration date.</remarks>
725  /// <remarks>Another example is the Corn 'DEC 2021 ZCZ1' contract, which expires on December, 14 2021, so the mapping date will be December 1, 2021.</remarks>
727  /// <summary>
728  /// The contract maps when the following back month contract has a higher open interest that the current front month (2)
729  /// </summary>
730  OpenInterest,
731  /// <summary>
732  /// The contract maps when any of the back month contracts of the next year have a higher volume that the current front month (3)
733  /// </summary>
735  }
736 
737  /// <summary>
738  /// The different types of <see cref="CashBook.Updated"/> events
739  /// </summary>
740  public enum CashBookUpdateType
741  {
742  /// <summary>
743  /// A new <see cref="Cash.Symbol"/> was added (0)
744  /// </summary>
745  Added,
746  /// <summary>
747  /// One or more <see cref="Cash"/> instances were removed (1)
748  /// </summary>
749  Removed,
750  /// <summary>
751  /// An existing <see cref="Cash.Symbol"/> was updated (2)
752  /// </summary>
753  Updated
754  }
755 
756  /// <summary>
757  /// Defines Lean exchanges codes and names
758  /// </summary>
759  public static class Exchanges
760  {
761  /// <summary>
762  /// Gets the exchange as single character representation.
763  /// </summary>
764  [MethodImpl(MethodImplOptions.AggressiveInlining)]
765  public static string GetPrimaryExchangeCodeGetPrimaryExchange(this string exchange,
766  SecurityType securityType = SecurityType.Equity,
767  string market = Market.USA)
768  {
769  return exchange.GetPrimaryExchange(securityType, market).Code;
770  }
771 
772  /// <summary>
773  /// Gets the exchange as PrimaryExchange object.
774  /// </summary>
775  /// <remarks>Useful for performance</remarks>
776  [MethodImpl(MethodImplOptions.AggressiveInlining)]
777  public static Exchange GetPrimaryExchange(this string exchange,
778  SecurityType securityType = SecurityType.Equity,
779  string market = Market.USA)
780  {
781  var primaryExchange = Exchange.UNKNOWN;
782  if (string.IsNullOrEmpty(exchange))
783  {
784  return primaryExchange;
785  }
786 
787  if (securityType == SecurityType.Equity)
788  {
789  switch (exchange.LazyToUpper())
790  {
791  case "T":
792  case "Q":
793  case "NASDAQ":
794  case "NASDAQ_OMX":
795  return Exchange.NASDAQ;
796  case "Z":
797  case "BATS":
798  case "BATS Z":
799  case "BATS_Z":
800  return Exchange.BATS;
801  case "P":
802  case "ARCA":
803  return Exchange.ARCA;
804  case "N":
805  case "NYSE":
806  return Exchange.NYSE;
807  case "C":
808  case "NSX":
809  case "NSE":
810  if (market == Market.USA)
811  {
812  return Exchange.NSX;
813  }
814  else if (market == Market.India)
815  {
816  return Exchange.NSE;
817  }
818  return Exchange.UNKNOWN;
819  case "D":
820  case "FINRA":
821  return Exchange.FINRA;
822  case "I":
823  case "ISE":
824  return Exchange.ISE;
825  case "M":
826  case "CSE":
827  return Exchange.CSE;
828  case "W":
829  case "CBOE":
830  return Exchange.CBOE;
831  case "A":
832  case "AMEX":
833  return Exchange.AMEX;
834  case "SIAC":
835  return Exchange.SIAC;
836  case "J":
837  case "EDGA":
838  return Exchange.EDGA;
839  case "K":
840  case "EDGX":
841  return Exchange.EDGX;
842  case "B":
843  case "NASDAQ BX":
844  case "NASDAQ_BX":
845  return Exchange.NASDAQ_BX;
846  case "X":
847  case "NASDAQ PSX":
848  case "NASDAQ_PSX":
849  return Exchange.NASDAQ_PSX;
850  case "Y":
851  case "BATS Y":
852  case "BATS_Y":
853  return Exchange.BATS_Y;
854  case "BB":
855  case "BOSTON":
856  return Exchange.BOSTON;
857  case "BSE":
858  return Exchange.BSE;
859  case "IEX":
860  return Exchange.IEX;
861  case "SMART":
862  return Exchange.SMART;
863  case "OTCX":
864  return Exchange.OTCX;
865  case "MP":
866  case "MIAX PEARL":
867  case "MIAX_PEARL":
868  return Exchange.MIAX_PEARL;
869  case "L":
870  case "LTSE":
871  return Exchange.LTSE;
872  case "MM":
873  case "MEMX":
874  return Exchange.MEMX;
875  }
876  }
877  else if (securityType == SecurityType.Option)
878  {
879  switch (exchange.LazyToUpper())
880  {
881  case "A":
882  case "AMEX":
883  return Exchange.AMEX_Options;
884  case "M":
885  case "MIAX":
886  return Exchange.MIAX;
887  case "ME":
888  case "MIAX EMERALD":
889  case "MIAX_EMERALD":
890  return Exchange.MIAX_EMERALD;
891  case "MP":
892  case "MIAX PEARL":
893  case "MIAX_PEARL":
894  return Exchange.MIAX_PEARL;
895  case "I":
896  case "ISE":
897  return Exchange.ISE;
898  case "H":
899  case "ISE GEMINI":
900  case "ISE_GEMINI":
901  return Exchange.ISE_GEMINI;
902  case "J":
903  case "ISE MERCURY":
904  case "ISE_MERCURY":
905  return Exchange.ISE_MERCURY;
906  case "O":
907  case "OPRA":
908  return Exchange.OPRA;
909  case "W":
910  case "C2":
911  return Exchange.C2;
912  default:
913  return Exchange.UNKNOWN;
914  }
915  }
916  else if (securityType == SecurityType.Future || securityType == SecurityType.FutureOption)
917  {
918  switch (exchange.LazyToUpper())
919  {
920  case "CME":
921  return Exchange.CME;
922  case "CBOT":
923  return Exchange.CBOT;
924  case "NYMEX":
925  return Exchange.NYMEX;
926  case "ICE":
927  return Exchange.ICE;
928  case "CFE":
929  return Exchange.CFE;
930  case "COMEX":
931  return Exchange.COMEX;
932  default:
933  return Exchange.UNKNOWN;
934  }
935  }
936  return Exchange.UNKNOWN;
937  }
938  }
939 
940  /// <summary>
941  /// Defines the different channel status values
942  /// </summary>
943  public static class ChannelStatus
944  {
945  /// <summary>
946  /// The channel is empty
947  /// </summary>
948  public const string Vacated = "channel_vacated";
949 
950  /// <summary>
951  /// The channel has subscribers
952  /// </summary>
953  public const string Occupied = "channel_occupied";
954  }
955 
956  /// <summary>
957  /// Represents the types deployment targets for algorithms
958  /// </summary>
959  [JsonConverter(typeof(StringEnumConverter))]
960  public enum DeploymentTarget
961  {
962  /// <summary>
963  /// Cloud Platform (0)
964  /// </summary>
966 
967  /// <summary>
968  /// Local Platform (1)
969  /// </summary>
971  }
972 
973  /// <summary>
974  /// Represents the deployment modes of an algorithm
975  /// </summary>
976  [JsonConverter(typeof(StringEnumConverter))]
977  public enum AlgorithmMode
978  {
979  /// <summary>
980  /// Live (0)
981  /// </summary>
982  Live,
983 
984  /// <summary>
985  /// Optimization (1)
986  /// </summary>
987  Optimization,
988 
989  /// <summary>
990  /// Backtesting (2)
991  /// </summary>
992  Backtesting,
993 
994  /// <summary>
995  /// Research (3)
996  /// </summary>
997  Research
998  }
999 }