Lean  $LEAN_TAG$
QuantConnect.Data.BaseData Class Reference

Abstract base data class of QuantConnect. It is intended to be extended to define generic user customizable data types while at the same time implementing the basics of data where possible More...

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

Public Member Functions

 BaseData ()
 Constructor for initialising the dase data class More...
 
virtual BaseData Reader (SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode)
 Reader converts each line of the data source into BaseData objects. Each data type creates its own factory method, and returns a new instance of the object each time it is called. The returned object is assumed to be time stamped in the config.ExchangeTimeZone. More...
 
virtual BaseData Reader (SubscriptionDataConfig config, StreamReader stream, DateTime date, bool isLiveMode)
 Reader converts each line of the data source into BaseData objects. Each data type creates its own factory method, and returns a new instance of the object each time it is called. The returned object is assumed to be time stamped in the config.ExchangeTimeZone. More...
 
virtual SubscriptionDataSource GetSource (SubscriptionDataConfig config, DateTime date, bool isLiveMode)
 Return the URL string source of the file. This will be converted to a stream More...
 
virtual bool RequiresMapping ()
 Indicates if there is support for mapping More...
 
virtual bool IsSparseData ()
 Indicates that the data set is expected to be sparse More...
 
virtual bool ShouldCacheToSecurity ()
 Indicates whether this contains data that should be stored in the security cache More...
 
virtual Resolution DefaultResolution ()
 Gets the default resolution for this data and security type More...
 
virtual List< ResolutionSupportedResolutions ()
 Gets the supported resolution for this data and security type More...
 
virtual DateTimeZone DataTimeZone ()
 Specifies the data time zone for this data type. This is useful for custom data types More...
 
void UpdateTrade (decimal lastTrade, decimal tradeSize)
 Updates this base data with a new trade More...
 
void UpdateQuote (decimal bidPrice, decimal bidSize, decimal askPrice, decimal askSize)
 Updates this base data with new quote information More...
 
void UpdateBid (decimal bidPrice, decimal bidSize)
 Updates this base data with the new quote bid information More...
 
void UpdateAsk (decimal askPrice, decimal askSize)
 Updates this base data with the new quote ask information More...
 
virtual void Update (decimal lastTrade, decimal bidPrice, decimal askPrice, decimal volume, decimal bidSize, decimal askSize)
 Update routine to build a bar/tick from a data update. More...
 
virtual BaseData Clone (bool fillForward)
 Return a new instance clone of this object, used in fill forward More...
 
virtual BaseData Clone ()
 Return a new instance clone of this object, used in fill forward More...
 
override string ToString ()
 Formats a string with the symbol and value. More...
 
virtual BaseData Reader (SubscriptionDataConfig config, string line, DateTime date, DataFeedEndpoint datafeed)
 Reader converts each line of the data source into BaseData objects. Each data type creates its own factory method, and returns a new instance of the object each time it is called. More...
 
virtual string GetSource (SubscriptionDataConfig config, DateTime date, DataFeedEndpoint datafeed)
 Return the URL string source of the file. This will be converted to a stream More...
 

Static Public Member Functions

static IEnumerable< BaseDataDeserializeMessage (string serialized)
 Deserialize the message from the data server More...
 

Public Attributes

virtual decimal Price => Value
 As this is a backtesting platform we'll provide an alias of value as price. More...
 

Static Protected Attributes

static readonly List< ResolutionAllResolutions
 A list of all Resolution More...
 
static readonly List< ResolutionDailyResolution = new List<Resolution> { Resolution.Daily }
 A list of Resolution.Daily More...
 
static readonly List< ResolutionMinuteResolution = new List<Resolution> { Resolution.Minute }
 A list of Resolution.Minute More...
 
static readonly List< ResolutionHighResolution = new List<Resolution> { Resolution.Minute, Resolution.Second, Resolution.Tick }
 A list of high Resolution, including minute, second, and tick. More...
 
static readonly List< ResolutionOptionResolutions = new List<Resolution> { Resolution.Daily, Resolution.Hour, Resolution.Minute }
 A list of resolutions support by Options More...
 

Properties

MarketDataType DataType = MarketDataType.Base [get, set]
 Market Data Type of this data - does it come in individual price packets or is it grouped into OHLC. More...
 
bool IsFillForward [get]
 True if this is a fill forward piece of data More...
 
DateTime Time [get, set]
 Current time marker of this data packet. More...
 
virtual DateTime EndTime [get, set]
 The end time of this data. Some data covers spans (trade bars) and as such we want to know the entire time span covered More...
 
Symbol Symbol = Symbol.Empty [get, set]
 Symbol representation for underlying Security More...
 
virtual decimal Value [get, set]
 Value representation of this data packet. All data requires a representative value for this moment in time. For streams of data this is the price now, for OHLC packets this is the closing price. More...
 
- Properties inherited from QuantConnect.Data.IBaseData
MarketDataType DataType [get, set]
 Market Data Type of this data - does it come in individual price packets or is it grouped into OHLC. More...
 
DateTime Time [get, set]
 Time keeper of data – all data is timeseries based. More...
 
DateTime EndTime [get, set]
 End time of data More...
 
Symbol Symbol [get, set]
 Symbol for underlying Security More...
 
decimal Value [get, set]
 All timeseries data is a time-value pair: More...
 
decimal Price [get]
 Alias of Value. More...
 

Detailed Description

Abstract base data class of QuantConnect. It is intended to be extended to define generic user customizable data types while at the same time implementing the basics of data where possible

Definition at line 38 of file BaseData.cs.

Constructor & Destructor Documentation

◆ BaseData()

QuantConnect.Data.BaseData.BaseData ( )

Constructor for initialising the dase data class

Definition at line 127 of file BaseData.cs.

Here is the caller graph for this function:

Member Function Documentation

◆ Reader() [1/3]

virtual BaseData QuantConnect.Data.BaseData.Reader ( SubscriptionDataConfig  config,
string  line,
DateTime  date,
bool  isLiveMode 
)
virtual

Reader converts each line of the data source into BaseData objects. Each data type creates its own factory method, and returns a new instance of the object each time it is called. The returned object is assumed to be time stamped in the config.ExchangeTimeZone.

Parameters
configSubscription data config setup object
lineLine of the source document
dateDate of the requested data
isLiveModetrue if we're in live mode, false for backtesting mode
Returns
Instance of the T:BaseData object generated by this line of the CSV

Implements QuantConnect.Data.IBaseData.

Reimplemented in QuantConnect.Data.Market.Tick, QuantConnect.Data.Market.QuoteBar, QuantConnect.Data.Market.TradeBar, QuantConnect.Indicators.IndicatorDataPoint, QuantConnect.Data.Custom.Intrinio.IntrinioEconomicData, QuantConnect.Data.Custom.FxcmVolume, QuantConnect.Python.PythonData, QuantConnect.Data.Market.OpenInterest, QuantConnect.Data.Market.Dividend, QuantConnect.Data.UniverseSelection.CoarseFundamental, QuantConnect.Data.UniverseSelection.ETFConstituentUniverse, QuantConnect.Data.Market.Split, QuantConnect.Data.Custom.IconicTypes.IndexedLinkedData2, QuantConnect.Data.Custom.IconicTypes.IndexedLinkedData, QuantConnect.Data.Market.Delisting, QuantConnect.Data.UniverseSelection.ConstituentsUniverseData, QuantConnect.Data.Fundamental.FundamentalUniverse, QuantConnect.Data.Market.BaseRenkoBar, QuantConnect.Data.Custom.IconicTypes.UnlinkedDataTradeBar, QuantConnect.Data.Custom.IconicTypes.UnlinkedData, QuantConnect.Data.Auxiliary.ZipEntryName, QuantConnect.Data.Custom.IconicTypes.LinkedData, and QuantConnect.Data.Custom.Tiingo.TiingoPrice.

Definition at line 141 of file BaseData.cs.

Here is the caller graph for this function:

◆ Reader() [2/3]

virtual BaseData QuantConnect.Data.BaseData.Reader ( SubscriptionDataConfig  config,
StreamReader  stream,
DateTime  date,
bool  isLiveMode 
)
virtual

Reader converts each line of the data source into BaseData objects. Each data type creates its own factory method, and returns a new instance of the object each time it is called. The returned object is assumed to be time stamped in the config.ExchangeTimeZone.

Parameters
configSubscription data config setup object
streamThe data stream
dateDate of the requested data
isLiveModetrue if we're in live mode, false for backtesting mode
Returns
Instance of the T:BaseData object generated by this line of the CSV

Implements QuantConnect.Data.IBaseData.

Reimplemented in QuantConnect.Data.Market.QuoteBar, QuantConnect.Data.Market.TradeBar, QuantConnect.Data.Market.MarginInterestRate, and QuantConnect.Data.Market.Tick.

Definition at line 159 of file BaseData.cs.

◆ GetSource() [1/2]

virtual SubscriptionDataSource QuantConnect.Data.BaseData.GetSource ( SubscriptionDataConfig  config,
DateTime  date,
bool  isLiveMode 
)
virtual

◆ RequiresMapping()

virtual bool QuantConnect.Data.BaseData.RequiresMapping ( )
virtual

Indicates if there is support for mapping

Relies on the Symbol property value

Returns
True indicates mapping should be used

Implements QuantConnect.Data.IBaseData.

Reimplemented in QuantConnect.Data.Custom.Tiingo.TiingoPrice, QuantConnect.Data.UniverseSelection.ETFConstituentUniverse, QuantConnect.Python.PythonData, QuantConnect.Data.Custom.IconicTypes.IndexedLinkedData2, QuantConnect.Data.UniverseSelection.ConstituentsUniverseData, QuantConnect.Data.Custom.IconicTypes.IndexedLinkedData, QuantConnect.Data.Custom.IconicTypes.UnlinkedDataTradeBar, QuantConnect.Data.Custom.IconicTypes.UnlinkedData, and QuantConnect.Data.Custom.IconicTypes.LinkedData.

Definition at line 201 of file BaseData.cs.

Here is the caller graph for this function:

◆ IsSparseData()

virtual bool QuantConnect.Data.BaseData.IsSparseData ( )
virtual

Indicates that the data set is expected to be sparse

Relies on the Symbol property value

This is a method and not a property so that python custom data types can override it

Returns
True if the data set represented by this type is expected to be sparse

Reimplemented in QuantConnect.Data.UniverseSelection.ETFConstituentUniverse, QuantConnect.Python.PythonData, QuantConnect.Data.Custom.IconicTypes.IndexedLinkedData2, QuantConnect.Data.UniverseSelection.ConstituentsUniverseData, QuantConnect.Data.Custom.IconicTypes.IndexedLinkedData, QuantConnect.Data.Custom.IconicTypes.UnlinkedDataTradeBar, QuantConnect.Data.Custom.IconicTypes.UnlinkedData, and QuantConnect.Data.Custom.IconicTypes.LinkedData.

Definition at line 213 of file BaseData.cs.

Here is the caller graph for this function:

◆ ShouldCacheToSecurity()

virtual bool QuantConnect.Data.BaseData.ShouldCacheToSecurity ( )
virtual

Indicates whether this contains data that should be stored in the security cache

Returns
Whether this contains data that should be stored in the security cache

Reimplemented in QuantConnect.Data.UniverseSelection.BaseDataCollection, and QuantConnect.Data.Auxiliary.ZipEntryName.

Definition at line 223 of file BaseData.cs.

◆ DefaultResolution()

◆ SupportedResolutions()

virtual List<Resolution> QuantConnect.Data.BaseData.SupportedResolutions ( )
virtual

◆ DataTimeZone()

virtual DateTimeZone QuantConnect.Data.BaseData.DataTimeZone ( )
virtual

◆ UpdateTrade()

void QuantConnect.Data.BaseData.UpdateTrade ( decimal  lastTrade,
decimal  tradeSize 
)

Updates this base data with a new trade

Parameters
lastTradeThe price of the last trade
tradeSizeThe quantity traded

Definition at line 274 of file BaseData.cs.

Here is the call graph for this function:

◆ UpdateQuote()

void QuantConnect.Data.BaseData.UpdateQuote ( decimal  bidPrice,
decimal  bidSize,
decimal  askPrice,
decimal  askSize 
)

Updates this base data with new quote information

Parameters
bidPriceThe current bid price
bidSizeThe current bid size
askPriceThe current ask price
askSizeThe current ask size

Definition at line 286 of file BaseData.cs.

Here is the call graph for this function:

◆ UpdateBid()

void QuantConnect.Data.BaseData.UpdateBid ( decimal  bidPrice,
decimal  bidSize 
)

Updates this base data with the new quote bid information

Parameters
bidPriceThe current bid price
bidSizeThe current bid size

Definition at line 296 of file BaseData.cs.

Here is the call graph for this function:

◆ UpdateAsk()

void QuantConnect.Data.BaseData.UpdateAsk ( decimal  askPrice,
decimal  askSize 
)

Updates this base data with the new quote ask information

Parameters
askPriceThe current ask price
askSizeThe current ask size

Definition at line 306 of file BaseData.cs.

Here is the call graph for this function:

◆ Update()

virtual void QuantConnect.Data.BaseData.Update ( decimal  lastTrade,
decimal  bidPrice,
decimal  askPrice,
decimal  volume,
decimal  bidSize,
decimal  askSize 
)
virtual

Update routine to build a bar/tick from a data update.

Parameters
lastTradeThe last trade price
bidPriceCurrent bid price
askPriceCurrent asking price
volumeVolume of this trade
bidSizeThe size of the current bid, if available
askSizeThe size of the current ask, if available

Reimplemented in QuantConnect.Data.Market.TradeBar, QuantConnect.Data.Market.Tick, and QuantConnect.Data.Market.QuoteBar.

Definition at line 320 of file BaseData.cs.

Here is the caller graph for this function:

◆ Clone() [1/2]

virtual BaseData QuantConnect.Data.BaseData.Clone ( bool  fillForward)
virtual

Return a new instance clone of this object, used in fill forward

This base implementation uses reflection to copy all public fields and properties

Parameters
fillForwardTrue if this is a fill forward clone
Returns
A clone of the current object

Reimplemented in QuantConnect.Data.Market.TradeBar.

Definition at line 333 of file BaseData.cs.

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

◆ Clone() [2/2]

virtual BaseData QuantConnect.Data.BaseData.Clone ( )
virtual

Return a new instance clone of this object, used in fill forward

This base implementation uses reflection to copy all public fields and properties

Returns
A clone of the current object

Implements QuantConnect.Data.IBaseData.

Reimplemented in QuantConnect.Data.Market.TradeBar, QuantConnect.Data.Market.Tick, QuantConnect.Data.Market.QuoteBar, QuantConnect.Data.Market.OptionChain, QuantConnect.Data.Market.FuturesChain, QuantConnect.Data.DynamicData, QuantConnect.Data.UniverseSelection.BaseDataCollection, QuantConnect.Data.Market.RenkoBar, QuantConnect.Data.Market.OpenInterest, QuantConnect.Data.UniverseSelection.ETFConstituentUniverse, QuantConnect.Data.Market.Dividend, QuantConnect.Data.Market.Split, QuantConnect.Data.Market.RangeBar, QuantConnect.Data.Market.Delisting, QuantConnect.Data.Fundamental.FundamentalUniverse, and QuantConnect.Data.Market.SymbolChangedEvent.

Definition at line 347 of file BaseData.cs.

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

◆ ToString()

override string QuantConnect.Data.BaseData.ToString ( )

Formats a string with the symbol and value.

Returns
string - a string formatted as SPY: 167.753

Definition at line 356 of file BaseData.cs.

◆ Reader() [3/3]

virtual BaseData QuantConnect.Data.BaseData.Reader ( SubscriptionDataConfig  config,
string  line,
DateTime  date,
DataFeedEndpoint  datafeed 
)
virtual

Reader converts each line of the data source into BaseData objects. Each data type creates its own factory method, and returns a new instance of the object each time it is called.

OBSOLETE:: This implementation is added for backward/forward compatibility purposes. This function is no longer called by the LEAN engine.

Parameters
configSubscription data config setup object
lineLine of the source document
dateDate of the requested data
datafeedType of datafeed we're requesting - a live or backtest feed.
Returns
Instance of the T:BaseData object generated by this line of the CSV

Implements QuantConnect.Data.IBaseData.

Definition at line 372 of file BaseData.cs.

◆ GetSource() [2/2]

virtual string QuantConnect.Data.BaseData.GetSource ( SubscriptionDataConfig  config,
DateTime  date,
DataFeedEndpoint  datafeed 
)
virtual

Return the URL string source of the file. This will be converted to a stream

OBSOLETE:: This implementation is added for backward/forward compatibility purposes. This function is no longer called by the LEAN engine.

Parameters
configConfiguration object
dateDate of this source file
datafeedType of datafeed we're reqesting - backtest or live
Returns
String URL of source file.

Implements QuantConnect.Data.IBaseData.

Definition at line 388 of file BaseData.cs.

◆ DeserializeMessage()

static IEnumerable<BaseData> QuantConnect.Data.BaseData.DeserializeMessage ( string  serialized)
static

Deserialize the message from the data server

Parameters
serializedThe data server's message
Returns
An enumerable of base data, if unsuccessful, returns an empty enumerable

Definition at line 400 of file BaseData.cs.

Here is the call graph for this function:

Member Data Documentation

◆ AllResolutions

readonly List<Resolution> QuantConnect.Data.BaseData.AllResolutions
staticprotected
Initial value:
=
Enum.GetValues(typeof(Resolution)).Cast<Resolution>().ToList()

A list of all Resolution

Definition at line 45 of file BaseData.cs.

◆ DailyResolution

readonly List<Resolution> QuantConnect.Data.BaseData.DailyResolution = new List<Resolution> { Resolution.Daily }
staticprotected

A list of Resolution.Daily

Definition at line 51 of file BaseData.cs.

◆ MinuteResolution

readonly List<Resolution> QuantConnect.Data.BaseData.MinuteResolution = new List<Resolution> { Resolution.Minute }
staticprotected

A list of Resolution.Minute

Definition at line 56 of file BaseData.cs.

◆ HighResolution

readonly List<Resolution> QuantConnect.Data.BaseData.HighResolution = new List<Resolution> { Resolution.Minute, Resolution.Second, Resolution.Tick }
staticprotected

A list of high Resolution, including minute, second, and tick.

Definition at line 61 of file BaseData.cs.

◆ OptionResolutions

readonly List<Resolution> QuantConnect.Data.BaseData.OptionResolutions = new List<Resolution> { Resolution.Daily, Resolution.Hour, Resolution.Minute }
staticprotected

A list of resolutions support by Options

Definition at line 66 of file BaseData.cs.

◆ Price

virtual decimal QuantConnect.Data.BaseData.Price => Value

As this is a backtesting platform we'll provide an alias of value as price.

Definition at line 122 of file BaseData.cs.

Property Documentation

◆ DataType

MarketDataType QuantConnect.Data.BaseData.DataType = MarketDataType.Base
getset

Market Data Type of this data - does it come in individual price packets or is it grouped into OHLC.

Data is classed into two categories - streams of instantaneous prices and groups of OHLC data.

Definition at line 73 of file BaseData.cs.

◆ IsFillForward

bool QuantConnect.Data.BaseData.IsFillForward
get

True if this is a fill forward piece of data

Definition at line 78 of file BaseData.cs.

◆ Time

DateTime QuantConnect.Data.BaseData.Time
getset

Current time marker of this data packet.

All data is timeseries based.

Definition at line 85 of file BaseData.cs.

◆ EndTime

virtual DateTime QuantConnect.Data.BaseData.EndTime
getset

The end time of this data. Some data covers spans (trade bars) and as such we want to know the entire time span covered

Definition at line 92 of file BaseData.cs.

◆ Symbol

Symbol QuantConnect.Data.BaseData.Symbol = Symbol.Empty
getset

Symbol representation for underlying Security

Definition at line 100 of file BaseData.cs.

◆ Value

virtual decimal QuantConnect.Data.BaseData.Value
getset

Value representation of this data packet. All data requires a representative value for this moment in time. For streams of data this is the price now, for OHLC packets this is the closing price.

Definition at line 108 of file BaseData.cs.


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