Lean  $LEAN_TAG$
QuantConnect.SecurityIdentifier Class Reference

Defines a unique identifier for securities More...

Inheritance diagram for QuantConnect.SecurityIdentifier:
[legend]

Public Member Functions

 SecurityIdentifier (string symbol, ulong properties)
 Initializes a new instance of the SecurityIdentifier class More...
 
 SecurityIdentifier (string symbol, ulong properties, SecurityIdentifier underlying)
 Initializes a new instance of the SecurityIdentifier class More...
 
int CompareTo (SecurityIdentifier other)
 Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. More...
 
int CompareTo (object obj)
 Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. More...
 
bool Equals (SecurityIdentifier other)
 Indicates whether the current object is equal to another object of the same type. More...
 
override bool Equals (object obj)
 Determines whether the specified T:System.Object is equal to the current T:System.Object. More...
 
override int GetHashCode ()
 Serves as a hash function for a particular type. More...
 
override string ToString ()
 Returns a string that represents the current object. More...
 

Static Public Member Functions

static SecurityIdentifier GenerateOption (DateTime expiry, SecurityIdentifier underlying, string market, decimal strike, OptionRight optionRight, OptionStyle optionStyle)
 Generates a new SecurityIdentifier for an option More...
 
static SecurityIdentifier GenerateOption (DateTime expiry, SecurityIdentifier underlying, string targetOption, string market, decimal strike, OptionRight optionRight, OptionStyle optionStyle)
 Generates a new SecurityIdentifier for an option More...
 
static SecurityIdentifier GenerateFuture (DateTime expiry, string symbol, string market)
 Generates a new SecurityIdentifier for a future More...
 
static SecurityIdentifier GenerateEquity (string symbol, string market, bool mapSymbol=true, IMapFileProvider mapFileProvider=null, DateTime? mappingResolveDate=null)
 Helper overload that will search the mapfiles to resolve the first date. This implementation uses the configured IMapFileProvider via the Composer.Instance More...
 
static string Ticker (Symbol symbol, DateTime date)
 For the given symbol will resolve the ticker it used at the requested date More...
 
static SecurityIdentifier GenerateEquity (DateTime date, string symbol, string market)
 Generates a new SecurityIdentifier for an equity More...
 
static SecurityIdentifier GenerateConstituentIdentifier (string symbol, SecurityType securityType, string market)
 Generates a new SecurityIdentifier for a ConstituentsUniverseData. Note that the symbol ticker is case sensitive here. More...
 
static string GenerateBaseSymbol (Type dataType, string symbol)
 Generates the Symbol property for QuantConnect.SecurityType.Base security identifiers More...
 
static bool TryGetCustomDataType (string symbol, out string type)
 Tries to fetch the custom data type associated with a symbol More...
 
static bool TryGetCustomDataTypeInstance (string symbol, out Type type)
 Tries to fetch the custom data type associated with a symbol More...
 
static SecurityIdentifier GenerateBase (Type dataType, string symbol, string market, bool mapSymbol=false, DateTime? date=null)
 Generates a new SecurityIdentifier for a custom security with the option of providing the first date More...
 
static SecurityIdentifier GenerateForex (string symbol, string market)
 Generates a new SecurityIdentifier for a forex pair More...
 
static SecurityIdentifier GenerateCrypto (string symbol, string market)
 Generates a new SecurityIdentifier for a Crypto pair More...
 
static SecurityIdentifier GenerateCryptoFuture (DateTime expiry, string symbol, string market)
 Generates a new SecurityIdentifier for a CryptoFuture pair More...
 
static SecurityIdentifier GenerateCfd (string symbol, string market)
 Generates a new SecurityIdentifier for a CFD security More...
 
static SecurityIdentifier GenerateIndex (string symbol, string market)
 Generates a new SecurityIdentifier for a INDEX security More...
 
static SecurityIdentifier Parse (string value)
 Parses the specified string into a SecurityIdentifier The string must be a 40 digit number. The first 20 digits must be parseable to a 64 bit unsigned integer and contain ancillary data about the security. The second 20 digits must also be parseable as a 64 bit unsigned integer and contain the symbol encoded from base36, this provides for 12 alpha numeric case insensitive characters. More...
 
static bool TryParse (string value, out SecurityIdentifier identifier)
 Attempts to parse the specified as a SecurityIdentifier. More...
 
static bool operator== (SecurityIdentifier left, SecurityIdentifier right)
 Override equals operator More...
 
static bool operator!= (SecurityIdentifier left, SecurityIdentifier right)
 Override not equals operator More...
 

Static Public Attributes

static readonly SecurityIdentifier Empty = new SecurityIdentifier(string.Empty, 0)
 Gets an instance of SecurityIdentifier that is empty, that is, one with no symbol specified More...
 
static readonly SecurityIdentifier None = new SecurityIdentifier("NONE", 0)
 Gets an instance of SecurityIdentifier that is explicitly no symbol More...
 
static readonly DateTime DefaultDate = DateTime.FromOADate(0)
 Gets the date to be used when it does not apply. More...
 
static readonly HashSet< char > InvalidSymbolCharacters = new HashSet<char>(InvalidCharacters)
 Gets the set of invalids symbol characters More...
 

Properties

bool HasUnderlying [get]
 Gets whether or not this SecurityIdentifier is a derivative, that is, it has a valid Underlying property More...
 
SecurityIdentifier Underlying [get]
 Gets the underlying security identifier for this security identifier. When there is no underlying, this property will return a value of Empty. More...
 
DateTime Date [get]
 Gets the date component of this identifier. For equities this is the first date the security traded. Technically speaking, in LEAN, this is the first date mentioned in the map_files. For futures and options this is the expiry date of the contract. For other asset classes, this property will throw an exception as the field is not specified. More...
 
string Symbol [get]
 Gets the original symbol used to generate this security identifier. For equities, by convention this is the first ticker symbol for which the security traded More...
 
string?? Market [get]
 Gets the market component of this security identifier. If located in the internal mappings, the full string is returned. If the value is unknown, the integer value is returned as a string. More...
 
SecurityType SecurityType [get]
 Gets the security type component of this security identifier. More...
 
decimal StrikePrice [get]
 Gets the option strike price. This only applies to SecurityType.Option and will thrown anexception if accessed otherwise. More...
 
OptionRight OptionRight [get]
 Gets the option type component of this security identifier. This only applies to SecurityType.Open and will throw an exception if accessed otherwise. More...
 
OptionStyle OptionStyle [get]
 Gets the option style component of this security identifier. This only applies to SecurityType.Open and will throw an exception if accessed otherwise. More...
 

Detailed Description

Defines a unique identifier for securities

The SecurityIdentifier contains information about a specific security. This includes the symbol and other data specific to the SecurityType. The symbol is limited to 12 characters

Definition at line 42 of file SecurityIdentifier.cs.

Constructor & Destructor Documentation

◆ SecurityIdentifier() [1/2]

QuantConnect.SecurityIdentifier.SecurityIdentifier ( string  symbol,
ulong  properties 
)

Initializes a new instance of the SecurityIdentifier class

Parameters
symbolThe base36 string encoded as a long using alpha [0-9A-Z]
propertiesOther data defining properties of the symbol including market, security type, listing or expiry date, strike/call/put/style for options, ect...

Definition at line 317 of file SecurityIdentifier.cs.

◆ SecurityIdentifier() [2/2]

QuantConnect.SecurityIdentifier.SecurityIdentifier ( string  symbol,
ulong  properties,
SecurityIdentifier  underlying 
)

Initializes a new instance of the SecurityIdentifier class

Parameters
symbolThe base36 string encoded as a long using alpha [0-9A-Z]
propertiesOther data defining properties of the symbol including market, security type, listing or expiry date, strike/call/put/style for options, ect...
underlyingSpecifies a SecurityIdentifier that represents the underlying security

Definition at line 350 of file SecurityIdentifier.cs.

Here is the call graph for this function:

Member Function Documentation

◆ GenerateOption() [1/2]

static SecurityIdentifier QuantConnect.SecurityIdentifier.GenerateOption ( DateTime  expiry,
SecurityIdentifier  underlying,
string  market,
decimal  strike,
OptionRight  optionRight,
OptionStyle  optionStyle 
)
static

Generates a new SecurityIdentifier for an option

Parameters
expiryThe date the option expires
underlyingThe underlying security's symbol
marketThe market
strikeThe strike price
optionRightThe option type, call or put
optionStyleThe option style, American or European
Returns
A new SecurityIdentifier representing the specified option security

Definition at line 380 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

◆ GenerateOption() [2/2]

static SecurityIdentifier QuantConnect.SecurityIdentifier.GenerateOption ( DateTime  expiry,
SecurityIdentifier  underlying,
string  targetOption,
string  market,
decimal  strike,
OptionRight  optionRight,
OptionStyle  optionStyle 
)
static

Generates a new SecurityIdentifier for an option

Parameters
expiryThe date the option expires
underlyingThe underlying security's symbol
targetOptionThe target option ticker. This is useful when the option ticker does not match the underlying, e.g. SPX index and the SPXW weekly option. If null is provided will use underlying
marketThe market
strikeThe strike price
optionRightThe option type, call or put
optionStyleThe option style, American or European
Returns
A new SecurityIdentifier representing the specified option security

Definition at line 401 of file SecurityIdentifier.cs.

Here is the call graph for this function:

◆ GenerateFuture()

static SecurityIdentifier QuantConnect.SecurityIdentifier.GenerateFuture ( DateTime  expiry,
string  symbol,
string  market 
)
static

Generates a new SecurityIdentifier for a future

Parameters
expiryThe date the future expires
symbolThe security's symbol
marketThe market
Returns
A new SecurityIdentifier representing the specified futures security

Definition at line 434 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

◆ GenerateEquity() [1/2]

static SecurityIdentifier QuantConnect.SecurityIdentifier.GenerateEquity ( string  symbol,
string  market,
bool  mapSymbol = true,
IMapFileProvider  mapFileProvider = null,
DateTime?  mappingResolveDate = null 
)
static

Helper overload that will search the mapfiles to resolve the first date. This implementation uses the configured IMapFileProvider via the Composer.Instance

Parameters
symbolThe symbol as it is known today
marketThe market
mapSymbolSpecifies if symbol should be mapped using map file provider
mapFileProviderSpecifies the IMapFileProvider to use for resolving symbols, specify null to load from Composer
mappingResolveDateThe date to use to resolve the map file. Default value is DateTime.Today
Returns
A new SecurityIdentifier representing the specified symbol today

Definition at line 451 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

◆ Ticker()

static string QuantConnect.SecurityIdentifier.Ticker ( Symbol  symbol,
DateTime  date 
)
static

For the given symbol will resolve the ticker it used at the requested date

Parameters
symbolThe symbol to get the ticker for
dateThe date to map the symbol to
Returns
The ticker for a date and symbol

Definition at line 470 of file SecurityIdentifier.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateEquity() [2/2]

static SecurityIdentifier QuantConnect.SecurityIdentifier.GenerateEquity ( DateTime  date,
string  symbol,
string  market 
)
static

Generates a new SecurityIdentifier for an equity

Parameters
dateThe first date this security traded (in LEAN this is the first date in the map_file
symbolThe ticker symbol this security traded under on the date
marketThe security's market
Returns
A new SecurityIdentifier representing the specified equity security

Definition at line 490 of file SecurityIdentifier.cs.

◆ GenerateConstituentIdentifier()

static SecurityIdentifier QuantConnect.SecurityIdentifier.GenerateConstituentIdentifier ( string  symbol,
SecurityType  securityType,
string  market 
)
static

Generates a new SecurityIdentifier for a ConstituentsUniverseData. Note that the symbol ticker is case sensitive here.

Parameters
symbolThe ticker to use for this constituent identifier
securityTypeThe security type of this constituent universe
marketThe security's market

This method is special in the sense that it does not force the Symbol to be upper which is required to determine the source file of the constituent ConstituentsUniverseData.GetSource(Data.SubscriptionDataConfig,DateTime,bool)

Returns
A new SecurityIdentifier representing the specified constituent universe

Definition at line 506 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

◆ GenerateBaseSymbol()

static string QuantConnect.SecurityIdentifier.GenerateBaseSymbol ( Type  dataType,
string  symbol 
)
static

Generates the Symbol property for QuantConnect.SecurityType.Base security identifiers

Parameters
dataTypeThe base data custom data type if namespacing is required, null otherwise
symbolThe ticker symbol
Returns
The value used for the security identifier's Symbol

Definition at line 517 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

◆ TryGetCustomDataType()

static bool QuantConnect.SecurityIdentifier.TryGetCustomDataType ( string  symbol,
out string  type 
)
static

Tries to fetch the custom data type associated with a symbol

Custom data type SecurityIdentifier symbol value holds their data type

Definition at line 532 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

◆ TryGetCustomDataTypeInstance()

static bool QuantConnect.SecurityIdentifier.TryGetCustomDataTypeInstance ( string  symbol,
out Type  type 
)
static

Tries to fetch the custom data type associated with a symbol

Custom data type SecurityIdentifier symbol value holds their data type

Definition at line 551 of file SecurityIdentifier.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateBase()

static SecurityIdentifier QuantConnect.SecurityIdentifier.GenerateBase ( Type  dataType,
string  symbol,
string  market,
bool  mapSymbol = false,
DateTime?  date = null 
)
static

Generates a new SecurityIdentifier for a custom security with the option of providing the first date

Parameters
dataTypeThe custom data type
symbolThe ticker symbol of this security
marketThe security's market
mapSymbolWhether or not we should map this symbol
dateFirst date that the security traded on
Returns
A new SecurityIdentifier representing the specified base security

Definition at line 566 of file SecurityIdentifier.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateForex()

static SecurityIdentifier QuantConnect.SecurityIdentifier.GenerateForex ( string  symbol,
string  market 
)
static

Generates a new SecurityIdentifier for a forex pair

Parameters
symbolThe currency pair in the format similar to: 'EURUSD'
marketThe security's market
Returns
A new SecurityIdentifier representing the specified forex pair

Definition at line 592 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

◆ GenerateCrypto()

static SecurityIdentifier QuantConnect.SecurityIdentifier.GenerateCrypto ( string  symbol,
string  market 
)
static

Generates a new SecurityIdentifier for a Crypto pair

Parameters
symbolThe currency pair in the format similar to: 'EURUSD'
marketThe security's market
Returns
A new SecurityIdentifier representing the specified Crypto pair

Definition at line 603 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

◆ GenerateCryptoFuture()

static SecurityIdentifier QuantConnect.SecurityIdentifier.GenerateCryptoFuture ( DateTime  expiry,
string  symbol,
string  market 
)
static

Generates a new SecurityIdentifier for a CryptoFuture pair

Parameters
expiryThe date the future expires
symbolThe currency pair in the format similar to: 'EURUSD'
marketThe security's market
Returns
A new SecurityIdentifier representing the specified CryptoFuture pair

Definition at line 615 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

◆ GenerateCfd()

static SecurityIdentifier QuantConnect.SecurityIdentifier.GenerateCfd ( string  symbol,
string  market 
)
static

Generates a new SecurityIdentifier for a CFD security

Parameters
symbolThe CFD contract symbol
marketThe security's market
Returns
A new SecurityIdentifier representing the specified CFD security

Definition at line 626 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

◆ GenerateIndex()

static SecurityIdentifier QuantConnect.SecurityIdentifier.GenerateIndex ( string  symbol,
string  market 
)
static

Generates a new SecurityIdentifier for a INDEX security

Parameters
symbolThe Index contract symbol
marketThe security's market
Returns
A new SecurityIdentifier representing the specified INDEX security

Definition at line 637 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

◆ Parse()

static SecurityIdentifier QuantConnect.SecurityIdentifier.Parse ( string  value)
static

Parses the specified string into a SecurityIdentifier The string must be a 40 digit number. The first 20 digits must be parseable to a 64 bit unsigned integer and contain ancillary data about the security. The second 20 digits must also be parseable as a 64 bit unsigned integer and contain the symbol encoded from base36, this provides for 12 alpha numeric case insensitive characters.

Parameters
valueThe string value to be parsed
Returns
A new SecurityIdentifier instance if the value is able to be parsed.
Exceptions
FormatExceptionThis exception is thrown if the string's length is not exactly 40 characters, or if the components are unable to be parsed as 64 bit unsigned integers

Definition at line 806 of file SecurityIdentifier.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryParse()

static bool QuantConnect.SecurityIdentifier.TryParse ( string  value,
out SecurityIdentifier  identifier 
)
static

Attempts to parse the specified as a SecurityIdentifier.

Parameters
valueThe string value to be parsed
identifierThe result of parsing, when this function returns true, identifier was properly created and reflects the input string, when this function returns false identifier will equal default(SecurityIdentifier)
Returns
True on success, otherwise false

Definition at line 826 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

◆ CompareTo() [1/2]

int QuantConnect.SecurityIdentifier.CompareTo ( SecurityIdentifier  other)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

Parameters
otherAn object to compare with this instance.
Returns
A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes other in the sort order. Zero This instance occurs in the same position in the sort order as other . Greater than zero This instance follows other in the sort order.

Definition at line 957 of file SecurityIdentifier.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompareTo() [2/2]

int QuantConnect.SecurityIdentifier.CompareTo ( object  obj)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

Parameters
objAn object to compare with this instance.
Returns
A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes obj in the sort order. Zero This instance occurs in the same position in the sort order as obj . Greater than zero This instance follows obj in the sort order.
Exceptions
T:System.ArgumentExceptionobj is not the same type as this instance.

Definition at line 977 of file SecurityIdentifier.cs.

Here is the call graph for this function:

◆ Equals() [1/2]

bool QuantConnect.SecurityIdentifier.Equals ( SecurityIdentifier  other)

Indicates whether the current object is equal to another object of the same type.

Returns
true if the current object is equal to the other parameter; otherwise, false.
Parameters
otherAn object to compare with this object.

Definition at line 1004 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

◆ Equals() [2/2]

override bool QuantConnect.SecurityIdentifier.Equals ( object  obj)

Determines whether the specified T:System.Object is equal to the current T:System.Object.

Returns
true if the specified object is equal to the current object; otherwise, false.
Parameters
objThe object to compare with the current object.

<filterpriority>2</filterpriority>

Definition at line 1018 of file SecurityIdentifier.cs.

Here is the call graph for this function:

◆ GetHashCode()

override int QuantConnect.SecurityIdentifier.GetHashCode ( )

Serves as a hash function for a particular type.

Returns
A hash code for the current T:System.Object.

<filterpriority>2</filterpriority>

Definition at line 1032 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

◆ operator==()

static bool QuantConnect.SecurityIdentifier.operator== ( SecurityIdentifier  left,
SecurityIdentifier  right 
)
static

Override equals operator

Definition at line 1045 of file SecurityIdentifier.cs.

Here is the call graph for this function:

◆ operator!=()

static bool QuantConnect.SecurityIdentifier.operator!= ( SecurityIdentifier  left,
SecurityIdentifier  right 
)
static

Override not equals operator

Definition at line 1053 of file SecurityIdentifier.cs.

Here is the call graph for this function:

◆ ToString()

override string QuantConnect.SecurityIdentifier.ToString ( )

Returns a string that represents the current object.

Returns
A string that represents the current object.

<filterpriority>2</filterpriority>

Definition at line 1065 of file SecurityIdentifier.cs.

Here is the caller graph for this function:

Member Data Documentation

◆ Empty

readonly SecurityIdentifier QuantConnect.SecurityIdentifier.Empty = new SecurityIdentifier(string.Empty, 0)
static

Gets an instance of SecurityIdentifier that is empty, that is, one with no symbol specified

Definition at line 54 of file SecurityIdentifier.cs.

◆ None

readonly SecurityIdentifier QuantConnect.SecurityIdentifier.None = new SecurityIdentifier("NONE", 0)
static

Gets an instance of SecurityIdentifier that is explicitly no symbol

Definition at line 59 of file SecurityIdentifier.cs.

◆ DefaultDate

readonly DateTime QuantConnect.SecurityIdentifier.DefaultDate = DateTime.FromOADate(0)
static

Gets the date to be used when it does not apply.

Definition at line 64 of file SecurityIdentifier.cs.

◆ InvalidSymbolCharacters

readonly HashSet<char> QuantConnect.SecurityIdentifier.InvalidSymbolCharacters = new HashSet<char>(InvalidCharacters)
static

Gets the set of invalids symbol characters

Definition at line 69 of file SecurityIdentifier.cs.

Property Documentation

◆ HasUnderlying

bool QuantConnect.SecurityIdentifier.HasUnderlying
get

Gets whether or not this SecurityIdentifier is a derivative, that is, it has a valid Underlying property

Definition at line 131 of file SecurityIdentifier.cs.

◆ Underlying

SecurityIdentifier QuantConnect.SecurityIdentifier.Underlying
get

Gets the underlying security identifier for this security identifier. When there is no underlying, this property will return a value of Empty.

Definition at line 140 of file SecurityIdentifier.cs.

◆ Date

DateTime QuantConnect.SecurityIdentifier.Date
get

Gets the date component of this identifier. For equities this is the first date the security traded. Technically speaking, in LEAN, this is the first date mentioned in the map_files. For futures and options this is the expiry date of the contract. For other asset classes, this property will throw an exception as the field is not specified.

Definition at line 160 of file SecurityIdentifier.cs.

◆ Symbol

string QuantConnect.SecurityIdentifier.Symbol
get

Gets the original symbol used to generate this security identifier. For equities, by convention this is the first ticker symbol for which the security traded

Definition at line 193 of file SecurityIdentifier.cs.

◆ Market

string?? QuantConnect.SecurityIdentifier.Market
get

Gets the market component of this security identifier. If located in the internal mappings, the full string is returned. If the value is unknown, the integer value is returned as a string.

Definition at line 203 of file SecurityIdentifier.cs.

◆ SecurityType

SecurityType QuantConnect.SecurityIdentifier.SecurityType
get

Gets the security type component of this security identifier.

Definition at line 221 of file SecurityIdentifier.cs.

◆ StrikePrice

decimal QuantConnect.SecurityIdentifier.StrikePrice
get

Gets the option strike price. This only applies to SecurityType.Option and will thrown anexception if accessed otherwise.

Definition at line 228 of file SecurityIdentifier.cs.

◆ OptionRight

OptionRight QuantConnect.SecurityIdentifier.OptionRight
get

Gets the option type component of this security identifier. This only applies to SecurityType.Open and will throw an exception if accessed otherwise.

Definition at line 266 of file SecurityIdentifier.cs.

◆ OptionStyle

OptionStyle QuantConnect.SecurityIdentifier.OptionStyle
get

Gets the option style component of this security identifier. This only applies to SecurityType.Open and will throw an exception if accessed otherwise.

Definition at line 289 of file SecurityIdentifier.cs.


The documentation for this class was generated from the following file: