Library Examples
Examples demonstrating PyneScript V6 library publishing, versioned exports, enum types, and selective import binding.
Library Authoring Examples#
| File | What it demonstrates | Best use | Download |
|---|---|---|---|
pynescript_library_enum_utils.py | Versioned library publishing with enum exports. | Library authoring pattern. | Download |
pynescript_library_enum_import_indicator.py | Selective import binding through import_library(...). | Library consumption pattern. | Download |
Library Declaration#
from source import library, import_library
library("Pyne Enum Utils", version=1, overlay=False,
description="Shared enum types and helper functions")
class TrendMode:
BULLISH = "BULLISH"
BEARISH = "BEARISH"
NEUTRAL = "NEUTRAL"
def resolve_length(value, minimum=1):
return max(int(value), int(minimum))Importing a Library#
from source import indicator, import_library
indicator("Library Consumer", overlay=False)
# Selective import — only pull what you need
utils = import_library("Pyne Enum Utils@1",
exports=["TrendMode", "resolve_length"])
mode = utils.TrendMode.BULLISH
safe_len = utils.resolve_length(0, 2) # returns 2