@Tradehull_Imran Sir I am practicing
Master Algo Trading with Python | Episode 10: Build Your Fourth Live Algo
but getting below
PS C:\Users\Subhajit Panja\Documents\Algorithim_HQ> & "c:/Users/Subhajit Panja/Documents/Algorithim_HQ/.venv/Scripts/python.exe" "c:/Users/Subhajit Panja/Documents/Algorithim_HQ/4th live Algo/Options selling Algo.py"
Codebase Version 2.3 : Solved - ATM issues
-----Logged into Dhan-----
reading existing file all_instrument 2024-12-10.csv
Got the instrument file
TATAMOTORS
Traceback (most recent call last):
File "c:/Users/Subhajit Panja/Documents/Algorithim_HQ/4th live Algo/Options selling Algo.py", line 48, in <module>
atm_ce_ltp = tsl.get_ltp(atm_ce_name)
AttributeError: 'Tradehull' object has no attribute 'get_ltp'
My code is below
# https://ta-lib.github.io/ta-lib-python/
# https://www.notion.so/TradeHull-Dhan-Codebase-76b32fa814e64aea843e14a148854214#efa40986725341e6bfa9ad6fcfc10a6d
import pdb
from Dhan_Tradehull import Tradehull
import pandas as pd
import talib
import time
import datetime
client_code = "#"
token_id = "#"
tsl = Tradehull(client_code,token_id)
available_balance = tsl.get_balance()
leveraged_margin = available_balance*5
max_trades = 1
per_trade_margin = (leveraged_margin/max_trades)
max_loss = (available_balance*1)/100*-1
watchlist = ['TATAMOTORS']
initial_entry_created = "no"
do_I_want_reentry = "yes"
while True:
live_pnl = tsl.get_live_pnl()
current_time = datetime.datetime.now().time()
if current_time < datetime.time(9, 20):
print("wait for market to start", current_time)
continue
if (current_time > datetime.time(23, 15)) or (live_pnl < max_loss):
I_want_to_trade_no_more = tsl.kill_switch('ON')
order_details = tsl.cancel_all_orders()
print("Market is over, Bye Bye see you tomorrow", current_time)
break
for stock_name in watchlist:
time.sleep(0.2)
print(stock_name)
# Make Initial Entry
if initial_entry_created == "no":
atm_ce_name, atm_pe_name, strike = tsl.ATM_Strike_Selection(stock_name,'26-12-2024')
atm_ce_ltp = tsl.get_ltp(atm_ce_name)
atm_pe_ltp = tsl.get_ltp(atm_pe_name)
lot_size = tsl.get_lot_size(atm_ce_name)
ce_orderid = tsl.order_placement(atm_ce_name,'NFO',lot_size, 0, 0, 'MARKET', 'SELL', 'MIS')
pe_orderid = tsl.order_placement(atm_pe_name,'NFO',lot_size, 0, 0, 'MARKET', 'SELL', 'MIS')
combined_premium_received = atm_ce_ltp + atm_pe_ltp
combined_sl_premium = combined_premium_received*1.2
initial_entry_created = "yes_I_have_shorted_straddle"
# check for Stoploss
if initial_entry_created == "yes_I_have_shorted_straddle":
atm_ce_ltp = tsl.get_ltp(atm_ce_name)
atm_pe_ltp = tsl.get_ltp(atm_pe_name)
running_combined_premium = atm_ce_ltp + atm_pe_ltp
if running_combined_premium > combined_sl_premium:
ce_orderid = tsl.order_placement(atm_ce_name,'NFO',lot_size, 0, 0, 'MARKET', 'BUY', 'MIS')
pe_orderid = tsl.order_placement(atm_pe_name,'NFO',lot_size, 0, 0, 'MARKET', 'BUY', 'MIS')
if do_I_want_reentry == "yes":
initial_entry_created = "no"
if do_I_want_reentry == "no":
I_want_to_trade_no_more = tsl.kill_switch('ON')
order_details = tsl.cancel_all_orders()
break
I have download from
and replace Dhan_Tradehull.py
from from below
Hi @Tradehull_Imran,
Started receving Dhan API error from morning, till yesterday everything was working fine I am using old dhan codebase 2.2 file which did not have time.sleep method and If I use the latest ‘Codebase Version 2.3 : Solved - ATM issues’ the algo works extremely slow.
@Tradehull_Imran sir and friends I’m thinking If SEBI restrict us by the rule(like retail trader or due to short capital ) then we need do our code flexible means
If allow fine otherwise
We can create trade alert as per our strategy which will show virtual show profit loss and and exit alert.(like back-testing )
We will just manually take the entry and exit without thinking
Sir please let me know your opinion
I am bit unclear about the question, are you trying to implement it on sublime text ?
do share me a screen recording of the process you are doing
Hi @babji3
solution link : Learn Algo Trading with Python | Codes | Youtube Series - #1330 by Tradehull_Imran
Hi @Lowkey_1999
We have upgraded the ltp process from webscoket to rest api call
see : Learn Algo Trading with Python | Codes | Youtube Series - #952 by Tradehull_Imran
call_list = [BANKNIFTY 24 DEC 53000 CALL
BANKNIFTY 24 DEC 53000 PUT
BANKNIFTY 24 DEC 53100 CALL
BANKNIFTY 24 DEC 53100 PUT
BANKNIFTY 24 DEC 53200 CALL
BANKNIFTY 24 DEC 53200 PUT
BANKNIFTY 24 DEC 53300 CALL
BANKNIFTY 24 DEC 53300 PUT
BANKNIFTY 24 DEC 53400 CALL
BANKNIFTY 24 DEC 53400 PUT
BANKNIFTY 24 DEC 53500 CALL
BANKNIFTY 24 DEC 53500 PUT
BANKNIFTY 24 DEC 53600 CALL
BANKNIFTY 24 DEC 53600 PUT
]
How to transpose the vertical list to horizontal mode with single quotes and commas sir.
It’s working out with ctrl + shift + j
Which is transposing to horizontal mode, but I am not able to find out , how to include the single quotes and commas in Sublime text sir.
VBR Prasad
yes this seems to be a edge case for codebase fetching “DAY” timeframe in “FUTURES”.
we will release the fix for it in Dhan_Tradehull_V3
Hi @Himansshu_Joshi
do make the changes in trading_symbol = “NIFTY 12 DEC 24700 PUT”
There is solution to every problem.
use these files : 10. Session10- 4th Live Algo.zip - Google Drive
Hi @Aijaz_Ahmad
if you are using ‘Codebase Version 2.3 : Solved - ATM issues’, then we don’t need to use time.sleep() in the main file…
we can remove time.sleep() from the main file
Hi @Subhajitpanja
yes In this case paper trading can still be done though algo,
Hi @Tradehull_Imran,
I did use codebase version 2.3 and I am still getting rate limit error.
Yes sir fully agreed
Some browser extension are there which will trigger broker side trade
Ultimate choice selenium is also there
Hi @Aijaz_Ahmad
do send .zip of code files and share to tradehull_mentorship@tradehull.com
reference video : Sublime Text shortcut.mp4 - Google Drive
use below steps,
I have removed any blank lines
ctrl + A
ctrl + shift + L
press Home
press "
press END
press "
press , (comma)
delete
space bar
make it into a list
Hello @Tradehull_Imran Sir
rsisma ko kis tarah code kre