|
|
@@ -1,6 +1,7 @@
|
|
|
from __future__ import annotations
|
|
|
|
|
|
import collections
|
|
|
+import json
|
|
|
import math
|
|
|
import sys
|
|
|
import typing
|
|
|
@@ -21,6 +22,8 @@ def main() -> None:
|
|
|
for p in cache.get('https://refined-prun.github.io/refined-prices/all.json') if p['ExchangeCode'] == 'IC1'}
|
|
|
consumption = get_consumption()
|
|
|
|
|
|
+ to_sell: dict[str, int] = {}
|
|
|
+ price_limits: dict[str, int] = {}
|
|
|
for item in ship_inventory:
|
|
|
ticker = item['MaterialTicker']
|
|
|
print(f'{item["MaterialAmount"]:5} {ticker:3}:', end=' ')
|
|
|
@@ -30,10 +33,26 @@ def main() -> None:
|
|
|
keep = item['MaterialAmount'] - sell
|
|
|
if sell > 0:
|
|
|
print('sell', sell, end=' ')
|
|
|
+ to_sell[ticker] = sell
|
|
|
+ ask = raw_prices[ticker]['Ask']
|
|
|
+ if ask is None:
|
|
|
+ print('(NO ASK)', end=' ')
|
|
|
+ else:
|
|
|
+ epsilon = 10 ** (int(math.log10(ask)) - 2)
|
|
|
+ price_limits[ticker] = ask - 2 * epsilon
|
|
|
if keep > 0:
|
|
|
print('keep', keep, end= ' ')
|
|
|
print()
|
|
|
|
|
|
+ print('\n' + json.dumps({
|
|
|
+ 'global': {'name': 'sell ' + ship},
|
|
|
+ 'groups': [{'type': 'Manual', 'name': 'A1', 'materials': to_sell}],
|
|
|
+ 'actions': [
|
|
|
+ {'name': 'sell', 'type': 'CX Sell', 'group': 'A1', 'exchange': 'IC1', 'origin': ship + ' Cargo',
|
|
|
+ 'priceLimits': price_limits, 'sellPartial': True, 'allowUnfilled': True},
|
|
|
+ ],
|
|
|
+ }))
|
|
|
+
|
|
|
def get_ship_storage(ship_name: str) -> typing.Sequence[market.StorageItem]:
|
|
|
ship_name = ship_name.casefold()
|
|
|
stores: typing.Sequence[market.Storage] = cache.get('https://rest.fnar.net/storage/' + config.username,
|