|
|
@@ -1,5 +1,6 @@
|
|
|
from __future__ import annotations
|
|
|
|
|
|
+import collections
|
|
|
import dataclasses
|
|
|
import sys
|
|
|
import typing
|
|
|
@@ -18,7 +19,7 @@ def main() -> None:
|
|
|
check_cxos()
|
|
|
|
|
|
raw_prices: list[RawPrice] = cache.get('https://refined-prun.github.io/refined-prices/all.json')
|
|
|
- markets: list[Market] = []
|
|
|
+ markets: dict[str, list[Market]] = collections.defaultdict(list)
|
|
|
for price in raw_prices:
|
|
|
if (traded := price['AverageTraded7D']) is None or traded < 100:
|
|
|
continue
|
|
|
@@ -36,13 +37,15 @@ def main() -> None:
|
|
|
if bid_fill_ratio < 0.05 or bid_fill_ratio > 0.95:
|
|
|
continue
|
|
|
max_profit = (price['Ask'] - price['Bid']) * min(bids_filled, asks_filled)
|
|
|
- markets.append(Market(price['FullTicker'], bid=price['Bid'], ask=price['Ask'], spread=spread, traded=traded,
|
|
|
- bids_filled=bids_filled, asks_filled=asks_filled, max_profit=max_profit))
|
|
|
- markets.sort(reverse=True)
|
|
|
+ markets[price['ExchangeCode']].append(Market(price['FullTicker'], bid=price['Bid'], ask=price['Ask'],
|
|
|
+ spread=spread, traded=traded, bids_filled=bids_filled, asks_filled=asks_filled, max_profit=max_profit))
|
|
|
|
|
|
print(f'{"mat":^8} {"bid":^5} {"ask":^5} spread {"traded":^7} bids filled asks filled max profit')
|
|
|
- for m in markets:
|
|
|
- print(f'{m.full_ticker:>8} {m.bid:5} {m.ask:5} {m.spread*100: 5.0f}% {m.traded:7.0f} {m.bids_filled:10.0f} {m.asks_filled:10.0f} {m.max_profit:10.0f}')
|
|
|
+ for commodities in markets.values():
|
|
|
+ commodities.sort(reverse=True)
|
|
|
+ for m in commodities:
|
|
|
+ print(f'{m.full_ticker:>8} {m.bid:5} {m.ask:5} {m.spread*100: 5.0f}% {m.traded:7.0f} {m.bids_filled:10.0f} {m.asks_filled:10.0f} {m.max_profit:10.0f}')
|
|
|
+ print()
|
|
|
|
|
|
def check_cxos() -> None:
|
|
|
orders: typing.Sequence[ExchangeOrder] = cache.get('https://rest.fnar.net/cxos/' + config.username,
|
|
|
@@ -112,6 +115,7 @@ class Storage(typing.TypedDict):
|
|
|
|
|
|
class RawPrice(typing.TypedDict):
|
|
|
FullTicker: str
|
|
|
+ ExchangeCode: str
|
|
|
Bid: float | None
|
|
|
Ask: float | None
|
|
|
HighYesterday: float | None
|