Code and error please help fast
Also when used on connect function it throws an error saying: DhanFeed.init() got an unexpected keyword argument ‘on_connect’.
Also when used on connect function it throws an error saying: DhanFeed.init() got an unexpected keyword argument ‘on_connect’.
Any updates?
Hello @Akash_Sapkal
Welcome to MadeForTrade community!
Can you confirm which version of DhanHQ Library are you using and if the example code is for that version itself?
V2 version of Dhan HQ library.
The sample code you are using was for V1. Hence, the error. Can you check Github and take latest sample code?
Thanks for prompt reply.
Code i am using: from dhanhq import marketfeed
client_id = “”
access_token = “”
instruments = [(marketfeed.NSE, “50301”, marketfeed.Ticker)]
version = “v2” # Mention Version and set to latest version ‘v2’
try:
data = marketfeed.DhanFeed(client_id, access_token, instruments, version)
while True:
data.run_forever()
response = data.get_data()
print(response)
except Exception as e:
print(e)
Output:
DhanFeed.init() takes 4 positional arguments but 5 were given
Any updates on this? @Hardik
Im getting the SAME error. dhanfeed.init() takes 4 positional args but 5 were given. Please fix this. Unable to get any Ltp @Hardik
@Hardik can you please share working code to subscribe to websocket
Hello @Akash_Sapkal @Msk92
Just ensure that you have upgraded python library to Version 2. To check, try running following in command line/terminal:
pip list
You’re talking about upgrading python dhanhq library right, It says:
dhanhq 1.3.3
How to upgrade?
Getting ltp ticker data is the most basic functionality please for subscribing to marketfeed api. Without which there is no point. Please fix soon.Even the basic order placement APis were not working for like 1.5 weeks cause you guys changed a parameter value and did not update the documentation. Please do this all properly.
For upgrading, simply use:
pip install --upgrade dhanhq
On order placement, there hasn’t been any changes to API functionality. The change to python library where the constants were missing has also been updated.
Okay. now Ive been getting the certificate error:
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)
I tried referring to the other links related to this, but I didnt get it fully. I downloaded
certifi-2024.8.30-py3-none-any.whl file from certifi · PyPI mentioned by you somewhere in other posts. Where should this file be? Also my openssl version command says “openssl” not recognized as an internal or external command"
should i download anything else and where should it be kept even?
And “pip install ceritifi” keeps saying this:
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: certifi in c:\users\rando\appdata\local\packages\pythonsoftwarefoundation.python… (the rest of the path)
what is missing / need to here please let me know soon.
Hello @Msk92 @Akash_Sapkal
You need to check the sample code here. If you disconnect code right after establishing connection and also do subscribe and unsubscribe instruments post that, the code will return error. Also, jupyter notebook handling is different.
@Msk92 you can refer to this thread:
I have i guess, that post says to do “pip install certifi --upgrade”
I have the output is:
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: certifi in c:\users\rando\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (2024.8.30)
does the certifi have to be in a particular folder or something? and is that “Defaulting to user installation because normal site-packages is not writeable” an issue? please let me know soon
Can you check the location of Python installation, if it is installed as root. And also the environment where you are then running your code?