Lean  $LEAN_TAG$
IBaseData.cs
1 /*
2  * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3  * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 using System;
17 using System.IO;
18 
19 namespace QuantConnect.Data
20 {
21  /// <summary>
22  /// Base Data Class: Type, Timestamp, Key -- Base Features.
23  /// </summary>
24  public interface IBaseData
25  {
26  /// <summary>
27  /// Market Data Type of this data - does it come in individual price packets or is it grouped into OHLC.
28  /// </summary>
30  {
31  get;
32  set;
33  }
34 
35  /// <summary>
36  /// Time keeper of data -- all data is timeseries based.
37  /// </summary>
38  DateTime Time
39  {
40  get;
41  set;
42  }
43 
44  /// <summary>
45  /// End time of data
46  /// </summary>
47  DateTime EndTime
48  {
49  get;
50  set;
51  }
52 
53 
54  /// <summary>
55  /// Symbol for underlying Security
56  /// </summary>
58  {
59  get;
60  set;
61  }
62 
63 
64  /// <summary>
65  /// All timeseries data is a time-value pair:
66  /// </summary>
67  decimal Value
68  {
69  get;
70  set;
71  }
72 
73 
74  /// <summary>
75  /// Alias of Value.
76  /// </summary>
77  decimal Price
78  {
79  get;
80  }
81 
82  /// <summary>
83  /// Reader Method :: using set of arguements we specify read out type. Enumerate
84  /// until the end of the data stream or file. E.g. Read CSV file line by line and convert
85  /// into data types.
86  /// </summary>
87  /// <returns>BaseData type set by Subscription Method.</returns>
88  [Obsolete("Reader(SubscriptionDataConfig, string, DateTime, DataFeedEndpoint) method has been made obsolete, use Reader(SubscriptionDataConfig, string, DateTime, bool) instead.")]
89 
90  BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, DataFeedEndpoint dataFeed);
91 
92  /// <summary>
93  /// 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
94  /// each time it is called. The returned object is assumed to be time stamped in the config.ExchangeTimeZone.
95  /// </summary>
96  /// <param name="config">Subscription data config setup object</param>
97  /// <param name="line">Line of the source document</param>
98  /// <param name="date">Date of the requested data</param>
99  /// <param name="isLiveMode">true if we're in live mode, false for backtesting mode</param>
100  /// <returns>Instance of the T:BaseData object generated by this line of the CSV</returns>
101  BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode);
102 
103  /// <summary>
104  /// 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
105  /// each time it is called. The returned object is assumed to be time stamped in the config.ExchangeTimeZone.
106  /// </summary>
107  /// <param name="config">Subscription data config setup object</param>
108  /// <param name="stream">The data stream</param>
109  /// <param name="date">Date of the requested data</param>
110  /// <param name="isLiveMode">true if we're in live mode, false for backtesting mode</param>
111  /// <returns>Instance of the T:BaseData object generated by this line of the CSV</returns>
112  BaseData Reader(SubscriptionDataConfig config, StreamReader stream, DateTime date, bool isLiveMode);
113 
114  /// <summary>
115  /// Return the URL string source of the file. This will be converted to a stream
116  /// </summary>
117  /// <param name="datafeed">Type of datafeed we're reqesting - backtest or live</param>
118  /// <param name="config">Configuration object</param>
119  /// <param name="date">Date of this source file</param>
120  /// <returns>String URL of source file.</returns>
121  string GetSource(SubscriptionDataConfig config, DateTime date, DataFeedEndpoint datafeed);
122 
123  /// <summary>
124  /// Indicates if there is support for mapping
125  /// </summary>
126  /// <returns>True indicates mapping should be used</returns>
127  bool RequiresMapping();
128 
129  /// <summary>
130  /// Return a new instance clone of this object
131  /// </summary>
132  /// <returns></returns>
133  BaseData Clone();
134 
135  } // End Base Data Class
136 
137 } // End QC Namespace