|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
|
import collections
|
|
import collections
|
|
|
import concurrent.futures
|
|
import concurrent.futures
|
|
|
import dataclasses
|
|
import dataclasses
|
|
|
|
|
+import sys
|
|
|
import typing
|
|
import typing
|
|
|
|
|
|
|
|
import cache
|
|
import cache
|
|
@@ -13,10 +14,11 @@ if typing.TYPE_CHECKING:
|
|
|
import market
|
|
import market
|
|
|
|
|
|
|
|
def main() -> None:
|
|
def main() -> None:
|
|
|
|
|
+ days = int(sys.argv[1])
|
|
|
with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
|
futures = [
|
|
futures = [
|
|
|
executor.submit(get_raw_prices),
|
|
executor.submit(get_raw_prices),
|
|
|
- executor.submit(get_total_buy), # what we need to buy
|
|
|
|
|
|
|
+ executor.submit(get_total_buy, days), # what we need to buy
|
|
|
executor.submit(supply.warehouse_inventory), # what we have
|
|
executor.submit(supply.warehouse_inventory), # what we have
|
|
|
executor.submit(get_planet_exports_and_ship_storage),
|
|
executor.submit(get_planet_exports_and_ship_storage),
|
|
|
executor.submit(get_bids), # what we already are bidding for
|
|
executor.submit(get_bids), # what we already are bidding for
|
|
@@ -56,12 +58,12 @@ def get_raw_prices() -> typing.Mapping[str, market.RawPrice]:
|
|
|
return {p['MaterialTicker']: p
|
|
return {p['MaterialTicker']: p
|
|
|
for p in cache.get('https://refined-prun.github.io/refined-prices/all.json') if p['ExchangeCode'] == 'IC1'}
|
|
for p in cache.get('https://refined-prun.github.io/refined-prices/all.json') if p['ExchangeCode'] == 'IC1'}
|
|
|
|
|
|
|
|
-def get_total_buy() -> typing.Mapping[str, int]:
|
|
|
|
|
|
|
+def get_total_buy(days: int) -> typing.Mapping[str, int]:
|
|
|
planets = [supply.Planet(fio_burn) for fio_burn in cache.get('https://rest.fnar.net/fioweb/burn/user/' + config.username,
|
|
planets = [supply.Planet(fio_burn) for fio_burn in cache.get('https://rest.fnar.net/fioweb/burn/user/' + config.username,
|
|
|
headers={'Authorization': config.fio_api_key})]
|
|
headers={'Authorization': config.fio_api_key})]
|
|
|
buy: dict[str, int] = collections.defaultdict(int)
|
|
buy: dict[str, int] = collections.defaultdict(int)
|
|
|
for planet in planets:
|
|
for planet in planets:
|
|
|
- for mat, amount in planet.supply_for_days(7).items():
|
|
|
|
|
|
|
+ for mat, amount in planet.supply_for_days(days).items():
|
|
|
buy[mat] += amount
|
|
buy[mat] += amount
|
|
|
return buy
|
|
return buy
|
|
|
|
|
|