Lean  $LEAN_TAG$
BaseRenkoBar.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 
19 {
20  /// <summary>
21  /// Represents a bar sectioned not by time, but by some amount of movement in a set field,
22  /// where:
23  /// - Open : Gets the opening value that started this bar
24  /// - Close : Gets the closing value or the current value if the bar has not yet closed.
25  /// - High : Gets the highest value encountered during this bar
26  /// - Low : Gets the lowest value encountered during this bar
27  /// </summary>
28  public abstract class BaseRenkoBar : TradeBar, IBaseDataBar
29  {
30  /// <summary>
31  /// Gets the kind of the bar
32  /// </summary>
33  public RenkoType Type { get; protected set; }
34 
35  /// <summary>
36  /// The preset size of the consolidated bar
37  /// </summary>
38  public decimal BrickSize { get; protected set; }
39 
40  /// <summary>
41  /// Gets the end time of this renko bar or the most recent update time if it <see cref="IsClosed"/>
42  /// </summary>
43  public override DateTime EndTime { get; set; }
44 
45  /// <summary>
46  /// Gets the time this bar started
47  /// </summary>
48  public DateTime Start
49  {
50  get { return Time; }
51  protected set { Time = value; }
52  }
53 
54  /// <summary>
55  /// Gets whether or not this bar is considered closed.
56  /// </summary>
57  public virtual bool IsClosed { get; protected set; }
58 
59  /// <summary>
60  /// Reader Method :: using set of arguements we specify read out type. Enumerate
61  /// until the end of the data stream or file. E.g. Read CSV file line by line and convert
62  /// into data types.
63  /// </summary>
64  /// <returns>BaseData type set by Subscription Method.</returns>
65  /// <param name="config">Config.</param>
66  /// <param name="line">Line.</param>
67  /// <param name="date">Date.</param>
68  /// <param name="isLiveMode">true if we're in live mode, false for backtesting mode</param>
69  public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode)
70  {
71  throw new NotSupportedException("RenkoBar does not support the Reader function. This function should never be called on this type.");
72  }
73 
74  /// <summary>
75  /// Return the URL string source of the file. This will be converted to a stream
76  /// </summary>
77  /// <param name="config">Configuration object</param>
78  /// <param name="date">Date of this source file</param>
79  /// <param name="isLiveMode">true if we're in live mode, false for backtesting mode</param>
80  /// <returns>String URL of source file.</returns>
81  public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLiveMode)
82  {
83  throw new NotSupportedException("RenkoBar does not support the GetSource function. This function should never be called on this type.");
84  }
85  }
86 }