Lean  $LEAN_TAG$
Prices.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;
18 
20 {
21  /// <summary>
22  /// Prices class used by <see cref="IFillModel"/>s
23  /// </summary>
24  public class Prices
25  {
26  /// <summary>
27  /// End time for these prices
28  /// </summary>
29  public DateTime EndTime { get; init; }
30 
31  /// <summary>
32  /// Current price
33  /// </summary>
34  public decimal Current { get; init; }
35 
36  /// <summary>
37  /// Open price
38  /// </summary>
39  public decimal Open { get; init; }
40 
41  /// <summary>
42  /// High price
43  /// </summary>
44  public decimal High { get; init; }
45 
46  /// <summary>
47  /// Low price
48  /// </summary>
49  public decimal Low { get; init; }
50 
51  /// <summary>
52  /// Closing price
53  /// </summary>
54  public decimal Close { get; init; }
55 
56  /// <summary>
57  /// Create an instance of Prices class with a data bar
58  /// </summary>
59  /// <param name="bar">Data bar to use for prices</param>
60  public Prices(IBaseDataBar bar)
61  : this(bar.EndTime, bar.Close, bar.Open, bar.High, bar.Low, bar.Close)
62  {
63  }
64 
65  /// <summary>
66  /// Create an instance of Prices class with a data bar and end time
67  /// </summary>
68  /// <param name="endTime">The end time for these prices</param>
69  /// <param name="bar">Data bar to use for prices</param>
70  public Prices(DateTime endTime, IBar bar)
71  : this(endTime, bar.Close, bar.Open, bar.High, bar.Low, bar.Close)
72  {
73  }
74 
75  /// <summary>
76  /// Create a instance of the Prices class with specific values for all prices
77  /// </summary>
78  /// <param name="endTime">The end time for these prices</param>
79  /// <param name="current">Current price</param>
80  /// <param name="open">Open price</param>
81  /// <param name="high">High price</param>
82  /// <param name="low">Low price</param>
83  /// <param name="close">Close price</param>
84  public Prices(DateTime endTime, decimal current, decimal open, decimal high, decimal low, decimal close)
85  {
86  EndTime = endTime;
87  Current = current;
88  Open = open == 0 ? current : open;
89  High = high == 0 ? current : high;
90  Low = low == 0 ? current : low;
91  Close = close == 0 ? current : close;
92  }
93  }
94 }