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 from TestPyPI
For testing installation from TestPyPI, use:
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple Tradehull-Delta-Exchange==0.0.5
Note: --extra-index-url https://pypi.org/simple is required because dependencies like aiohttp, pandas, and requests are downloaded from real PyPI.
Upgrade
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
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 tradehull_delta_exchange-0.0.5.tar.gz.
File metadata
- Download URL: tradehull_delta_exchange-0.0.5.tar.gz
- Upload date:
- Size: 26.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01f1577c64eda909dfc2a865f46ea0811d848a33660b1b06c7f54dbae28e1087
|
|
| MD5 |
80df7ef151597418362b14fc7150b588
|
|
| BLAKE2b-256 |
50fb61c9ef87bddea1b1d3ae8803218b729c1f5959a13cf15b11010fb38679c4
|
File details
Details for the file tradehull_delta_exchange-0.0.5-py3-none-any.whl.
File metadata
- Download URL: tradehull_delta_exchange-0.0.5-py3-none-any.whl
- Upload date:
- Size: 27.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85ccea1179f2f6120b7725f83b59d47d07c1f8ec1580039a99ae9867e1800518
|
|
| MD5 |
cb1279e90de0861ca8ad52d0e3ba6ab5
|
|
| BLAKE2b-256 |
879619d193f7786b331afc662b78c97a1e85eba2bb5105d3bca6ca8978f3aa0d
|