Learn Algo Trading with Python | Codes | Youtube Series

Hello @Tradehull_Imran

Sir, I use to scan NIFTY 200 stocks in about 4 minutes, but now the scanning is very slow, taking about 15 mins, what can be done to increase speed.

thank you

Hello @Babasaheb_Jagtap

I too used to get the error while scanning M&MFIN, however it got resolved by replacing the Dhan_Tradehull_V2 file, Try to replace the old file with new one. Hope this helps

Thanks

@Tradehull_Imran Sir how can we get tick data for nifty index …i want to automate the process of getting latest strike price .
Please let me know .

Hi @babji3

use below code

chart = tsl.get_historical_data(tradingsymbol = 'M&M Financial Services',exchange = 'NSE',timeframe="5")

for any name confusion, just copy the exact name which shows on watchlist

Hi @SUDIP_NATH

  1. Use this file for Dhan_Tradehull_V2,
    Dhan_Tradehull_V2.py - Google Drive

  2. Much of the development of Trailing SL is connected with code architecture that we use, we will be covering trailing SL and its variations in upcoming videos.

1 Like

Hi @rahulcse56

do check this file : Learn Algo Trading with Python | Codes | Youtube Series - #1330 by Tradehull_Imran

Hi @Priyesh_Sharma

do share the .zip of code folder that you are using.

Hi @Hitesh_Maurya

use this for tick data

ltp   = tsl.get_ltp_data(names = ['NIFTY'])

use this to get the latest strike price

ce_strike, pe_strike, strike = tsl.ATM_Strike_Selection(Underlying ='NIFTY',Expiry ='12-12-2024')

Also this is the latest file to be used : Learn Algo Trading with Python | Codes | Youtube Series - #1330 by Tradehull_Imran

@Priyesh_Sharma

share the access to tradehull_mentorship@tradehull.com
do remove any confidential information.

i think 1 min TF historical data option removed from this V2 file and enabled 2T timeframe. my code is giving error now. seems i have to update the code based on the updated version.

please share me the zip file, am using Dhan_Tradehull_V2 only

Thank you sir,

Hi @Priyesh_Sharma

as of now rate limit has been fixed, we don’t need to use time.sleep() in the main code

print(f"start {datetime.datetime.now()}")

for name in pre_market_watchlist:
	print(f"Pre market scanning {name}")
	daily_data = tsl.get_historical_data(tradingsymbol = name, exchange = 'NSE',timeframe="5")
	ldc = daily_data.iloc[-1]  #last_day_candle
	body_percentage = ((ldc['close'] - ldc['open'])/ldc['open'])*100
	body_dict[name] = round(body_percentage, 2)

print(f"end {datetime.datetime.now()}")

Also the speed for scanning after this step for 50 scripts was 87 seconds,
which is for 200 scripts it will be around 5-6 min

Logs

C:py "Pre Market Scanner.py"Lecture Sessions\Forum Support\Forum Code Questions\32. Priyesh\3rd live Algo1\3rd live Algo1>py pr
Codebase Version 2.2 : Rate Limits
-----Logged into Dhan-----
reading existing file all_instrument 2024-12-06.csv
Got the instrument file
start 2024-12-06 14:47:20.123406
Pre market scanning INFY
Pre market scanning M&M
Pre market scanning M&MFIN
Pre market scanning HINDALCO
Pre market scanning TATASTEEL
Pre market scanning NTPC
Pre market scanning MARUTI
Pre market scanning TATAMOTORS
Pre market scanning ONGC
Pre market scanning BPCL
Pre market scanning WIPRO
Pre market scanning SHRIRAMFIN
Pre market scanning ADANIPORTS
Pre market scanning JSWSTEEL
Pre market scanning COALINDIA
Pre market scanning ULTRACEMCO
Pre market scanning BAJAJ-AUTO
Pre market scanning LT
Pre market scanning POWERGRID
Pre market scanning ADANIENT
Pre market scanning SBIN
Pre market scanning HCLTECH
Pre market scanning TCS
Pre market scanning EICHERMOT
Pre market scanning BAJAJFINSV
Pre market scanning TECHM
Pre market scanning LTIM
Pre market scanning HINDUNILVR
Pre market scanning BHARTIARTL
Pre market scanning AXISBANK
Pre market scanning GRASIM
Pre market scanning HEROMOTOCO
Pre market scanning DRREDDY
Pre market scanning ICICIBANK
Pre market scanning HDFCBANK
Pre market scanning BAJFINANCE
Pre market scanning SBILIFE
Pre market scanning RELIANCE
Pre market scanning KOTAKBANK
Pre market scanning ITC
Pre market scanning TITAN
Pre market scanning SUNPHARMA
Pre market scanning INDUSINDBK
Pre market scanning APOLLOHOSP
Pre market scanning BRITANNIA
Pre market scanning NESTLEIND
Pre market scanning HDFCLIFE
Pre market scanning DIVISLAB
Pre market scanning CIPLA
Pre market scanning ASIANPAINT
Pre market scanning TATACONSUM
end 2024-12-06 14:48:47.542610
TATAMOTORS
{'Direction': 'buy', 'level': 810.75}

Thank you Sir

Hi @rahulcse56

Code is fine for 1 mins data also

C:\Users\imran\Desktop\Dhan Lecture Sessions\Forum Support\Forum Code Questions\X.1 Copy me for Codebase support>py "Dhan Login ltp and hist.py"
Codebase Version 2.2 : Rate Limits
-----Logged into Dhan-----
reading existing file all_instrument 2024-12-06.csv
Got the instrument file
--Return--
[0] > c:\users\imran\desktop\dhan lecture sessions\forum support\forum code questions\x.1 copy me for codebase support\dhan login ltp and hist.py(16)<module>()->None
-> pdb.set_trace()
(Pdb++) chart = tsl.get_historical_data(tradingsymbol = 'NIFTY',exchange = 'INDEX',timeframe="1")
(Pdb++) chart
          open          high           low     close  volume                 timestamp
0     24488.75  24501.150391  24446.849609  24465.70     0.0 2024-12-04 09:15:00+05:30
1     24465.85  24483.850000  24465.850000  24476.00     0.0 2024-12-04 09:16:00+05:30
2     24475.35  24480.400000  24465.450000  24475.55     0.0 2024-12-04 09:17:00+05:30
3     24475.30  24483.900000  24473.400000  24481.85     0.0 2024-12-04 09:18:00+05:30
4     24482.70  24483.700000  24471.450000  24479.25     0.0 2024-12-04 09:19:00+05:30
...        ...           ...           ...       ...     ...                       ...
1086  24680.35  24683.350000  24677.200000  24679.15     0.0 2024-12-06 14:51:00+05:30
1087  24678.80  24689.550000  24677.300000  24688.05     0.0 2024-12-06 14:52:00+05:30
1088  24686.35  24692.500000  24686.350000  24689.05     0.0 2024-12-06 14:53:00+05:30
1089  24688.70  24693.250000  24687.350000  24690.35     0.0 2024-12-06 14:54:00+05:30
1090  24690.35  24693.350000  24688.000000  24692.05     0.0 2024-12-06 14:55:00+05:30

[1091 rows x 6 columns]
(Pdb++)

code : Dhan_Tradehull_V2.py - Google Drive

1 Like

Hi @Qaisar

code for ATM_Strike_Selection Nifty_T10_watchlist is in progress
fix for the same will be released in Dhan_Tradehull_V3.

till then you may remove such scripts.

Thank you very much sir.

thanks… my bad i was looking at intraday function… historical data will work

Hi Imran, I am facing the same issue. Kindly share with me the Dhan_websocket SSL_issue_fixed.py .
Thanks in advance.
Regards, Sunil

Hi @arora_sunil

SSL issue can be faced in WebSocket method, however we have now moved to a upgraded method
see : Learn Algo Trading with Python | Codes | Youtube Series - #952 by Tradehull_Imran