@Tradehull_Imran I placed a buy order for “NIFTY 06 FEB 23600 CALL.” However, after the order was executed, it was converted to a different format: “NIFTY-Feb2025-23600-CE.” When I tried to retrieve the trading symbol from the positions DataFrame using the “NIFTY 06 FEB 23600 CALL”, it was unsuccessful. What is the solution to this issue?
@Tradehull_Imran sir,
Trying this
`import pdb
from Dhan_Tradehull_V2 import Tradehull
import pandas as pd
import talib
import math
import time
client_code = “123”
token_id = “abc”
tsl = Tradehull(client_code,token_id)
watchlist = [‘NIFTY’, ‘RELIANCE’, ‘HDFCBANK’]
traded_watchlist=
#FIRST to get the balance amount
bal = tsl.get_balance()
print("Account Balance= ", bal)
for stock_name in watchlist:
print(“Stock Name :”, stock_name)
if stock_name == ‘NIFTY’:
exchange=“INDEX”
else:
exchaneg=“NSE”
# fetching intraday data
data= get_intraday_data(stock_name, exchange, ‘5’)
print(data).`
I am getting error-
Stock Name : NIFTY
Traceback (most recent call last):
File “falgo_1.py”, line 42, in
data= get_intraday_data(stock_name, exchange, ‘5’)
NameError: name ‘get_intraday_data’ is not defined
iam facing this issue please kindly help me…
input code import pdb
import time
import datetime
import traceback
import talib
from Dhan_Tradehull_V2 import Tradehull
import pandas as pd
client_code = “xxx”
token_id = “xxx”
tsl = Tradehull(client_code,token_id) # tradehull_support_library
NY_List = [‘ADANIENT’, ‘ADANIPORTS’, ‘APOLLOHOSP’, ‘ASIANPAINT’, ‘AXISBANK’, ‘BAJAJ-AUTO’, ‘BAJAJFINSV’, ‘BAJFINANCE’, ‘BEL’, ‘BHARTIARTL’, ‘BPCL’, ‘BRITANNIA’, ‘CIPLA’, ‘COALINDIA’, ‘DRREDDY’, ‘EICHERMOT’, ‘GRASIM’, ‘HCLTECH’, ‘HDFCBANK’, ‘HDFCLIFE’, ‘HEROMOTOCO’, ‘HINDALCO’, ‘HINDUNILVR’, ‘ICICIBANK’, ‘INDUSINDBK’, ‘INFY’, ‘ITC’, ‘JSWSTEEL’, ‘KOTAKBANK’, ‘LT’, ‘M&M’, ‘MARUTI’, ‘NESTLEIND’, ‘NTPC’, ‘ONGC’, ‘POWERGRID’, ‘RELIANCE’, ‘SBILIFE’, ‘SBIN’, ‘SHRIRAMFIN’, ‘SUNPHARMA’, ‘TATACONSUM’, ‘TATAMOTORS’, ‘TATASTEEL’, ‘TCS’, ‘TECHM’, ‘TITAN’, ‘TRENT’, ‘ULTRACEMCO’, ‘WIPRO’]
FNO_List = [‘AARTIIND’, ‘ABB’, ‘ABBOTINDIA’, ‘ABCAPITAL’, ‘ABFRL’, ‘ACC’, ‘ADANIENSOL’, ‘ADANIENT’, ‘ADANIGREEN’, ‘ADANIPORTS’, ‘ALKEM’, ‘AMBUJACEM’, ‘ANGELONE’, ‘APLAPOLLO’, ‘APOLLOHOSP’, ‘APOLLOTYRE’, ‘ASHOKLEY’, ‘ASIANPAINT’, ‘ASTRAL’, ‘ATGL’, ‘ATUL’, ‘AUBANK’, ‘AUROPHARMA’, ‘AXISBANK’, ‘BAJAJ-AUTO’, ‘BAJAJFINSV’, ‘BAJFINANCE’, ‘BALKRISIND’, ‘BANDHANBNK’, ‘BANKBARODA’, ‘BANKINDIA’, ‘BATAINDIA’, ‘BEL’, ‘BERGEPAINT’, ‘BHARATFORG’, ‘BHARTIARTL’, ‘BHEL’, ‘BIOCON’, ‘BOSCHLTD’, ‘BPCL’, ‘BRITANNIA’, ‘BSE’, ‘BSOFT’, ‘CAMS’, ‘CANBK’, ‘CANFINHOME’, ‘CDSL’, ‘CESC’, ‘CGPOWER’, ‘CHAMBLFERT’, ‘CHOLAFIN’, ‘CIPLA’, ‘COALINDIA’, ‘COFORGE’, ‘COLPAL’, ‘CONCOR’, ‘COROMANDEL’, ‘CROMPTON’, ‘CUB’, ‘CUMMINSIND’, ‘CYIENT’, ‘DABUR’, ‘DALBHARAT’, ‘DEEPAKNTR’, ‘DELHIVERY’, ‘DIVISLAB’, ‘DIXON’, ‘DLF’, ‘DMART’, ‘DRREDDY’, ‘EICHERMOT’, ‘ESCORTS’, ‘EXIDEIND’, ‘FEDERALBNK’, ‘GAIL’, ‘GLENMARK’, ‘GMRAIRPORT’, ‘GNFC’, ‘GODREJCP’, ‘GODREJPROP’, ‘GRANULES’, ‘GRASIM’, ‘GUJGASLTD’, ‘HAL’, ‘HAVELLS’, ‘HCLTECH’, ‘HDFCAMC’, ‘HDFCBANK’, ‘HDFCLIFE’, ‘HEROMOTOCO’, ‘HFCL’, ‘HINDALCO’, ‘HINDCOPPER’, ‘HINDPETRO’, ‘HINDUNILVR’, ‘HUDCO’, ‘ICICIBANK’, ‘ICICIGI’, ‘ICICIPRULI’, ‘IDEA’, ‘IDFCFIRSTB’, ‘IEX’, ‘IGL’, ‘INDHOTEL’, ‘INDIAMART’, ‘INDIANB’, ‘INDIGO’, ‘INDUSINDBK’, ‘INDUSTOWER’, ‘INFY’, ‘IOC’, ‘IPCALAB’, ‘IRB’, ‘IRCTC’, ‘IRFC’, ‘ITC’, ‘JINDALSTEL’, ‘JIOFIN’, ‘JKCEMENT’, ‘JSL’, ‘JSWENERGY’, ‘JSWSTEEL’, ‘JUBLFOOD’, ‘KALYANKJIL’, ‘KEI’, ‘KOTAKBANK’, ‘KPITTECH’, ‘LALPATHLAB’, ‘LAURUSLABS’, ‘LICHSGFIN’, ‘LICI’, ‘LODHA’, ‘LT’, ‘LTF’, ‘LTIM’, ‘LTTS’, ‘LUPIN’, ‘M&M’, ‘M&MFIN’, ‘MANAPPURAM’, ‘MARICO’, ‘MARUTI’, ‘MAXHEALTH’, ‘MCX’, ‘METROPOLIS’, ‘MFSL’, ‘MGL’, ‘MOTHERSON’, ‘MPHASIS’, ‘MRF’, ‘MUTHOOTFIN’, ‘NATIONALUM’, ‘NAUKRI’, ‘NAVINFLUOR’, ‘NCC’, ‘NESTLEIND’, ‘NHPC’, ‘NMDC’, ‘NTPC’, ‘NYKAA’, ‘OBEROIRLTY’, ‘OFSS’, ‘OIL’, ‘ONGC’, ‘PAGEIND’, ‘PAYTM’, ‘PEL’, ‘PERSISTENT’, ‘PETRONET’, ‘PFC’, ‘PIDILITIND’, ‘PIIND’, ‘PNB’, ‘POLICYBZR’, ‘POLYCAB’, ‘POONAWALLA’, ‘POWERGRID’, ‘PRESTIGE’, ‘PVRINOX’, ‘RAMCOCEM’, ‘RBLBANK’, ‘RECLTD’, ‘RELIANCE’, ‘SAIL’, ‘SBICARD’, ‘SBILIFE’, ‘SBIN’, ‘SHREECEM’, ‘SHRIRAMFIN’, ‘SIEMENS’, ‘SJVN’, ‘SONACOMS’, ‘SRF’, ‘SUNPHARMA’, ‘SUNTV’, ‘SUPREMEIND’, ‘SYNGENE’, ‘TATACHEM’, ‘TATACOMM’, ‘TATACONSUM’, ‘TATAELXSI’, ‘TATAMOTORS’, ‘TATAPOWER’, ‘TATASTEEL’, ‘TCS’, ‘TECHM’, ‘TIINDIA’, ‘TITAN’, ‘TORNTPHARM’, ‘TRENT’, ‘TVSMOTOR’, ‘UBL’, ‘ULTRACEMCO’, ‘UNIONBANK’, ‘UNITDSPR’, ‘UPL’, ‘VBL’, ‘VEDL’, ‘VOLTAS’, ‘WIPRO’, ‘YESBANK’, ‘ZOMATO’, ‘ZYDUSLIFE’]
available_balance = tsl.get_balance()
max_risk_for_the_day = (available_balance1)/100-1
print(“available_balance”, available_balance)
for stock_name in NY_List:
symbol = tsl.get_intraday_data(stock_name, ‘NSE’, 5)
symbol[‘rsi’] = talib.RSI(symbol[‘close’], timeperiod=14)
bc = symbol.iloc[-2] #pandas breakout_candle
ic = symbol.iloc[-3] #pandas inside_candle
ba_c = symbol.iloc[-4] #pandas base_candle
uptrend = bc['rsi'] > 60
downtrend = bc['rsi'] < 40
upper_side_breakout = (ba_c['high'] > ic['high'])
lower_side_breakdown = (ba_c['low'] < ic['low'])
if upper_side_breakout:
print(stock_name, "is in uptrend")
if lower_side_breakdown:
print(stock_name, "is in downtrend")
print(stock_name)
# pdb.set_trace()
I am using two python scripts one for Entry and one for Exit. Occasionally I am getting the following error. How can overcome this error …
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: {‘data’: {‘805’: ‘Too many requests. Further requests may result in the user being blocked.’}, ‘status’: ‘failed’}}
ERROR:root:Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: {‘data’: {‘805’: ‘Too many requests. Further requests may result in the user being blocked.’}, ‘status’: ‘failed’}}
Traceback (most recent call last):
File “G:\Sree\Options\Dhan_Tradehull_V2.py”, line 689, in get_ltp_data
raise Exception(data)
Exception: {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: {‘data’: {‘805’: ‘Too many requests. Further requests may result in the user being blocked.’}, ‘status’: ‘failed’}}
exception got in ce_pe_option_df ‘KOTAKBANK’
INFO:root:Price Change for KOTAKBANK: 2.48
INFO:root:Processing None …
Exception in Getting OHLC data as ‘NoneType’ object has no attribute ‘upper’
ERROR:root:Exception in Getting OHLC data as ‘NoneType’ object has no attribute ‘upper’
Traceback (most recent call last):
File “G:\Sree\Options\Dhan_Tradehull_V2.py”, line 445, in get_historical_data
tradingsymbol = tradingsymbol.upper()
AttributeError: ‘NoneType’ object has no attribute ‘upper’
Traceback (most recent call last):
File “TestEntry.py”, line 172, in
ema_slope_uptrend, ema_uptrend_signal, touch_ema_uptrend, bc, uptrend, rsi_5_slope_uptrend, touch_rsi_uptrend, rsi_uptrend = check_trend_and_touch_ema(chart)
File “TestEntry.py”, line 65, in check_trend_and_touch_ema
chart[‘5rsi’] = talib.RSI(chart[‘close’], timeperiod=5)
TypeError: ‘NoneType’ object is not subscriptable
Finally
Excited
from Dhan_Tradehull_V2 import Tradehull
import pandas as pd
from pprint import pprint
import pandas_ta as pta
import pandas_ta as ta
import warnings
import matplotlib.pyplot as plt
import mplfinance as mpf
import requests
warnings.filterwarnings(“ignore”)
client_code = “ccc”
token_id = “ccc”
bot_token = “ccc”
receiver_chat_id = “ccc”
tsl = Tradehull(client_code, token_id)
watchlist = [‘LUPIN’]
for stock_name in watchlist:
ce_name, pe_name, strike = tsl.ATM_Strike_Selection(stock_name, Expiry=0)
ce_ltp = tsl.get_ltp_data(names=[ce_name])[ce_name]
print(ce_name, ce_ltp)
Codebase Version 2.8 : Solved - Strike Selection Issue
-----Logged into Dhan-----
reading existing file all_instrument 2025-02-05.csv
Got the instrument file
exception got in ce_pe_option_df Unable to find the ATM strike for the LUPIN
Exception for instrument name None as ‘NoneType’ object has no attribute ‘upper’
Traceback (most recent call last):
File “e:/Algo Trading/test.py”, line 27, in
ce_ltp = tsl.get_ltp_data(names=[ce_name])[ce_name]
KeyError: None
I’m eagerly waiting for the upcoming series.
Hi @Kanha_Meher ,
We can use the security id of the instrument rather then using trading symbol to compare it. We can get the security id of an instrument using instrument file.
Hi @anandc ,
Do use get_historical_data()
function as ‘get_intraday_data()’ function will be deprecated.
Refer the below video:
do use this upgraded codebase file : Dhan_Tradehull_V2.py - Google Drive
Sir i want to get nifty pre open session data like nifty 9.0 to 9.08 am high low data , how to get it. and give that which has all methods tradehull code base library. notion.so/ something
Hi @parameshwar ,
The code seems to be working fine:
available_balance = tsl.get_balance()
max_risk_for_the_day = (available_balance) / 100 - 1
print("Available balance:", available_balance)
Hi @sreetd14 ,
The best alternative solution to avoid rate limits are to combine both entry and exit python script.
Additionally we will be specifically covering about this topic in our advanced algo series.
@Tradehull_Imran SIR,
Thanks for the reply, you can see the code, i am using Tradehull v2 only.
Will go thru the video once again…
Thanks a lot again.
Hi @Abhishek_Pawde ,
The issue is fixed now kindly download the latest codebase.
https://drive.google.com/file/d/1h8J6VOLrHMAaF1NGP4_vJj2wtkNxfPDw/viewsir i want to select strike price based on price like throw strike price which value is less than 20. or more than 300 . how to do that.
Hi @Tradehull_Imran ,
Highlighted yellow is ATM Strike Data (i.e, 23700),
Here,
I want to calculate the “CE OI” & “CE Chg in OI” of the ITM or OTM Strikes,
highlighted with Red and Orange box.
TIA
Thank You @Tradehull_Imran
thank you sir for the reply, my code is working fine now. but it is taking 22:39 minutes to scan whole watchlist . is there any other method to scan stocks faster.
Hi @Tradehull_Imran,
what does this error mean and how to resolve this …
→ ce_name, pe_name, strike = tsl.ATM_Strike_Selection(Underlying=‘TITAN’, Expiry=0)
(Pdb++) n
exception got in ce_pe_option_df TITAN Not in the step list