/*
* 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 NodaTime;
using QuantConnect.Securities;
namespace QuantConnect.Data
{
///
/// Represents a request for historical data
///
public class HistoryRequest
{
private Resolution? _fillForwardResolution;
///
/// Gets the start time of the request.
///
public DateTime StartTimeUtc { get; set; }
///
/// Gets the end time of the request.
///
public DateTime EndTimeUtc { get; set; }
///
/// Gets the symbol to request data for
///
public Symbol Symbol { get; set; }
///
/// Gets the exchange hours used for processing fill forward requests
///
public SecurityExchangeHours ExchangeHours { get; set; }
///
/// Gets the requested data resolution
///
public Resolution Resolution { get; set; }
///
/// Gets the requested fill forward resolution, set to null for no fill forward behavior.
/// Will always return null when Resolution is set to Tick.
///
public Resolution? FillForwardResolution
{
get
{
return Resolution == Resolution.Tick ? null : _fillForwardResolution;
}
set
{
_fillForwardResolution = value;
}
}
///
/// Gets whether or not to include extended market hours data, set to false for only normal market hours
///
public bool IncludeExtendedMarketHours { get; set; }
///
/// Gets the data type used to process the subscription request, this type must derive from BaseData
///
public Type DataType { get; set; }
///
/// Gets the time zone of the time stamps on the raw input data
///
public DateTimeZone DataTimeZone { get; set; }
///
/// TickType of the history request
///
public TickType TickType { get; set; }
///
/// Gets true if this is a custom data request, false for normal QC data
///
public bool IsCustomData { get; set; }
///
/// Gets the normalization mode used for this subscription
///
public DataNormalizationMode DataNormalizationMode { get; set; }
///
/// Initializes a new instance of the class from the specified parameters
///
/// The start time for this request,
/// The start time for this request
/// The data type of the output data
/// The symbol to request data for
/// The requested data resolution
/// The exchange hours used in fill forward processing
/// The time zone of the data
/// The requested fill forward resolution for this request
/// True to include data from pre/post market hours
/// True for custom user data, false for normal QC data
/// Specifies normalization mode used for this subscription
/// The tick type used to created the for the retrieval of history data
public HistoryRequest(DateTime startTimeUtc,
DateTime endTimeUtc,
Type dataType,
Symbol symbol,
Resolution resolution,
SecurityExchangeHours exchangeHours,
DateTimeZone dataTimeZone,
Resolution? fillForwardResolution,
bool includeExtendedMarketHours,
bool isCustomData,
DataNormalizationMode dataNormalizationMode,
TickType tickType)
{
StartTimeUtc = startTimeUtc;
EndTimeUtc = endTimeUtc;
Symbol = symbol;
ExchangeHours = exchangeHours;
DataTimeZone = dataTimeZone;
Resolution = resolution;
FillForwardResolution = fillForwardResolution;
IncludeExtendedMarketHours = includeExtendedMarketHours;
DataType = dataType;
IsCustomData = isCustomData;
DataNormalizationMode = dataNormalizationMode;
TickType = tickType;
}
///
/// Initializes a new instance of the class from the specified config and exchange hours
///
/// The subscription data config used to initalize this request
/// The exchange hours used for fill forward processing
/// The start time for this request,
/// The start time for this request
public HistoryRequest(SubscriptionDataConfig config, SecurityExchangeHours hours, DateTime startTimeUtc, DateTime endTimeUtc)
{
StartTimeUtc = startTimeUtc;
EndTimeUtc = endTimeUtc;
Symbol = config.Symbol;
ExchangeHours = hours;
Resolution = config.Resolution;
FillForwardResolution = config.FillDataForward ? config.Resolution : (Resolution?) null;
IncludeExtendedMarketHours = config.ExtendedMarketHours;
DataType = config.Type;
IsCustomData = config.IsCustomData;
DataNormalizationMode = config.DataNormalizationMode;
DataTimeZone = config.DataTimeZone;
TickType = config.TickType;
}
}
}