Răsfoiți Sursa

buy: show deposits of current bids

raylu 1 zi în urmă
părinte
comite
38e73bfa0d
1 a modificat fișierele cu 9 adăugiri și 2 ștergeri
  1. 9 2
      buy.py

+ 9 - 2
buy.py

@@ -39,10 +39,11 @@ def main() -> None:
 	# what we already are bidding for
 	orders: typing.Sequence[market.ExchangeOrder] = cache.get('https://rest.fnar.net/cxos/' + config.username,
 			headers={'Authorization': config.fio_api_key})
+	orders = [order for order in orders
+			if order['OrderType'] == 'BUYING' and order['Status'] != 'FILLED' and order['ExchangeCode'] == 'IC1']
+
 	bids = collections.defaultdict(int)
 	for order in orders:
-		if order['OrderType'] == 'SELLING' or order['Status'] == 'FILLED' or order['ExchangeCode'] != 'IC1':
-			continue
 		bids[order['MaterialTicker']] += order['Amount']
 
 	# what's left to buy
@@ -64,6 +65,12 @@ def main() -> None:
 	for m in materials:
 		print(f'{m.ticker:4} {m.amount:>5} {m.bids:>5} {m.warehouse:>5} {m.amount - m.bids - m.warehouse:>5} {m.savings:8.0f}')
 
+	# deposits of current bids
+	orders.sort(key=lambda order: order['Limit'] * order['Amount'], reverse=True)
+	print('\ncurrent bid deposits:')
+	for order in orders:
+		print(f"{order['MaterialTicker']:4} {order['Limit'] * order['Amount']:7,.0f}")
+
 @dataclasses.dataclass(eq=False, slots=True)
 class Material:
 	ticker: str