Add CONTD contract evaluator, deadline-aware buy pricing, actpkg JSON generator
- puga/contd.py, tools/contd.py: price open CONTD contract offers against real buy-fresh cost, flagging conditions that can't be priced from the API alone. - tools/buyat.py: cheapest bid price likely to fill by a hard deadline (stockout risk), using the empirical first-passage model from history.py. - puga/actpkg.py, tools/actpkg.py: Refined PrUn XIT ACT buy-list JSON packages. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python3
|
||||
"""List this account's OPEN CONTD contract offers (the NPC logistics-officer pool shown in APEX's
|
||||
CONTD panel - usually 3 at a time, only one acceptable) with payment, priced material requirements,
|
||||
and net. Judging the actual best deal is NOT this tool's job for anything it flags as unpriced
|
||||
(EXPLORATION, REPAIR_SHIP, etc. - see puga/contd.py's docstring) or for situational cheapness (a ship
|
||||
already flying that route, material already in free/uncommitted storage) - it reports the breakdown,
|
||||
the caller reasons about context.
|
||||
|
||||
puga contd
|
||||
puga contd --cx AI1
|
||||
"""
|
||||
import argparse, sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
from puga import config, contd
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--cx", default=config.DEFAULT_CX)
|
||||
a = ap.parse_args()
|
||||
|
||||
contracts = contd.open_contracts()
|
||||
if not contracts:
|
||||
print("no OPEN contract offers right now")
|
||||
return
|
||||
|
||||
for c in contracts:
|
||||
r = contd.evaluate(c, a.cx)
|
||||
print(f"\n{r['id']} partner={r['partner']} deadline {r['deadline_days']:.1f}d"
|
||||
+ (" +reputation" if r["reputation"] else ""))
|
||||
print(f" payment: {r['payment']:,.2f} AIC")
|
||||
for req in r["requirements"]:
|
||||
flag = " SHORT: book can't fill this qty" if req["short"] else ""
|
||||
print(f" requires: {req['ticker']} x{req['qty']:g} @ {req['address']} buy-fresh cost {req['cost']:,.0f}{flag}")
|
||||
for ftype, addr in r["flags"]:
|
||||
print(f" UNPRICED CONDITION: {ftype}" + (f" @ {addr}" if addr else "") + " - context-dependent, judge separately")
|
||||
print(f" material cost: {r['material_cost']:,.0f} -> net (payment - buy-fresh cost): {r['net']:,.0f}")
|
||||
|
||||
priceable = [c for c in contracts if not contd.evaluate(c, a.cx)["flags"]]
|
||||
if len(priceable) == len(contracts):
|
||||
best = max(contracts, key=lambda c: contd.evaluate(c, a.cx)["net"])
|
||||
print(f"\nby buy-fresh net alone, best priced: {best['ContractLocalId']}"
|
||||
" - but check storage for materials you may already hold before trusting this")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user