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.5.tar.gz (19.0 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.5-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file openalgo_backtrader-0.1.5.tar.gz.

File metadata

  • Download URL: openalgo_backtrader-0.1.5.tar.gz
  • Upload date:
  • Size: 19.0 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.5.tar.gz
Algorithm Hash digest
SHA256 57bc79e55cec81a38299eb6edadc4b76e3e8c15eaacc060051cf73a1abfaf32d
MD5 0e3c62a0bff54661a34cab527437cd76
BLAKE2b-256 4e091bdeac12b592a755f2e3b988efdff3dd9fac1a3b7c8c23875dc38875980e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openalgo_backtrader-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d9ce7799d5c35b424ff6c01b9c1bbb3198756075d379d5c142c358508123fc97
MD5 6f196d351b6e95705ac3858fc25a8f1c
BLAKE2b-256 a37d4c6f4f047bfa2240d61d33f12ef780b8b3897716d96720c7935324792cf8

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