Backtrader integration for OpenAlgo (India) - stores, feeds, and brokers
Project description
openalgo-backtrader
Backtrader integration for OpenAlgo (India) - stores, feeds, and brokers.
Installation
uv pip install openalgo-backtrader
Usage
Import the package in your code as follows:
from openalgo_bt.stores.oa import OAStore
from openalgo_bt.feeds.oa import OAData
Project Structure
openalgo_bt/- Main packagestores/oa.py- OAStore for OpenAlgo APIfeeds/oa.py- OAData for Backtrader feedsbrokers/oabroker.py- OABroker for Backtrader brokers
Sample Store/Broker Creation
Here is how to setup a Store/Broker (example tested with Zerodha backend at OpenAlgo). Both blocks are for "LIVE" setup
from openalgo_bt.stores.oa import OAStore
store = OAStore()
broker = store.getbroker(
product="MIS",
strategy="Live Consistent Trend Bracket",
debug=True,
simulate_fills=False, # Use real broker for live trading
use_funds=False # Use local cash management
)
cerebro.setbroker(broker)
And to setup a Data (or multiple for that matter)
data = OAData(
symbol=symbol,
interval="1m", # Explicit OpenAlgo interval to bypass timeframe/compression mapping
compression=1, # 1-minute bars
fromdate=datetime.now() - timedelta(days=1), # Some historical data for warmup
live=True, # Enable live streaming
ws_url=ws_url,
ws_mode=2, # Quote mode
)
cerebro.adddata(data, name=symbol)
Requirements
- Python 3.8+
- python-dotenv
- backtrader (user must install)
- openalgo (user must install)
License
See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openalgo_backtrader-0.1.6.tar.gz.
File metadata
- Download URL: openalgo_backtrader-0.1.6.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8c941df2205488d7ec9fbd9484ea39463a3ed67b14b03e5c021c583092d0d2e
|
|
| MD5 |
222b44f34894ebd8ee89a461e7aec05f
|
|
| BLAKE2b-256 |
3a16e7482b7abf34b0cf4fd4b4278f1de856f3b75b00363aab22b540bc9fb479
|
File details
Details for the file openalgo_backtrader-0.1.6-py3-none-any.whl.
File metadata
- Download URL: openalgo_backtrader-0.1.6-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
862bce7bee3ac333690c8471838bd660493f49ed78d99b36ebc83b91cf9f2d5f
|
|
| MD5 |
d3833a24d050a049f26330b11405a7f5
|
|
| BLAKE2b-256 |
243db6316737e7ece025b23a68417340c8afdeeb713495bb2ea2cea31c61f970
|