1
0

2 Ревизии 1d1f3e57e1 ... e221706391

Автор SHA1 Съобщение Дата
  raylu e221706391 roi: profit per area преди 1 седмица
  raylu 6ce8b39acc roi: show expertise преди 1 седмица
променени са 1 файла, в които са добавени 14 реда и са изтрити 13 реда
  1. 14 13
      roi.py

+ 14 - 13
roi.py

@@ -21,14 +21,14 @@ def main() -> None:
 			profits.append(profit)
 	profits.sort(reverse=True)
 	for p in profits:
-		print(f'{p.output:5} \033[32m{p.profit: 10,.0f}\033[31m', end='')
+		print(f'{p.output:5} \033[32m{p.profit_per_area: 10,.0f}\033[31m', end='')
 		if p.low_volume:
 			print(' low volume', end='')
 		if p.heavy_logistics:
 			print(' heavy logistics', end='')
 		if p.high_opex:
 			print(' high opex', end='')
-		print(f'\n\033[30m{p.recipe:30} \033[33m{p.capex: 6,.0f} \033[35m{p.cost_per_day: 6,.0f}\033[0m')
+		print(f'\n\033[30m{p.recipe:30} \033[0m{p.expertise:19} \033[33m{p.capex:7,.0f} \033[35m{p.cost_per_day:7,.0f}\033[0m')
 
 def calc_profit(recipe: Recipe, buildings: typing.Mapping[str, Building], materials: typing.Mapping[str, Material],
 		prices: typing.Mapping[str, Price]) -> Profit | None:
@@ -42,8 +42,9 @@ def calc_profit(recipe: Recipe, buildings: typing.Mapping[str, Building], materi
 	except KeyError: # skip recipes with thinly traded materials
 		return
 	revenue = output_price.vwap * output['Amount']
+	building = buildings[recipe['BuildingTicker']]
 	capex = sum(bm['Amount'] * prices[bm['CommodityTicker']].vwap
-			for bm in buildings[recipe['BuildingTicker']]['BuildingCosts'])
+			for bm in building['BuildingCosts'])
 	profit_per_run = revenue - cost
 	runs_per_day = 24 * 60 * 60 * 1000 / recipe['TimeMs']
 	cost_per_day = cost * runs_per_day
@@ -54,7 +55,9 @@ def calc_profit(recipe: Recipe, buildings: typing.Mapping[str, Building], materi
 		materials[output['Ticker']]['Weight'] * output['Amount'],
 		materials[output['Ticker']]['Volume'] * output['Amount'],
 	) * runs_per_day
-	return Profit(output['Ticker'], recipe['RecipeName'], profit=profit_per_run * runs_per_day,
+	return Profit(output['Ticker'], recipe['RecipeName'],
+			expertise=building['Expertise'].replace('_', ' ').lower(),
+			profit_per_area=profit_per_run * runs_per_day / building['AreaCost'],
 			capex=capex,
 			cost_per_day=cost_per_day,
 			low_volume=output_price.average_traded < output_per_day * 20,
@@ -72,9 +75,10 @@ class RecipeMat(typing.TypedDict):
 	Amount: int
 
 class Building(typing.TypedDict):
-    Ticker: str
-    AreaCost: int
-    BuildingCosts: list[BuildingMat]
+	Ticker: str
+	Expertise: str
+	AreaCost: int
+	BuildingCosts: list[BuildingMat]
 
 class BuildingMat(typing.TypedDict):
 	CommodityTicker: str
@@ -101,7 +105,8 @@ class Price:
 class Profit:
 	output: str
 	recipe: str
-	profit: float
+	expertise: str
+	profit_per_area: float
 	capex: float
 	cost_per_day: float
 	low_volume: bool
@@ -111,13 +116,9 @@ class Profit:
 
 	def __post_init__(self) -> None:
 		self.high_opex = self.cost_per_day > 50_000
-		self.score = self.profit
+		self.score = self.profit_per_area
 		if self.low_volume:
 			self.score *= 0.2
-		if self.heavy_logistics:
-			self.score *= 0.5
-		if self.high_opex:
-			self.score *= 0.8
 
 	def __lt__(self, other: Profit) -> bool:
 		return self.score < other.score