@admin, do we have any active support or not?
Posts made by Ramesh
-
Unable to get to tick data
@admin , I used to get the tick data by using the below code, in the recent past it was NOT providing the tick data, can you pl help me know if anything needs to be updated?
from smartapi import SmartConnect # or from smartapi.smartConnect import SmartConnect
#from smartapiwebsocket import SmartWebSocket
from smartapi import SmartWebSocketANGEL_API_KEY = "XXXXXX"
#ANGEL_SEC_KEY = "XXXXX"
TOTP="XXXXX"ANGEL_CLIENT_ID = "XXXXXX"
ANGEL_PASSSWORD = "XXXXX"refreshToken = None
feedToken = None
smartObj = Nonetokens = None
ss = None
task = Nonedef smartApiInitialization():
global refreshToken
global feedToken
global smartObjtry:
smartObj = SmartConnect(api_key=ANGEL_API_KEY)
totp = pyotp.TOTP(TOTP) #'replace with Text that appears below QR code'
totp = totp.now()
print("pasrse: ",totp)
attempts = 5
while attempts > 0:
attempts = attempts - 1data = self.smartObj.generateSession(ANGEL_CLIENT_ID,ANGEL_PASSSWORD,totp)
print(data)
if data['status']:
break
time.sleep(2)refreshToken = data['data']['refreshToken']
print(refreshToken)fetch the feedtoken
feedToken = self.smartObj.getfeedToken()
print(feedToken)
time.sleep(1)except Exception as ex:
print("Exception in smartApiInitialization method : {}".format(str(ex)))
def on_message(ws, message):
print("Ticks: {}".format(message))
def on_open(ws):
global tokens
global task
global ssprint("on open") ss.subscribe(task, tokens)
def on_error(ws, error):
print(error)def on_close(ws):
print("Close")def initialize_websocket():
global tokens
global ss
global task
global feedTokentry: tokens = "nse_cm|26000&nse_cm|26009" task = "mw" ss = SmartWebSocket(feedToken, ANGEL_CLIENT_ID) # Assign the callbacks. ss._on_open = on_open ss._on_message = on_message ss._on_error = on_error ss._on_close = on_close ss.connect() except Exception as ex: print('exception in initialize_websocket : {}'.format(ex))
if name == 'main':
smartApiInitialization() initialize_websocket()
-
RE: Important Announcement: Change in Angel One Login Policy
Hi Admin,
I was not able to login by using python sdk with below code
{
"clientcode":"Your_client_code",
"password":"Your_PIN"
"totp":"enter_the_code_displayed_on_your_authenticator_app"
}however getting the below error,
{'message': 'LoginbyPassword is not allowed. Please switch to Login by MPIN now.', 'errorcode': 'AB7001', 'status': False, 'data': None}
am i doing anythign wrong? pl advise
-
RE: Historical data is not fetching for few symbols
@admin Hi trying to get one day time frame data all F&O symbol for a week.
-
RE: Historical data is not fetching for few symbols
@webseos I'm getting data for few symbols and not for others, please see below response, where getting data for GAIL and not for TATACHEM and AARTIIND. Please guide
TATACHEM
{'status': True, 'message': 'SUCCESS', 'errorcode': '', 'data': []}
No Historical Data for this symbol : TATACHEM
GAIL
{'status': True, 'message': 'SUCCESS', 'errorcode': '', 'data': [['2021-05-04T00:00:00+05:30', 138.5, 145.65, 137.35, 143.75, 31185770], ['2021-05-05T00:00:00+05:30', 147.3, 148.85, 143.0, 145.05, 21912068], ['2021-05-06T00:00:00+05:30', 145.9, 151.85, 145.6, 151.15, 26499738], ['2021-05-07T00:00:00+05:30', 151.3, 152.65, 148.7, 150.25, 18927457], ['2021-05-10T00:00:00+05:30', 150.25, 155.5, 150.25, 154.55, 16390776], ['2021-05-11T00:00:00+05:30', 153.0, 163.5, 152.2, 161.9, 35767570], ['2021-05-12T00:00:00+05:30', 162.6, 165.75, 158.7, 161.05, 26642955], ['2021-05-14T00:00:00+05:30', 161.5, 161.75, 152.15, 152.7, 20845453], ['2021-05-17T00:00:00+05:30', 154.0, 154.8, 150.35, 153.15, 14494672], ['2021-05-18T00:00:00+05:30', 155.0, 158.0, 152.5, 152.8, 14263487], ['2021-05-19T00:00:00+05:30', 152.8, 154.55, 151.3, 152.8, 8993112], ['2021-05-20T00:00:00+05:30', 151.95, 152.3, 146.75, 147.35, 14895731], ['2021-05-21T00:00:00+05:30', 147.6, 150.45, 145.3, 145.75, 17043863], ['2021-05-24T00:00:00+05:30', 146.5, 152.6, 145.9, 151.7, 15732196], ['2021-05-25T00:00:00+05:30', 153.6, 155.75, 151.7, 155.1, 26222882], ['2021-05-26T00:00:00+05:30', 155.0, 155.8, 151.7, 152.1, 8663643], ['2021-05-27T00:00:00+05:30', 152.25, 155.0, 150.55, 152.8, 15013582], ['2021-05-28T00:00:00+05:30', 153.2, 157.4, 152.05, 153.05, 15352282], ['2021-05-31T00:00:00+05:30', 154.0, 161.4, 153.2, 159.95, 48101205], ['2021-06-01T00:00:00+05:30', 160.6, 161.75, 158.0, 160.45, 14125060], ['2021-06-02T00:00:00+05:30', 162.4, 163.45, 157.65, 158.85, 14123542], ['2021-06-03T00:00:00+05:30', 159.8, 162.25, 158.7, 161.05, 11740971], ['2021-06-04T00:00:00+05:30', 161.3, 164.75, 160.3, 162.0, 13443192], ['2021-06-07T00:00:00+05:30', 162.5, 169.9, 162.05, 168.35, 33219121], ['2021-06-08T00:00:00+05:30', 168.2, 169.8, 165.0, 167.8, 16692868], ['2021-06-09T00:00:00+05:30', 170.0, 170.3, 158.3, 162.4, 41513695], ['2021-06-10T00:00:00+05:30', 164.5, 166.0, 160.5, 163.5, 23519675], ['2021-06-11T00:00:00+05:30', 165.0, 167.75, 161.2, 163.75, 23815900], ['2021-06-14T00:00:00+05:30', 164.4, 164.6, 160.1, 163.15, 17059851], ['2021-06-15T00:00:00+05:30', 164.5, 166.2, 162.55, 163.0, 14365617], ['2021-06-16T00:00:00+05:30', 163.3, 165.75, 161.2, 161.75, 12490077], ['2021-06-17T00:00:00+05:30', 161.5, 163.65, 158.7, 160.5, 10112009], ['2021-06-18T00:00:00+05:30', 161.25, 161.95, 152.6, 155.05, 18169757], ['2021-06-21T00:00:00+05:30', 153.0, 156.15, 151.25, 155.25, 13484830], ['2021-06-22T00:00:00+05:30', 157.0, 158.7, 154.9, 155.3, 7859425], ['2021-06-23T00:00:00+05:30', 157.0, 157.0, 152.7, 153.35, 8189214], ['2021-06-24T00:00:00+05:30', 153.9, 154.95, 151.75, 152.25, 8153848], ['2021-06-25T00:00:00+05:30', 153.0, 154.7, 152.25, 153.1, 6551074], ['2021-06-28T00:00:00+05:30', 154.6, 155.15, 152.2, 153.35, 7206825], ['2021-06-29T00:00:00+05:30', 153.45, 153.75, 151.35, 152.0, 6406676], ['2021-06-30T00:00:00+05:30', 152.05, 152.55, 149.25, 149.65, 10512615], ['2021-07-01T00:00:00+05:30', 150.7, 153.75, 150.0, 153.0, 12357143], ['2021-07-02T00:00:00+05:30', 153.95, 153.95, 151.0, 151.3, 7467504], ['2021-07-05T00:00:00+05:30', 152.3, 153.65, 151.55, 152.15, 6273400], ['2021-07-06T00:00:00+05:30', 152.7, 155.1, 148.8, 150.35, 12998966], ['2021-07-07T00:00:00+05:30', 149.8, 152.1, 148.55, 149.95, 8210966], ['2021-07-08T00:00:00+05:30', 149.85, 151.1, 148.45, 148.7, 8533698], ['2021-07-09T00:00:00+05:30', 148.7, 149.05, 147.0, 147.15, 6837801], ['2021-07-12T00:00:00+05:30', 148.5, 149.2, 146.5, 146.75, 9767750], ['2021-07-13T00:00:00+05:30', 148.15, 151.4, 147.5, 148.8, 14198854], ['2021-07-14T00:00:00+05:30', 148.0, 149.95, 147.2, 147.85, 6200851], ['2021-07-15T00:00:00+05:30', 148.9, 148.9, 143.9, 144.4, 13149215], ['2021-07-16T00:00:00+05:30', 145.0, 145.2, 143.0, 144.8, 11323698], ['2021-07-19T00:00:00+05:30', 144.8, 148.0, 143.8, 144.35, 13175418], ['2021-07-20T00:00:00+05:30', 144.4, 145.0, 140.75, 142.35, 8956762], ['2021-07-22T00:00:00+05:30', 144.6, 145.2, 141.7, 143.8, 11671203], ['2021-07-23T00:00:00+05:30', 144.0, 145.0, 142.0, 142.4, 7355532], ['2021-07-26T00:00:00+05:30', 142.0, 142.1, 139.7, 141.35, 9260846], ['2021-07-27T00:00:00+05:30', 141.85, 142.0, 138.55, 139.05, 8747495], ['2021-07-28T00:00:00+05:30', 139.9, 139.9, 136.6, 137.85, 9152741], ['2021-07-29T00:00:00+05:30', 138.9, 139.6, 136.95, 137.5, 6949660], ['2021-07-30T00:00:00+05:30', 138.0, 141.8, 137.25, 139.55, 14416176], ['2021-08-02T00:00:00+05:30', 140.95, 143.3, 139.35, 142.85, 7539166], ['2021-08-03T00:00:00+05:30', 143.95, 144.15, 141.85, 143.3, 8902280], ['2021-08-04T00:00:00+05:30', 144.25, 146.2, 141.85, 142.4, 9592503], ['2021-08-05T00:00:00+05:30', 143.0, 145.6, 140.3, 142.9, 19500102], ['2021-08-06T00:00:00+05:30', 147.0, 153.95, 144.9, 148.75, 63506840], ['2021-08-09T00:00:00+05:30', 150.2, 150.5, 145.2, 145.8, 11261259], ['2021-08-10T00:00:00+05:30', 145.9, 148.15, 143.8, 144.85, 14949570], ['2021-08-11T00:00:00+05:30', 145.5, 148.5, 144.5, 144.65, 6378762]]}
date open high low close volume
0 2021-05-04T00:00:00+05:30 138.50 145.65 137.35 143.75 31185770
1 2021-05-05T00:00:00+05:30 147.30 148.85 143.00 145.05 21912068
2 2021-05-06T00:00:00+05:30 145.90 151.85 145.60 151.15 26499738
3 2021-05-07T00:00:00+05:30 151.30 152.65 148.70 150.25 18927457
4 2021-05-10T00:00:00+05:30 150.25 155.50 150.25 154.55 16390776
AARTIIND
{'status': True, 'message': 'SUCCESS', 'errorcode': '', 'data': []}
No Historical Data for this symbol : AARTIIND -
RE: Historical data is not fetching for few symbols
@webseos said in Historical data is not fetching for few symbols:
PI Key and User/Password ,make them ***** or XXXX
have already shared the code, please do let me know if you need more details
-
RE: Historical data is not fetching for few symbols
@webseos please find below code
import json
from datetime import datetime, timedelta
from time import strftime
import timepackage import statement
from smartapi import SmartConnect
symbolslist = [['IDEA','1111'],['ADANIENT','2222'],['GAIL','3333']] # 157 symbols
API_KEY = ""
SEC_KEY = ""CLIENT_ID = ""
PASSSWORD = ""feedToken = None
userProfile = None
smartObj = Nonedays_to_subtract = 100 # Specify in terms days
days_to_subtract_hours = 50 # Specify in terms days
days_to_subtract_5mins = 5 # Specify in terms daysdef smartApiInitialization():
try:
global feedToken
global userProfile
global smartObj
handleLoggerInitialization()
createKPIBackupFile()# import smartapi.smartExceptions(for smartExceptions) # create object of call smartObj =SmartConnect(api_key=API_KEY) # login api call data = smartObj.generateSession(CLIENT_ID ,PASSSWORD) refreshToken= data['data']['refreshToken'] # fetch the feedtoken feedToken =smartObj.getfeedToken() # fetch User Profile userProfile= smartObj.getProfile(refreshToken) except Exception as ex: logging.error("Exception in smartApiInitialization method : {}".format(str(ex))) print("Exception in smartApiInitialization method : {}".format(str(ex)))
def smartAppLogout():
try:
global smartObjlogout = smartObj.terminateSession(CLIENT_ID) print("Logout Successfull") logging.info("Logout Successfull") except Exception as ex: print("Exception in smartAppLogout method : {}".format(str(ex))) logging.error("Exception in smartAppLogout method : {}".format(str(ex)))
def getDayHistoricalData():
try: global smartObj global days_to_subtract global symbolslist lastDate = datetime.today() fromDate = lastDate - timedelta(days=days_to_subtract) lastDate = lastDate.strftime("%Y-%m-%d %H:%M") fromDate = fromDate.strftime("%Y-%m-%d %H:%M") for symbol in symbolslist : print(symbol) historicParam = { "exchange": "NSE", "symboltoken": symbol[1], "interval": "ONE_DAY", "fromdate": fromDate, "todate": lastDate } respdatajson = smartObj.getCandleData(historicParam) #print(respdatajson) respdata = respdatajson['data'] if len(respdata) == 0: print("No Historical Data for this symbol : {}".format(symbol)) logging.info("No Historical Data for this symbol : {}".format(symbol)) time.sleep(2) continue df = pd.DataFrame(respdata) print(df.head() time.sleep(2) except Exception as ex: print("Exception in getHistoricalData method : {}".format(str(ex))) logging.error("Exception in getHistoricalData method : {}".format(str(ex)))
if name == 'main':
smartApiInitialization()
getDayHistoricalData()smartAppLogout()
-
RE: Historical data is not fetching for few symbols
@admin Please find below request details for one day (not for 1 min)
historicParam = {
"exchange": "NSE",
"symboltoken": "XXXX",
"interval": "ONE_DAY",
"fromdate": fromDate,
"todate": lastDate
}
respdatajson = smartObj.getCandleData(historicParam) -
RE: Historical data is not fetching for few symbols
@admin Please find below request details for one day (not for 1 min)
historicParam = {
"exchange": "NSE",
"symboltoken": "XXXX",
"interval": "ONE_DAY",
"fromdate": fromDate,
"todate": lastDate
}
respdatajson = smartObj.getCandleData(historicParam) -
RE: Historical data is not fetching for few symbols
@admin I want to fetch historical data for all nifty 50 stock with 1min and 5 min and getting the aboe message. Can you please let me know if i have missed anything?
-
Historical data is not fetching for few symbols
Hi Admin,
I was trying to fetch the historical data with 1Min and 5 Mins time frame, however getting message as "No Historical data for this symbol <symbol name>. Also for 5 mins no values any symbol.
AARTIIND
No Historical Data for this symbol : AARTIIND
INDUSINDBK
No Historical Data for this symbol : INDUSINDBK
PEL
date open high low close volume
0 2021-05-03T00:00:00+05:30 1655.10 1715.80 1654.50 1707.35 635596
1 2021-05-04T00:00:00+05:30 1712.00 1726.65 1656.50 1664.55 754058
2 2021-05-05T00:00:00+05:30 1689.00 1733.00 1674.35 1720.90 977858
3 2021-05-06T00:00:00+05:30 1727.95 1730.00 1685.00 1700.10 565595
4 2021-05-07T00:00:00+05:30 1709.00 1713.50 1660.00 1669.65 727400No Five Min Historical Data for this symbol : TATACHEM
No Five Min Historical Data for this symbol : AARTIIND
No Five Min Historical Data for this symbol : INDUSINDBK
No Five Min Historical Data for this symbol : ASTRAL
No Five Min Historical Data for this symbol : ADANIPORTSAppreciate your suggestions.