import ssl
import logging
from dhanhq import dhanhq
from Dhan_Tradehull import Tradehull
Bypass SSL verification (not recommended for production)
ssl._create_default_https_context = ssl._create_unverified_context
logging.basicConfig(level=logging.DEBUG)
API_KEY = “1106293837”
ACCESS_TOKEN = “eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJkaGFuIiwicGFydG5lcklkIjoiIiwiZXhwIjoxNzUwMzEwMjA3LCJ0b2tlbkNvbnN1bWVyVHlwZSI6IlNFTEYiLCJ3ZWJob29rVXJsIjoibXVrZSIsImRoYW5DbGllbnRJZCI6IjExMDYyOTM4MzcifQ.vg-Z88xZAIc8Hbt8VgAFF8jtpQ9785W0gXx7wwhSSGIiDNgXWBua3Y4VLoG1AzNXPo3jhfBmof3Ktarjsh9z0A”
dhan = dhanhq(API_KEY, ACCESS_TOKEN)
tsl = Tradehull(API_KEY, ACCESS_TOKEN)
# Fetch historical data (adjust parameters based on method definition)
data = tsl.get_historical_data(Underlying=‘NIFTY’) # Remove unsupported ‘Expiry’ argument
print(data)
# Ensure ATM_Strike is an integer before comparison
option_data = tsl.ATM_Strike_Selection(Underlying=‘NIFTY’)
if option_data is not None and ‘ATM_Strike’ in option_data:
atm_strike = int(option_data[‘ATM_Strike’]) # Convert to integer
strikes = [atm_strike - 2, atm_strike - 1, atm_strike, atm_strike + 1, atm_strike + 2]
print(f"ATM Strike: {atm_strike}, Strikes: {strikes}")[Running] python -u “c:\Users\Administrator\Desktop\dhan tradehull\DhanHQ-py\examples\orders.py”
Traceback (most recent call last):
File “c:\Users\Administrator\Desktop\dhan tradehull\DhanHQ-py\examples\orders.py”, line 4, in
from Dhan_Tradehull import Tradehull
File “C:\Program Files\Python312\Lib\site-packages\Dhan_Tradehull_init_.py”, line 1, in
from .Dhan_Tradehull import Tradehull
ImportError: cannot import name ‘Tradehull’ from ‘Dhan_Tradehull.Dhan_Tradehull’ (C:\Program Files\Python312\Lib\site-packages\Dhan_Tradehull\Dhan_Tradehull.py)
[Done] exited with code=1 in 1.517 seconds @Tradehull_Imran