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 : ISymbolProvider
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  /// All timeseries data is a time-value pair:
56  /// </summary>
57  decimal Value
58  {
59  get;
60  set;
61  }
62 
63 
64  /// <summary>
65  /// Alias of Value.
66  /// </summary>
67  decimal Price
68  {
69  get;
70  }
71 
72  /// <summary>
73  /// Reader Method :: using set of arguements we specify read out type. Enumerate
74  /// until the end of the data stream or file. E.g. Read CSV file line by line and convert
75  /// into data types.
76  /// </summary>
77  /// <returns>BaseData type set by Subscription Method.</returns>
78  [Obsolete("Reader(SubscriptionDataConfig, string, DateTime, DataFeedEndpoint) method has been made obsolete, use Reader(SubscriptionDataConfig, string, DateTime, bool) instead.")]
79 
80  BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, DataFeedEndpoint dataFeed);
81 
82  /// <summary>
83  /// 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
84  /// each time it is called. The returned object is assumed to be time stamped in the config.ExchangeTimeZone.
85  /// </summary>
86  /// <param name="config">Subscription data config setup object</param>
87  /// <param name="line">Line of the source document</param>
88  /// <param name="date">Date of the requested data</param>
89  /// <param name="isLiveMode">true if we're in live mode, false for backtesting mode</param>
90  /// <returns>Instance of the T:BaseData object generated by this line of the CSV</returns>
91  BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode);
92 
93  /// <summary>
94  /// 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
95  /// each time it is called. The returned object is assumed to be time stamped in the config.ExchangeTimeZone.
96  /// </summary>
97  /// <param name="config">Subscription data config setup object</param>
98  /// <param name="stream">The data stream</param>
99  /// <param name="date">Date of the requested data</param>
100  /// <param name="isLiveMode">true if we're in live mode, false for backtesting mode</param>
101  /// <returns>Instance of the T:BaseData object generated by this line of the CSV</returns>
102  BaseData Reader(SubscriptionDataConfig config, StreamReader stream, DateTime date, bool isLiveMode);
103 
104  /// <summary>
105  /// Return the URL string source of the file. This will be converted to a stream
106  /// </summary>
107  /// <param name="datafeed">Type of datafeed we're reqesting - backtest or live</param>
108  /// <param name="config">Configuration object</param>
109  /// <param name="date">Date of this source file</param>
110  /// <returns>String URL of source file.</returns>
111  string GetSource(SubscriptionDataConfig config, DateTime date, DataFeedEndpoint datafeed);
112 
113  /// <summary>
114  /// Indicates if there is support for mapping
115  /// </summary>
116  /// <returns>True indicates mapping should be used</returns>
117  bool RequiresMapping();
118 
119  /// <summary>
120  /// Return a new instance clone of this object
121  /// </summary>
122  /// <returns></returns>
123  BaseData Clone();
124 
125  } // End Base Data Class
126 
127 } // End QC Namespace