/*
* 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 Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.ComponentModel;
using QuantConnect.Securities;
using Newtonsoft.Json.Converters;
using System.Runtime.Serialization;
using System.Runtime.CompilerServices;
namespace QuantConnect
{
///
/// Shortcut date format strings
///
public static class DateFormat
{
/// Year-Month-Date 6 Character Date Representation
public const string SixCharacter = "yyMMdd";
/// YYYY-MM-DD Eight Character Date Representation
public const string EightCharacter = "yyyyMMdd";
/// Daily and hourly time format
public const string TwelveCharacter = "yyyyMMdd HH:mm";
/// JSON Format Date Representation
public static string JsonFormat { get; } = "yyyy-MM-ddTHH:mm:ss";
/// MySQL Format Date Representation
public const string DB = "yyyy-MM-dd HH:mm:ss";
/// QuantConnect UX Date Representation
public const string UI = "yyyy-MM-dd HH:mm:ss";
/// en-US Short Date and Time Pattern
public const string USShort = "M/d/yy h:mm tt";
/// en-US Short Date Pattern
public const string USShortDateOnly = "M/d/yy";
/// en-US format
public const string US = "M/d/yyyy h:mm:ss tt";
/// en-US Date format
public const string USDateOnly = "M/d/yyyy";
/// Date format of QC forex data
public const string Forex = "yyyyMMdd HH:mm:ss.ffff";
/// Date format of FIX Protocol UTC Timestamp without milliseconds
public const string FIX = "yyyyMMdd-HH:mm:ss";
/// Date format of FIX Protocol UTC Timestamp with milliseconds
public const string FIXWithMillisecond = "yyyyMMdd-HH:mm:ss.fff";
/// YYYYMM Year and Month Character Date Representation (used for futures)
public const string YearMonth = "yyyyMM";
}
///
/// Singular holding of assets from backend live nodes:
///
[JsonConverter(typeof(HoldingJsonConverter))]
public class Holding
{
private decimal? _conversionRate;
private decimal _marketValue;
private decimal _unrealizedPnl;
private decimal _unrealizedPnLPercent;
/// Symbol of the Holding:
[JsonIgnore]
public Symbol Symbol { get; set; } = Symbol.Empty;
/// Type of the security
[JsonIgnore]
public SecurityType Type => Symbol.SecurityType;
/// The currency symbol of the holding, such as $
[DefaultValue("$")]
[JsonProperty(PropertyName = "c", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string CurrencySymbol { get; set; }
/// Average Price of our Holding in the currency the symbol is traded in
[JsonConverter(typeof(DecimalJsonConverter))]
[JsonProperty(PropertyName = "a", DefaultValueHandling = DefaultValueHandling.Ignore)]
public decimal AveragePrice { get; set; }
/// Quantity of Symbol We Hold.
[JsonConverter(typeof(DecimalJsonConverter))]
[JsonProperty(PropertyName = "q", DefaultValueHandling = DefaultValueHandling.Ignore)]
public decimal Quantity { get; set; }
/// Current Market Price of the Asset in the currency the symbol is traded in
[JsonConverter(typeof(DecimalJsonConverter))]
[JsonProperty(PropertyName = "p", DefaultValueHandling = DefaultValueHandling.Ignore)]
public decimal MarketPrice { get; set; }
/// Current market conversion rate into the account currency
[JsonConverter(typeof(DecimalJsonConverter))]
[JsonProperty(PropertyName = "r", DefaultValueHandling = DefaultValueHandling.Ignore)]
public decimal? ConversionRate
{
get
{
return _conversionRate;
}
set
{
if (value != 1)
{
_conversionRate = value;
}
}
}
/// Current market value of the holding
[JsonConverter(typeof(DecimalJsonConverter))]
[JsonProperty(PropertyName = "v", DefaultValueHandling = DefaultValueHandling.Ignore)]
public decimal MarketValue
{
get
{
return _marketValue;
}
set
{
_marketValue = value.SmartRoundingShort();
}
}
/// Current unrealized P/L of the holding
[JsonConverter(typeof(DecimalJsonConverter))]
[JsonProperty(PropertyName = "u", DefaultValueHandling = DefaultValueHandling.Ignore)]
public decimal UnrealizedPnL
{
get
{
return _unrealizedPnl;
}
set
{
_unrealizedPnl = value.SmartRoundingShort();
}
}
/// Current unrealized P/L % of the holding
[JsonConverter(typeof(DecimalJsonConverter))]
[JsonProperty(PropertyName = "up", DefaultValueHandling = DefaultValueHandling.Ignore)]
public decimal UnrealizedPnLPercent
{
get
{
return _unrealizedPnLPercent;
}
set
{
_unrealizedPnLPercent = value.SmartRoundingShort();
}
}
/// Create a new default holding:
public Holding()
{
CurrencySymbol = "$";
}
///
/// Create a simple JSON holdings from a Security holding class.
///
/// The security instance
public Holding(Security security)
: this()
{
var holding = security.Holdings;
Symbol = holding.Symbol;
Quantity = holding.Quantity;
MarketValue = holding.HoldingsValue;
CurrencySymbol = Currencies.GetCurrencySymbol(security.QuoteCurrency.Symbol);
ConversionRate = security.QuoteCurrency.ConversionRate;
var rounding = security.SymbolProperties.MinimumPriceVariation.GetDecimalPlaces();
AveragePrice = Math.Round(holding.AveragePrice, rounding);
MarketPrice = Math.Round(holding.Price, rounding);
UnrealizedPnL = Math.Round(holding.UnrealizedProfit, 2);
UnrealizedPnLPercent = Math.Round(holding.UnrealizedProfitPercent * 100, 2);
}
///
/// Clones this instance
///
/// A new Holding object with the same values as this one
public Holding Clone()
{
return new Holding
{
AveragePrice = AveragePrice,
Symbol = Symbol,
Quantity = Quantity,
MarketPrice = MarketPrice,
MarketValue = MarketValue,
UnrealizedPnL = UnrealizedPnL,
UnrealizedPnLPercent = UnrealizedPnLPercent,
ConversionRate = ConversionRate,
CurrencySymbol = CurrencySymbol
};
}
///
/// Writes out the properties of this instance to string
///
public override string ToString()
{
return Messages.Holding.ToString(this);
}
private class DecimalJsonConverter : JsonConverter
{
public override bool CanRead => false;
public override bool CanConvert(Type objectType) => typeof(decimal) == objectType;
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
writer.WriteRawValue(((decimal)value).NormalizeToStr());
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
throw new NotImplementedException();
}
}
private class HoldingJsonConverter : JsonConverter
{
public override bool CanWrite => false;
public override bool CanConvert(Type objectType) => typeof(Holding) == objectType;
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var jObject = JObject.Load(reader);
var result = new Holding
{
Symbol = jObject["symbol"]?.ToObject() ?? jObject["Symbol"]?.ToObject() ?? Symbol.Empty,
CurrencySymbol = jObject["c"]?.Value() ?? jObject["currencySymbol"]?.Value() ?? jObject["CurrencySymbol"]?.Value() ?? string.Empty,
AveragePrice = jObject["a"]?.Value() ?? jObject["averagePrice"]?.Value() ?? jObject["AveragePrice"]?.Value() ?? 0,
Quantity = jObject["q"]?.Value() ?? jObject["quantity"]?.Value() ?? jObject["Quantity"]?.Value() ?? 0,
MarketPrice = jObject["p"]?.Value() ?? jObject["marketPrice"]?.Value() ?? jObject["MarketPrice"]?.Value() ?? 0,
ConversionRate = jObject["r"]?.Value() ?? jObject["conversionRate"]?.Value() ?? jObject["ConversionRate"]?.Value() ?? null,
MarketValue = jObject["v"]?.Value() ?? jObject["marketValue"]?.Value() ?? jObject["MarketValue"]?.Value() ?? 0,
UnrealizedPnL = jObject["u"]?.Value() ?? jObject["unrealizedPnl"]?.Value() ?? jObject["UnrealizedPnl"]?.Value() ?? 0,
UnrealizedPnLPercent = jObject["up"]?.Value() ?? jObject["unrealizedPnLPercent"]?.Value() ?? jObject["UnrealizedPnLPercent"]?.Value() ?? 0,
};
if (!result.ConversionRate.HasValue)
{
result.ConversionRate = 1;
}
if (string.IsNullOrEmpty(result.CurrencySymbol))
{
result.CurrencySymbol = "$";
}
return result;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
}
}
///
/// Represents the types of environments supported by brokerages for trading
///
[JsonConverter(typeof(StringEnumConverter))]
public enum BrokerageEnvironment
{
///
/// Live trading (0)
///
[EnumMember(Value = "live")]
Live,
///
/// Paper trading (1)
///
[EnumMember(Value = "paper")]
Paper
}
///
/// Multilanguage support enum: which language is this project for the interop bridge converter.
///
[JsonConverter(typeof(StringEnumConverter))]
public enum Language
{
///
/// C# Language Project (0)
///
[EnumMember(Value = "C#")]
CSharp,
///
/// FSharp Project (1)
///
[EnumMember(Value = "F#")]
FSharp,
///
/// Visual Basic Project (2)
///
[EnumMember(Value = "VB")]
VisualBasic,
///
/// Java Language Project (3)
///
[EnumMember(Value = "Ja")]
Java,
///
/// Python Language Project (4)
///
[EnumMember(Value = "Py")]
Python
}
///
/// Live server types available through the web IDE. / QC deployment.
///
public enum ServerType
{
///
/// Additional server (0)
///
Server512,
///
/// Upgraded server (1)
///
Server1024,
///
/// Server with 2048 MB Ram (2)
///
Server2048
}
///
/// Type of tradable security / underlying asset
///
public enum SecurityType
{
///
/// Base class for all security types (0)
///
Base,
///
/// US Equity Security (1)
///
Equity,
///
/// Option Security Type (2)
///
Option,
///
/// Commodity Security Type (3)
///
Commodity,
///
/// FOREX Security (4)
///
Forex,
///
/// Future Security Type (5)
///
Future,
///
/// Contract For a Difference Security Type (6)
///
Cfd,
///
/// Cryptocurrency Security Type (7)
///
Crypto,
///
/// Futures Options Security Type (8)
///
///
/// Futures options function similar to equity options, but with a few key differences.
/// Firstly, the contract unit of trade is 1x, rather than 100x. This means that each
/// option represents the right to buy or sell 1 future contract at expiry/exercise.
/// The contract multiplier for Futures Options plays a big part in determining the premium
/// of the option, which can also differ from the underlying future's multiplier.
///
FutureOption,
///
/// Index Security Type (9)
///
Index,
///
/// Index Option Security Type (10)
///
///
/// For index options traded on American markets, they tend to be European-style options and are Cash-settled.
///
IndexOption,
///
/// Crypto Future Type (11)
///
CryptoFuture,
}
///
/// Account type: margin or cash
///
public enum AccountType
{
///
/// Margin account type (0)
///
Margin,
///
/// Cash account type (1)
///
Cash
}
///
/// Market data style: is the market data a summary (OHLC style) bar, or is it a time-price value.
///
public enum MarketDataType
{
/// Base market data type (0)
Base,
/// TradeBar market data type (OHLC summary bar) (1)
TradeBar,
/// Tick market data type (price-time pair) (2)
Tick,
/// Data associated with an instrument (3)
Auxiliary,
/// QuoteBar market data type (4) [Bid(OHLC), Ask(OHLC) and Mid(OHLC) summary bar]
QuoteBar,
/// Option chain data (5)
OptionChain,
/// Futures chain data (6)
FuturesChain
}
///
/// Datafeed enum options for selecting the source of the datafeed.
///
public enum DataFeedEndpoint
{
/// Backtesting Datafeed Endpoint (0)
Backtesting,
/// Loading files off the local system (1)
FileSystem,
/// Getting datafeed from a QC-Live-Cloud (2)
LiveTrading,
/// Database (3)
Database
}
///
/// Cloud storage permission options.
///
public enum StoragePermissions
{
/// Public Storage Permissions (0)
Public,
/// Authenticated Read Storage Permissions (1)
Authenticated
}
///
/// Types of tick data
///
/// QuantConnect currently only has trade, quote, open interest tick data.
public enum TickType
{
/// Trade type tick object (0)
Trade ,
/// Quote type tick object (1)
Quote,
/// Open Interest type tick object (for options, futures) (2)
OpenInterest
}
///
/// Specifies the type of data
///
public enum DelistingType
{
///
/// Specifies a warning of an imminent delisting (0)
///
Warning = 0,
///
/// Specifies the symbol has been delisted (1)
///
Delisted = 1
}
///
/// Specifies the type of data
///
public enum SplitType
{
///
/// Specifies a warning of an imminent split event (0)
///
Warning = 0,
///
/// Specifies the symbol has been split (1)
///
SplitOccurred = 1
}
///
/// Resolution of data requested.
///
/// Always sort the enum from the smallest to largest resolution
public enum Resolution
{
/// Tick Resolution (0)
Tick,
/// Second Resolution (1)
Second,
/// Minute Resolution (2)
Minute,
/// Hour Resolution (3)
Hour,
/// Daily Resolution (4)
Daily
}
///
/// Specifies what side a position is on, long/short
///
public enum PositionSide
{
///
/// A short position, quantity less than zero (-1)
///
Short = -1,
///
/// No position, quantity equals zero (0)
///
None = 0,
///
/// A long position, quantity greater than zero (1)
///
Long = 1
}
///
/// Specifies the different types of options
///
public enum OptionRight
{
///
/// A call option, the right to buy at the strike price (0)
///
Call,
///
/// A put option, the right to sell at the strike price (1)
///
Put
}
///
/// Specifies the style of an option
///
public enum OptionStyle
{
///
/// American style options are able to be exercised at any time on or before the expiration date (0)
///
American,
///
/// European style options are able to be exercised on the expiration date only (1)
///
European
}
///
/// Specifies the type of settlement in derivative deals
///
public enum SettlementType
{
///
/// Physical delivery of the underlying security (0)
///
PhysicalDelivery,
///
/// Cash is paid/received on settlement (1)
///
Cash
}
///
/// Wrapper for algorithm status enum to include the charting subscription.
///
public class AlgorithmControl
{
///
/// Default initializer for algorithm control class.
///
public AlgorithmControl()
{
// default to true, API can override
Initialized = false;
HasSubscribers = true;
Status = AlgorithmStatus.Running;
ChartSubscription = Messages.AlgorithmControl.ChartSubscription;
}
///
/// Register this control packet as not defaults.
///
public bool Initialized { get; set; }
///
/// Current run status of the algorithm id.
///
public AlgorithmStatus Status { get; set; }
///
/// Currently requested chart.
///
public string ChartSubscription { get; set; }
///
/// True if there's subscribers on the channel
///
public bool HasSubscribers { get; set; }
}
///
/// States of a live deployment.
///
public enum AlgorithmStatus
{
/// Error compiling algorithm at start (0)
DeployError,
/// Waiting for a server (1)
InQueue,
/// Running algorithm (2)
Running,
/// Stopped algorithm or exited with runtime errors (3)
Stopped,
/// Liquidated algorithm (4)
Liquidated,
/// Algorithm has been deleted (5)
Deleted,
/// Algorithm completed running (6)
Completed,
/// Runtime Error Stoped Algorithm (7)
RuntimeError,
/// Error in the algorithm id (not used) (8)
Invalid,
/// The algorithm is logging into the brokerage (9)
LoggingIn,
/// The algorithm is initializing (10)
Initializing,
/// History status update (11)
History
}
///
/// Specifies where a subscription's data comes from
///
public enum SubscriptionTransportMedium
{
///
/// The subscription's data comes from disk (0)
///
LocalFile,
///
/// The subscription's data is downloaded from a remote source (1)
///
RemoteFile,
///
/// The subscription's data comes from a rest call that is polled and returns a single line/data point of information (2)
///
Rest,
///
/// The subscription's data is streamed (3)
///
Streaming,
///
/// The subscription's data comes from the object store (4)
///
ObjectStore
}
///
/// Used by the to determine which merge write policy should be applied
///
public enum WritePolicy
{
///
/// Will overwrite any existing file or zip entry with the new content (0)
///
Overwrite = 0,
///
/// Will inject and merge new content with the existings file content (1)
///
Merge,
///
/// Will append new data to the end of the file or zip entry (2)
///
Append
}
///
/// enum Period - Enum of all the analysis periods, AS integers. Reference "Period" Array to access the values
///
public enum Period
{
/// Period Short Codes - 10
TenSeconds = 10,
/// Period Short Codes - 30 Second
ThirtySeconds = 30,
/// Period Short Codes - 60 Second
OneMinute = 60,
/// Period Short Codes - 120 Second
TwoMinutes = 120,
/// Period Short Codes - 180 Second
ThreeMinutes = 180,
/// Period Short Codes - 300 Second
FiveMinutes = 300,
/// Period Short Codes - 600 Second
TenMinutes = 600,
/// Period Short Codes - 900 Second
FifteenMinutes = 900,
/// Period Short Codes - 1200 Second
TwentyMinutes = 1200,
/// Period Short Codes - 1800 Second
ThirtyMinutes = 1800,
/// Period Short Codes - 3600 Second
OneHour = 3600,
/// Period Short Codes - 7200 Second
TwoHours = 7200,
/// Period Short Codes - 14400 Second
FourHours = 14400,
/// Period Short Codes - 21600 Second
SixHours = 21600
}
///
/// Specifies how data is normalized before being sent into an algorithm
///
public enum DataNormalizationMode
{
///
/// 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)
///
Raw,
///
/// Splits and dividends are backward-adjusted into the price of the asset. The price today is identical to the current market price. (1)
///
Adjusted,
///
/// 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)
///
SplitAdjusted,
///
/// Equity splits are applied to the price adjustment and the value of all future dividend payments is added to the initial asset price. (3)
///
TotalReturn,
///
/// 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)
///
/// First contract is the true one, factor 0
ForwardPanamaCanal,
///
/// 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)
///
/// Last contract is the true one, factor 0
BackwardsPanamaCanal,
///
/// Eliminates price jumps between two consecutive contracts, multiplying the prices by their ratio. The last contract has the true price. Factor 1. (6)
///
/// Last contract is the true one, factor 1
BackwardsRatio,
///
/// Splits and dividends are adjusted into the prices in a given date. Only for history requests. (7)
///
ScaledRaw,
}
///
/// Continuous contracts mapping modes
///
public enum DataMappingMode
{
///
/// The contract maps on the previous day of expiration of the front month (0)
///
LastTradingDay,
///
/// The contract maps on the first date of the delivery month of the front month. If the contract expires prior to this date,
/// then it rolls on the contract's last trading date instead (1)
///
/// 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.
/// Another example is the Corn 'DEC 2021 ZCZ1' contract, which expires on December, 14 2021, so the mapping date will be December 1, 2021.
FirstDayMonth,
///
/// The contract maps when the following back month contract has a higher open interest that the current front month (2)
///
OpenInterest,
///
/// The contract maps when any of the back month contracts of the next year have a higher volume that the current front month (3)
///
OpenInterestAnnual,
}
///
/// The different types of events
///
public enum CashBookUpdateType
{
///
/// A new was added (0)
///
Added,
///
/// One or more instances were removed (1)
///
Removed,
///
/// An existing was updated (2)
///
Updated
}
///
/// Defines Lean exchanges codes and names
///
public static class Exchanges
{
///
/// Gets the exchange as single character representation.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string GetPrimaryExchangeCodeGetPrimaryExchange(this string exchange,
SecurityType securityType = SecurityType.Equity,
string market = Market.USA)
{
return exchange.GetPrimaryExchange(securityType, market).Code;
}
///
/// Gets the exchange as PrimaryExchange object.
///
/// Useful for performance
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Exchange GetPrimaryExchange(this string exchange,
SecurityType securityType = SecurityType.Equity,
string market = Market.USA)
{
var primaryExchange = Exchange.UNKNOWN;
if (string.IsNullOrEmpty(exchange))
{
return primaryExchange;
}
if (securityType == SecurityType.Equity)
{
switch (exchange.LazyToUpper())
{
case "T":
case "Q":
case "NASDAQ":
case "NASDAQ_OMX":
return Exchange.NASDAQ;
case "Z":
case "BATS":
case "BATS Z":
case "BATS_Z":
return Exchange.BATS;
case "P":
case "ARCA":
return Exchange.ARCA;
case "N":
case "NYSE":
return Exchange.NYSE;
case "C":
case "NSX":
case "NSE":
if (market == Market.USA)
{
return Exchange.NSX;
}
else if (market == Market.India)
{
return Exchange.NSE;
}
return Exchange.UNKNOWN;
case "D":
case "FINRA":
return Exchange.FINRA;
case "I":
case "ISE":
return Exchange.ISE;
case "M":
case "CSE":
return Exchange.CSE;
case "W":
case "CBOE":
return Exchange.CBOE;
case "A":
case "AMEX":
return Exchange.AMEX;
case "SIAC":
return Exchange.SIAC;
case "J":
case "EDGA":
return Exchange.EDGA;
case "K":
case "EDGX":
return Exchange.EDGX;
case "B":
case "NASDAQ BX":
case "NASDAQ_BX":
return Exchange.NASDAQ_BX;
case "X":
case "NASDAQ PSX":
case "NASDAQ_PSX":
return Exchange.NASDAQ_PSX;
case "Y":
case "BATS Y":
case "BATS_Y":
case "BYX":
return Exchange.BATS_Y;
case "BB":
case "BOSTON":
return Exchange.BOSTON;
case "BSE":
return Exchange.BSE;
case "IEX":
return Exchange.IEX;
case "SMART":
return Exchange.SMART;
case "OTCX":
return Exchange.OTCX;
case "MP":
case "MIAX PEARL":
case "MIAX_PEARL":
return Exchange.MIAX_PEARL;
case "L":
case "LTSE":
return Exchange.LTSE;
case "MM":
case "MEMX":
return Exchange.MEMX;
case "CSFB":
return Exchange.CSFB;
}
}
else if (securityType == SecurityType.Option)
{
switch (exchange.LazyToUpper())
{
case "A":
case "AMEX":
return Exchange.AMEX_Options;
case "M":
case "MIAX":
return Exchange.MIAX;
case "ME":
case "MIAX EMERALD":
case "MIAX_EMERALD":
return Exchange.MIAX_EMERALD;
case "MP":
case "MIAX PEARL":
case "MIAX_PEARL":
return Exchange.MIAX_PEARL;
case "I":
case "ISE":
return Exchange.ISE;
case "H":
case "ISE GEMINI":
case "ISE_GEMINI":
return Exchange.ISE_GEMINI;
case "J":
case "ISE MERCURY":
case "ISE_MERCURY":
return Exchange.ISE_MERCURY;
case "O":
case "OPRA":
return Exchange.OPRA;
case "W":
case "C2":
return Exchange.C2;
case "XNDQ":
return Exchange.NASDAQ_Options;
case "ARCX":
return Exchange.ARCA_Options;
case "EDGO":
return Exchange.EDGO;
case "BOX":
case "B":
return Exchange.BOX;
case "PHLX":
return Exchange.PHLX;
case "SPHR":
case "MIAX SAPPHIRE":
case "MIAX_SAPPHIRE":
return Exchange.MIAX_SAPPHIRE;
default:
return Exchange.UNKNOWN;
}
}
else if (securityType == SecurityType.Future || securityType == SecurityType.FutureOption)
{
switch (exchange.LazyToUpper())
{
case "CME":
return Exchange.CME;
case "CBOT":
return Exchange.CBOT;
case "NYMEX":
return Exchange.NYMEX;
case "ICE":
return Exchange.ICE;
case "CFE":
return Exchange.CFE;
case "COMEX":
return Exchange.COMEX;
case "NYSELIFFE":
return Exchange.NYSELIFFE;
case "EUREX":
return Exchange.EUREX;
default:
return Exchange.UNKNOWN;
}
}
return Exchange.UNKNOWN;
}
}
///
/// Defines the different channel status values
///
public static class ChannelStatus
{
///
/// The channel is empty
///
public const string Vacated = "channel_vacated";
///
/// The channel has subscribers
///
public const string Occupied = "channel_occupied";
}
///
/// Represents the types deployment targets for algorithms
///
[JsonConverter(typeof(StringEnumConverter))]
public enum DeploymentTarget
{
///
/// Cloud Platform (0)
///
CloudPlatform,
///
/// Local Platform (1)
///
LocalPlatform,
///
/// Private Cloud Platform (2)
///
PrivateCloudPlatform
}
///
/// Represents the deployment modes of an algorithm
///
[JsonConverter(typeof(StringEnumConverter))]
public enum AlgorithmMode
{
///
/// Live (0)
///
Live,
///
/// Optimization (1)
///
Optimization,
///
/// Backtesting (2)
///
Backtesting,
///
/// Research (3)
///
Research
}
}