Learn Algo Trading with Python | Codes | Youtube Series

Hye sir @Tradehull_Imran
why i get this error while testing Algo for crudeoil in the evening time, I am using time.sleep(1)
I’m now using time.sleep(30), how to avoid Rate Limit error

Hi
@Tradehull_Imran
Now my code is working good
But
While I am working with moving average it gives wrong data or something mossing by me
So request you to please do correct it
Function given below which I use - 20 moving average and 15 min time frame

chart_15[‘ma’] = talib.MA(chart_15[‘close’], timeperiod=15, matype=0)

And one more favour
How to add supertrend in time frame as stop loss of triger a trade

Thank You

Hi,

Unable to understand…totally confuse…

Hi, It’s correct and I am able to get available balance.

Hi @Tradehull_Imran

Did you get a chance to look into my issue. If so, please guide me to resolve it.

Thanks @Tradehull_Imran, i am able to place SL and target orders… i need to write a logic… when SL hit target order automatically cancelled and vice versa…

Hi @Tradehull_Imran,

I am trying to buy the stock at the limit price, but whenever I am using the below code, the order get’s executed at market price instead of limit price.

In the below code, I want to buy the stock at 719 price but it get’s executed at current market price.

buy_entry_orderid = tsl.order_placement(first_stock['Ticker'], 'NSE', 1, 719, 0, 'LIMIT', 'BUY', 'MIS')

and if I try this way I get error:

(Pdb++) buy_entry_orderid = tsl.order_placement(first_stock['Ticker'], 'NSE', 1, 0, 719, 'LIMIT', 'BUY', 'MIS')

Traceback (most recent call last):
  File "C:\Users\Aijaz\AppData\Local\Programs\Python\Python38\lib\cmd.py", line 214, in onecmd
    func = getattr(self, 'do_' + cmd)
AttributeError: 'Pdb' object has no attribute 'do_buy_entry_orderid'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Dhan\My Algo\Dhan_Tradehull_V2.py", line 144, in order_placement
    orderid = order["data"]["orderId"]
KeyError: 'orderId'

Hi @Minakshi_Kuila

  1. Do use latest file for Dhan_Tradehull_V2 :
    see : Learn Algo Trading with Python | Codes | Youtube Series - #827 by Tradehull_Imran

  2. Also it may be a version mismatch issue , send following commands on CMD

pip uninstall dhanhq

pip install dhanhq==2.0.0

pip show dhanhq

Hi @avinashkumar07412
use below code to get values for pivot points

def get_pivot_point(chart_data):
    PP = (chart_data['high'].max() + chart_data['low'].min() + chart_data["close"].iloc[-1])/3 
    R1 = 2 * PP - chart_data['low'].min()
    R2 = PP + (chart_data['high'].max() - chart_data['low'].min())         
    R3 = PP + 2 * (chart_data['high'].max() - chart_data['low'].min())          
    S1 = 2 * PP - chart_data['high'].max()          
    S2 = PP - (chart_data['high'].max() - chart_data['low'].min())
    S3 = PP - 2 * (chart_data['high'].max() - chart_data['low'].min()) 

    return PP, R1, R2, R3, S1, S2, S3


1 Like

Hi @Zee2Zahid

Rate : is basically no of time we call the api
Rate limit : is the maximum number of time we can call the api

rate limit error

{‘errorType’: ‘Rate_Limit’, ‘errorCode’: ‘DH-904’, ‘errorMessage’: ‘Too many requests on server from single user breaching rate limits. Try throttling API calls.’}

below are the rate limits

Also rate limit reset depends on what level limit is breached.

  • If per minute rate limit is breached , it gets reset the next minute
  • If per hour rate limit is breached , it gets reset the next hour
  • If per day rate limit is breached , it gets reset the next day

when you call tsl.get_historical_data() 1 api request is spent.
we can manage rate limits by using time.sleep()

use below file to manage rate limits, is has sleep in build to manage rate limits

2 Likes

Hi @Kalpeshh_Patel

The code and values I have received seems to be correct,

chart_15 = tsl.get_historical_data(tradingsymbol='NIFTY NOV FUT', exchange='NFO', timeframe="15")
chart_15['ma'] = talib.MA(chart_15['close'], timeperiod=15, matype=0)

If still any wrong values issues, upload the dataframe with indicator attached on excel … and send me google drive link

Also for “supertrend in time frame as stop loss” , I have just created a video yesterday which talks about how can we take “supertrend in time frame as Target”, that will solve your question

Hi @shailendra1982kumar

Check the series from beginning

when you have any doubt related to any video you can ask the questions here

Hi @Jyothi_Chilukoti

client_code = sheet.range(‘C_CODE’).value
this reads client code incorrectly, print and see its value, it would add a decimal point and 0 at the end of client id.

use this code instead

import pdb
import time
import datetime
import traceback
import talib
from Dhan_Tradehull_V2 import Tradehull
import pandas as pd
from pprint import pprint
import time
import xlwings as xw

# Excel sheet setup
wb = xw.Book("Websocket.xlsx")
sheet = wb.sheets['Strategy']


client_code = int(sheet.range('C_CODE').value)
token_id = str(sheet.range('TKN_ID').value)



Hi
Thanks
Yes it works as 20 ma

How can I change 20ma to 9ma

What is the difference between
I understand that one is historical and other one is intraday but historical is also fetch intraday data
Is this right?

chart_15 = tsl.get_historical_data(tradingsymbol = stock_name,exchange = ‘NSE’,timeframe=“15”)

and

chart_15 = tsl.get_intraday_data(stock_name, ‘NSE’, 15)

1 Like

Hi
@Subhajitpanja @Zee2Zahid @Md_Naquibuddin @Jyothi_Chilukoti @rahulcse56 @Manish_Goel @Khandu_Kshirsagar @Kalpeshh_Patel @ddeogharkar @Kishore007

I would like check on your progress, Let me know.

  1. Any issues in Basic python

  2. Have you seen all sessions till now including V2 version: https://www.youtube.com/watch?v=HLiEpNZSD80

  3. Have you received historical data in okey format :
    use latest codebase if any issues : Learn Algo Trading with Python | Codes | Youtube Series - #827 by Tradehull_Imran

  4. Any issues in LTP or Order Placement
    see this if any issues in order placement : Learn Algo Trading with Python | Codes | Youtube Series - #847 by Tradehull_Imran

  5. Any pending question that you want to ask me

  6. Have you upgraded to Latest codebase
    see : Learn Algo Trading with Python | Codes | Youtube Series - #827 by Tradehull_Imran

  7. How do you feel regarding algorithmic trading now.

As of now we were working on very basic algo, soon we will start working on Intermediate level Algo, So I want things to be ready before we start.

3 Likes

@Vijen_Singh @Kuldeep_Khaladkar @jain79 @Aijaz_Ahmad @ramakriishna @Gautam_Singh_Pawar @CBrid @Hitesh_Maurya @Siddhesh_Amrute

Do update the same

1 Like

@Abhishek_Konda @CapTn_Mohit @pratik_patil2 @thakurmhn

do update the same

1 Like

Hi Sir,
I am not use pivot point, I am draw manual
support and resistance. I need to use manual draw support and resistance python code.

Hi Sir,
I am not use pivot point, I am draw manual
support and resistance. I need to use manual draw support and resistance python code.

@Tradehull_Imran

please help.