[Configuration]

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

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

There is no required pynescript.toml for core use.

Interface surface

Package extras (pyproject.toml)

ExtraDependenciesEnables
(none)antlr4-runtime, click, requests, tqdmCLI + AST + linter + literal_eval
lsppygls, lsprotocolpynescript-lsp
dev-lsppygls, lsprotocol, pytest-lspLSP + protocol tests
dataccxtExchange historical data
datafeedccxtSame as data (alias for realtime feed paths)

Console scripts

NameEntry pointNotes
pynescriptpynescript.__main__:cliAlways with core install
pynescript-lsppynescript.langserver.__main__:mainNeeds importable pygls

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
parse-and-dump--encoding, --indent, --output-file
parse-and-unparse--encoding, --output-file
lint--encoding, --fix, --fail-on {errors,warnings,all}
data--provider, --period, --interval, --api-key, --secret, --exchange
download-builtin-scripts--script-dir (required)

--fix on lint is accepted by Click; auto-fix behavior may be incomplete — .

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, localhost regexCORS allowlist (comma-separated; may include regex strings)
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)

Also relevant:

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

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, …
modeinterpret (default), compileAST walker vs compiled subset

Editor / LSP client settings

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

SettingDefaultMeaning
pynescript.lsp.enabledtrueToggle server
pynescript.lsp.commandpynescript-lspBinary path
pynescript.formatting.enabledtrueFormat document
pynescript.diagnostics.enabledtrueLint squiggles
pynescript.completion.snippetstrueSnippet completions

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
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
pynescript lint strategy.pine --fail-on errors

Editor workstation

pip install "hoox-pyne[lsp]"
# ensure which 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