public static ProfitEntry CreateProfitEntry(
            Entity.CommodityType commodityType, Entity.MarketEntry localMarketEntry, Entity.MarketEntry remoteMarketEntry
            )
        {
            var profitEntry = new ProfitEntry()
            {
                CommodityGroup      = commodityType.CommodityGroup,
                CommodityType       = commodityType,
                LocalStation        = localMarketEntry.SpaceStation,
                RemoteStation       = remoteMarketEntry.SpaceStation,
                LocalSystem         = localMarketEntry.SpaceStation.SolarSystem,
                RemoteSystem        = remoteMarketEntry.SpaceStation.SolarSystem,
                BuyFromMarketPrice  = localMarketEntry.BuyFromStationPrice,
                SellToMarketPrice   = remoteMarketEntry.SellToStationPrice,
                Supply              = localMarketEntry.Supply,
                Demand              = remoteMarketEntry.Demand,
                LastBuyPriceUpdate  = localMarketEntry.LastUpdate,
                LastSellPriceUpdate = remoteMarketEntry.LastUpdate
            };

            if (profitEntry.BuyFromMarketPrice.HasValue && profitEntry.SellToMarketPrice.HasValue)
            {
                profitEntry.Profit = profitEntry.SellToMarketPrice - profitEntry.BuyFromMarketPrice;
                profitEntry.ProfitPerInvestment = (int)((double)profitEntry.Profit / (double)profitEntry.BuyFromMarketPrice * 100.0);
            }

            return(profitEntry);
        }
        /// <summary>
        /// Retrieves the best profits for a round trip between two stations.
        /// </summary>
        /// <param name="allStations">The list of all space stations.</param>
        /// <param name="maximumCostPerUnit">The maximum cost per unit.</param>
        /// <returns>A list with two profit entries (one for each direction).</returns>
        public static List <ProfitEntry> FindBestRoundTripForThreeStations(List <Entity.SpaceStation> allStations, int maximumCostPerUnit)
        {
            int         highestProfit = 0;
            ProfitEntry profitEntry1  = null;
            ProfitEntry profitEntry2  = null;
            ProfitEntry profitEntry3  = null;

            foreach (var spaceStation1 in allStations)
            {
                foreach (var spaceStation2 in allStations)
                {
                    foreach (var spaceStation3 in allStations)
                    {
                        var bestProfitEntry1 = Calculation.ProfitCalculator.FindBestProfitEntry(spaceStation1, spaceStation2, maximumCostPerUnit);
                        var bestProfitEntry2 = Calculation.ProfitCalculator.FindBestProfitEntry(spaceStation2, spaceStation3, maximumCostPerUnit);
                        var bestProfitEntry3 = Calculation.ProfitCalculator.FindBestProfitEntry(spaceStation3, spaceStation1, maximumCostPerUnit);

                        if (bestProfitEntry1 == null || bestProfitEntry2 == null || bestProfitEntry3 == null)
                        {
                            continue;
                        }

                        var totalProfit = (bestProfitEntry1.Profit.Value + bestProfitEntry2.Profit.Value + bestProfitEntry3.Profit.Value);

                        if (totalProfit > highestProfit)
                        {
                            highestProfit = totalProfit;
                            profitEntry1  = bestProfitEntry1;
                            profitEntry2  = bestProfitEntry2;
                            profitEntry3  = bestProfitEntry3;
                        }
                    }
                }
            }

            if (profitEntry1 == null || profitEntry2 == null || profitEntry3 == null)
            {
                return(null);
            }

            return(new List <ProfitEntry>()
            {
                profitEntry1, profitEntry2, profitEntry3
            });
        }