Skip to main content

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 package
    • stores/oa.py - OAStore for OpenAlgo API
    • feeds/oa.py - OAData for Backtrader feeds
    • brokers/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

License

See LICENSE.

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

openalgo_backtrader-0.1.6.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

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

openalgo_backtrader-0.1.6-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

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

Hashes for openalgo_backtrader-0.1.6.tar.gz
Algorithm Hash digest
SHA256 b8c941df2205488d7ec9fbd9484ea39463a3ed67b14b03e5c021c583092d0d2e
MD5 222b44f34894ebd8ee89a461e7aec05f
BLAKE2b-256 3a16e7482b7abf34b0cf4fd4b4278f1de856f3b75b00363aab22b540bc9fb479

See more details on using hashes here.

File details

Details for the file openalgo_backtrader-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for openalgo_backtrader-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 862bce7bee3ac333690c8471838bd660493f49ed78d99b36ebc83b91cf9f2d5f
MD5 d3833a24d050a049f26330b11405a7f5
BLAKE2b-256 243db6316737e7ece025b23a68417340c8afdeeb713495bb2ea2cea31c61f970

See more details on using hashes here.

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