Merge pull request #2768 from Martin-Molinero/refactor-2767-add-new-history-request-factory-class

Adding new HistoryRequestFactory
This commit is contained in:
Jared
2018-12-21 08:56:23 -08:00
committed by GitHub
5 changed files with 126 additions and 79 deletions
+9 -7
View File
@@ -588,7 +588,7 @@ namespace QuantConnect.Algorithm
.FirstOrDefault(s => s.Type.BaseType == CreateType(type).BaseType);
if (config == null) return null;
return CreateHistoryRequest(config, start, end, resolution);
return _historyRequestFactory.CreateHistoryRequest(config, start, end, GetExchangeHours(x), resolution);
});
return PandasConverter.GetDataFrame(History(requests.Where(x => x != null)).Memoize());
@@ -615,9 +615,10 @@ namespace QuantConnect.Algorithm
.FirstOrDefault(s => s.Type.BaseType == CreateType(type).BaseType);
if (config == null) return null;
Resolution? res = resolution ?? security.Resolution;
var start = GetStartTimeAlgoTz(x, periods, resolution).ConvertToUtc(TimeZone);
return CreateHistoryRequest(config, start, UtcTime.RoundDown(res.Value.ToTimeSpan()), resolution);
var res = GetResolution(x, resolution);
var exchange = GetExchangeHours(x);
var start = _historyRequestFactory.GetStartTimeAlgoTz(x, periods, res.Value, exchange);
return _historyRequestFactory.CreateHistoryRequest(config, start, Time.RoundDown(res.Value.ToTimeSpan()), exchange, res);
});
return PandasConverter.GetDataFrame(History(requests.Where(x => x != null)).Memoize());
@@ -659,7 +660,7 @@ namespace QuantConnect.Algorithm
throw new ArgumentException("The specified security is not of the requested type. Symbol: " + symbol.ToString() + " Requested Type: " + requestedType.Name + " Actual Type: " + actualType);
}
var request = CreateHistoryRequest(config, start, end, resolution);
var request = _historyRequestFactory.CreateHistoryRequest(config, start, end, GetExchangeHours(symbol), resolution);
return PandasConverter.GetDataFrame(History(request).Memoize());
}
@@ -677,8 +678,9 @@ namespace QuantConnect.Algorithm
{
if (resolution == Resolution.Tick) throw new ArgumentException("History functions that accept a 'periods' parameter can not be used with Resolution.Tick");
var start = GetStartTimeAlgoTz(symbol, periods, resolution);
var end = Time.RoundDown((resolution ?? Securities[symbol].Resolution).ToTimeSpan());
var res = GetResolution(symbol, resolution);
var start = _historyRequestFactory.GetStartTimeAlgoTz(symbol, periods, res.Value, GetExchangeHours(symbol));
var end = Time.RoundDown(res.Value.ToTimeSpan());
return History(type, symbol, start, end, resolution);
}