I am using python sdk for authentication..
I have checked the code (for getting candle data again...(given in this post) ... It still returns http 404 error... can you see anything wrong with the code ???
I am successfully using market data API...
I am using python sdk for authentication..
I have checked the code (for getting candle data again...(given in this post) ... It still returns http 404 error... can you see anything wrong with the code ???
I am successfully using market data API...
@ngk Hello, I also faced the problem suddenly....and what I found was a silly post processing routine execution error(bug)....but the websocket client thinks is somehting to do with "subsciption /unsubscription"...thats all..
CHECK the following in your code...
can you print the received tick as it is ? ...the printed data should tell you if there is an error ...if printed data shows buy/sell or ltp etc..you have no connection/subsciption problems....
are you calling any function or processing (ie, doing any thing to received data for the strategy...)the received data ?
if yes, thoroughly check that code...any error in that code will cause an error for websocket client and cause it to fire its on_error...which is "Attempting...."...but the actual error was an execution error in the post processing function/routine....
Hope it helps...
@Moderator_2 Hi, I was trying out WebSocket2 as suggested.
I was successful in the first few attempts to and received ticks...
but now I get "Attempting to resubscribe/reconnect (Attempt 1)..." and then I get "Connection closed due to max retry attempts reached." consistently.
I logged out, rebooted the machine but still gets the same error.
Code sample I am using is the websocket2 example from github.
@baahu_chanduwad Dont know if you have resolved this...just in case,
SmartConnect.py tries to connect to api.ipfy.org to get the the client PublicAPI...there is no url named api.ipfy.org...IT SHOULD BE api64.ipfy.org
@Moderator_2 I have tried smartApi.getCandleData, I get the same http 400 error....http response has no error message either to debug!!!!
Is there something additional to be added to the HEADER data for Historical API ? I am successfully sing the same header to retrieve quote data.
can you try my code and see whats wrong ?
@Moderator_2 I am posting the code again.....
http = urllib3.PoolManager()
API_ENDPOINT = "https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData"
#thirty_days_ago = datetime.now() - timedelta(days=30)
#from_date = thirty_days_ago.strftime("%Y-%m-%d %H:%M")
#to_date = datetime.now().strftime("%Y-%m-%d %H:%M")
from_date = "2021-07-01 09:41"
to_date = "2021-07-29 10:41"
print(from_date)
print(to_date)
payload = { "exchange": "NSE",
"symboltoken": "3045",
"interval": "ONE_HOUR",
"fromdate": from_date,
"todate": to_date
}
encoded_data = json.dumps(payload).encode('utf-8')
r = http.request('POST', API_ENDPOINT,
headers=headers,
body=encoded_data)
print(r.status)
print('DRAW:',r.data)
resp_body = r.data.decode('utf-8')
print(f'DATA:{resp_body}')
@Moderator_2 so basically, rephrasing my question again, you dont provide level 3 data ??? thank you.
@Moderator_2 below is the simple code that I am testing... I am trying off market hours not live...
http = urllib3.PoolManager()
API_ENDPOINT = "https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData"
#thirty_days_ago = datetime.now() - timedelta(days=30)
#from_date = thirty_days_ago.strftime("%Y-%m-%d %H:%M")
#to_date = datetime.now().strftime("%Y-%m-%d %H:%M")
from_date = "2021-07-01 09:41"
to_date = "2021-07-29 10:41"
print(from_date)
print(to_date)
payload = { "exchange": "NSE",
"symboltoken": "3045",
"interval": "ONE_HOUR",
"fromdate": from_date,
"todate": to_date
}
encoded_data = json.dumps(payload).encode('utf-8')
r = http.request('POST', API_ENDPOINT,
headers=headers,
body=encoded_data)
print(r.status)
print('DRAW:',r.data)
resp_body = r.data.decode('utf-8')
print(f'DATA:{resp_body}')
@Moderator_2 my question was , does it give only best five ? not 20 ?
Does the quote API give only best 5 buy/sell quantities ???
I am using python sdk for authentication..
I have checked the code (for getting candle data again...(given in this post) ... It still returns http 404 error... can you see anything wrong with the code ???
I am successfully using market data API...