Sir would making official GitHub repo for trade hull be a better idea ?
with frequent pulls, everybody could stay updated easily
or is there already one ?
@Tradehull_Imran
Sir would making official GitHub repo for trade hull be a better idea ?
with frequent pulls, everybody could stay updated easily
or is there already one ?
@Tradehull_Imran
use tradehull v2 , then you will not get this issue.
Sir, good morning, one help more if i place limit order then how to track order is executed or not and wait there in for limit order execution , if not executed after reasonable time , cancel order. help me with it .
Hi @Abhishek_kumar97 ,
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
dear @Tradehull_Imran sir,
today while testing the algo got this error-
[2025-02-07 12:58:46] PUT Trade: Entry at 134.55, SL: 23586.78, Target: 120.9, R:R = 0.0
[2025-02-07 12:58:47] PUT Order placed at 134.55 at 2025-02-07 12:58:47
Exception in Getting OHLC data as {'status': 'failure', 'remarks': 'HTTPSConnectionPool(host=\'api.dhan.co\', port=443): Max retries exceeded with url: /v2/charts/intraday (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x0000020A47E0F520>: Failed to resolve \'api.dhan.co\' ([Errno 11001] getaddrinfo failed)"))', 'data': ''}
can you pls explain what does this means…?
regards and thanks a lot
Have a nice day
Hi @rahulcse56 ,
To get the last 5 days data from dhan api, make the changes in Dhan_Tradehull_V2 file get_start_date() function.
start_date = df.iloc[-2]['timestamp'] # change -2 to -5
Hi @sathwik_natha ,
Latest codebase link - 3.1 Codebase Upgrade.zip - Google Drive
Latest codebase link - 3.1 Codebase Upgrade.zip - Google Drive
Latest codebase link- 3.1 Codebase Upgrade.zip - Google Drive
Latest codebase link is below - 3.1 Codebase Upgrade.zip - Google Drive
Since previous data data does not chagne, we do not need to call it inside for while loop.
we can call previous data outside while loop and store the data received in a dictionary, and use the dictionary when we want to access previous day data.
This change will make the code run atleast 2x faster
see below code
import pdb
import time
import datetime
import traceback
from Dhan_Tradehull_V2 import Tradehull
import pandas as pd
from pprint import pprint
import talib
import pandas_ta as pta
import pandas_ta as ta
import warnings
import requests
warnings.filterwarnings("ignore")
client_code = "ccc"
token_id = "cc"
bot_token = "ccc"
receiver_chat_id = "cc"
tsl = Tradehull(client_code, token_id)
traded_watchlist = []
scanned_watchlist = []
available_balance = tsl.get_balance()
max_loss = (available_balance*5)/100*-1
max_trades = 3
fno_watchlist = ["AARTIIND", "ABB", "ABBOTINDIA", "ABCAPITAL", "ACC", "ADANIENT", "ADANIENSOL", "ADANIGREEN", "ADANIPORTS", "AUBANK", "AUROPHARMA", "AXISBANK", "BAJAJ-AUTO", "BAJAJFINSV", "BAJFINANCE", "BALKRISIND", "BANDHANBNK", "BANKBARODA", "BANKINDIA", "BATAINDIA", "BEL", "BERGEPAINT", "BHARATFORG", "BHARTIARTL", "BHEL", "BIOCON", "BPCL", "BRITANNIA", "BSOFT", "CANBK", "CANFINHOME", "CDSL", "CHAMBLFERT", "CHOLAFIN", "CIPLA", "COALINDIA", "COFORGE", "COLPAL", "CONCOR", "COROMANDEL", "CROMPTON", "CUB", "CUMMINSIND", "CYIENT", "DABUR", "DALBHARAT", "DEEPAKNTR", "DELHIVERY", "DIVISLAB", "DLF", "DMART", "DRREDDY", "EICHERMOT", "ESCORTS", "EXIDEIND", "FEDERALBNK", "GAIL", "GLENMARK", "GMRAIRPORT", "GODREJCP", "GODREJPROP", "GRANULES", "GRASIM", "GUJGASLTD", "HAL", "HAVELLS", "HCLTECH", "HDFCAMC", "HDFCBANK", "HDFCLIFE", "HEROMOTOCO", "HINDALCO", "HINDCOPPER", "HINDPETRO", "HINDUNILVR", "HINDZINC","HUDCO", "ICICIBANK", "ICICIGI", "ICICIPRULI", "IDFCFIRSTB", "IEX", "IGL", "INDHOTEL", "INDIAMART", "INDIGO", "INDUSINDBK", "INDUSTOWER", "INFY", "IOC", "IRB", "IRCTC", "IRFC", "ITC", "JINDALSTEL", "JIOFIN", "JKCEMENT", "JSL", "JUBLFOOD", "KALYANKJIL", "KEI", "KOTAKBANK", "KPITTECH", "LALPATHLAB", "LAURUSLABS", "LICHSGFIN", "LICI", "LT", "LTF", "LTIM", "LTTS", "LUPIN", "MANAPPURAM", "MARICO", "MARUTI", "MAXHEALTH", "MCX", "MOTHERSON", "MPHASIS", "MUTHOOTFIN", "NATIONALUM", "NAUKRI", "NAVINFLUOR", "NCC", "NESTLEIND", "NMDC", "NTPC", "OBEROIRLTY", "OFSS", "ONGC", "PEL", "PETRONET", "PFC", "PIDILITIND", "PIIND", "POLICYBZR", "POLYCAB", "POWERGRID", "PRESTIGE", "PVRINOX","PHOENIXLTD", "RAMCOCEM", "RBLBANK", "RECLTD", "RELIANCE", "SAIL", "SBICARD", "SBILIFE", "SBIN", "SHREECEM", "SHRIRAMFIN", "SIEMENS","SOLARINDS", "SONACOMS", "SRF", "SUNPHARMA", "SUNTV", "SYNGENE", "TATACHEM", "TATACOMM", "TATACONSUM", "TATAMOTORS","TIINDIA","TATAPOWER", "TATASTEEL", "TCS", "TECHM", "TITAN", "TORNTPHARM","TORNTPOWER", "TRENT", "TVSMOTOR", "UBL", "ULTRACEMCO", "UNIONBANK","UNITDSPR", "UPL", "VEDL", "VOLTAS", "WIPRO", "YESBANK", "ZYDUSLIFE"]
def calculate_pivot_points(daily_candle):
"""Calculates standard pivot points."""
high = daily_candle['high']
low = daily_candle['low']
close = daily_candle['close']
pivot = (high + low + close) / 3
r1 = (2 * pivot) - low
s1 = (2 * pivot) - high
r2 = pivot + (high - low)
s2 = pivot - (high - low)
r3 = high + 2 * (pivot - low)
s3 = low - 2 * (high - pivot)
return {'pivot': pivot,'r1': r1,'s1': s1,'r2': r2,'s2': s2,'r3': r3,'s3': s3}
daily_data = {}
for stock_name in fno_watchlist:
daily_chart = tsl.get_historical_data(stock_name,"NSE","DAY")
if daily_chart is not None:
daily_chart.set_index(pd.DatetimeIndex(daily_chart['timestamp']), inplace=True)
pivot_points = calculate_pivot_points(daily_chart.iloc[-1]) # Use previous day's data
r1 = pivot_points['r1']
p = pivot_points['pivot']
s1 = pivot_points['s1']
ldc = daily_chart.iloc[-1] #last day candle
body_percentage = (ldc['close'] - ldc['open'])/ldc['open']*100
daily_data[stock_name] = {'r1': r1, 'p': p, 's1': s1, 'ldc': ldc, 'body_percentage': body_percentage}
while True:
for stock_name in fno_watchlist:
current_time = datetime.datetime.now().time()
live_pnl = tsl.get_live_pnl()
if current_time < datetime.time(9,20):
print(f"Wait to start scanning", current_time)
time.sleep(60)
continue
if current_time > datetime.time(10,30) or (live_pnl < max_loss):
print(f"Entry is closed", current_time)
time.sleep(60)
break
# Get daily data for current stock
daily_stock_data = daily_data.get(stock_name)
if not daily_stock_data:
continue
r1 = daily_stock_data['r1']
p = daily_stock_data['p']
s1 = daily_stock_data['s1']
ldc = daily_stock_data['ldc']
body_percentage = daily_stock_data['body_percentage']
chart_5 = tsl.get_historical_data(stock_name, "NSE", "5")
if chart_5 is not None:
chart_5["rsi"] = talib.RSI(chart_5['close'], timeperiod=14)
chart_5['average_volume'] = chart_5['volume'].rolling(window=20).mean()
chart_5.set_index(pd.DatetimeIndex(chart_5['timestamp']), inplace=True)
chart_5['vwap'] = pta.vwap(chart_5['high'],chart_5['low'],chart_5['close'],chart_5['volume'])
indi = ta.supertrend(chart_5['high'],chart_5['low'],chart_5['close'],10,2)
chart_5 = pd.concat([chart_5, indi],axis=1, join='inner')
scanned_candle = chart_5.iloc[-2]
breakout_candle = chart_5.iloc[-1]
first_candle = chart_5.between_time("9:15","09:15").iloc[-1]
no_repeat_order = stock_name not in traded_watchlist
max_order_limit = len(traded_watchlist) <= max_trades
print(f"scanning for {stock_name} {current_time}")
#---------------------previous day high breakout with 2% change------------------
if breakout_candle['close'] > ldc['high'] and body_percentage > 2:
bc1 = scanned_candle['rsi'] > 65 and scanned_candle['close'] > scanned_candle['SUPERT_10_2.0'] and scanned_candle['close'] > scanned_candle['vwap'] and scanned_candle['volume'] > scanned_candle['average_volume']
bc2 = breakout_candle['close'] > scanned_candle['high'] and breakout_candle['rsi'] > scanned_candle['rsi'] and breakout_candle['volume'] > breakout_candle['average_volume']
bc3 = breakout_candle['close'] > p and scanned_candle['close'] > scanned_candle['open'] and first_candle['volume'] > first_candle['average_volume'] * 2 and first_candle['close'] > first_candle['open']
if bc1 and bc2 and bc3 and no_repeat_order and max_order_limit:
ltp = tsl.get_ltp_data(names=[stock_name])[stock_name]
if ltp > first_candle['high']:
print(f"CALL signal is generated buy this script {stock_name} at {breakout_candle['high']}" )
ce_name,pe_name,strike = tsl.ATM_Strike_Selection(stock_name, Expiry=0)
ce_ltp = tsl.get_ltp_data(names=[ce_name])[ce_name]
lot_size = tsl.get_lot_size(ce_name)*1
capital_required = round((ce_ltp * lot_size),1)
entry_price = round((ce_ltp * 1.02),2)
sl_price = round((ce_ltp * 0.85),2)
tg_price = round((ce_ltp * 1.40),2)
print (f"{ce_name} required capital is {capital_required}, entry price is {entry_price}, stoploss is {sl_price}, target price is {tg_price}")
scanned_watchlist.append(stock_name)
print(scanned_watchlist)
encoded_message = f"CASH ENTRY \n {stock_name} is forming a signal \n do enter for cash entry at {breakout_candle['high']}. \n current ltp is {ltp} 1\n\n DERIVATIVE ENTRY \n {stock_name} at {ce_name} required capital is {capital_required}, entry price is {entry_price},stoploss is {sl_price}, target price is {tg_price}"
telegram_alert = tsl.send_telegram_alert(encoded_message,receiver_chat_id, bot_token)
else:
encoded_message = (f"High is not broken yet buy {stock_name} at {first_candle['high']} or {breakout_candle['high']} whichever is high. current ltp is {ltp}")
telegram_alert = tsl.send_telegram_alert(encoded_message,receiver_chat_id, bot_token)
if breakout_candle['close'] < ldc['low'] and body_percentage < (-2):
sc1 = scanned_candle['rsi'] < 35 and scanned_candle['close'] < scanned_candle['SUPERT_10_2.0'] and scanned_candle['close'] < scanned_candle['vwap'] and scanned_candle['close'] < scanned_candle['open'] and scanned_candle['volume'] > scanned_candle['average_volume']
sc2 = breakout_candle['rsi'] < scanned_candle['rsi'] and breakout_candle['close'] < scanned_candle['low'] and breakout_candle['open'] > breakout_candle['close'] and breakout_candle['volume'] > breakout_candle['average_volume']
sc3 = breakout_candle['close'] < p and breakout_candle['open'] > breakout_candle['close'] and first_candle['volume'] > first_candle['average_volume'] * 2 and first_candle['close'] < first_candle['open']
if sc1 and sc2 and sc3 and no_repeat_order and max_order_limit:
ltp = tsl.get_ltp_data(names=[stock_name])[stock_name]
if ltp < first_candle['low']:
print(f"PUT signal is generate buy this script {stock_name} at {breakout_candle['low']}")
ce_name, pe_name, strike = tsl.ATM_Strike_Selection(stock_name, Expiry=0)
pe_ltp = tsl.get_ltp_data(names=[pe_name])[pe_name]
lot_size = tsl.get_lot_size(pe_name)*1
capital_required = round((pe_ltp * lot_size),1)
entry_price = round((pe_ltp * 1.02),2)
sl_price = round((pe_ltp * 0.85),2)
tg_price = round((pe_ltp * 1.40),2)
print(f"{pe_name} required capital is {capital_required}, entry price is {entry_price}, stoploss is {sl_price}, target price is {tg_price}")
scanned_watchlist.append(stock_name)
print(scanned_watchlist)
encoded_message = f"{stock_name} is forming a signal, CASH ENTRY \n AT {breakout_candle['low']}. \n current ltp is {ltp} 1\n\n DERIVATIVE ENTRY \n {pe_name} required capital is {capital_required}, \n entry price is {entry_price}, \n stoploss is {sl_price},\n target price is {tg_price}"
telegram_alert = tsl.send_telegram_alert(encoded_message,receiver_chat_id, bot_token)
else:
encoded_message = f"low is not broken yet, sell {stock_name} at {first_candle['low']} or {breakout_candle['low']} whichever is low. current ltp is {ltp}"
telegram_alert = tsl.send_telegram_alert(encoded_message,receiver_chat_id, bot_token)
# things to learn for algo - open interest (add highest open interest levels as support and resistance)
# learn how to backtest the strategy
Hi @Ganesh,
refere the code below:
orderid = '12241210603927' order_status = tsl.get_order_status(orderid=orderid)
2.Get Order Cancelation
orderid = ‘12241210603927’ order_status = tsl.cancel_order(OrderID=orderid)
Hi Imran. Any update on this pls ? Would there be any other work around to place both stop loss and profit at the time of order placement pls ? Your youtube videos has inspired me to try algo pls. Thank you…
thanks sir now my first live algo is ready and working perfectly … thanks sir again to take me in next level of trading career.
def trail_stop_loss(self, trade_dict):
india_tz = pytz.timezone('Asia/Kolkata')
end_time = datetime.now(india_tz).replace(hour=15, minute=15, second=0, microsecond=0)
while True:
current_time_india = datetime.now(india_tz)
orderbook = self.get_orderbook()
if current_time_india >= end_time:
print("Time is 3:15 PM or later. Cancelling all orders.")
self.cancel_all_orders()
break
if 'PENDING' not in orderbook['orderStatus'].values:
print("No orders are pending. Breaking the loop.")
break
for stock, details in trade_dict.items():
call_at_the_money = details['Option']
stop_loss = details['Stop_Loss']
average_buy_price = details['average_buy_price']
stop_loss_order_id = details['stop_loss_order_id']
ltp = self.get_ltp_data(names=[call_at_the_money])[call_at_the_money]
profit_percentage = ((ltp - average_buy_price) / average_buy_price) * 100
# Determine the new stop loss based on profit percentage
if profit_percentage >= 75:
new_stop_loss = ltp * 0.95 # 5% stop loss
elif profit_percentage >= 50:
new_stop_loss = ltp * 0.90 # 10% stop loss
else:
new_stop_loss = ltp * 0.80 # 20% stop loss
if new_stop_loss > stop_loss:
self.modify_order(
order_id=stop_loss_order_id,
oder_type='STOPMARKET',
trigger_price=new_stop_loss
)
trade_dict[stock]['Stop Loss'] = new_stop_loss
print(f"Updated stop loss for {stock} to {new_stop_loss}")
time.sleep(1)
Input DIct.
traded_stocks[stock] = {
'Option': call_at_the_money,
'Stop_Loss': stop_loss,
'average_buy_price': average_buy_price,
'stop_loss_order_id': Stop_loss_order_id
}
Hello, Imran sir @Tradehull_Imran ,
I implemented, Dynamic Trailing_stop_loss
, which moves closer as the profit increases,
would it be a good approach? here we just update the initial stop_loss order
one more question I have is, once we modify_order(), do we use the new order_id
? or it stay the same?
Sorry, it is difficult to test for me as
Market hours are not available for me, as at the time is midnight for me, as I live outside of India.
Hello @Tradehull_Imran Sir,
I have downloaded from Latest codebase link - 3.1 Codebase Upgrade.zip - Google Drive
Below file I have fixed some part like
from Dhan_Tradehull import Tradehull
to from Dhan_Tradehull_V2 import Tradehull
'NIFTY 19 DEC 24000 PUT'
to 'NIFTY 27 FEB 23000 PUT'
etc
How to use updated codebase.py ( Downloaded code below )
import pdb
import time
import datetime
import traceback
from Dhan_Tradehull import Tradehull
import pandas as pd
from pprint import pprint
import talib
client_code = "1102790337"
token_id = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJkaGFuIiwicGFydG5lcklkIjoiIiwiZXhwIjoxNzM2ODYwMTMxLCJ0b2tlbkNvbnN1bWVyVHlwZSI6IlNFTEYiLCJ3ZWJob29rVXJsIjoiIiwiZGhhbkNsaWVudElkIjoiMTEwMjc5MDMzNyJ9.Leop6waGeVfmBOtczNEcjRWmC8pUGWQf54YPINGDi_PZjk1IvW-DDdaYXsgM_s8McOT44q4MjEQxGXU0lduK0A"
tsl = Tradehull(client_code,token_id)
all_ltp_data = tsl.get_ltp_data(names = ['NIFTY 19 DEC 24000 akshdgasjhgdhgasjgdhjagsdCALL', 'NIFTY 19 DEC 24000 PUT', "ACC", "CIPLA"])
acc_ltp = all_ltp_data['ACC']
pe_ltp = all_ltp_data['NIFTY 19 DEC 24000 PUT']
stock_name = 'NIFTY'
ltp = tsl.get_ltp_data(names = [stock_name])[stock_name]
chart = tsl.get_historical_data(tradingsymbol = 'NIFTY', exchange = 'INDEX',timeframe="DAY")
data = tsl.get_historical_data(tradingsymbol = 'NIFTY 19 DEC 24000 CALL' ,exchange = 'NFO' ,timeframe="15")
order_status = tsl.get_order_status(orderid=82241218256027)
order_price = tsl.get_executed_price(orderid=82241218256027)
order_time = tsl.get_exchange_time(orderid=82241218256027)
positions = tsl.get_positions()
orderbook = tsl.get_orderbook()
tradebook = tsl.get_trade_book()
holdings = tsl.get_holdings()
ce_name, pe_name, strike = tsl.ATM_Strike_Selection(Underlying='NIFTY', Expiry=0)
ce_name, pe_name, ce_strike, pe_strike = tsl.OTM_Strike_Selection(Underlying='NIFTY', Expiry=0, OTM_count=3)
ce_name, pe_name, ce_strike, pe_strike = tsl.ITM_Strike_Selection(Underlying='NIFTY', Expiry=0, OTM_count=5)
# Equity
entry_orderid = tsl.order_placement(tradingsymbol='ACC' ,exchange='NSE', quantity=1, price=0, trigger_price=0, order_type='MARKET', transaction_type='BUY', trade_type='MIS')
sl_orderid = tsl.order_placement(tradingsymbol='ACC' ,exchange='NSE', quantity=1, price=0, trigger_price=2200, order_type='STOPMARKET', transaction_type ='SELL', trade_type='MIS')
# Options
entry_orderid = tsl.order_placement(tradingsymbol='NIFTY 19 DEC 24400 CALL' ,exchange='NFO', quantity=50, price=0, trigger_price=0, order_type='MARKET', transaction_type='BUY', trade_type='MIS')
sl_orderid = tsl.order_placement(tradingsymbol='NIFTY 19 DEC 24400 CALL' ,exchange='NFO', quantity=25, price=29, trigger_price=30, order_type='STOPLIMIT', transaction_type='SELL', trade_type='MIS')
modified_order = tsl.modify_order(order_id=sl_orderid,order_type="STOPLIMIT",quantity=50,price=price,trigger_price=trigger_price)
order_ids = tsl.place_slice_order(tradingsymbol="NIFTY 19 DEC 24400 CALL", exchange="NFO",quantity=5000, transaction_type="BUY",order_type="LIMIT",trade_type="MIS",price=0.05)
margin = tsl.margin_calculator(tradingsymbol='ACC', exchange='NSE', transaction_type='BUY', quantity=2, trade_type='MIS', price=2180, trigger_price=0)
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)
margin = tsl.margin_calculator(tradingsymbol='NIFTY 19 DEC 24400 CALL', exchange='NFO', transaction_type='BUY', quantity=25, trade_type='MARGIN', price=43, trigger_price=0)
margin = tsl.margin_calculator(tradingsymbol='NIFTY DEC FUT', exchange='NFO', transaction_type='BUY', quantity=25, trade_type='MARGIN', price=24350, trigger_price=0)
exit_all = tsl.cancel_all_orders()
Updated code below
import pdb
import time
import datetime
import traceback
from Dhan_Tradehull_V2 import Tradehull
import pandas as pd
from pprint import pprint
import talib
client_code = ""
token_id = ""
tsl = Tradehull(client_code,token_id)
all_ltp_data = tsl.get_ltp_data(names = ['NIFTY 27 FEB 23000 CALL', 'NIFTY 27 FEB 23000 PUT', "ACC", "CIPLA"])
acc_ltp = all_ltp_data['ACC']
pe_ltp = all_ltp_data['NIFTY 27 FEB 23000 PUT']
stock_name = 'NIFTY'
ltp = tsl.get_ltp_data(names = [stock_name])[stock_name]
chart = tsl.get_historical_data(tradingsymbol = 'NIFTY', exchange = 'INDEX',timeframe="DAY")
data = tsl.get_historical_data(tradingsymbol = 'NIFTY 27 FEB 23000 PUT' ,exchange = 'NFO' ,timeframe="15")
order_status = tsl.get_order_status(orderid=82241218256027)
order_price = tsl.get_executed_price(orderid=82241218256027)
order_time = tsl.get_exchange_time(orderid=82241218256027)
positions = tsl.get_positions()
orderbook = tsl.get_orderbook()
tradebook = tsl.get_trade_book()
holdings = tsl.get_holdings()
ce_name, pe_name, strike = tsl.ATM_Strike_Selection(Underlying='NIFTY', Expiry=0)
ce_name, pe_name, ce_strike, pe_strike = tsl.OTM_Strike_Selection(Underlying='NIFTY', Expiry=0, OTM_count=3)
ce_name, pe_name, ce_strike, pe_strike = tsl.ITM_Strike_Selection(Underlying='NIFTY', Expiry=0, OTM_count=5)
# Equity
entry_orderid = tsl.order_placement(tradingsymbol='ACC' ,exchange='NSE', quantity=1, price=0, trigger_price=0, order_type='MARKET', transaction_type='BUY', trade_type='MIS')
sl_orderid = tsl.order_placement(tradingsymbol='ACC' ,exchange='NSE', quantity=1, price=0, trigger_price=2200, order_type='STOPMARKET', transaction_type ='SELL', trade_type='MIS')
# Options
entry_orderid = tsl.order_placement(tradingsymbol='NIFTY 27 FEB 23000 CALL' ,exchange='NFO', quantity=50, price=0, trigger_price=0, order_type='MARKET', transaction_type='BUY', trade_type='MIS')
sl_orderid = tsl.order_placement(tradingsymbol='NIFTY 27 FEB 23000 CALL' ,exchange='NFO', quantity=25, price=29, trigger_price=30, order_type='STOPLIMIT', transaction_type='SELL', trade_type='MIS')
modified_order = tsl.modify_order(order_id=sl_orderid,order_type="STOPLIMIT",quantity=50,price=price,trigger_price=trigger_price)
order_ids = tsl.place_slice_order(tradingsymbol="NIFTY 27 FEB 23000 CALL", exchange="NFO",quantity=5000, transaction_type="BUY",order_type="LIMIT",trade_type="MIS",price=0.05)
margin = tsl.margin_calculator(tradingsymbol='ACC', exchange='NSE', transaction_type='BUY', quantity=2, trade_type='MIS', price=2180, trigger_price=0)
margin = tsl.margin_calculator(tradingsymbol='NIFTY 27 FEB 23000 CALL', exchange='NFO', transaction_type='SELL', quantity=25, trade_type='MARGIN', price=43, trigger_price=0)
margin = tsl.margin_calculator(tradingsymbol='NIFTY 27 FEB 23000 CALL', exchange='NFO', transaction_type='BUY', quantity=25, trade_type='MARGIN', price=43, trigger_price=0)
margin = tsl.margin_calculator(tradingsymbol='NIFT FEB PUT', exchange='NFO', transaction_type='BUY', quantity=25, trade_type='MARGIN', price=24350, trigger_price=0)
exit_all = tsl.cancel_all_orders()
Output
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/3.1 Codebase Upgrade/How to use updated codebase.py"
Codebase Version 2.8 : Solved - Strike Selection Issue
-----Logged into Dhan-----
reading existing file all_instrument 2025-02-07.csv
Got the instrument file
Error at getting order status as list index out of range
Error at get_executed_price as list index out of range
Error at get_exchange_time as list index out of range
Traceback (most recent call last):
File "c:/Users/Subhajit Panja/Documents/Algorithim_HQ/3.1 Codebase Upgrade/How to use updated codebase.py", line 49, in <module>
ce_name, pe_name, ce_strike, pe_strike = tsl.ITM_Strike_Selection(Underlying='NIFTY', Expiry=0, OTM_count=5)
TypeError: ITM_Strike_Selection() got an unexpected keyword argument 'OTM_count'
PS C:\Users\Subhajit Panja\Documents\Algorithim_HQ>
How it is still getting
reading existing file
all_instrument 2025-02-07.csv
@Tradehull_Imran Unable to file access.plz give the access.thanks
chart = tsl.get_intraday_data('NIFTY FEB FUT', 'NSE', 5)
Error:
Exception: {'status': 'failure', 'remarks': {'error_code': 'DH-907', 'error_type': 'Data_Error', 'error_message': 'System is unable to fetch data due to incorrect parameters or no data present'}, 'data': {'errorType': 'Data_Error', 'errorCode': 'DH-907', 'errorMessage': 'System is unable to fetch data due to incorrect parameters or no data present'}}
Very Good Moring Sir. Is this Latest 3.1 codebase Upgrade is to updated by everyone in the group.
I mean to say , is it updated in the very recent days?
VBR Prasad