/// <summary> /// Stations in the EVE Universe /// </summary> /// <returns><c>Bag</c> of Stations in the EVE Universe</returns> internal static Bag <StaStation> Stations() { var list = new IndexedList <StaStation>(); foreach (staStations station in Context.staStations) { var item = new StaStation { ID = station.stationID, Name = station.stationName, }; if (station.reprocessingEfficiency.HasValue) { item.ReprocessingEfficiency = (float)station.reprocessingEfficiency.Value; } if (station.reprocessingStationsTake.HasValue) { item.ReprocessingStationsTake = (float)station.reprocessingStationsTake.Value; } if (station.security.HasValue) { item.SecurityLevel = station.security.Value; } if (station.solarSystemID.HasValue) { item.SolarSystemID = station.solarSystemID.Value; } if (station.corporationID.HasValue) { item.CorporationID = station.corporationID.Value; } list.Items.Add(item); } return(new Bag <StaStation>(list)); }
public async Task <IList <MarketAnalyzerEntry> > AnalyzeAsync(MapRegion region, StaStation station, IEnumerable <InvType> invTypes, int days) { var items = invTypes.Select(type => type.TypeId).ToList(); var priceResult = await _eveMarketService.GetItemPricesAsync(region.RegionId, station.StationId, items).ConfigureAwait(false); var historyResult = await _eveMarketService.GetItemHistoryAsync(region.RegionId, items, days).ConfigureAwait(false); var analyzer = new MarketAnalyzer(invTypes, priceResult.Prices.Where(o => o.OrderType == OrderType.Sell), priceResult.Prices.Where(o => o.OrderType == OrderType.Buy), historyResult); analyzer.Analyze(); foreach (var entry in analyzer.Result) { entry.Order = entry.InvType.Orders.SingleOrDefault(order => order.ApiKeyEntity_Id == ApplicationHelper.ActiveEntity.Id && order.StationId == station.StationId); } return(analyzer.Result); }
public async Task LoadMarketDataAsync(IEnumerable <OrderVm> orderViewModels, MapRegion region, StaStation station, int dayLimit) { var orders = orderViewModels.Select(f => f.Order); var enumerable = orders as IList <Order> ?? orders.ToList(); var regionId = region != null ? region.RegionId : 0; var stationId = station != null ? station.StationId : 0; var pricesTask = _eveMarketService.GetItemPricesAsync(regionId, stationId, enumerable.Select(o => o.TypeId)).ConfigureAwait(false); var historyTask = _eveMarketService.GetItemHistoryAsync(regionId, enumerable.Select(o => o.TypeId), dayLimit); var prices = await pricesTask; var priceLookup = prices.Prices.ToLookup(f => f.TypeId); var history = await historyTask; var historyLookup = history.ToLookup(f => f.TypeId); foreach (Order order in enumerable) { var itemHistory = historyLookup[order.TypeId].ToList(); var price = priceLookup[order.TypeId].ToList(); order.CurrentBuyPrice = price.Single(t => t.OrderType == OrderType.Buy).Price; order.CurrentSellPrice = price.Single(t => t.OrderType == OrderType.Sell).Price; if (!itemHistory.IsEmpty()) { order.AvgPrice = itemHistory.Average(f => f.AvgPrice); order.AvgVolume = itemHistory.Average(f => f.Volume); } } }