Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public void FillFromMarketEntry(Entity.MarketEntry marketEntry)
 {
     SetTextBoxValue(this.SellToStationPrice, marketEntry.SellToStationPrice);
     SetTextBoxValue(this.BuyFromStationPrice, marketEntry.BuyFromStationPrice);
     SetTextBoxValue(this.Demand, marketEntry.Demand);
     SetTextBoxValue(this.Supply, marketEntry.Supply);
     LastUpdateLabel.Text = marketEntry.LastUpdate.ToString("yyyy-MM-dd hh:mm:ss");
 }