/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using QuantConnect.Data.Market;
namespace QuantConnect.Orders.Fills
{
///
/// Prices class used by s
///
public class Prices
{
///
/// End time for these prices
///
public DateTime EndTime { get; init; }
///
/// Current price
///
public decimal Current { get; init; }
///
/// Open price
///
public decimal Open { get; init; }
///
/// High price
///
public decimal High { get; init; }
///
/// Low price
///
public decimal Low { get; init; }
///
/// Closing price
///
public decimal Close { get; init; }
///
/// Create an instance of Prices class with a data bar
///
/// Data bar to use for prices
public Prices(IBaseDataBar bar)
: this(bar.EndTime, bar.Close, bar.Open, bar.High, bar.Low, bar.Close)
{
}
///
/// Create an instance of Prices class with a data bar and end time
///
/// The end time for these prices
/// Data bar to use for prices
public Prices(DateTime endTime, IBar bar)
: this(endTime, bar.Close, bar.Open, bar.High, bar.Low, bar.Close)
{
}
///
/// Create a instance of the Prices class with specific values for all prices
///
/// The end time for these prices
/// Current price
/// Open price
/// High price
/// Low price
/// Close price
public Prices(DateTime endTime, decimal current, decimal open, decimal high, decimal low, decimal close)
{
EndTime = endTime;
Current = current;
Open = open == 0 ? current : open;
High = high == 0 ? current : high;
Low = low == 0 ? current : low;
Close = close == 0 ? current : close;
}
}
}