소스 검색

market: check filled bids

raylu 3 주 전
부모
커밋
c44f33ab1d
2개의 변경된 파일23개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      config.py
  2. 21 0
      market.py

+ 2 - 0
config.py

@@ -2,11 +2,13 @@ from __future__ import annotations
 
 import dataclasses
 import tomllib
+import typing
 
 @dataclasses.dataclass(eq=False, frozen=True, slots=True)
 class Config:
     username: str
     fio_api_key: str
+    ignore_warehouses: typing.Sequence[str]
 
     def __init__(self) -> None:
         with open('config.toml', 'rb') as f:

+ 21 - 0
market.py

@@ -43,6 +43,18 @@ def check_cxos() -> None:
 			print('outbid on', f'{order["MaterialTicker"]}.{order["ExchangeCode"]}')
 		elif order['OrderType'] == 'SELLING' and state['Ask'] is not None and state['Ask'] < order['Limit']:
 			print('undercut on', f'{order["MaterialTicker"]}.{order["ExchangeCode"]}')
+	print()
+
+	warehouses: typing.Sequence[Warehouse] = cache.get('https://rest.fnar.net/sites/warehouses/' + config.username,
+			headers={'Authorization': config.fio_api_key})
+	for warehouse in warehouses:
+		if warehouse['LocationNaturalId'] in config.ignore_warehouses:
+			continue
+		storage: Storage = cache.get(f'https://rest.fnar.net/storage/{config.username}/{warehouse["StoreId"]}',
+			headers={'Authorization': config.fio_api_key})
+		if storage['WeightLoad'] > 0 or storage['VolumeLoad'] > 0:
+			print('warehouse', warehouse['LocationNaturalId'], 'is not empty')
+	print()
 
 class ExchangeOrder(typing.TypedDict):
 	MaterialTicker: str
@@ -56,6 +68,15 @@ class ExchangeSummary(typing.TypedDict):
 	Bid: float | None
 	Ask: float | None
 
+class Warehouse(typing.TypedDict):
+	StoreId: str
+	LocationNaturalId: str
+
+class Storage(typing.TypedDict):
+	StorageItems: typing.Sequence
+	WeightLoad: float
+	VolumeLoad: float
+
 class RawPrice(typing.TypedDict):
 	FullTicker: str
 	Bid: float | None