PyneCore™ candlestick_chart

A Pine Script™ like Python trading framework, which is highly compatible with TradingView`s results.

Pine Script™ is a trademark of TradingView. PyneCore™ is not affiliated with TradingView.
PyneCore™ is a trademark of PYNESYS LLC.
Snakes on Pine Tree

What is PyneCore?

PyneCore is a fast, very clean, backtesting framework written in Python. It is similar to Pine Script™, the language used in TradingView. The goal is to make it 100% compatible with Pine Script™.

Park

Pine Script™ Compatible

Though Pyne is actually Python code, with its magic it works the same way as Pine Script™. There are persistent variables, series and function are isolated the same way as in Pine. If you like Pine Script™, you will love Pyne too.

Open Source

PyneCore is open source and licensed under the Apache v2.0 license. You can use it for free, and you can modify it for your own needs. Contributions are very welcome.

currency_exchange

Multiple Exchange Providers

PyneCore contains multiple exchange providers, which can be easily extended. Providers are used to get historical data, and can be extended to do real-time trading.

local_library

Complete Library

Almost all library functions are implemented. They are tested against Pine Script™ results, the goal is to make them 100% compatible with high accuracy.

link_off

No Dependencies

There are no mandatory dependencies to other libraries (e.g. numpy, pandas) if you just want to use it in your own project. If you use it as a standalone app in CLI, you need to install typer and it is recommended to install rich.

speed

Fast and Clean

It is designed to be as fast as possible, mostly use recursive functions to avoid loops. It is clean, everything is annotated and documented. It is easy to understand and to extend.

thumb_up

Very Easy to Use

PyneCore is designed to be as easy to use as possible. It is very similar to Pine Script™, so if you know Pine Script™, you will know Pyne too. If you don’t know, it is very easy and straightforward to learn.

code

Easy Integration

PyneCore can be easily integrated into your own project. It is designed to be as simple as possible. You can use it as a standalone app in CLI, or you can use it in your own project without any additional dependencies.

check_circle

High Accuracy

PyneCore is tested against Pine Script™ results. The goal is to make it 100% compatible TradingView results. Most of the time it is 14-15 digits accurate, which is the same as Pine Script™.

How Pyne code is compared to Pine Script™?

This is a Bollinger Bands strategy in Pine Script™ and Pyne side by side. As you can see, the code is very similar, though Pyne is more pythonic.

Pine Script™
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//@version=6









strategy("Bollinger Bands Strategy", overlay=true)



source = input.source(close, "Source")
length = input.int(20, minval=1)
mult = input.float(2.0, minval=0.001, maxval=50)

basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
upper = basis + dev
lower = basis - dev

buyEntry = ta.crossover(source, lower)
sellEntry = ta.crossunder(source, upper)

if buyEntry
    strategy.entry("BBandLE",
         strategy.long, stop=lower,
         oca_name="BollingerBands",
         oca_type=strategy.oca.cancel,
         comment="BBandLE")
else
    strategy.cancel(id="BBandLE")

if sellEntry
    strategy.entry("BBandSE",
         strategy.short, stop=upper,
         oca_name="BollingerBands",
         oca_type=strategy.oca.cancel,
         comment="BBandSE")
else
    strategy.cancel(id="BBandSE")


plot(basis, "Basis", color=color.blue)


plot(upper, "Upper", color=color.red)
plot(lower, "Lower", color=color.green)

plot(source - source[1], "diff", color=color.yellow)
 
Pyne (Python)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""@pyne"""  # Must start with "@pyne" magic comment
# Import Series type
from pynecore import Series
# You can import Pine Script compatible functions
#  and properties from pynecore.lib
from pynecore.lib import (script, strategy, input,
                          ta, plot, color)


# You can define a strategy or indicator with decorator
@script.strategy("Bollinger Bands Strategy", overlay=True)
# Every Pyne code must have a main function
def main(
        # Inputs are defined in main function arguments
        source: Series[float] = input.source("close", "Source"),
        length: int = input.int(20, minval=1),
        mult: float = input.float(2.0, minval=0.001, maxval=50)
):
    basis = ta.sma(source, length)
    dev = mult * ta.stdev(source, length)
    upper = basis + dev
    lower = basis - dev

    buy_entry = ta.crossover(source, lower)
    sell_entry = ta.crossunder(source, upper)

    if buy_entry:
        strategy.entry("BBandLE",
                       strategy.long, stop=lower,
                       oca_name="BollingerBands",
                       oca_type=strategy.oca.cancel,
                       comment="BBandLE")
    else:
        strategy.cancel(id="BBandLE")

    if sell_entry:
        strategy.entry("BBandSE",
                       strategy.short, stop=upper,
                       oca_name="BollingerBands",
                       oca_type=strategy.oca.cancel,
                       comment="BBandSE")
    else:
        strategy.cancel(id="BBandSE")

    # You can use plot function as in Pine...
    plot(basis, "Basis", color=color.blue)
    # ... or return a dictionary with the values
    return {
        "upper": upper,
        "lower": lower,
        # Series annotated variables can be used like in Pine
        "diff": source - source[1]
    }

Pine Script™ Compiler

PyneCore contains a connector to our pynesys.io service, which has a fully compatible Pine Script™ compiler (or transpiler if you like). You can compile your Pine Script™ code to Pyne code. If you have API key, PyneCore can compile and run Pine Script™ code directly from CLI or from your own project. The compiler compiles Pine Script™ code to readable and easily understandable Python code, with the help of PyneCore.

PyneCore Terminal Demo

PyneCore Command Line Interface

PyneCore CLI provides an intuitive command-line interface for downloading data, running scripts, and performing analyses. With user-friendly formatting, color codes, and progress bars, every operation becomes transparent. You can also run your Pine Script™ codes directly in a Python environment using the compile command (coming soon). More information about PyneCore CLI can be found in the PyneCore CLI documentation.