Kotak-Neo / kotak-neo-api

120 stars 112 forks source link

Facing Issue while placing order #207

Closed VNivasChowdary closed 4 months ago

VNivasChowdary commented 4 months ago

The error message says

{'stat': 'Not_Ok', 'error': [{'code': '10020', 'message': 'Authentication Failed'}], 'tid': 'server3_27430'}

here is my code

try:
    od=client.place_order(exchange_segment='nse_cm', product='NRML', price='0', order_type='MKT', quantity='15', validity='DAY', trading_symbol='IDFC-EQ',
                       transaction_type='B', amo="NO", 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)
nprejit commented 4 months ago

@VNivasChowdary This error occurred because your authentication was not completed properly see #166

VNivasChowdary commented 4 months ago

@nprejit

This is my login code

from neo_api_client import NeoAPI
import creds as c

client = NeoAPI(consumer_key=c.consumer_key, consumer_secret=c.consumer_secret, environment='prod',
                access_token=None, neo_fin_key=None)

# client = NeoAPI(consumer_key=c.consumer_key, consumer_secret=c.consumer_secret, environment='prod') I have tried with this also 

print(client.login(mobilenumber="+91XXXXXXXX", password=c.password))
print(client.session_2fa(OTP=c.mpin))

This is my place order code

print(client.place_order(exchange_segment="nse_fo", product="NRML", price="0", order_type="MKT", quantity="15", validity="DAY", trading_symbol="BANKNIFTY2471652300PE",
                       transaction_type="B", amo="NO", disclosed_quantity="0", market_protection="0", pf="N",
                       trigger_price="0",tag=None))

My creds are correct, I was able to fetch my name and other details but it is showing below error

{'error': [{'code': '10525', 'message': 'Your account is locked, your account locked for today'}]}
nprejit commented 4 months ago

@VNivasChowdary

Your account is locked because of 5 wrong credential attempts, you change the password from the web or wait for tomorrow.

Note: check client.session_2fa response 'rid' and 'sid' must be same as client.login response, if not, place order show the error {'stat': 'Not_Ok', 'error': [{'code': '10020', 'message': 'Authentication Failed'}] other functions will work like margins, order report etc.