@Tradehull_Imran hi sir mene youtube pr session 8 dekha or code ko copy kiya pr mere isme error aa rhi hai
wait for market to start 09:29:58.468498
wait for market to start 09:29:59.547835
MOTHERSON
dhanhq.intraday_minute_data() takes 4 positional arguments but 7 were given
Traceback (most recent call last):
File "/Users/vijju/Desktop/Stock Algo/Dhan Algo/8. Session8- 2nd Live Algo/2nd live Algo/Dhan_Tradehull_V2.py", line 257, in get_historical_data
ohlc = self.Dhan.intraday_minute_data(str(security_id),exchange_segment,instrument_type,self.start_date,self.end_date,int(interval))
TypeError: dhanhq.intraday_minute_data() takes 4 positional arguments but 7 were given
Traceback (most recent call last):
File "/Users/vijju/Desktop/Stock Algo/Dhan Algo/8. Session8- 2nd Live Algo/2nd live Algo/Multi timeframe Algo.py", line 58, in <module>
chart_1['rsi'] = talib.RSI(chart_1['close'], timeperiod=14) #pandas
TypeError: 'NoneType' object is not subscriptable
vijjus-MacBook-Air:8. Session8- 2nd Live Algo vijju$
ye mera code hai
# https://ta-lib.github.io/ta-lib-python/
# https://www.notion.so/TradeHull-Dhan-Codebase-76b32fa814e64aea843e14a148854214#efa40986725341e6bfa9ad6fcfc10a6d
import pdb
from Dhan_Tradehull_V2 import Tradehull
import pandas as pd
import talib
import time
import datetime
client_code = "1101529493"
token_id = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJkaGFuIiwicGFydG5lcklkIjoiIiwiZXhwIjoxNzMxNzcxMDU4LCJ0b2tlbkNvbnN1bWVyVHlwZSI6IlNFTEYiLCJ3ZWJob29rVXJsIjoiIiwiZGhhbkNsaWVudElkIjoiMTEwMTUyOTQ5MyJ9.Oo3_dwF1lGkiSenKu-XdpsMZIav5og-BK2CxzuTPyaAZGyUMDJEb_lCaTOLXwydfeeXbwzeKRs3pHXhlosKGGQ"
tsl = Tradehull(client_code,token_id) # tradehull_support_library
available_balance = tsl.get_balance()
leveraged_margin = available_balance*5
max_trades = 3
per_trade_margin = (leveraged_margin/max_trades)
max_loss = (available_balance*1)/100*-1
watchlist = ['MOTHERSON', 'OFSS', 'MANAPPURAM', 'BSOFT', 'CHAMBLFERT', 'DIXON', 'NATIONALUM', 'DLF', 'IDEA', 'ADANIPORTS', 'SAIL', 'HINDCOPPER', 'INDIGO', 'RECLTD', 'PNB', 'HINDALCO', 'RBLBANK', 'GNFC', 'ALKEM', 'CONCOR', 'PFC', 'GODREJPROP', 'MARUTI', 'ADANIENT', 'ONGC', 'CANBK', 'OBEROIRLTY', 'BANDHANBNK', 'SBIN', 'HINDPETRO', 'CANFINHOME', 'TATAMOTORS', 'LALPATHLAB', 'MCX', 'TATACHEM', 'BHARTIARTL', 'INDIAMART', 'LUPIN', 'INDUSTOWER', 'VEDL', 'SHRIRAMFIN', 'POLYCAB', 'WIPRO', 'UBL', 'SRF', 'BHARATFORG', 'GRASIM', 'IEX', 'BATAINDIA', 'AARTIIND', 'TATASTEEL', 'UPL', 'HDFCBANK', 'LTF', 'TVSMOTOR', 'GMRINFRA', 'IOC', 'ABCAPITAL', 'ACC', 'IDFCFIRSTB', 'ABFRL', 'ZYDUSLIFE', 'GLENMARK', 'TATAPOWER', 'PEL', 'IDFC', 'LAURUSLABS', 'BANKBARODA', 'KOTAKBANK', 'CUB', 'GAIL', 'DABUR', 'TECHM', 'CHOLAFIN', 'BEL', 'SYNGENE', 'FEDERALBNK', 'NAVINFLUOR', 'AXISBANK', 'LT', 'ICICIGI', 'EXIDEIND', 'TATACOMM', 'RELIANCE', 'ICICIPRULI', 'IPCALAB', 'AUBANK', 'INDIACEM', 'GRANULES', 'HDFCAMC', 'COFORGE', 'LICHSGFIN', 'BAJAJFINSV', 'INFY', 'BRITANNIA', 'M&MFIN', 'BAJFINANCE', 'PIIND', 'DEEPAKNTR', 'SHREECEM', 'INDUSINDBK', 'DRREDDY', 'TCS', 'BPCL', 'PETRONET', 'NAUKRI', 'JSWSTEEL', 'MUTHOOTFIN', 'CUMMINSIND', 'CROMPTON', 'M&M', 'GODREJCP', 'IGL', 'BAJAJ-AUTO', 'HEROMOTOCO', 'AMBUJACEM', 'BIOCON', 'ULTRACEMCO', 'VOLTAS', 'BALRAMCHIN', 'SUNPHARMA', 'ASIANPAINT', 'COALINDIA', 'SUNTV', 'EICHERMOT', 'ESCORTS', 'HAL', 'ASTRAL', 'NMDC', 'ICICIBANK', 'TORNTPHARM', 'JUBLFOOD', 'METROPOLIS', 'RAMCOCEM', 'INDHOTEL', 'HINDUNILVR', 'TRENT', 'TITAN', 'JKCEMENT', 'ASHOKLEY', 'SBICARD', 'BERGEPAINT', 'JINDALSTEL', 'MFSL', 'BHEL', 'NESTLEIND', 'HDFCLIFE', 'COROMANDEL', 'DIVISLAB', 'ITC', 'TATACONSUM', 'APOLLOTYRE', 'AUROPHARMA', 'HCLTECH', 'LTTS', 'BALKRISIND', 'DALBHARAT', 'APOLLOHOSP', 'ABBOTINDIA', 'ATUL', 'UNITDSPR', 'PVRINOX', 'SIEMENS', 'SBILIFE', 'IRCTC', 'GUJGASLTD', 'BOSCHLTD', 'NTPC', 'POWERGRID', 'MARICO', 'HAVELLS', 'MPHASIS', 'COLPAL', 'CIPLA', 'MGL', 'ABB', 'PIDILITIND', 'MRF', 'LTIM', 'PAGEIND', 'PERSISTENT']
# watchlist = ['CRUDEOIL']
traded_wathclist = []
while True:
live_pnl = tsl.get_live_pnl()
current_time = datetime.datetime.now().time()
if current_time < datetime.time(9, 30):
print("wait for market to start", current_time)
continue
if (current_time > datetime.time(15, 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)
# Conditions that are on 1 minute timeframe
# chart_1 = tsl.get_intraday_data(stock_name, 'NSE', 1) # 1 minute chart # this call has been updated to get_historical_data call,
chart_1 = tsl.get_historical_data(tradingsymbol = stock_name,exchange = 'NSE',timeframe="1")
chart_1['rsi'] = talib.RSI(chart_1['close'], timeperiod=14) #pandas
cc_1 = chart_1.iloc[-2] #pandas completed candle of 1 min timeframe
uptrend = cc_1['rsi'] > 50
# downtrend = cc_1['rsi'] < 49
# Conditions that are on 5 minute timeframe
# chart_5 = tsl.get_intraday_data(stock_name, 'NSE', 5) # 5 minute chart
chart_5 = tsl.get_historical_data(tradingsymbol = stock_name,exchange = 'NSE',timeframe="5") # this call has been updated to get_historical_data call,
chart_5['upperband'], chart_5['middleband'], chart_5['lowerband'] = talib.BBANDS(chart_5['close'], timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
cc_5 = chart_5.iloc[-1] # pandas
ub_breakout = cc_5['high'] > cc_5['upperband']
# lb_breakout = cc_5['low'] < cc_5['lowerband']
no_repeat_order = stock_name not in traded_wathclist
max_order_limit = len(traded_wathclist) <= max_trades
if uptrend and ub_breakout and no_repeat_order and max_order_limit:
print(stock_name, "is in uptrend, Buy this script")
sl_price = round((cc_1['close']*0.98),1)
qty = int(per_trade_margin/cc_1['close'])
buy_entry_orderid = tsl.order_placement(stock_name,'NSE', 1, 0, 0, 'MARKET', 'BUY', 'MIS')
sl_orderid = tsl.order_placement(stock_name,'NSE', 1, 0, sl_price, 'STOPMARKET', 'SELL', 'MIS')
traded_wathclist.append(stock_name)
# if downtrend and lb_breakout and no_repeat_order and max_order_limit:
# print(stock_name, "is in downtrend, Sell this script")
# sl_price = round((cc_1['close']*1.02),1)
# qty = int(per_trade_margin/cc_1['close'])
# buy_entry_orderid = tsl.order_placement(stock_name,'NSE', 1, 0, 0, 'MARKET', 'SELL', 'MIS')
# sl_orderid = tsl.order_placement(stock_name,'NSE', 1, 0, sl_price, 'STOPMARKET', 'BUY', 'MIS')
# traded_wathclist.append(stock_name)