Lean  $LEAN_TAG$
QuantConnect.Data.Slice Class Reference

Provides a data structure for all of an algorithm's data at a single time step More...

Inheritance diagram for QuantConnect.Data.Slice:
[legend]

Public Member Functions

 Slice (DateTime time, IEnumerable< BaseData > data, DateTime utcTime)
 Initializes a new instance of the Slice class, lazily instantiating the Slice.Bars and Slice.Ticks collections on demand More...
 
 Slice (DateTime time, List< BaseData > data, DateTime utcTime)
 Initializes a new instance of the Slice class, lazily instantiating the Slice.Bars and Slice.Ticks collections on demand More...
 
 Slice (DateTime time, List< BaseData > data, TradeBars tradeBars, QuoteBars quoteBars, Ticks ticks, OptionChains optionChains, FuturesChains futuresChains, Splits splits, Dividends dividends, Delistings delistings, SymbolChangedEvents symbolChanges, MarginInterestRates marginInterestRates, DateTime utcTime, bool? hasData=null)
 Initializes a new instance of the Slice class More...
 
DataDictionary< T > Get< T > ()
 Gets the DataDictionary<T> for all data of the specified type More...
 
dynamic Get (Type type)
 Gets the data of the specified type. More...
 
Get< T > (Symbol symbol)
 Gets the data of the specified symbol and type. More...
 
virtual bool ContainsKey (Symbol symbol)
 Determines whether this instance contains data for the specified symbol More...
 
override bool TryGetValue (Symbol symbol, out dynamic data)
 Gets the data associated with the specified symbol More...
 
void MergeSlice (Slice inputSlice)
 Merge two slice with same Time More...
 
IEnumerator< KeyValuePair< Symbol, BaseData > > GetEnumerator ()
 Returns an enumerator that iterates through the collection. More...
 
- Public Member Functions inherited from QuantConnect.ExtendedDictionary< dynamic >
virtual void Clear ()
 Removes all items from the T:System.Collections.Generic.ICollection`1. More...
 
abstract bool TryGetValue (Symbol symbol, out T value)
 Gets the value associated with the specified Symbol. More...
 
virtual bool Remove (Symbol symbol)
 Removes the value 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

 Slice (Slice slice)
 Initializes a new instance used by the PythonSlice More...
 
dynamic GetImpl (Type type, Slice instance)
 Gets the data of the specified type. More...
 

Protected Attributes

override IEnumerable< SymbolGetKeys => _data.Value.Keys
 Gets an T:System.Collections.Generic.ICollection`1 containing the Symbol objects of the T:System.Collections.Generic.IDictionary`2. More...
 
override IEnumerable< dynamic > GetValues => GetKeyValuePairEnumerable().Select(data => (dynamic)data.Value)
 Gets an T:System.Collections.Generic.ICollection`1 containing the values in the T:System.Collections.Generic.IDictionary`2. More...
 

Properties

List< BaseDataAllData [get]
 All the data hold in this slice More...
 
DateTime Time [get]
 Gets the timestamp for this slice of data More...
 
DateTime UtcTime [get]
 Gets the timestamp for this slice of data in UTC More...
 
bool HasData [get]
 Gets whether or not this slice has data More...
 
TradeBars Bars [get]
 Gets the TradeBars for this slice of data More...
 
QuoteBars QuoteBars [get]
 Gets the QuoteBars for this slice of data More...
 
Ticks Ticks [get]
 Gets the Ticks for this slice of data More...
 
OptionChains OptionChains [get]
 Gets the OptionChains for this slice of data More...
 
FuturesChains FuturesChains [get]
 Gets the FuturesChains for this slice of data More...
 
FuturesChains FutureChains [get]
 Gets the FuturesChains for this slice of data More...
 
Splits Splits [get]
 Gets the Splits for this slice of data More...
 
Dividends Dividends [get]
 Gets the Dividends for this slice of data More...
 
Delistings Delistings [get]
 Gets the Delistings for this slice of data More...
 
SymbolChangedEvents SymbolChangedEvents [get]
 Gets the Market.SymbolChangedEvents for this slice of data More...
 
MarginInterestRates MarginInterestRates [get]
 Gets the Market.MarginInterestRates for this slice of data More...
 
virtual int Count [get]
 Gets the number of symbols held in this slice More...
 
virtual IReadOnlyList< SymbolKeys [get]
 Gets all the symbols in this slice More...
 
virtual IReadOnlyList< BaseDataValues [get]
 Gets a list of all the data in this slice More...
 
override dynamic this[Symbol symbol] [get]
 Gets the data corresponding to the specified symbol. If the requested data is of MarketDataType.Tick, then a List<Tick> will be returned, otherwise, it will be the subscribed type, for example, TradeBar or event UnlinkedData for custom data. More...
 
- Properties inherited from QuantConnect.ExtendedDictionary< dynamic >
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...
 

Additional Inherited Members

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

Detailed Description

Provides a data structure for all of an algorithm's data at a single time step

Definition at line 32 of file Slice.cs.

Constructor & Destructor Documentation

◆ Slice() [1/4]

QuantConnect.Data.Slice.Slice ( DateTime  time,
IEnumerable< BaseData data,
DateTime  utcTime 
)

Initializes a new instance of the Slice class, lazily instantiating the Slice.Bars and Slice.Ticks collections on demand

Parameters
timeThe timestamp for this slice of data
dataThe raw data in this slice
utcTimeThe timestamp for this slice of data in UTC

Definition at line 218 of file Slice.cs.

◆ Slice() [2/4]

QuantConnect.Data.Slice.Slice ( DateTime  time,
List< BaseData data,
DateTime  utcTime 
)

Initializes a new instance of the Slice class, lazily instantiating the Slice.Bars and Slice.Ticks collections on demand

Parameters
timeThe timestamp for this slice of data
dataThe raw data in this slice
utcTimeThe timestamp for this slice of data in UTC

Definition at line 231 of file Slice.cs.

◆ Slice() [3/4]

QuantConnect.Data.Slice.Slice ( Slice  slice)
protected

Initializes a new instance used by the PythonSlice

Parameters
sliceslice object to wrap

This is required so that python slice enumeration works correctly since it relies on the private _data collection

Definition at line 251 of file Slice.cs.

◆ Slice() [4/4]

QuantConnect.Data.Slice.Slice ( DateTime  time,
List< BaseData data,
TradeBars  tradeBars,
QuoteBars  quoteBars,
Ticks  ticks,
OptionChains  optionChains,
FuturesChains  futuresChains,
Splits  splits,
Dividends  dividends,
Delistings  delistings,
SymbolChangedEvents  symbolChanges,
MarginInterestRates  marginInterestRates,
DateTime  utcTime,
bool?  hasData = null 
)

Initializes a new instance of the Slice class

Parameters
timeThe timestamp for this slice of data
dataThe raw data in this slice
tradeBarsThe trade bars for this slice
quoteBarsThe quote bars for this slice
ticksThis ticks for this slice
optionChainsThe option chains for this slice
futuresChainsThe futures chains for this slice
splitsThe splits for this slice
dividendsThe dividends for this slice
delistingsThe delistings for this slice
symbolChangesThe symbol changed events for this slice
marginInterestRatesThe margin interest rates for this slice
utcTimeThe timestamp for this slice of data in UTC
hasDatatrue if this slice contains data

Definition at line 293 of file Slice.cs.

Member Function Documentation

◆ Get< T >() [1/2]

Gets the DataDictionary<T> for all data of the specified type

Template Parameters
TThe type of data we want, for example, TradeBar or UnlinkedData, etc...
Returns
The DataDictionary<T> containing the data of the specified type
Type Constraints
T :IBaseData 

Definition at line 343 of file Slice.cs.

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

◆ Get()

dynamic QuantConnect.Data.Slice.Get ( Type  type)

Gets the data of the specified type.

Parameters
typeThe type of data we seek
Returns
The DataDictionary<T> instance for the requested type

Definition at line 354 of file Slice.cs.

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

◆ GetImpl()

dynamic QuantConnect.Data.Slice.GetImpl ( Type  type,
Slice  instance 
)
protected

Gets the data of the specified type.

Supports both C# and Python use cases

Definition at line 363 of file Slice.cs.

Here is the caller graph for this function:

◆ Get< T >() [2/2]

T QuantConnect.Data.Slice.Get< T > ( Symbol  symbol)

Gets the data of the specified symbol and type.

Template Parameters
TThe type of data we seek
Parameters
symbolThe specific symbol was seek
Returns
The data for the requested symbol
Type Constraints
T :BaseData 

Definition at line 477 of file Slice.cs.

Here is the call graph for this function:

◆ ContainsKey()

virtual bool QuantConnect.Data.Slice.ContainsKey ( Symbol  symbol)
virtual

Determines whether this instance contains data for the specified symbol

Parameters
symbolThe symbol we seek data for
Returns
True if this instance contains data for the symbol, false otherwise

Reimplemented in QuantConnect.Python.PythonSlice.

Definition at line 488 of file Slice.cs.

◆ TryGetValue()

override bool QuantConnect.Data.Slice.TryGetValue ( Symbol  symbol,
out dynamic  data 
)

Gets the data associated with the specified symbol

Parameters
symbolThe symbol we want data for
dataThe data for the specifed symbol, or null if no data was found
Returns
True if data was found, false otherwise

Definition at line 499 of file Slice.cs.

◆ MergeSlice()

void QuantConnect.Data.Slice.MergeSlice ( Slice  inputSlice)

Merge two slice with same Time

Parameters
inputSliceslice instance

Will change the input collection for re-use

Definition at line 516 of file Slice.cs.

Here is the caller graph for this function:

◆ GetEnumerator()

IEnumerator<KeyValuePair<Symbol, BaseData> > QuantConnect.Data.Slice.GetEnumerator ( )

Returns an enumerator that iterates through the collection.

Returns
A T:System.Collections.Generic.IEnumerator`1 that can be used to iterate through the collection.

<filterpriority>1</filterpriority>

Definition at line 674 of file Slice.cs.

Member Data Documentation

◆ GetKeys

override IEnumerable<Symbol> QuantConnect.Data.Slice.GetKeys => _data.Value.Keys
protected

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

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 192 of file Slice.cs.

◆ GetValues

override IEnumerable<dynamic> QuantConnect.Data.Slice.GetValues => GetKeyValuePairEnumerable().Select(data => (dynamic)data.Value)
protected

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

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 200 of file Slice.cs.

Property Documentation

◆ AllData

List<BaseData> QuantConnect.Data.Slice.AllData
get

All the data hold in this slice

Definition at line 56 of file Slice.cs.

◆ Time

DateTime QuantConnect.Data.Slice.Time
get

Gets the timestamp for this slice of data

Definition at line 62 of file Slice.cs.

◆ UtcTime

DateTime QuantConnect.Data.Slice.UtcTime
get

Gets the timestamp for this slice of data in UTC

Definition at line 70 of file Slice.cs.

◆ HasData

bool QuantConnect.Data.Slice.HasData
get

Gets whether or not this slice has data

Definition at line 78 of file Slice.cs.

◆ Bars

TradeBars QuantConnect.Data.Slice.Bars
get

Gets the TradeBars for this slice of data

Definition at line 86 of file Slice.cs.

◆ QuoteBars

QuoteBars QuantConnect.Data.Slice.QuoteBars
get

Gets the QuoteBars for this slice of data

Definition at line 94 of file Slice.cs.

◆ Ticks

Ticks QuantConnect.Data.Slice.Ticks
get

Gets the Ticks for this slice of data

Definition at line 102 of file Slice.cs.

◆ OptionChains

OptionChains QuantConnect.Data.Slice.OptionChains
get

Gets the OptionChains for this slice of data

Definition at line 110 of file Slice.cs.

◆ FuturesChains

FuturesChains QuantConnect.Data.Slice.FuturesChains
get

Gets the FuturesChains for this slice of data

Definition at line 118 of file Slice.cs.

◆ FutureChains

FuturesChains QuantConnect.Data.Slice.FutureChains
get

Gets the FuturesChains for this slice of data

Definition at line 126 of file Slice.cs.

◆ Splits

Splits QuantConnect.Data.Slice.Splits
get

Gets the Splits for this slice of data

Definition at line 134 of file Slice.cs.

◆ Dividends

Dividends QuantConnect.Data.Slice.Dividends
get

Gets the Dividends for this slice of data

Definition at line 142 of file Slice.cs.

◆ Delistings

Delistings QuantConnect.Data.Slice.Delistings
get

Gets the Delistings for this slice of data

Definition at line 150 of file Slice.cs.

◆ SymbolChangedEvents

SymbolChangedEvents QuantConnect.Data.Slice.SymbolChangedEvents
get

Gets the Market.SymbolChangedEvents for this slice of data

Definition at line 158 of file Slice.cs.

◆ MarginInterestRates

MarginInterestRates QuantConnect.Data.Slice.MarginInterestRates
get

Gets the Market.MarginInterestRates for this slice of data

Definition at line 166 of file Slice.cs.

◆ Count

virtual int QuantConnect.Data.Slice.Count
get

Gets the number of symbols held in this slice

Definition at line 174 of file Slice.cs.

◆ Keys

virtual IReadOnlyList<Symbol> QuantConnect.Data.Slice.Keys
get

Gets all the symbols in this slice

Definition at line 182 of file Slice.cs.

◆ Values

virtual IReadOnlyList<BaseData> QuantConnect.Data.Slice.Values
get

Gets a list of all the data in this slice

Definition at line 206 of file Slice.cs.

◆ this[Symbol symbol]

override dynamic QuantConnect.Data.Slice.this[Symbol symbol]
get

Gets the data corresponding to the specified symbol. If the requested data is of MarketDataType.Tick, then a List<Tick> will be returned, otherwise, it will be the subscribed type, for example, TradeBar or event UnlinkedData for custom data.

Parameters
symbolThe data's symbols
Returns
The data for the specified symbol

Definition at line 326 of file Slice.cs.


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