|
@@ -11,9 +11,16 @@ def main() -> None:
|
|
|
buildings: dict[str, Building] = {m['Ticker']: m for m in cache.get('https://api.prunplanner.org/data/buildings')}
|
|
buildings: dict[str, Building] = {m['Ticker']: m for m in cache.get('https://api.prunplanner.org/data/buildings')}
|
|
|
materials: dict[str, Material] = {m['Ticker']: m for m in cache.get('https://api.prunplanner.org/data/materials')}
|
|
materials: dict[str, Material] = {m['Ticker']: m for m in cache.get('https://api.prunplanner.org/data/materials')}
|
|
|
raw_prices: list[RawPrice] = cache.get('https://refined-prun.github.io/refined-prices/all.json')
|
|
raw_prices: list[RawPrice] = cache.get('https://refined-prun.github.io/refined-prices/all.json')
|
|
|
|
|
+ for cx in ['AI1', 'CI1', 'IC1', 'NC1']:
|
|
|
|
|
+ profits = calc_for_cx(cx, recipes, buildings, materials, raw_prices)
|
|
|
|
|
+ with open(f'www/roi_{cx.lower()}.json', 'w') as f:
|
|
|
|
|
+ json.dump([dataclasses.asdict(p) for p in profits], f, indent='\t')
|
|
|
|
|
+
|
|
|
|
|
+def calc_for_cx(cx: str, recipes: typing.Collection[Recipe], buildings: typing.Mapping[str, Building],
|
|
|
|
|
+ materials: typing.Mapping[str, Material], raw_prices: typing.Collection[RawPrice]) -> typing.Sequence[Profit]:
|
|
|
prices: dict[str, Price] = {
|
|
prices: dict[str, Price] = {
|
|
|
p['MaterialTicker']: Price(p['VWAP7D'], p['AverageTraded7D'], p['VWAP30D']) for p in raw_prices # pyright: ignore[reportArgumentType]
|
|
p['MaterialTicker']: Price(p['VWAP7D'], p['AverageTraded7D'], p['VWAP30D']) for p in raw_prices # pyright: ignore[reportArgumentType]
|
|
|
- if p['ExchangeCode'] == 'IC1'
|
|
|
|
|
|
|
+ if p['ExchangeCode'] == cx
|
|
|
}
|
|
}
|
|
|
habitation: typing.Mapping[Worker, str] = {
|
|
habitation: typing.Mapping[Worker, str] = {
|
|
|
'Pioneers': 'HB1',
|
|
'Pioneers': 'HB1',
|
|
@@ -33,8 +40,7 @@ def main() -> None:
|
|
|
if profit := calc_profit(recipe, buildings, hab_area_cost, hab_capex, materials, prices):
|
|
if profit := calc_profit(recipe, buildings, hab_area_cost, hab_capex, materials, prices):
|
|
|
profits.append(profit)
|
|
profits.append(profit)
|
|
|
profits.sort()
|
|
profits.sort()
|
|
|
- with open('www/roi.json', 'w') as f:
|
|
|
|
|
- json.dump([dataclasses.asdict(p) for p in profits], f, indent='\t')
|
|
|
|
|
|
|
+ return profits
|
|
|
|
|
|
|
|
def calc_profit(recipe: Recipe, buildings: typing.Mapping[str, Building], hab_area_cost: typing.Mapping[Worker, float],
|
|
def calc_profit(recipe: Recipe, buildings: typing.Mapping[str, Building], hab_area_cost: typing.Mapping[Worker, float],
|
|
|
hab_capex: typing.Mapping[Worker, float], materials: typing.Mapping[str, Material],
|
|
hab_capex: typing.Mapping[Worker, float], materials: typing.Mapping[str, Material],
|