Skip to main content

TradeHull Delta Exchange API wrapper for market data, option chain, and order placement.

Project description

Tradehull Delta Exchange

Tradehull Delta Exchange is a Python wrapper for Delta Exchange India API.

It supports market data, LTP, OHLC historical candles, option-chain data, account information, wallet balance, open positions, order placement, bracket orders, order cancellation, and position closing.

Installation

Install from the normal PyPI package index:

python -m pip install Tradehull-Delta-Exchange

Upgrade

python -m pip install --upgrade Tradehull-Delta-Exchange

Import

from tradehull_delta_exchange import Tradehull

Authentication

from tradehull_delta_exchange import Tradehull

api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"

tdx = Tradehull(
    api_key=api_key,
    api_secret=api_secret
)

You can also use environment variables:

set DELTA_API_KEY=YOUR_API_KEY
set DELTA_API_SECRET=YOUR_API_SECRET

Then:

from tradehull_delta_exchange import Tradehull

tdx = Tradehull()

Get LTP

from tradehull_delta_exchange import Tradehull

tdx = Tradehull(
    api_key="YOUR_API_KEY",
    api_secret="YOUR_API_SECRET"
)

ltp = tdx.get_ltp("BTCUSD")
print(ltp)

Get Full Quote

quote = tdx.get_quote("BTCUSD")
print(quote)

Get OHLC Historical Data

df = tdx.get_chart(
    name="BTCUSD",
    timeframe="15minute",
    days=7
)

print(df.tail())

Supported timeframe examples:

1minute
3minute
5minute
15minute
30minute
60minute
day
week

Get Option Chain

option_chain = tdx.get_option_chain(
    underlying="BTC",
    expiry_date=0,
    limit=20,
    view="broker"
)

print(option_chain)

Get Call Option Chain

call_df = tdx.get_option_chain(
    underlying="BTC",
    expiry_date=0,
    limit=20,
    view="call"
)

print(call_df)

Get Put Option Chain

put_df = tdx.get_option_chain(
    underlying="BTC",
    expiry_date=0,
    limit=20,
    view="put"
)

print(put_df)

Get Combined Option Chain

combined_df = tdx.get_option_chain(
    underlying="BTC",
    expiry_date=0,
    limit=20,
    view="combine"
)

print(combined_df)

Get ATM Option Name

option_name = tdx.get_option_name(
    symbolname="BTC",
    moneyness=0,
    right="CE",
    expiry=0
)

print(option_name)

Get ITM Option

itm_option = tdx.get_itm_option(
    underlying="BTC",
    itm_level=1,
    expiry_date=0
)

print(itm_option)

Account Information

profile = tdx.get_profile()
print(profile)

wallet = tdx.get_wallet_balance()
print(wallet)

positions = tdx.get_open_positions()
print(positions)

Place Market Order

Live order placement is disabled by default in the safe wrapper.

To place a real order, you must intentionally pass:

Example:

order = tdx.place_order(
    symbol="BTCUSD",
    side="buy",
    order_type="market_order",
    quantity=1,
    price=None
)

print(order)

Place Bracket Order

result = tdx.place_bracket_order(
    symbol="BTCUSD",
    side="buy",
    quantity=1,
    entry_price=None,
    target_price=72000,
    sl_price=61000,
    sl_limit_price=60950,
    target_limit_price=72000
)

print(result)

Cancel Order

cancel_status = tdx.cancel_order(
    order_id=123456,
    product_id=27,
)

print(cancel_status)

Close All Orders and Positions

result = tdx.close_all_orders()

print(result)

Safety Warning

This package can place real orders on Delta Exchange.

Use live trading functions carefully.

Always test with small quantity first.

Do not publish your API key or API secret in code, GitHub, PyPI, screenshots, or shared files.

Main Features

  • Get LTP
  • Get full quote
  • Get OHLC historical candles
  • Get option chain
  • Get call option chain
  • Get put option chain
  • Get combined option chain
  • Get ATM option
  • Get ITM option
  • Get profile
  • Get wallet balance
  • Get open positions
  • Place plain order
  • Place bracket order
  • Cancel order
  • Cancel all orders
  • Close open position
  • Close all orders and positions

Basic Usage

from tradehull_delta_exchange import Tradehull

tdx = Tradehull(
    api_key="YOUR_API_KEY",
    api_secret="YOUR_API_SECRET"
)

ltp = tdx.get_ltp("BTCUSD")
print("BTCUSD LTP:", ltp)

License

MIT 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

tradehull_delta_exchange-0.0.6.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

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

tradehull_delta_exchange-0.0.6-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file tradehull_delta_exchange-0.0.6.tar.gz.

File metadata

File hashes

Hashes for tradehull_delta_exchange-0.0.6.tar.gz
Algorithm Hash digest
SHA256 8b2235a2876a2bdd70c16f8758b2ec40447f09e29ad310246e94fdac2ad8edc2
MD5 2590917a73849ddc2ff295703915b58e
BLAKE2b-256 844900c0c6783e3a97c2e1b40701ad8d1f93349970ee09aa43f6aa81d8eb09ed

See more details on using hashes here.

File details

Details for the file tradehull_delta_exchange-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for tradehull_delta_exchange-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2261f5673ef255dbc186bc298adf668f1fde68a74cf40e19b4897c466fa22c04
MD5 3063c23b4d97f733431d68e1c282d40b
BLAKE2b-256 24a10b2c0f3dcb8d3ce0e562ec947b160b1d6d9c3a8837ab5c3e9e9ed4b49633

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