FirScript
A modular scripting engine designed for algo trading. Write PineScript-like python code to define strategies, indicators, and libraries — then plug them into a clean, scriptable engine that does the orchestration for you.
💡 Why FirScript?
Building your own backtesting stack?
FirScript gives you a flexible core to run strategy and indicator code, manage dependencies, and control execution — without locking you into one opinionated interface.
- ✅ Write strategy logic as regular Python scripts
- ⚙️ Parse, register, and run strategies dynamically
- 🧹 Bring your own data, namespaces, and post-processors
- 🛠️ Easily embed into larger trading and backtesting systems or apps
- 🧪 Perfect for research, prototyping, and integration into custom trading platforms
Table of Contents
Getting Started
📦 Installation
pip install FirScript talipp pandas numpy
🚀 Quick Start
from FirScript import Engine
strategy_source = '''
def setup():
global fast_length, slow_length
fast_length = input.int("Fast MA Length", 10)
slow_length = input.int("Slow MA Length", 20)
def process():
if ta.crossover(ta.ema(data.all.close, fast_length), ta.ema(data.all.close, slow_length)):
strategy.long()
'''
data = pd.DataFrame({
'timestamp': pd.date_range('2025-01-01', periods=50),
'open': [100 + 0.5*i + random.random() for i in range(50)],
'close': [100 + 0.5*i + random.random() for i in range(50)],
'high': [100 + 0.5*i + random.random() for i in range(50)],
'low': [100 + 0.5*i + random.random() for i in range(50)],
'volume': [100 + 0.5*i + random.random() for i in range(50)]
})
engine = Engine(data, main_script_str=strategy_source)
results = engine.run()
print(results)
TADA - You just ran your first strategy!
💡 Examples
Want to see it in action? Explore these ready-to-run examples in the examples folder:
- Simple Strategy – A basic trading strategy to get you started.
- Simple Indicator – How to define and use a custom indicator.
- Simple Library – Create reusable components with a simple library.
- Importing Indicators Into Strategy – Combine indicators into your strategy logic.
- Using Libraries In Strategy – Integrate libraries directly into your strategies.
- Custom Namespace – Extend your functionality using custom namespaces.
🧠 Namespaces, Your Way
FirScript ships with default namespaces (ta, input, chart, color, data, strategy) — but you can register your own.
class MySignals:
@staticmethod
def crossover(fast, slow):
return (fast > slow) & (fast.shift() < slow.shift())
registry.register("signals", MySignals())
Now your script can do:
if signals.crossover(ema_fast, ema_slow):
strategy.long()
Check out the full implementation here.
🧹 Who is FirScript for?
- Build your own backtesting UI or cloud platform
- Dynamically load and run user-submitted strategies
- Combine with Pandas, Plotly, or any data science tool
- Use as a logic core for live or paper trading systems
🚫 What FirScript Isn't
- ❌ A charting library (use Plotly, Matplotlib, etc.)
- ❌ A full broker API or execution engine
- ❌ A replacement for full frameworks like Backtrader — FirScript is lean, modular, and pluggable
🤝 Contribute
We welcome issues, ideas, and PRs — especially if you're building on top of this engine.
📖 License
FirScript is licensed under a MIT license.
Metadata
Release files for firscript 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| firscript-1.0.0.tar.gz | 29.2 kB | Without provenance | Details for firscript-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| firscript-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for firscript-1.0.0-py3-none-any.whl |
Total release size: 51.1 kB
Release files / firscript-1.0.0.tar.gz
| Download URL | firscript-1.0.0.tar.gz |
|---|---|
| Size | 29.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eaf131548d9540f05e5dc867cd78cd43a49553689a0c34e37f81d4b4fbab3ad3
|
|
BLAKE2b-256 checksum How to use checksums |
76b0bb6837ffb27ced80fcad346ce073cf9a376d146787aeff697fcca272b8d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / firscript-1.0.0-py3-none-any.whl
| Download URL | firscript-1.0.0-py3-none-any.whl |
|---|---|
| Size | 21.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4985fc1503d079cd93634b4062fef836b780c957b11b8bbaab517dd3c065b29
|
|
BLAKE2b-256 checksum How to use checksums |
72bc8ad47f82e55e4fdf9aeb99451e7c1d518a5f058336e40aa0a3750ada1b50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for firscript 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.