pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/PyneSys/pynecore-examples/tree/main/02-programmatic

origen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/repository-6534fbc3f5e83ac0.css" /> pynecore-examples/02-programmatic at main · PyneSys/pynecore-examples · GitHub
Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

02 — Programmatic Usage

Use PyneCore's ScriptRunner API to run scripts from your own Python code. This is the foundation for building trading bots, custom dashboards, backtesting pipelines, and integrations.

Run

# Indicator — prints Bollinger Bands values bar-by-bar
uv run run_indicator.py

# Strategy — runs SMA Crossover with custom inputs, prints trades
uv run run_strategy.py

What You'll Learn

run_indicator.py — Running an Indicator

  1. Convert CSV to OHLCVDataConverter.convert_to_ohlcv() creates binary data + symbol info
  2. Create ScriptRunner — pass script path, OHLCV iterator, and symbol info
  3. Iterate with run_iter() — yields (candle, plot_data) for each bar
  4. Read outputplot_data is a dict with named values (e.g. {"Basis": 1.136, "Upper": 1.139, ...})

run_strategy.py — Running a Strategy with Trade Output

  1. Override inputs — pass inputs={"Length": 15} to change script parameters without editing the file
  2. Capture trades — strategies yield (candle, plot_data, new_trades) with closed trades
  3. Trade fieldsentry_price, exit_price, profit, cum_profit, size, and more
  4. Build custom stats — calculate win rate, total P&L, or feed trades into your own analytics

Key API

from pynecore.core.script_runner import ScriptRunner
from pynecore.core.syminfo import SymInfo
from pynecore.core.ohlcv import OHLCVReader
from pynecore.core.data_converter import DataConverter

# Convert CSV once
DataConverter.convert_to_ohlcv(Path("data/EURUSD_1h.csv"))

# Load and run
syminfo = SymInfo.load_toml(Path("data/EURUSD_1h.toml"))
with OHLCVReader(Path("data/EURUSD_1h.ohlcv")) as reader:
    runner = ScriptRunner(
        script_path=Path("scripts/bollinger_bands.py"),
        ohlcv_iter=reader.read_from(reader.start_timestamp, reader.end_timestamp),
        syminfo=syminfo,
        inputs={"Length": 20},       # optional: override script inputs
        plot_path=Path("output.csv") # optional: save all output to CSV
    )
    for candle, plot_data in runner.run_iter():
        # Your logic here
        pass
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy