2 Commits a1fca9c0cb ... c772b15403

Autor SHA1 Mensaje Fecha
  raylu c772b15403 market: convert to a market making tool hace 2 semanas
  raylu 44cf4f0d1c wcb upgrade hace 3 semanas
Se han modificado 4 ficheros con 52 adiciones y 24 borrados
  1. 1 1
      config.py
  2. 5 21
      market.py
  3. 3 2
      readme.md
  4. 43 0
      www/wcb_upgrade.html

+ 1 - 1
config.py

@@ -31,7 +31,7 @@ class Config:
 
 @dataclasses.dataclass(eq=False, frozen=True, slots=True)
 class MarketConfig:
-	ignore_warehouses: typing.Sequence[str]
+	mm_items: typing.Mapping[str, int]
 
 @dataclasses.dataclass(eq=False, frozen=True, slots=True)
 class SupplyConfig:

+ 5 - 21
market.py

@@ -23,6 +23,7 @@ def main() -> None:
 		return
 
 	check_cxos()
+	return
 
 	markets: dict[str, list[Market]] = collections.defaultdict(list)
 	with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
@@ -43,32 +44,15 @@ def main() -> None:
 		print()
 
 def check_cxos() -> None:
-	orders: typing.Sequence[ExchangeOrder] = cache.get('https://rest.fnar.net/cxos/' + config.username,
-			headers={'Authorization': config.fio_api_key})
-	summary: typing.Mapping[tuple[str, str], ExchangeSummary] = {
-		(summary['MaterialTicker'], summary['ExchangeCode']): summary
-		for summary in cache.get('https://rest.fnar.net/exchange/all')
-	}
-	for order in orders:
-		if order['Status'] == 'FILLED':
-			continue
-		state = summary[order['MaterialTicker'], order['ExchangeCode']]
-		if order['OrderType'] == 'BUYING' and state['Bid'] is not None and state['Bid'] > order['Limit']:
-			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.market.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()
+		for item in storage['StorageItems']:
+			threshold = config.market.mm_items.get(item['MaterialTicker'])
+			if threshold is not None and item['MaterialAmount'] > threshold:
+				print(f'{item["MaterialAmount"] - threshold} {item["MaterialTicker"]} at {warehouse["LocationNaturalId"]}')
 
 def analyze_raw_price(price: RawPrice) -> Market | None:
 	if (traded := price['AverageTraded7D']) is None or traded < 100:

+ 3 - 2
readme.md

@@ -6,9 +6,10 @@ get a FIO API key from https://fio.fnar.net/settings and create a `config.toml`
 ```toml
 username = 'raylu'
 fio_api_key = 'uuid_here'
+punoted_api_key = ''
 
-[market]
-ignore_warehouses = ['HRT']
+[market.mm_items]
+TCL = 0
 
 [supply.promitor]
 ignore_materials = ['RAT']

+ 43 - 0
www/wcb_upgrade.html

@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<meta charset="UTF-8">
+	<title>PrUn WCB upgrade</title>
+	<link rel="stylesheet" type="text/css" href="style.css">
+	<link rel="icon" href="https://www.raylu.net/hammer-man.svg" />
+	<meta name="viewport" content="width=device-width, initial-scale=1">
+	<meta name="theme-color" content="#222">
+</head>
+<body>
+	<a href="/">← back</a>
+	<main class="production">
+		<form>
+			<label>PUNoted API key: <input type="password" size="30" id="api-key"></label>
+			<input type="button" value="fetch" id="fetch">
+		</form>
+		<section id="loader"></section>
+		<div id="wcb_upgrade"></div>
+	</main>
+	<div id="popover" popover="hint"></div>
+	<script type="module">
+		import {setupProduction} from './production.js';
+		const blueprint = {
+			'LFE': 1,
+			'WCB': 1,
+			'MFL': 1,
+			'LHP': 64,
+			'SSC': 26,
+		};
+		const buy = new Set([
+			// definitely buy
+			'C', 'FLX', 'H', 'H2O', 'HAL', 'HCP', 'HE', 'LST', 'MG', 'N', 'NA', 'NCS', 'NS', 'O', 'PE', 'PG', 'S', 'TCL', 'THF',
+			// maybe buy
+			'AIR', 'AU', 'BE', 'BRM', 'BOR', 'BTS', 'CU', 'FAN', 'FC', 'FE', 'HCC', 'HD', 'LDI', 'LI', 'MFK', 'MWF', 'NFI',
+			'REA', 'RG', 'RGO', 'ROM', 'SFK', 'SI', 'STL', 'TCO', 'TPU',
+			// import
+			'AAR', 'AWF', 'CAP', 'CF', 'RAD',
+		])
+		setupProduction(blueprint, buy, 'IC1', 10, document.querySelector('#wcb_upgrade'));
+	</script>
+</body>
+</html>