89 private Map<String, CommodityStats> priceData =
new HashMap<String, CommodityStats>();
133 CommodityStats stats =
getStats(com.getId());
134 float average = stats.getAverageSupplyPrice();
141 float flat = Misc.getProfitMarginFlat();
142 float mult = Misc.getProfitMarginMult();
144 return price <= average - flat || price <= average / mult;
154 CommodityStats stats =
getStats(com.getId());
155 float average = stats.getAverageDemandPrice();
160 float flat = Misc.getProfitMarginFlat();
161 float mult = Misc.getProfitMarginMult();
163 return price >= average + flat || price >= average * mult;
204 List<MarketAPI> markets = economy.getMarketsCopy();
206 float totalSupply = 0;
207 float totalDemand = 0;
208 float totalStockpiles = 0;
209 float minSupplyPrice = Float.MAX_VALUE;
210 float maxDemandPrice = 0;
212 float totalSupplyPrice = 0;
213 float totalDemandPrice = 0;
215 for (MarketAPI market : markets) {
216 CommodityOnMarketAPI com = market.getCommodityData(commodityId);
219 float demand = com.getDemand().getDemandValue();
220 float supply = demand;
221 float stockpile = com.getStockpile();
223 if (supply < 10 && demand < 10 && stockpile < 10)
continue;
225 float supplyPrice = Math.round(market.getSupplyPrice(com.getId(), 1,
true));
226 float demandPrice = Math.round(market.getDemandPrice(com.getId(), 1,
true));
228 if (supplyPrice < minSupplyPrice) {
229 minSupplyPrice = supplyPrice;
231 if (demandPrice > maxDemandPrice) {
232 maxDemandPrice = demandPrice;
235 totalSupply += supply;
236 totalDemand += demand;
237 totalStockpiles += stockpile;
239 totalSupplyPrice += stockpile * supplyPrice;
240 totalDemandPrice += demand * demandPrice;
243 CommodityStats stats =
getStats(commodityId);
245 stats.setTotalSupply(totalSupply);
246 stats.setTotalDemand(totalDemand);
247 stats.setTotalStockpiles(totalStockpiles);
248 stats.setMaxDemandPrice(maxDemandPrice);
249 stats.setMinSupplyPrice(minSupplyPrice);
251 if (totalStockpiles > 0) {
252 stats.setAverageSupplyPrice(totalSupplyPrice / totalStockpiles);
254 stats.setAverageSupplyPrice(0);
257 if (totalDemand > 0) {
258 stats.setAverageDemandPrice(totalDemandPrice / totalDemand);
260 stats.setAverageDemandPrice(0);