Learn Algo Trading with Python | Codes | Youtube Series

@Tradehull_Imran sir I have one question

Sir, You have updated for Master Algo Trading with Python | Episode 8: Build Your Second Live Algo

But what action I should take for older videos(1-7) please suggest

Dear sir

can we restrict the historical data into time bond,
just we can say that ,i want previous day hysterical data only for last 30 min to till now time
is our tradehull code by this.
if not what change we have to do.

Hi
@Tradehull_Imran
How to solve following errors


Codebase Version 2.1
-----Logged into Dhan-----
reading existing file all_instrument 2024-11-22.csv
Got the instrument file
M&M its free, Buy this script
Error at get_executed_price as list index out of range
Traceback (most recent call last):
File “Demo1.py”, line 88, in
sl_price1 = round((cc_2[‘low’]*0.999),0.5)
TypeError: integer argument expected, got float


reading existing file all_instrument 2024-11-22.csv
Got the instrument file
M&M its free, Buy this script
Error at get_executed_price as list index out of range
Traceback (most recent call last):
File “Demo1.py”, line 89, in
target_1 = order_price + ((order_price - sl_price1)*2)
TypeError: unsupported operand type(s) for -: ‘dict’ and ‘float’

Hello @Tradehull_Imran
I want to execute scalping strategy with 5 points profit and stoploss.
How can I place the trade or how can I place Bracket order so that profit and stoploss can be placed at the same time.
How can I place target and stoploss at the same time in points.

Hi @Aijaz_Ahmad

To cancel order after certain time if its still pending use this example code


buy_entry_orderid = tsl.order_placement(tradingsymbol='TATASTEEL', exchange='NSE', quantity=1, price=138, trigger_price=0, order_type='LIMIT', transaction_type='BUY', trade_type ='MIS')


while True:

	time.sleep(3)

	current_time = datetime.datetime.now()

	try:
		order_detail = tsl.get_order_detail(orderid=buy_entry_orderid)
		orderStatus  = order_detail['orderStatus']
		createTime   = order_detail['createTime']
	except Exception as e:
		print(e)
		continue


	print(current_time)

	createTime   = datetime.datetime.strptime(createTime, '%Y-%m-%d %H:%M:%S')
	wait_time_over = current_time > (createTime + datetime.timedelta(minutes=1))

	if (orderStatus == "PENDING") and wait_time_over:
		tsl.Dhan.cancel_order(buy_entry_orderid)
		break

Hi @Kalpeshh_Patel

Yes calling get_historical_data for the watchlist you mentioned
will result to 10 data api calls

Hi @Subhajitpanja

No action required for session 1-7 , it was majorly python and codebase.

1 Like

Hi @Deodas_kumar
Yes it can be done by defining start datetime

But restricting the data would not give any additional benefits because ,

it will be still counted as 1 data api call and it would take nearly same time to fetch the trimmed data.

Hi @Kalpeshh_Patel

  1. Use
    sl_price1 = round((cc_2[‘low’]*0.999),1)

  2. In below code order_price seems to be dictionary, so its not allowing addition
    target_1 = order_price + ((order_price - sl_price1)*2)

Hi @Scooby_Doo

use below code to place Bracket Order


tradingsymbol = 'TATASTEEL'
exchange = tsl.Dhan.NSE
security_id = tsl.instrument_df[((tsl.instrument_df['SEM_TRADING_SYMBOL']==tradingsymbol)|(tsl.instrument_df['SEM_CUSTOM_SYMBOL']==tradingsymbol))&(tsl.instrument_df['SEM_EXM_EXCH_ID']=='NSE')].iloc[-1]['SEM_SMST_SECURITY_ID']
tsl.Dhan.place_order(security_id=int(security_id), exchange_segment=exchange, transaction_type='BUY', quantity=1,order_type='MARKET', product_type='BO', price=0, trigger_price=0, disclosed_quantity=0, after_market_order=False, validity='DAY', amo_time='OPEN',bo_profit_value=5, bo_stop_loss_Value=5, tag=None)

Hi everyone,

New video releasing today.

4 Likes

Hi @Tradehull_Imran
I’m getting the below error while using modify_order and cancel_order functions. Could you pls suggest what needs to be done

p_orders = pd.DataFrame(self.xts1.get_order_book()['result'])
                        ^^^^^^^^^

AttributeError: ‘Tradehull’ object has no attribute ‘xts1’

@Tradehull_Imran Sir morning it was working fine just 30mins ago it is failing

something is happening we need to check

I just ran left Now now I am facing.
yesterday also saw some massage like yesterday it was working today not I don’t exactly is that same issue or not

@Zee2Zahid can you please check from your side also
just run left 2 file

1.Multi timeframe Algo.py

from
Master Algo Trading with Python | Episode 8: Build Your Second Live Algo

and

    1. Good Historical Data.py
      from Api Upgrade

and @Tradehull_Imran sir before posting this I deleted all the folder again download and follow all process but still result is same


@Tradehull_Imran sir this one also valid

RELIANCE
Exception in Getting OHLC data as {'status': 'failure', 'remarks': {'error_code': 'DH-904', 'error_type': 'Rate_Limit', 'error_message': 'Too many requests on server from single user breaching rate limits. Try throttling API calls.'}, 'data': {'errorType': 'Rate_Limit', 'errorCode': 'DH-904', 'errorMessage': 'Too many requests on server from single user breaching rate limits. Try throttling API calls.'}}
Exception in Getting OHLC data as {'status': 'failure', 'remarks': {'error_code': 'DH-904', 'error_type': 'Rate_Limit', 'error_message': 'Too many requests on server from single user breaching rate limits. Try throttling API calls.'}, 'data': {'errorType': 'Rate_Limit', 'errorCode': 'DH-904', 'errorMessage': 'Too many requests on server from single user breaching rate limits. Try throttling API calls.'}}

> error string is below

Hi @Subhajitpanja
This error is because rate limits were breached.

see : Learn Algo Trading with Python | Codes | Youtube Series - #860 by Tradehull_Imran

you need to implement time.sleep(3) after calling data from api

Sorry @Tradehull_Imran sir this the disadvantage of late practice.
Thank you so much. I am checking

Hi @kristrades99

Use below code to cancel order
tsl.Dhan.cancel_order(buy_entry_orderid)

for order modification the codebase support will be released in Dhan_Tradehull_V3

1 Like

@Tradehull_Imran sir. I can one example also

70% to 75% doubt already clear. Rest of the doubt hopefully will be clear after watching your video again and with lots of practice

1 Like

Thank you :pray:. This worked!!

1 Like

Sir can this apply on options because whenever i apply the code on index options trading the order is getting rejected because of ‘trigger price is not in range.’ But if i place stoploss and target of more than 30 points then the Bracket order is getting executed.

Otherwise how can we apply the code on options scalping for 3 points or 5 points or 10 points

Thanks it worked.

1 Like