|
|
@@ -39,6 +39,66 @@ def add_company_ranks(totals: typing.Mapping[str, CompanyTotals]) -> typing.Mapp
|
|
|
company_totals['volumeRank'] = rank
|
|
|
return totals
|
|
|
|
|
|
+def calc_consumption_profit(prod_data: typing.Mapping[str, ProdData], company_data: CompanyData) -> None:
|
|
|
+ # reddead_solo derived these from apr26 data
|
|
|
+ extraction_cost = {
|
|
|
+ 'ALO': 46.469626236277556,
|
|
|
+ 'AMM': 64.22413645940814,
|
|
|
+ 'AR': 47.70764360662854,
|
|
|
+ 'AUO': 54.44708670483523,
|
|
|
+ 'BER': 53.972209698989495,
|
|
|
+ 'BOR': 83.72543770145344,
|
|
|
+ 'BRM': 27.888018032559867,
|
|
|
+ 'BTS': 78.06705317448308,
|
|
|
+ 'CLI': 35.136976457308684,
|
|
|
+ 'CUO': 50.86203030902945,
|
|
|
+ 'F': 131.4747740048254,
|
|
|
+ 'FEO': 48.650761183540155,
|
|
|
+ 'GAL': 57.92699044231113,
|
|
|
+ 'H': 22.44162253371223,
|
|
|
+ 'H2O': 20.786470813001372,
|
|
|
+ 'HAL': 73.71971131519504,
|
|
|
+ 'HE': 75.22625975185184,
|
|
|
+ 'HE3': 124.06892211329114,
|
|
|
+ 'HEX': 42.936879245965734,
|
|
|
+ 'KR': 69.26330139617842,
|
|
|
+ 'LES': 107.34219811491415,
|
|
|
+ 'LIO': 27.095584832287784,
|
|
|
+ 'LST': 22.711465634512184,
|
|
|
+ 'MAG': 187.27617420211016,
|
|
|
+ 'MGS': 58.51507605569296,
|
|
|
+ 'N': 27.282314763847143,
|
|
|
+ 'NE': 59.13606618175083,
|
|
|
+ 'O': 27.57488101890798,
|
|
|
+ 'REO': 80.67539173234522,
|
|
|
+ 'SCR': 55.37980023917345,
|
|
|
+ 'SIO': 31.748301836118316,
|
|
|
+ 'TAI': 54.2528323296315,
|
|
|
+ 'TCO': 67.4922174225306,
|
|
|
+ 'TIO': 40.709175823948684,
|
|
|
+ 'TS': 47.68370385324906,
|
|
|
+ 'ZIR': 53.627181874429766,
|
|
|
+ }
|
|
|
+ pio_consumable_price_ratios = {
|
|
|
+ 'DW': 0.23852885030544477 / 107.1798998000011,
|
|
|
+ 'RAT': 0.37223040985862066 / 167.25699210000184,
|
|
|
+ 'OVE': 0.03871106977501096 / 139.15460790000103,
|
|
|
+ 'COF': 0.302139841269314 / 1086.1015050000133,
|
|
|
+ 'PWO': 0.04838982879160972 / 434.86706069999866,
|
|
|
+ }
|
|
|
+
|
|
|
+ universe_consumption: dict[str, float] = collections.defaultdict(float)
|
|
|
+ for co_data in company_data['individual'].values():
|
|
|
+ for mat, mat_data in co_data.items():
|
|
|
+ if (cost := extraction_cost.get(mat)) is not None:
|
|
|
+ total_cost = mat_data['amount'] * cost
|
|
|
+ mat_data['profit'] = mat_data['volume'] - total_cost
|
|
|
+ for consumed_mat, ratio in pio_consumable_price_ratios.items():
|
|
|
+ universe_consumption[consumed_mat] += ratio * total_cost
|
|
|
+
|
|
|
+ for mat, mat_data in prod_data.items():
|
|
|
+ mat_data['consumed'] = universe_consumption.get(mat, 0.0)
|
|
|
+
|
|
|
def write_data(month: str, data: dict[str, list[Row]],
|
|
|
prod_data: typing.Mapping[str, ProdData], company_data: CompanyData) -> None:
|
|
|
with open(f'www/data/prod-data-{month}.json', 'w') as f:
|
|
|
@@ -88,6 +148,7 @@ class Price(typing.TypedDict):
|
|
|
class ProdData(typing.TypedDict):
|
|
|
amount: float
|
|
|
volume: float
|
|
|
+ consumed: typing.NotRequired[float]
|
|
|
|
|
|
class CompanyData(typing.TypedDict):
|
|
|
totals: typing.Mapping[str, CompanyTotals]
|
|
|
@@ -96,6 +157,7 @@ class CompanyData(typing.TypedDict):
|
|
|
class CompanyTickerData(typing.TypedDict):
|
|
|
amount: float
|
|
|
volume: float
|
|
|
+ profit: typing.NotRequired[float]
|
|
|
rank: int
|
|
|
|
|
|
class CompanyTotals(typing.TypedDict):
|