Lean  $LEAN_TAG$
QuantConnect.Securities.SecurityManager Class Reference

Enumerable security management class for grouping security objects into an array and providing any common properties. More...

Inheritance diagram for QuantConnect.Securities.SecurityManager:
[legend]

Public Member Functions

 SecurityManager (ITimeKeeper timeKeeper)
 Initialise the algorithm security manager with two empty dictionaries More...
 
void Add (Symbol symbol, Security security)
 Add a new security with this symbol to the collection. More...
 
void Add (Security security)
 Add a new security with this symbol to the collection. More...
 
void Add (KeyValuePair< Symbol, Security > pair)
 Add a symbol-security by its key value pair. More...
 
override void Clear ()
 Clear the securities array to delete all the portfolio and asset information. More...
 
bool Contains (KeyValuePair< Symbol, Security > pair)
 Check if this collection contains this key value pair. More...
 
bool ContainsKey (Symbol symbol)
 Check if this collection contains this symbol. More...
 
void CopyTo (KeyValuePair< Symbol, Security >[] array, int number)
 Copy from the internal array to an external array. More...
 
bool Remove (KeyValuePair< Symbol, Security > pair)
 Remove a key value of of symbol-securities from the collections. More...
 
override bool Remove (Symbol symbol)
 Remove this symbol security: Dictionary interface implementation. More...
 
override bool TryGetValue (Symbol symbol, out Security security)
 Try and get this security object with matching symbol and return true on success. More...
 
void SetSecurityService (SecurityService securityService)
 Sets the Security Service to be used More...
 
Security CreateSecurity (Symbol symbol, List< SubscriptionDataConfig > subscriptionDataConfigList, decimal leverage=0, bool addToSymbolCache=true, Security underlying=null)
 Creates a new security More...
 
Security CreateSecurity (Symbol symbol, SubscriptionDataConfig subscriptionDataConfig, decimal leverage=0, bool addToSymbolCache=true, Security underlying=null)
 Creates a new security More...
 
void SetLiveMode (bool isLiveMode)
 Set live mode state of the algorithm More...
 
- Public Member Functions inherited from QuantConnect.ExtendedDictionary< Security >
abstract bool TryGetValue (Symbol symbol, out T value)
 Gets the value associated with the specified Symbol. More...
 
void clear ()
 Removes all keys and values from the IExtendedDictionary<TKey, TValue>. More...
 
PyDict copy ()
 Creates a shallow copy of the IExtendedDictionary<TKey, TValue>. More...
 
PyDict fromkeys (Symbol[] sequence)
 Creates a new dictionary from the given sequence of elements. More...
 
PyDict fromkeys (Symbol[] sequence, T value)
 Creates a new dictionary from the given sequence of elements with a value provided by the user. More...
 
get (Symbol symbol)
 Returns the value for the specified Symbol if Symbol is in dictionary. More...
 
get (Symbol symbol, T value)
 Returns the value for the specified Symbol if Symbol is in dictionary. More...
 
PyList items ()
 Returns a view object that displays a list of dictionary's (Symbol, value) tuple pairs. More...
 
PyTuple popitem ()
 Returns and removes an arbitrary element (Symbol, value) pair from the dictionary. More...
 
setdefault (Symbol symbol)
 Returns the value of a Symbol (if the Symbol is in dictionary). If not, it inserts Symbol with a value to the dictionary. More...
 
setdefault (Symbol symbol, T default_value)
 Returns the value of a Symbol (if the Symbol is in dictionary). If not, it inserts Symbol with a value to the dictionary. More...
 
pop (Symbol symbol)
 Removes and returns an element from a dictionary having the given Symbol. More...
 
pop (Symbol symbol, T default_value)
 Removes and returns an element from a dictionary having the given Symbol. More...
 
void update (PyObject other)
 Updates the dictionary with the elements from the another dictionary object or from an iterable of Symbol/value pairs. The update() method adds element(s) to the dictionary if the Symbol is not in the dictionary.If the Symbol is in the dictionary, it updates the Symbol with the new value. More...
 
PyList keys ()
 Returns a view object that displays a list of all the Symbol objects in the dictionary More...
 
PyList values ()
 Returns a view object that displays a list of all the values in the dictionary. More...
 

Protected Member Functions

virtual void OnCollectionChanged (NotifyCollectionChangedEventArgs changedEventArgs)
 Event invocator for the CollectionChanged event More...
 

Protected Attributes

override IEnumerable< SymbolGetKeys => Keys
 Gets an T:System.Collections.Generic.ICollection`1 containing the Symbol objects of the T:System.Collections.Generic.IDictionary`2. More...
 
override IEnumerable< SecurityGetValues => Values
 Gets an T:System.Collections.Generic.ICollection`1 containing the values in the T:System.Collections.Generic.IDictionary`2. More...
 

Properties

DateTime UtcTime [get]
 Gets the most recent time this manager was updated More...
 
int Count [get]
 Count of the number of securities in the collection. More...
 
override bool IsReadOnly [get]
 Flag indicating if the internal array is read only. More...
 
ICollection< SymbolKeys [get]
 List of the symbol-keys in the collection of securities. More...
 
ICollection< SecurityValues [get]
 Get a list of the security objects for this collection. More...
 
ICollection< SecurityTotal [get]
 Get a list of the complete security objects for this collection, including non active or delisted securities More...
 
override Security this[Symbol symbol] [get, set]
 Indexer method for the security manager to access the securities objects by their symbol. More...
 
- Properties inherited from QuantConnect.ExtendedDictionary< Security >
abstract IEnumerable< SymbolGetKeys [get]
 Gets an T:System.Collections.Generic.ICollection`1 containing the Symbol objects of the T:System.Collections.Generic.IDictionary`2. More...
 
abstract IEnumerable< T > GetValues [get]
 Gets an T:System.Collections.Generic.ICollection`1 containing the values in the T:System.Collections.Generic.IDictionary`2. More...
 
virtual T this[Symbol symbol] [get, set]
 Indexer method for the base dictioanry to access the objects by their symbol. More...
 
virtual T this[string ticker] [get, set]
 Indexer method for the base dictioanry to access the objects by their symbol. More...
 

Events

NotifyCollectionChangedEventHandler CollectionChanged
 Event fired when a security is added or removed from this collection More...
 

Additional Inherited Members

- Public Attributes inherited from QuantConnect.ExtendedDictionary< Security >
virtual bool IsReadOnly
 Gets a value indicating whether the IDictionary object is read-only. More...
 

Detailed Description

Enumerable security management class for grouping security objects into an array and providing any common properties.

Implements IDictionary for the index searching of securities by symbol

Definition at line 30 of file SecurityManager.cs.

Constructor & Destructor Documentation

◆ SecurityManager()

QuantConnect.Securities.SecurityManager.SecurityManager ( ITimeKeeper  timeKeeper)

Initialise the algorithm security manager with two empty dictionaries

Parameters
timeKeeper

Definition at line 60 of file SecurityManager.cs.

Member Function Documentation

◆ Add() [1/3]

void QuantConnect.Securities.SecurityManager.Add ( Symbol  symbol,
Security  security 
)

Add a new security with this symbol to the collection.

IDictionary implementation

Parameters
symbolsymbol for security we're trading
securitysecurity object
See also
Add(Security)

Definition at line 74 of file SecurityManager.cs.

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

◆ Add() [2/3]

void QuantConnect.Securities.SecurityManager.Add ( Security  security)

Add a new security with this symbol to the collection.

Parameters
securitysecurity object

Definition at line 97 of file SecurityManager.cs.

Here is the call graph for this function:

◆ Add() [3/3]

void QuantConnect.Securities.SecurityManager.Add ( KeyValuePair< Symbol, Security pair)

Add a symbol-security by its key value pair.

IDictionary implementation

Parameters
pair

Definition at line 107 of file SecurityManager.cs.

Here is the call graph for this function:

◆ Clear()

override void QuantConnect.Securities.SecurityManager.Clear ( )
virtual

Clear the securities array to delete all the portfolio and asset information.

IDictionary implementation

Reimplemented from QuantConnect.ExtendedDictionary< Security >.

Definition at line 116 of file SecurityManager.cs.

◆ Contains()

bool QuantConnect.Securities.SecurityManager.Contains ( KeyValuePair< Symbol, Security pair)

Check if this collection contains this key value pair.

Parameters
pairSearch key-value pair

IDictionary implementation

Returns
Bool true if contains this key-value pair

Definition at line 134 of file SecurityManager.cs.

◆ ContainsKey()

bool QuantConnect.Securities.SecurityManager.ContainsKey ( Symbol  symbol)

Check if this collection contains this symbol.

Parameters
symbolSymbol we're checking for.

IDictionary implementation

Returns
Bool true if contains this symbol pair

Definition at line 148 of file SecurityManager.cs.

Here is the caller graph for this function:

◆ CopyTo()

void QuantConnect.Securities.SecurityManager.CopyTo ( KeyValuePair< Symbol, Security >[]  array,
int  number 
)

Copy from the internal array to an external array.

Parameters
arrayArray we're outputting to
numberStarting index of array

IDictionary implementation

Definition at line 162 of file SecurityManager.cs.

◆ Remove() [1/2]

bool QuantConnect.Securities.SecurityManager.Remove ( KeyValuePair< Symbol, Security pair)

Remove a key value of of symbol-securities from the collections.

IDictionary implementation

Parameters
pairKey Value pair of symbol-security to remove
Returns
Boolean true on success

Definition at line 200 of file SecurityManager.cs.

◆ Remove() [2/2]

override bool QuantConnect.Securities.SecurityManager.Remove ( Symbol  symbol)
virtual

Remove this symbol security: Dictionary interface implementation.

Parameters
symbolSymbol we're searching for
Returns
true success

Reimplemented from QuantConnect.ExtendedDictionary< Security >.

Definition at line 210 of file SecurityManager.cs.

Here is the call graph for this function:

◆ TryGetValue()

override bool QuantConnect.Securities.SecurityManager.TryGetValue ( Symbol  symbol,
out Security  security 
)

Try and get this security object with matching symbol and return true on success.

Parameters
symbolString search symbol
securityOutput Security object

IDictionary implementation

Returns
True on successfully locating the security object

Definition at line 253 of file SecurityManager.cs.

Here is the caller graph for this function:

◆ OnCollectionChanged()

virtual void QuantConnect.Securities.SecurityManager.OnCollectionChanged ( NotifyCollectionChangedEventArgs  changedEventArgs)
protectedvirtual

Event invocator for the CollectionChanged event

Parameters
changedEventArgsEvent arguments for the CollectionChanged event

Definition at line 391 of file SecurityManager.cs.

Here is the caller graph for this function:

◆ SetSecurityService()

void QuantConnect.Securities.SecurityManager.SetSecurityService ( SecurityService  securityService)

Sets the Security Service to be used

Definition at line 402 of file SecurityManager.cs.

Here is the caller graph for this function:

◆ CreateSecurity() [1/2]

Security QuantConnect.Securities.SecurityManager.CreateSecurity ( Symbol  symbol,
List< SubscriptionDataConfig subscriptionDataConfigList,
decimal  leverage = 0,
bool  addToSymbolCache = true,
Security  underlying = null 
)

Creates a new security

Following the obsoletion of Security.Subscriptions, both overloads will be merged removing SubscriptionDataConfig arguments

Definition at line 412 of file SecurityManager.cs.

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

◆ CreateSecurity() [2/2]

Security QuantConnect.Securities.SecurityManager.CreateSecurity ( Symbol  symbol,
SubscriptionDataConfig  subscriptionDataConfig,
decimal  leverage = 0,
bool  addToSymbolCache = true,
Security  underlying = null 
)

Creates a new security

Following the obsoletion of Security.Subscriptions, both overloads will be merged removing SubscriptionDataConfig arguments

Definition at line 428 of file SecurityManager.cs.

Here is the call graph for this function:

◆ SetLiveMode()

void QuantConnect.Securities.SecurityManager.SetLiveMode ( bool  isLiveMode)

Set live mode state of the algorithm

Parameters
isLiveModeTrue, live mode is enabled

Definition at line 443 of file SecurityManager.cs.

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

Member Data Documentation

◆ GetKeys

override IEnumerable<Symbol> QuantConnect.Securities.SecurityManager.GetKeys => Keys
protected

Gets an T:System.Collections.Generic.ICollection`1 containing the Symbol objects of the T:System.Collections.Generic.IDictionary`2.

Excludes non active or delisted securities

Returns
An T:System.Collections.Generic.ICollection`1 containing the Symbol objects of the object that implements T:System.Collections.Generic.IDictionary`2.

Definition at line 268 of file SecurityManager.cs.

◆ GetValues

override IEnumerable<Security> QuantConnect.Securities.SecurityManager.GetValues => Values
protected

Gets an T:System.Collections.Generic.ICollection`1 containing the values in the T:System.Collections.Generic.IDictionary`2.

Excludes non active or delisted securities

Returns
An T:System.Collections.Generic.ICollection`1 containing the values in the object that implements T:System.Collections.Generic.IDictionary`2.

Definition at line 277 of file SecurityManager.cs.

Property Documentation

◆ UtcTime

DateTime QuantConnect.Securities.SecurityManager.UtcTime
get

Gets the most recent time this manager was updated

Definition at line 52 of file SecurityManager.cs.

◆ Count

int QuantConnect.Securities.SecurityManager.Count
get

Count of the number of securities in the collection.

IDictionary implementation

Definition at line 175 of file SecurityManager.cs.

◆ IsReadOnly

override bool QuantConnect.Securities.SecurityManager.IsReadOnly
get

Flag indicating if the internal array is read only.

IDictionary implementation

Definition at line 190 of file SecurityManager.cs.

◆ Keys

ICollection<Symbol> QuantConnect.Securities.SecurityManager.Keys
get

List of the symbol-keys in the collection of securities.

Excludes non active or delisted securities

Definition at line 231 of file SecurityManager.cs.

◆ Values

ICollection<Security> QuantConnect.Securities.SecurityManager.Values
get

Get a list of the security objects for this collection.

Excludes non active or delisted securities

Definition at line 284 of file SecurityManager.cs.

◆ Total

ICollection<Security> QuantConnect.Securities.SecurityManager.Total
get

Get a list of the complete security objects for this collection, including non active or delisted securities

Definition at line 303 of file SecurityManager.cs.

◆ this[Symbol symbol]

override Security QuantConnect.Securities.SecurityManager.this[Symbol symbol]
getset

Indexer method for the security manager to access the securities objects by their symbol.

IDictionary implementation

Parameters
symbolSymbol object indexer
Returns
Security

Definition at line 355 of file SecurityManager.cs.

Event Documentation

◆ CollectionChanged

NotifyCollectionChangedEventHandler QuantConnect.Securities.SecurityManager.CollectionChanged

Event fired when a security is added or removed from this collection

Definition at line 35 of file SecurityManager.cs.


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