Configuration

Package extras, console scripts, Pro API environment variables, data providers, and editor LSP settings for PYNE.

This page

Configuration

Abstract

PYNE is mostly convention-over-config at the library layer: parse and evaluate take explicit arguments rather than a global config file. Configuration appears at three boundaries: install extras (what code is available), process environment (Pro API host, CORS, API keys store), and editor / LSP client settings (diagnostics, formatting, binary path). This page inventories those knobs for end users.

Conceptual model

Diagram

Rendering…

There is no pynescript.toml (or similar) for core use. Parse, evaluate, and CLI flags are per-invocation.

Interface surface

Package extras (pyproject.toml)

ExtraDependenciesEnables
(none)antlr4-runtime, click, requests, tqdmCLI + AST + linter + literal_eval + pynescript.runtime
lsppygls, lsprotocolpyne-lsp (alias pynescript-lsp)
dev-lsppygls, lsprotocol, pytest-lspLSP + protocol tests
dataccxtExchange historical data
datafeedccxtSame as data (alias for realtime feed paths)
compilenumpy, numbaCompile / run / prewarm Numba path
proFlask stack (+ redis optional)Self-hosted Pro API

Console scripts

NameEntry pointNotes
pynepynescript.__main__:cliPreferred desk CLI
pyne-lsppynescript.langserver.__main__:mainPreferred language server
pynescriptsame as pyneLegacy alias
pynescript-lspsame as pyne-lspLegacy alias

Invoke without scripts on PATH:

python -m pynescript --help
python -m pynescript.langserver

CLI flags that act as “config”

Per-invocation only (no persistence):

CommandNotable options
check--encoding, -q/--quiet, --ext (directory walk)
format / fmt-w/--write, --check, -o/--output-file
parse-and-dump--encoding, --indent, --output-file
parse-and-unparse--encoding, --output-file
lint--encoding, --fail-on {errors,warnings,all,never}, --json, -q
compile--emit, -o, --time/--no-time
prewarm--force, --json
run--bars (default 50), --json, -qcompile-only synthetic OHLCV
data--provider, --period, --interval, --api-key, --secret, --exchange, --format

lint has no --fix. Structural rewrite is pyne format -w (parse → unparse).

Pro API environment variables

Consumed by backend/app.py and middleware:

VariableDefaultPurpose
HOST127.0.0.1Bind address when running __main__
PORT5002Bind port
ALLOWED_ORIGINShttps://pynescript.ai, https://app.pynescript.ai, plus localhost regexCORS allowlist (comma-separated; regex allowed). Code also appends localhost, private-LAN, and product-origin (hoox.sh / pynescript.ai / pynescript.online) regexes unless *
ADMIN_TOKENunsetRequired for POST /auth/create_key; if unset, create returns 403
API_KEY_STORE/root/pynescript/data/api_keys.jsonPath for key store (override for local)
ALERT_WEBHOOK_URLunsetDefault L2 alert webhook for /run when body omits webhook_url
ALERT_WEBHOOK_TIMEOUT10Webhook HTTP timeout (seconds)

Also relevant:

VariableContext
MAX_CONTENT_LENGTHHardcoded 5 MiB on Flask app config (not env) — large OHLCV POSTs fail above this

Runtime / evaluate environment variables

Used by pynescript.runtime.Runtime (src/pynescript/runtime/host.py) and the compiler host. backend.runtime is a compat re-export only.

VariableDefaultPurpose
PYNE_RUNTIME_MODEinterpretDefault when Runtime.run(..., mode=None) omits mode (Pro API schema default is still auto; pyne run ignores this — compile-only)
PYNE_SERIES_CAPonTrim append-only host series lists; set 0 / false / off to disable (oracle / debug)
PYNE_SERIES_MAXunsetAbsolute series history depth (overrides default 256 + max_bars_back)
PYNE_TA_INCREMENTALonBar-mode incremental ta.* hot path; set 0 to force full recompute
PYNE_SERIES_RINGoffChronological tail view; skip dual list write. Keep off unless you need the ring path
PYNE_PARSE_CACHEonProcess-local LRU of successful parse() trees; set 0 to disable
PYNE_PARSE_CACHE_MAX128Max parse-cache entries
PYNE_COMPILE_DISK_CACHEoften 1 in deployPersist compiled IR across processes
PYNE_COMPILE_CACHE_DIRXDG cache / Docker /data/compile-cacheDisk IR location
PYNE_COMPILE_PREWARMdeploy-dependentHost cold-start prewarm of Numba builtins

See Series & history, Technical builtins, and Compiler overview.

Local run:

export HOST=127.0.0.1
export PORT=5002
export ALLOWED_ORIGINS="http://localhost:8081,http://127.0.0.1:8081"
export ADMIN_TOKEN="dev-only-token"
export API_KEY_STORE="$PWD/.data/api_keys.json"
python -m backend.app
# or: make run

Data providers

CLI pynescript data / library providers:

ProviderAuthNotes
mocknoneDeterministic offline bars (default)
yahoononeYahoo Finance path
alphavantage--api-key (falls back to demo)Limited with demo key
ccxtoptional key/secret; --exchangeRequires [data] extra

Pro API /run optional fields:

FieldValuesRole
data_source"", mock, ccxt, ccxtpro, yahoo, alphavantageWires request.* resolution
data_optionsobjectexchange, api_key, seed, …
modeauto (default), interpret, compilePrefer warm compile + fallback; strict compile; full interpret
inputsobjectinput.* overrides by title (forces interpret under auto)
librarieslist[{namespace, name, version, source}] — max 32; also on /run/batch; interpret / auto fallback
timeout_secondsnumberOptional interpret wall-clock budget; omit / null / ≤ 0 → no timeout
profilerboolPer-line timings; forces interpret
webhook_urlstringPer-request L2 alert webhook (overrides ALERT_WEBHOOK_URL)
forward_alerts / alert_last_bar / alert_batchboolWebhook delivery controls (see Alerts)

timeout_seconds is accepted on Runtime.run, POST /run, and POST /run/batch. Extra keys that are not in the schema still → UNKNOWN_FIELDS.

Operators can also POST /compile/prewarm or run pyne prewarm (and pyne prewarm script.pine …) to warm Numba builtins / script IR caches before interactive traffic. Requires pip install "hoox-pyne[compile]" for full Numba warm-up.

Free-tier Pro API guards (unauthenticated /run) are off by default. Set FREE_TIER_LIMITS=1 to enable FREE_MAX_BARS, FREE_MAX_SCRIPT_CHARS, FREE_MAX_CONCURRENT, FREE_RATE_LIMIT / FREE_RATE_WINDOW_SEC — see Pro API usage.

Editor / LSP client settings

VS Code extension keys (from clients/README.md):

SettingDefaultMeaning
pynescript.lsp.enabledtrueToggle server
pynescript.lsp.commandautoauto tries pyne-lsppynescript-lsppython3 -m pynescript.langserver; or an absolute path
pynescript.lsp.pythonpython3Interpreter when command is auto and no binary is on PATH
pynescript.lsp.args[]Extra args to the language server
pynescript.formatting.enabledtrueFormat document
pynescript.diagnostics.enabledtrueLint squiggles
pynescript.completion.snippetstrueSnippet completions

Extension id: hoox-sh.pyne.

Neovim (clients/neovim.lua):

settings = {
  pinescript = {
    formatting = { enabled = true },
    diagnostics = { enabled = true },
    completion = { snippets = true },
  },
}

Zed: language_servers.pynescript.command / arguments: ["--stdio"] — see Editors.

AXIS / frontend coupling (optional)

When running SuperChart Lite PWA against local Flask:

Make targetPort (typical)
make runAPI :5002
make run-frontendPWA :8081
make worker-devCF Worker :8787

CORS must allow the PWA origin via ALLOWED_ORIGINS.

Internals (repo paths)

PathConfig surface
pyproject.tomlextras, scripts, Python requires
src/pynescript/__main__.pyCLI options
src/pynescript/runtime/host.pyRuntime.run (mode, libraries, timeout_seconds, inputs)
backend/app.pyFlask, CORS, HOST/PORT, body size
backend/middleware/auth.pyAPI_KEY_STORE, key tiers
backend/middleware/schemas.pyRequest field defaults (mode, symbol, …)
`clients/*.jsonlua
vscode-extension/Extension contribution points

Invariants & edge cases

  • Unknown JSON fields on Pro API are rejected (UNKNOWN_FIELDS) — schemas are strict.
  • CORS defaults exclude arbitrary production domains — set ALLOWED_ORIGINS deliberately.
  • Key store default path is production-oriented (/root/...) — always override locally.
  • Lint --fail-on only affects process exit code; it does not change which rules run.
  • Recursion limit during parse is raised to at least 5000 temporarily inside helper._parse for deep nests; not user-configurable.

Worked examples

Desk-only machine

python -m venv .venv && source .venv/bin/activate
pip install hoox-pyne
# no env vars required
pyne lint strategy.pine --fail-on errors

Editor workstation

pip install "hoox-pyne[lsp]"
# ensure which pyne-lsp  (alias: pynescript-lsp)
# paste clients/neovim.lua or clients/zed.json as documented

Local API + AXIS

pip install -e ".[lsp]"
pip install -r backend/requirements.txt
export API_KEY_STORE="$PWD/.data/api_keys.json"
export ALLOWED_ORIGINS="http://localhost:8081"
make run
# other terminal:
make run-frontend

Scripted Alpha Vantage fetch

export AV_KEY=your_key
pynescript data EUR/USD --provider alphavantage --api-key "$AV_KEY" --period 3mo

Failure modes

SymptomConfig fix
Browser CORS error on /runAdd origin to ALLOWED_ORIGINS
create_key always 403Set ADMIN_TOKEN and send X-Admin-Token
API keys vanish / permission errorPoint API_KEY_STORE to writable path
Payload too largeSplit bars or stay under 5 MiB body limit
Editor “server failed to start”Fix pynescript.lsp.command PATH; install [lsp]
ccxt import errorsInstall [data] extra

See also