Skip to main content

Python based Pine Script like runtime and API

Project description

PyneCore Logo

PyneCore™

Pine Script in Python - Without Limitations

Python License

🚀 Have Pine Script code? Get automatic Python translation →

What is PyneCore?

PyneCore brings TradingView's Pine Script capabilities to Python through a revolutionary approach - it transforms regular Python code to behave like Pine Script through AST transformations, while maintaining the full power of the Python ecosystem.

Instead of creating another object-oriented wrapper or a new language, PyneCore modifies your Python code at import time, giving you the intuitive bar-by-bar execution model of Pine Script without leaving Python's rich environment.

Key Features

  • Native Pine Script Semantics in Python: Write familiar Python code that runs with Pine Script's bar-by-bar execution model
  • AST Transformation Magic: Your code is transformed at import time to implement Pine Script behavior
  • High Performance: Zero mandatory external dependencies with highly optimized implementation
  • Series & Persistent Variables: Full support for Pine Script's time series and state persistence
  • Function Isolation: Each function call gets its own isolated persistent state
  • NA Handling: Graceful handling of missing data with Pine Script's NA system
  • Technical Analysis Library: Comprehensive set of Pine Script-compatible indicators and functions
  • Strategy Backtesting: Pine Script compatible framework for developing and testing trading strategies

Quick Example

"""
@pyne
"""
from pynecore import Series
from pynecore.lib import script, close, ta, plot, color, input

@script.indicator(title="Bollinger Bands")
def main(
    length=input.int("Length", 20, minval=1),
    mult=input.float("Multiplier", 2.0, minval=0.1, step=0.1),
    src=input.source("Source", close)
):
    # Calculate Bollinger Bands
    basis = ta.sma(src, length)
    dev = mult * ta.stdev(src, length)

    upper = basis + dev
    lower = basis - dev

    # Output to chart
    plot(basis, "Basis", color=color.orange)
    plot(upper, "Upper", color=color.blue)
    plot(lower, "Lower", color=color.blue)

Innovative Concepts

PyneCore introduces several revolutionary concepts:

1. Magic Comment & Import Hook

Identify your scripts with a simple magic comment:

"""
@pyne
"""

This activates PyneCore's import hook system which intercepts Python imports and applies AST transformations to recognized scripts.

2. Series Variables

Track historical data across bars, just like in Pine Script:

from pynecore import Series

price: Series[float] = close
previous_price = price[1]  # Access previous bar's price

3. Persistent Variables

Maintain state between bars with simple type annotations:

from pynecore import Persistent

counter: Persistent[int] = 0
counter += 1  # Increments with each bar

4. Function Isolation

Each call to a function maintains its own isolated state:

def my_indicator(src, length):
    # Each call gets its own instance of sum
    sum: Persistent[float] = 0
    sum += src
    return sum / length

Installation

# Basic installation
pip install pynesys-pynecore

# With CLI tools (recommended)
pip install pynesys-pynecore[cli]

# With all features including data providers
pip install pynesys-pynecore[all]

Note for Windows users: PyneCore requires timezone data that is not included in Windows by default. The [cli] and [all] installations automatically include the tzdata package. If you're using the basic installation and encounter timezone errors, install it manually with pip install tzdata.

Getting Started

Create a Simple Script

  1. Create a file with the @pyne annotation:
"""
@pyne
"""
from pynecore.lib import script, close, plot

@script.indicator("My First Indicator")
def main():
    # Calculate a simple moving average
    sma_value = (close + close[1] + close[2]) / 3

    # Plot the result
    plot(sma_value, "Simple Moving Average")
  1. Run your script with the PyneCore CLI:
# First, download some price data
pyne data download ccxt --symbol "BYBIT:BTC/USDT:USDT"

# Then run your script on the data
pyne run my_script.py ccxt_BYBIT_BTC_USDT_USDT_1D.ohlcv

Why Choose PyneCore?

  • Beyond TradingView Limitations: No more platform restrictions, code size limits, or subscription fees
  • Python Ecosystem Access: Use Python's data science, ML, and analysis libraries alongside trading logic
  • Performance & Precision: Designed for speed and precision, the same results as Pine Script
  • Open Source Foundation: The core library and runtime is open source under Apache 2.0 license
  • Professional Trading Tools: Build institutional-grade systems with Pine Script simplicity
  • Advanced Backtesting: Run sophisticated strategy tests outside platform constraints

Pine Script Migration Made Easy

Have existing Pine Script code you want to run in Python? PyneSys now offers automatic Pine Script to PyneCore translation through our web platform and Discord bot.

🚀 Get Started Instantly

  • Try for free on Discord: Use /pine-help in our Discord for instant conversion - 3 free translations!
  • Full service: Visit pynesys.io for subscriptions and higher limits

💡 Support the Ecosystem

Love PyneCore and want to see it grow? Consider a Seed subscription or higher ($5+/mo) to support continued development:

  • Daily translations of your Pine Script files (5+ per day)
  • Larger script support for complex indicators and strategies
  • Direct contribution to keeping PyneCore open source and advancing

Every subscription helps maintain this free, open-source runtime and drives innovation in algorithmic trading tools.

Documentation & Support

Community

License

PyneCore is licensed under the Apache License 2.0.

Disclaimer

Pine Script™ is a trademark of TradingView, Inc. PyneCore is not affiliated with, endorsed by, or sponsored by TradingView. This project is an independent implementation that aims to provide compatibility with the Pine Script language concept in the Python ecosystem.

Risk Warning

Trading involves significant risk of loss and is not suitable for all investors. The use of PyneCore does not guarantee any specific results. Past performance is not indicative of future results.

  • PyneCore is provided "as is" without any warranty of any kind
  • PyneCore is not a trading advisor and does not provide trading advice
  • Scripts created with PyneCore should be thoroughly tested before using with real funds
  • Users are responsible for their own trading decisions
  • You should consult with a licensed financial advisor before making any financial decisions

By using PyneCore, you acknowledge that you are using the software at your own risk. The creators and contributors of PyneCore shall not be held liable for any financial loss or damage resulting from the use of this software.

Commercial Support

PyneCore is part of the PyneSys ecosystem. For commercial support, custom development, or enterprise solutions:


Elevate Your Trading with the Power of Python & Pine Script

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pynesys_pynecore-6.0.13.tar.gz (157.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pynesys_pynecore-6.0.13-py3-none-any.whl (199.5 kB view details)

Uploaded Python 3

File details

Details for the file pynesys_pynecore-6.0.13.tar.gz.

File metadata

  • Download URL: pynesys_pynecore-6.0.13.tar.gz
  • Upload date:
  • Size: 157.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pynesys_pynecore-6.0.13.tar.gz
Algorithm Hash digest
SHA256 9713a7ecda6cca51135c5927e177f1cf1f8d8a258a1fa0a1232ac3418b520251
MD5 e06c50f3a3ad25f01765c563768aca23
BLAKE2b-256 ad1ed1298b7b0d78f569fa751e6c08b16856810f88b5df847dcf1e278850b573

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynesys_pynecore-6.0.13.tar.gz:

Publisher: release.yml on PyneSys/pynecore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynesys_pynecore-6.0.13-py3-none-any.whl.

File metadata

File hashes

Hashes for pynesys_pynecore-6.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 8f0526e2a88ed8bcbff0709f1be2ff17f5dd71b67e99ecbf2c52067c00b90bc8
MD5 2f5702daa83c794c07cc0ddd1c2f9b6a
BLAKE2b-256 b5e415dedcb8165a9a010710f0039a70486786f69a3ac0b45a0bea7035a0f6d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynesys_pynecore-6.0.13-py3-none-any.whl:

Publisher: release.yml on PyneSys/pynecore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page