|
@@ -10,7 +10,9 @@ BUY = frozenset([
|
|
|
# definitely buy
|
|
# definitely buy
|
|
|
'C', 'FLX', 'H', 'H2O', 'HAL', 'HCP', 'HE', 'LST', 'MG', 'N', 'NA', 'NCS', 'NS', 'O', 'PE', 'PG', 'S', 'TCL', 'THF',
|
|
'C', 'FLX', 'H', 'H2O', 'HAL', 'HCP', 'HE', 'LST', 'MG', 'N', 'NA', 'NCS', 'NS', 'O', 'PE', 'PG', 'S', 'TCL', 'THF',
|
|
|
# maybe buy
|
|
# maybe buy
|
|
|
- 'AU', 'BRM', 'CU', 'FE', 'LI', 'RG', 'ROM', 'SI', 'TI',
|
|
|
|
|
|
|
+ 'AIR', 'AU', 'BE', 'BRM', 'CU', 'FAN', 'FC', 'FE', 'HCC', 'HD', 'LDI', 'LI', 'MFK', 'MWF', 'REA', 'RG', 'RGO', 'ROM', 'SFK', 'SI', 'STL', 'TI', 'TPU',
|
|
|
|
|
+ # import
|
|
|
|
|
+ 'AAR', 'AWF', 'CAP', 'CF',
|
|
|
# skip
|
|
# skip
|
|
|
'LFE', 'LHP', 'MFE', 'SFE', 'SSC',
|
|
'LFE', 'LHP', 'MFE', 'SFE', 'SSC',
|
|
|
])
|
|
])
|
|
@@ -36,9 +38,10 @@ def main() -> None:
|
|
|
recipes = recipe_for_mats()
|
|
recipes = recipe_for_mats()
|
|
|
|
|
|
|
|
production: dict[str, dict[str, float]] = collections.defaultdict(lambda: collections.defaultdict(float))
|
|
production: dict[str, dict[str, float]] = collections.defaultdict(lambda: collections.defaultdict(float))
|
|
|
|
|
+ buy: dict[str, float] = collections.defaultdict(float)
|
|
|
cost = 0.0
|
|
cost = 0.0
|
|
|
for mat, amount in blueprint.items():
|
|
for mat, amount in blueprint.items():
|
|
|
- cost += analyze_mat(0, mat, amount, production, prices, recipes)
|
|
|
|
|
|
|
+ cost += analyze_mat(0, mat, amount, production, buy, prices, recipes)
|
|
|
print()
|
|
print()
|
|
|
print(f'total cost: {cost:,}')
|
|
print(f'total cost: {cost:,}')
|
|
|
|
|
|
|
@@ -59,6 +62,11 @@ def main() -> None:
|
|
|
print(f' {amount:g}×\033[31m{mat}\033[0m', end='')
|
|
print(f' {amount:g}×\033[31m{mat}\033[0m', end='')
|
|
|
print()
|
|
print()
|
|
|
|
|
|
|
|
|
|
+ print('buy')
|
|
|
|
|
+ for mat, amount in buy.items():
|
|
|
|
|
+ price = prices[mat]
|
|
|
|
|
+ print(f'{amount:g}×{mat}', price['Demand'])
|
|
|
|
|
+
|
|
|
def recipe_for_mats() -> dict[str, roi.Recipe]:
|
|
def recipe_for_mats() -> dict[str, roi.Recipe]:
|
|
|
all_recipes: list[roi.Recipe] = cache.get('https://api.prunplanner.org/data/recipes/', expiry=cache.ONE_DAY)
|
|
all_recipes: list[roi.Recipe] = cache.get('https://api.prunplanner.org/data/recipes/', expiry=cache.ONE_DAY)
|
|
|
mat_recipes = collections.defaultdict(list) # all ways to make a mat
|
|
mat_recipes = collections.defaultdict(list) # all ways to make a mat
|
|
@@ -72,12 +80,13 @@ def recipe_for_mats() -> dict[str, roi.Recipe]:
|
|
|
mat_recipe[mat] = recipes[0]
|
|
mat_recipe[mat] = recipes[0]
|
|
|
return mat_recipe
|
|
return mat_recipe
|
|
|
|
|
|
|
|
-def analyze_mat(level: int, mat: str, amount: float, production: dict[str, dict[str, float]],
|
|
|
|
|
|
|
+def analyze_mat(level: int, mat: str, amount: float, production: dict[str, dict[str, float]], buy: dict[str, float],
|
|
|
prices: typing.Mapping[str, RawPrice], recipes: dict[str, roi.Recipe]) -> float:
|
|
prices: typing.Mapping[str, RawPrice], recipes: dict[str, roi.Recipe]) -> float:
|
|
|
price = prices[mat]
|
|
price = prices[mat]
|
|
|
traded = price['AverageTraded30D'] or 0
|
|
traded = price['AverageTraded30D'] or 0
|
|
|
if mat in BUY:
|
|
if mat in BUY:
|
|
|
print('\t' * level + f'{amount:g}×{mat} buy: {price["Ask"]}, daily traded {traded:5.1f}')
|
|
print('\t' * level + f'{amount:g}×{mat} buy: {price["Ask"]}, daily traded {traded:5.1f}')
|
|
|
|
|
+ buy[mat] += amount
|
|
|
assert price['Ask'] is not None
|
|
assert price['Ask'] is not None
|
|
|
return price['Ask'] * amount
|
|
return price['Ask'] * amount
|
|
|
else:
|
|
else:
|
|
@@ -96,7 +105,7 @@ def analyze_mat(level: int, mat: str, amount: float, production: dict[str, dict[
|
|
|
total_cost = 0.0
|
|
total_cost = 0.0
|
|
|
for input_mat in recipe['inputs']:
|
|
for input_mat in recipe['inputs']:
|
|
|
input_amount = input_mat['material_amount'] * amount / recipe['outputs'][0]['material_amount']
|
|
input_amount = input_mat['material_amount'] * amount / recipe['outputs'][0]['material_amount']
|
|
|
- total_cost += analyze_mat(level + 1, input_mat['material_ticker'], input_amount, production, prices, recipes)
|
|
|
|
|
|
|
+ total_cost += analyze_mat(level + 1, input_mat['material_ticker'], input_amount, production, buy, prices, recipes)
|
|
|
print('\t' * level + f'\tcost: {total_cost:,.0f}')
|
|
print('\t' * level + f'\tcost: {total_cost:,.0f}')
|
|
|
return total_cost
|
|
return total_cost
|
|
|
|
|
|
|
@@ -106,6 +115,7 @@ class RawPrice(typing.TypedDict):
|
|
|
Ask: float | None
|
|
Ask: float | None
|
|
|
AverageTraded30D: float | None # averaged daily traded volume over last 30 days
|
|
AverageTraded30D: float | None # averaged daily traded volume over last 30 days
|
|
|
Supply: int
|
|
Supply: int
|
|
|
|
|
+ Demand: int
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
main()
|
|
main()
|