# dinezh

Best Python function to calculate RSI def calc_RSI(series, period=14): delta = series.diff().dropna() ups = delta * 0 downs = ups.copy() ups[delta > 0] = delta[delta > 0] downs[delta < 0] = -delta[delta < 0] ups[ups.index[period-1]] = np.mean( ups[:period] ) #first value is sum of avg gains ups = ups.drop(ups.index[:(period-1)]) downs[downs.index[period-1]] = np.mean( downs[:period] ) #first value is sum of avg losses downs = downs.drop(downs.index[:(period-1)]) rs = ups.ewm(com=period-1,min_periods=0,adjust=False,ignore_na=False).mean() / \ downs.ewm(com=period-1,min_periods=0,adjust=False,ignore_na=False).mean() return 100 - 100 / (1 + rs)

Username
dinezh
Joined
Visits
32
Last Active
Roles
Member

## Comments

• please make sure you're comparing right token and symbol on Kite web app and on your script
Comment by dinezh November 2020
• This code is just for understanding the idea of the algo you're asking. once you understand the idea you can completely automate it
Comment by dinezh November 2020
• @ShaileshChavan999 it's quite simple Eg: position = False breakout_price = 12000 if nifty_price > breakout_price and position == False: position = True kite.placeorder( symbol="NIFTY20NOV{ breakout_price }CE" …
Comment by dinezh November 2020
• @mlearner You did not give the "trigger price"
Comment by dinezh November 2020
• @Ninja2020 do you use multiple virtual envs?
Comment by dinezh November 2020
• @AvinashKrishnappa @madankumar This is the best method to calculate rsi This method will give you RSI values which matches TRADINGVIEW RSI values. def calc_RSI(series, period=14): delta = series.diff().dropna() ups = delta * 0 downs =…
Comment by dinezh November 2020
• @AvinashKrishnappa I don't know why it cause this error for sure, it can't find the right route maybe because you're not providing all the information of your order, Incase if you have a trigger price you must include the trigger price also. def …
Comment by dinezh November 2020
• @Hsadikot Not a problem! and you got a error for this code because I forgot to add the "," paste the below code and it'll run just fine for instrument in kite.instruments("NSE"): print(instrument['name'],':', instrument['instrument_token'])…
Comment by dinezh November 2020
• @ Hsadikot The above code will fetch data of all the symbols in NSE and it will store the data of each symbol in individual csv file You can store it to your SQL DataBase if you want I made it simple so everybody can understand.
Comment by dinezh November 2020
• @ Hsadikot from kiteconnect import KiteConnect import pandas as pd cwd = os.chdir("C:\\Users\\Administrator\\Desktop\\Zerodha") #generate trading session access_token = open("access_token.txt",'r').read() key_secret = open("credentials.txt",'r')…
Comment by dinezh November 2020
• @Hsadikot Oh for all the tokens available
Comment by dinezh November 2020
• this will work fine for now it's better to save the insturments Name, TradingSymbol, Token etc to your Database so you can fetch it easily.
Comment by dinezh November 2020
• @Hsadikot # Once you fetch the SYMBOLS from DataBase # Convert the dataframe to a list tickers = ticker["SYMBOL"].to_list() # you'll have a list of symbols that you want to fetch Historical data # Now at end of the code for instrument in kite.i…
Comment by dinezh November 2020
• Okay I think I understood wrong, What you want to do is extract 5 minute data for lists of tickers, Right
Comment by dinezh November 2020
• @Hsadikot Just run this code and you'll get the exact idea what to do next This code will return you name:token of the all the symbols in NSE just like you asked RELIANCE Happy trading! for instrument in kite.instruments("NSE"): ----print(instruem…
Comment by dinezh November 2020
• @nickmccullum so your other kite methods like kite.quote() working fine?
Comment by dinezh November 2020
• @mlearner I faced errors like this pykiteconnect with python 3.8 So this working for me fine: create a new environment. install python==3.7.7 version and all the other packages you need and everything will run just fine and most stable way.
Comment by dinezh November 2020
• can you please explain a bit more with an example?
Comment by dinezh November 2020
• 10rs is too much variation I just now calculated it using talib and numpy and the calculations matches the IQ chart Make sure that you have selected Moving average type as "SIMPLE" and not as "EXPONENTIAL" on your IQ charts and right timeframe try…
Comment by dinezh November 2020
• Nope you cannot fetch even single day data without subscribing to Kite Historical Data. If you want to save money by not subscribing to ktie historical data You can save your tick data to a Database and resample the tick data to any timeframe like 1…
Comment by dinezh November 2020
• it's very simple to calculate sma how much variation do you get from chart IQ? paste your code so others can help too try numpy mean() list = [ fetch historical data ] 20SMA = np.mean(list[-20:]) 50SMA = np.mean(list[-50:]) that's it.
Comment by dinezh November 2020
• what were you trying to do?
Comment by dinezh September 2020
• incase if you automated your login generate and assign the api_key access_token manually and if it worked then definitely you're having issues with your automation code
Comment by dinezh September 2020