[PYNE live trading]

Bar-close cron: PYNE strategy events become HOOX WebhookPayloads on trade-worker. Alerts are a separate webhook path.

PYNE live trading

Deploy pyne-worker, register a strategy, give it R2 bars, and let the 1-minute cron re-run on new closes. StrategyEvent rows map to HOOX actions and hop to trade-worker over TRADE_SERVICE. This is the supported Pine → order path.

Warning

Test with test: true / testnet keys first. close_all becomes two payloads (CLOSE_LONG and CLOSE_SHORT).

Abstract

pyne-worker vendors pynescript (hoox-pyne) and speaks the same evaluate contract as Flask POST /run (mode interpret | compile | auto). It is a tooling isolate: public /run uses X-API-Key (API_KEY), not mesh INTERNAL_KEY_BINDING. The mesh key is sent only on the trade hop.

Conceptual model

Event map (trade_forwarder.py)

StrategyEvent.kindHOOX action
entry + longLONG
entry + shortSHORT
close / exit + longCLOSE_LONG
close / exit + shortCLOSE_SHORT
close_allCLOSE_LONG and CLOSE_SHORT
ordermapped from direction

Idempotency: pyne:{script}:{symbol}:{kind}:{direction}:{bar}:{time}:{action}.

Alert path (not orders)

alert() / alertcondition() → JSON type: pine_alert, source: pyne-worker to ALERT_WEBHOOK_URL or per-job webhook_url. HTTPS + public host only (SSRF fail-closed). Discord-style content is supported. Does not hit trade-worker unless you point the webhook at the gateway yourself.

Interface surface

Secrets

hoox secrets set pyne-worker API_KEY
hoox secrets set pyne-worker INTERNAL_KEY_BINDING   # live TRADE_SERVICE
hoox secrets set pyne-worker ALERT_WEBHOOK_URL      # optional
hoox secrets set pyne-worker DEFAULT_EXCHANGE       # optional
hoox secrets set dashboard PYNE_API_KEY             # match API_KEY

Deploy and health

hoox pyne deploy
hoox pyne health
# or: hoox deploy worker pyne-worker

Operator CLI

hoox pyne {health,run,scripts,cron,feed,ingest,sync-vendor,deploy}

Caps (isolate): 5 MB body, 100 KB script, 100 K bars, /run wall 30 s. Rate limit 100 req / 60 s per key.

Internals

PiecePath / binding
Workerworkers/pyne-worker (submodule)
R2OHLCV_DATA
Trade hopTRADE_SERVICE → trade-worker POST /webhook
Cron* * * * * — skip if R2 has no newer bar
Languagevendored pynescript.runtime

KV: pyne dashboard.jsonc is secrets only (API_KEY, ALERT_WEBHOOK_URL). Cron and TRADE_SERVICE are wrangler, not CONFIG_KV.

Invariants

  1. Same-symbol request.security may work; foreign / missing feed → na. The isolate will not invent bars to force a trade.
  2. Unset API_KEY is open dev mode — do not ship that.
  3. Without INTERNAL_KEY_BINDING, live forwards are rejected by requireInternalAuth.
  4. Paid Workers is recommended for a 1-minute cron; free-tier limits apply.

Worked examples

  1. hoox pyne deploy and hoox pyne health.
  2. hoox pyne ingest (or /ingest) a testnet symbol.
  3. hoox pyne scripts — register a strategy with tiny size.
  4. hoox pyne cron — enable the job.
  5. Confirm trade-worker test fills, then remove test: true.

Language-level event fields: PYNE strategy events. Alert frequency: PYNE alerts.

Failure modes

SymptomCauseFix
/run 401Bad X-API-KeyMatch API_KEY
Events in /run JSON, no orderMissing TRADE_SERVICE / internal keySet INTERNAL_KEY_BINDING
Cron idleR2 has no new barhoox pyne feed / ingest
Alert fired, no fillAlert path ≠ trade pathExpected
AXIS showed the same scriptAXIS does not executeThis page, not the PWA

See also