unable to place order
Manoj250 opened this issue · comments
I'm getting {'code': '10020', 'message': 'Authentication Failed'} for place order . Please help.
code :
client = NeoAPI(
consumer_key="",
consumer_secret="",
environment="prod",
access_token="",
neo_fin_key="neotradeapi",
)
client.login(mobilenumber="+91", mpin="")
otp = input("enter otp: ")
client.session_2fa(OTP=otp)
try:
od = client.place_order(exchange_segment="nse_cm", product="CNC", price="0", order_type="MKT", quantity="1", validity="DAY", trading_symbol="SBIN-EQ",
transaction_type="B", amo="YES", disclosed_quantity="0", market_protection="0", pf="N",
trigger_price="0", tag=None)
print(od)
except Exception as e:
print("Exception when calling OrderApi->place_order: %s\n" % e)
below place order also fails:
client.place_order(exchange_segment="nse_fo", product="NRML", price="0", order_type="MKT", quantity="15", validity="DAY", trading_symbol="BANKNIFTY2451547500CE", transaction_type="B", amo="YES", disclosed_quantity="0", market_protection="0", pf="N", trigger_price="0", tag=None)
response:
{'stat': 'Not_Ok', 'error': [{'code': '10020', 'message': 'Authentication Failed'}]}
try this format.
install latest version api, no need of neo_fin_key, pass none or leave it, and no need to pass access_token, leave this none or dont pass,
client login by mobile number and your trading platform password (NOT api login password)
2fa can validate by giving OTP or MPIN (both are valid)
consumer_key = ""
secret_key = ""
mobile_number = "+91"
login_password = ""
client = NeoAPI(consumer_key= consumer_key,consumer_secret=secret_key,environment="prod")
client.login(mobilenumber= mobile_number, password=login_password)
otp = input("enter otp: ")
client.session_2fa(OTP=otp)
@saurabhguptarock
mobile number with prefix +91
ex. "+919876543210"
show me the error
I am using the latest version of SDK, which was just updated, also I have tried using the API password and NEO web password both are not working.
@saurabhguptarock
which python version u are using?
is this order placing response?
@saurabhguptarock which python version u are using? is this order placing response?
3.9 and yes
Same Issue,
How were you able to resolve it ?
I am able to login fine / get instrument files / get quotes via socket - all fine
But when placing the order
{'stat': 'Not_Ok', 'error': [{'code': '10020', 'message': 'Authentication Failed'}]}
- Tried both the passwords - API Portal and Trading
- Have to use PAN , as my mobile is associated with two accounts
- Use the Default PIN , instead of OTP
client = NeoAPI(consumer_key=consumer_key,consumer_secret=consumer_secret,environment="prod")
client.login(pan="dddd", password="ddddd")
client.session_2fa("123456")
try:
# Place a Order
a = client.place_order(exchange_segment="nse_fo", product="NRML",price="0", order_type="MKT", quantity="20", validity="DAY", trading_symbol="SENSEX2461476800CE",
transaction_type="B", amo="NO", disclosed_quantity="0", market_protection="0", pf="N",
trigger_price="0", tag=None)
print(a)
except Exception as e:
print("Exception when calling OrderApi->place_order: %s\n" % e)
Same Issue, How were you able to resolve it ?
I am able to login fine / get instrument files / get quotes via socket - all fine But when placing the order
{'stat': 'Not_Ok', 'error': [{'code': '10020', 'message': 'Authentication Failed'}]}
- Tried both the passwords - API Portal and Trading
- Have to use PAN , as my mobile is associated with two accounts
- Use the Default PIN , instead of OTP
client = NeoAPI(consumer_key=consumer_key,consumer_secret=consumer_secret,environment="prod") client.login(pan="dddd", password="ddddd") client.session_2fa("123456")
try: # Place a Order a = client.place_order(exchange_segment="nse_fo", product="NRML",price="0", order_type="MKT", quantity="20", validity="DAY", trading_symbol="SENSEX2461476800CE", transaction_type="B", amo="NO", disclosed_quantity="0", market_protection="0", pf="N", trigger_price="0", tag=None) print(a) except Exception as e: print("Exception when calling OrderApi->place_order: %s\n" % e)
Hi,
please download latest neo api from github. no need to install it , just extract the file and place "neo_api_client" folder, where you run the code from, (you can find this folder inside the extracted "kotak-neo-api-main" folder.
in place order code you are using sensex to trade, so you have to use "bse_fo" as exchange_segment. Rest your code looks good.👍
use trading login password, dont use api portal password.
try this also, use the below code to accept otp from user
otp=input("Enter Kotak OTP: ")
client.session_2fa(otp)
and try with otp (here you can give both otp received on mobile or MPIN)
Im having the same issue, even though my sid and rid are matching for login and 2fa.
I am trying:
client.place_order(exchange_segment="nse_fo", product="NRML", price="0", order_type="MKT", quantity="15", validity="DAY", trading_symbol="BANKNIFTY2451547500CE", transaction_type="B", amo="YES", disclosed_quantity="0", market_protection="0", pf="N", trigger_price="0", tag=None)
as from working example. But i get :
{'stat': 'Not_Ok', 'error': [{'code': '10020', 'message': 'Authentication Failed'}], 'tid': 'server3_1792187'}
show me ur login process code
client login pass only pan and password (NOT API LOGIN PASSWORD, PASSWORD OF YOUR TRADING LOGIN)
client.login(pan="dddd", password="ddddd")
AND GIVE MPIN AS 2FA (otp also work)
client.session_2fa("123456")
before this check you are using latest version of kotak API else update to latest kotak api from github
use latest symbol.
"BANKNIFTY2451547500CE" has expired,
this can also throw an error
client login pass only pan and password (NOT API LOGIN PASSWORD, PASSWORD OF YOUR TRADING LOGIN) client.login(pan="dddd", password="ddddd")
AND GIVE MPIN AS 2FA (otp also work) client.session_2fa("123456")
before this check you are using latest version of kotak API else update to latest kotak api from github
This seems to have been the problem nd it seems to be working now! tysm!
I changed my password and it started working. Thanks everyone for the help