|
|
@@ -0,0 +1,49 @@
|
|
|
+from __future__ import annotations
|
|
|
+
|
|
|
+import dataclasses
|
|
|
+import typing
|
|
|
+
|
|
|
+import cache
|
|
|
+from config import config
|
|
|
+import market
|
|
|
+
|
|
|
+if typing.TYPE_CHECKING:
|
|
|
+ import supply
|
|
|
+
|
|
|
+def main() -> None:
|
|
|
+ raw_prices: typing.Mapping[str, market.RawPrice] = {p['MaterialTicker']: p
|
|
|
+ for p in cache.get('https://refined-prun.github.io/refined-prices/all.json') if p['ExchangeCode'] == 'IC1'}
|
|
|
+
|
|
|
+ planets: typing.Sequence[supply.FIOBurn] = cache.get('https://rest.fnar.net/fioweb/burn/user/' + config.username,
|
|
|
+ headers={'Authorization': config.fio_api_key})
|
|
|
+ producing = frozenset(mat['MaterialTicker'] for planet in planets for mat in planet['OrderProduction'])
|
|
|
+ materials = []
|
|
|
+ for mat in producing:
|
|
|
+ price = raw_prices[mat]
|
|
|
+ if price['Bid'] is None or price['Ask'] is None:
|
|
|
+ print(mat, 'has no bid/ask')
|
|
|
+ continue
|
|
|
+ spread = (price['Ask'] - price['Bid']) / price['Ask']
|
|
|
+ bids_filled, asks_filled = market.estimate_filled_orders(mat + '.IC1', (price['Bid'] + price['Ask']) / 2)
|
|
|
+ ask_fill_ratio = asks_filled / (bids_filled + asks_filled)
|
|
|
+ materials.append(Material(mat, spread=spread, bids_filled=bids_filled, asks_filled=asks_filled, score=spread * ask_fill_ratio))
|
|
|
+ materials.sort()
|
|
|
+
|
|
|
+ print(f'{"mat":^4} spread bids filled asks filled')
|
|
|
+ for m in materials:
|
|
|
+ print(f'{m.ticker:4} {m.spread*100:5.1f}% {m.bids_filled:12.0f} {m.asks_filled:12.0f}')
|
|
|
+
|
|
|
+@dataclasses.dataclass(eq=False, slots=True)
|
|
|
+class Material:
|
|
|
+ ticker: str
|
|
|
+ spread: float
|
|
|
+ bids_filled: float
|
|
|
+ asks_filled: float
|
|
|
+ score: float
|
|
|
+
|
|
|
+ def __lt__(self, o) -> bool:
|
|
|
+ return self.score < o.score
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ main()
|