/// <summary> /// Gets the calculated market price for an item, based on the current configuration. /// </summary> /// <param name="item"></param> /// <returns></returns> public static int GetMarketPrice(Item item) { if (item == null) { throw new ArgumentNullException(nameof(item), "Cannot determine market price for null item."); } if (!item.AllMarketData.Any()) { return(0); } if (UseMostRecent) { return(GetPriceFunction().Invoke(item.CurrentMarketData)); } Dictionary <DateTime, double> history; if (MaximumObservationAgeInDays == 0) { history = MarketHistoryBuilder.BuildHistory(item.AllMarketData, InterpolationMethod, GetPriceFunction()); } else { history = MarketHistoryBuilder.BuildHistory(item.AllMarketData, InterpolationMethod, GetPriceFunction(), MaximumObservationAgeInDays); } //todo: weighted average if (UseWeightedAverage) { return((int)GetWeightedAverage(history)); } return((int)GetStraightAverage(history)); }
/// <summary> /// Gets the items market history, by day, using the selected <see cref="InterpolationMethod"/>. /// </summary> /// <param name="item"></param> /// <returns></returns> public static Dictionary <DateTime, double> GetFullMarketHistory(Item item) { return(MarketHistoryBuilder.BuildHistory(item.AllMarketData, InterpolationMethod, GetPriceFunction())); }