private Func<IEnumerable<SearchResult>, IList<PriceHistory>> CreatePriceAggregatorForAggregationPeriod(AggregationPeriod aggregationPeriod) { if(aggregationPeriod == AggregationPeriod.Daily) return new Func<IEnumerable<SearchResult>, IList<PriceHistory>>(AggregatePriceDataDaily); else return new Func<IEnumerable<SearchResult>, IList<PriceHistory>>(AggregatePriceDataMonthly); }
public void OptionUpdate(List <string> args, AggregationOptions options) { // Single character version string input = args[1]; if (input.Length == 1) { char periodChar = input[0]; AggregationPeriod period = AggregationPeriod.AllPeriods.FirstOrDefault(p => p.Flag == periodChar); options.AggregationPeriod = period ?? throw new NotImplementedException($"Could not find period corresponding to {periodChar}"); } else { AggregationPeriod period = AggregationPeriod.AllPeriods.FirstOrDefault(p => string.Equals(p.Description, input, StringComparison.OrdinalIgnoreCase)); options.AggregationPeriod = period ?? throw new NotImplementedException($"Could not find period corresponding to {input}"); } }
public BaseIndicator(string symbol, int period, AggregationPeriod aggregationPeriod, Field field = Field.Close) { if (period < 1) { throw new Exception("Period must be greater than 1."); } // TODO: Add support for other AggregationPeriodUnit values if (aggregationPeriod.Unit != AggregationPeriodUnit.Day) { throw new NotImplementedException("AggregationPeriodUnit Day is the only supported unit."); } queue = new FixedSizeQueue <IAgg>(period); Symbol = symbol; Period = Period; AggregationPeriod = aggregationPeriod; Field = field; }
/// <summary> /// List the start times of the available aggregated profiles of a profiling group for an aggregation period within the specified time range. /// ListProfileTimes /profilingGroups/{profilingGroupName}/profileTimes#endTime&period&startTime /// </summary> /// <param name="endTime">The end time of the time range from which to list the profiles.</param> /// <param name="maxResults">The maximum number of profile time results returned by <code>ListProfileTimes</code> in paginated output. When this parameter is used, <code>ListProfileTimes</code> only returns <code>maxResults</code> results in a single page with a <code>nextToken</code> response element. The remaining results of the initial request can be seen by sending another <code>ListProfileTimes</code> request with the returned <code>nextToken</code> value. </param> /// <param name="nextToken"><p>The <code>nextToken</code> value returned from a previous paginated <code>ListProfileTimes</code> request where <code>maxResults</code> was used and the results exceeded the value of that parameter. Pagination continues from the end of the previous results that returned the <code>nextToken</code> value. </p> <note> <p>This token should be treated as an opaque identifier that is only used to retrieve the next items in a list and not for other programmatic purposes.</p> </note></param> /// <param name="orderBy">The order (ascending or descending by start time of the profile) to use when listing profiles. Defaults to <code>TIMESTAMP_DESCENDING</code>. </param> /// <param name="period">The aggregation period.</param> /// <param name="profilingGroupName">The name of the profiling group.</param> /// <param name="startTime">The start time of the time range from which to list the profiles.</param> /// <returns>Success</returns> public async Task <ListProfileTimesResponse> ListProfileTimesAsync(System.DateTimeOffset endTime, int maxResults, string nextToken, OrderBy orderBy, AggregationPeriod period, string profilingGroupName, System.DateTimeOffset startTime, Action <System.Net.Http.Headers.HttpRequestHeaders> handleHeaders = null) { var requestUri = "/profilingGroups/" + (profilingGroupName == null? "" : Uri.EscapeDataString(profilingGroupName)) + "/profileTimes#endTime&period&startTime?endTime=" + endTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ") + "&maxResults=" + maxResults + "&nextToken=" + (nextToken == null? "" : Uri.EscapeDataString(nextToken)) + "&orderBy=" + orderBy + "&period=" + period + "&startTime=" + startTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); using (var request = new HttpRequestMessage(HttpMethod.Get, requestUri)) { if (handleHeaders != null) { handleHeaders(request.Headers); } var responseMessage = await client.SendAsync(request); try { responseMessage.EnsureSuccessStatusCodeEx(); var stream = await responseMessage.Content.ReadAsStreamAsync(); using (JsonReader jsonReader = new JsonTextReader(new System.IO.StreamReader(stream))) { var serializer = new JsonSerializer(); return(serializer.Deserialize <ListProfileTimesResponse>(jsonReader)); } } finally { responseMessage.Dispose(); } } }
public IList<PriceHistory> CreateBasicPriceHistory(int productId, int conditionId, AggregationPeriod aggregationPeriod) { var aggregator = CreatePriceAggregatorForAggregationPeriod(aggregationPeriod); var result = _repository.GetSearchResultsByProductID (productId, conditionId,false); return aggregator(result); }
/// <summary> /// Returns a string that represents the current object. /// </summary> public override string ToString() { return(string.Format("AggregatorConfig [{0},{1},{2},{3},[{4}]]", MaxLevel?.ToString() ?? "null", AggregationAlgorithm?.ToString() ?? "null", AggregationPeriod?.ToString() ?? "null", MaxRequests?.ToString() ?? "null", GetParentUrisString())); }
/// <inheritdoc /> public Task <PVOutputArrayResponse <IAggregatedOutput> > GetAggregatedOutputsAsync(DateTime fromDate, DateTime toDate, AggregationPeriod period, CancellationToken cancellationToken = default) { var loggingScope = new Dictionary <string, object>() { [LoggingEvents.RequestId] = LoggingEvents.OutputService_GetAggregatedOutputs, [LoggingEvents.Parameter_FromDate] = fromDate, [LoggingEvents.Parameter_ToDate] = toDate, [LoggingEvents.Parameter_AggregationPeriod] = period }; Guard.Argument(toDate, nameof(toDate)).GreaterThan(fromDate).IsNoFutureDate().NoTimeComponent(); Guard.Argument(fromDate, nameof(fromDate)).NoTimeComponent(); var handler = new RequestHandler(Client); return(handler.ExecuteArrayRequestAsync <IAggregatedOutput>(new OutputRequest { FromDate = fromDate, ToDate = toDate, Aggregation = period }, loggingScope, cancellationToken)); }