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,40 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Emit a Refined PrUn XIT ACT action-package JSON for a buy list - paste into the extension's
|
||||
"Import Action Package" (XIT ACT -> IMPORT) to pre-fill the CXPO buy tile for each material; you
|
||||
still click the real buy button yourself. See puga/actpkg.py for the schema/gotcha notes.
|
||||
|
||||
puga actpkg "Nike PP1 BDE buildout" BDE:3 BBH:3 BSE:4 MCG:76 PE:750
|
||||
puga actpkg "Nike PP1 BDE buildout" BDE:3 BBH:3 BSE:4 MCG:76 PE:750 --cx AI1 -o nike_pp1.json
|
||||
"""
|
||||
import argparse, json, sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
from puga import config, actpkg
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("name", help="package name (letters/digits/spaces only - punctuation is stripped)")
|
||||
ap.add_argument("materials", nargs="+", help="TICKER:QTY pairs, e.g. BDE:3 MCG:76")
|
||||
ap.add_argument("--cx", default=config.DEFAULT_CX)
|
||||
ap.add_argument("-o", "--out", help="write to this file instead of stdout")
|
||||
a = ap.parse_args()
|
||||
|
||||
mats = {}
|
||||
for m in a.materials:
|
||||
tk, _, qty = m.partition(":")
|
||||
if not qty:
|
||||
sys.exit(f"bad material spec {m!r}, expected TICKER:QTY")
|
||||
mats[tk] = float(qty)
|
||||
|
||||
pkg = actpkg.build_package(a.name, mats, a.cx)
|
||||
text = json.dumps(pkg, indent=2)
|
||||
if a.out:
|
||||
Path(a.out).write_text(text)
|
||||
print(f"wrote {a.out}")
|
||||
else:
|
||||
print(text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user