Hi @s_nandi ,
Do share the complete code.
Hi @s_nandi ,
Do share the complete code.
hi @Vasili_Prasad ,
Do correct these lines in the code as:
if chart_1 is None:
continue
none needs to be changed to ‘None’
sir when i m learning with " Master Algo Trading with Python | Episode 3: Code Base | FREE Algo Trading Course" this and trying to get ltp of ACC , it not fetching current data. its fetching 2344 rupe which is not current price.
when excel sheet opens it has some data and code fetch that data not updated data. how to solve this isssue.
when i run websocket it shows updated data.
where is mistake which i m doing.
Sir another one issue is with next lecture where you trying to write first algo
this is my code
import pdb
import time
import datetime
import traceback
import talib
from Dhan_Tradehull import Tradehull
import pandas as pd
client_code = “something”
token_id = “something”
tsl = Tradehull(client_code, token_id) # tsl for trader support library
Watchlist = [‘ADANIPORTS’, ‘SHRIRAMFIN’, ‘BEL’, ‘TATAMOTORS’, ‘TRENT’, ‘TITAN’, ‘WIPRO’, ‘ADANIPORTS’, ‘DRREDDY’, ‘HDFCLIFE’, ‘NTPC’, ‘BAJAJ-AUTO’, ‘INFY’, ‘BRITANNIA’, ‘POWERGRID’, ‘SBILIFE’, ‘HINDALCO’, ‘TATACONSUM’, ‘BAJFINANCE’, ‘SBIN’, ‘TECHM’, ‘BPCL’, ‘HEROMOTOCO’, ‘TCS’, ‘ASIANPAINT’, ‘RELIANCE’, ‘CIPLA’, ‘SUNPHARMA’, ‘ONGC’, ‘ULTRACEMCO’, ‘KOTAKBANK’, ‘ITC’, ‘INDUSINDBK’, ‘EICHERMOT’, ‘COALINDIA’, ‘GRASIM’, ‘TATASTEEL’, ‘MARUTI’, ‘NESTLEIND’, ‘APOLLOHOSP’, ‘M&M’, ‘ICICIBANK’, ‘BHARTIARTL’, ‘JSWSTEEL’, ‘HCLTECH’, ‘HDFCBANK’, ‘AXISBANK’, ‘HINDUNILVR’, ‘ADANIENT’, ‘BAJAJFINSV’, ‘ITCHOTELS’, ]
for Stock_list in Watchlist:
chart = tsl.get_intraday_data(Stock_list,‘NSE’,1)
print(Stock_list)
pdb.set_trace()
this is the error
----Logged into Dhan-----
reading existing file all_instrument 2025-01-31.csv
Got the instrument file
intraday_minute_data() missing 2 required positional arguments: ‘from_date’ and ‘to_date’
Traceback (most recent call last):
File “C:\Users\Ganesh\Downloads\DHAN\3. Session3 - Codebase\3. Session3 - Codebase\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 253, in get_intraday_data
ohlc = self.Dhan.intraday_minute_data(str(security_id),exchangeSegment,instrument_type)
TypeError: intraday_minute_data() missing 2 required positional arguments: ‘from_date’ and ‘to_date’
ADANIPORTS
[0] > ←[33;01mc:\users\ganesh\downloads\dhan\3. session3 - codebase\3. session3 - codebase\3. session3 - codebase\dhan codebase\dhan_codebase usage - copy.py←[00m(←[36;01m22←[00m)()
→ for Stock_list in Watchlist:
(Pdb++) chart
(Pdb++)
please provide updated tradehull v2 or anything else link sir g , which folder you are working.
Hello @Tradehull_Imran,
when are you planning to start backtest algo video series ?
we are eagerly waiting for it.
Thanks in advance
thanks sir . i m trading in nifty options since almost one year and sole buyer of cheap premium of call and put. I have just started to learning algo. i had also completed my degree in Information technology (B.sc.IT from NIIT Patna) in 2012, so my background will help me here. i was looking for best guide in this topic and i met with that in form of you.
thank for kind of quick support. please add me in your disciple sir. Thanks a lot.
Thank You sir.
Hi @Tradehull_Imran ,
Consider Nifty is at 23500,
How can I get [CE OI] of 23600, 23700 …?
i.e, ITM or OTM Strikes…?
TIA
Codebase Version 2.7 : Solved - Option Chain Issue
-----Logged into Dhan-----
reading existing file all_instrument 2025-02-01.csv
Got the instrument file
scanning for SJVN 10:50:22.257235
exception got in ce_pe_option_df SJVN Not in the step list
Exception for instrument name None as ‘NoneType’ object has no attribute ‘upper’
Traceback (most recent call last):
File “e:/Algo Trading/Open Interest Breakout.py”, line 123, in
ce_ltp = tsl.get_ltp_data(names=[ce_name])[ce_name]
KeyError: None
@Tradehull_Imran Sir, Ta-lib is not working in the vs code, please give the correct method to import it.
Is there a way to check how much margin is required to buy a strike? I want to put a check vs available margin before placing the order. Thanks
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_balance*1)/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()
Hi @Abhishek_Pawde ,
Do share complete code.
refer the below code:
To get the margin for the stocks, futures and options
margin = tsl.margin_calculator(tradingsymbol='NIFTY 19 DEC 24400 CALL', exchange='NFO', transaction_type='SELL', quantity=25, trade_type='MARGIN' price=43, trigger_price=0)
Hi @Tradehull_Imran ,
Consider Nifty is at 23500,
How can I get [CE OI] of 23600, 23700 …?
i.e, ITM or OTM Strikes…?
TIA
Folks!
Exciting update – the second series of Algo Trading is launching soon!
This time, @Tradehull_Imran has gone in-depth, covering a lot of valuable insights. Some videos are over an hour long, packed with step-by-step explanations and detailed workings.
Stay tuned exclusively on the DhanHQ YouTube channel!
The first video drops this Thursday at 9 PM!
Hi @Akshay_Bawane ,
refer the below code:
ce_quote = tsl.get_quote(['NIFTY 13 FEB 23600 CALL'])
ce_oi = ce_quote[ce_otm]['oi']