Closed ramakrishna-goli closed 3 years ago
@ramakrishna-goli it is clearly giving you error. Please learn python and read the README properly. That is the only problem you have.
issue is not with the access_token.txt file if that is what you are refering to. I agve user, password, 2 fa all correctly .. it went to __get_question_ids.. There I am getting 200 response which is good however, the response message contained "error" saying to enter valid password. however, the credentials are perfectly fine. Thats where I am stuck. can you help pls
@ramakrishna-goli what was the time you ran the login script? Some you get this error when you run code while the server is under maintenance mode. I don't know what you are doing and what versions you are using. But at my end everything is working perfectly, just checked it now 11 am 26 Oc t 2021.
import datetime
import json
from time import sleep
# pip install https://github.com/algo2t/alphatrade
from alphatrade import AlphaTrade, LiveFeedType, OrderType, ProductType, TransactionType
import config
# NOTE create a config.py file in the same directory as sas_login_eg.py file
# Contents of the config.py must be as below, config.py is used for storing credentials
#### config.py START ####
# login_id = "RR"
# password = "SAS@131"
# twofa = "rr"
# try:
# access_token = open('access_token.txt', 'r').read().rstrip()
# except Exception as e:
# print('Exception occurred :: {}'.format(e))
# access_token = None
#### config.py END ####
sas = AlphaTrade(login_id=config.login_id, password=config.password, twofa=config.twofa)
# NOTE access_token can be supplied if already available
# sas = AlphaTrade(login_id=config.login_id, password=config.password,
# twofa=config.twofa, access_token=config.access_token)
# NOTE access_token can be supplied if already available and master_contracts to download
# sas = AlphaTrade(login_id=config.login_id, password=config.password,
# twofa=config.twofa, access_token=config.access_token, master_contracts_to_download=['CDS'])
print(sas.get_profile())
usd_inr = sas.get_instrument_by_symbol('CDS', 'USDINR NOV FUT')
print(usd_inr)
print(sas.get_balance())
Output ::
{'status': 'success', 'message': '', 'data': {'pan_number': 'ABCDE1234Z', 'name': 'RAHUL RAUT', 'login_id': 'RR', 'exchanges': ['NSE', 'NFO', 'CDS', 'BSE', 'MCX'], 'email_address': 'rxx@gmail.com', 'dp_ids': [], 'broker_name': 'SOUTHASIAN', 'banks': [{'branch_name': '', 'bank_name': 'xxxxBank', 'account_id': 'RR'}, {'branch_name': '', 'bank_name': '', 'account_id': 'RR'}, {'branch_name': '', 'bank_name': '', 'account_id': 'RR'}, {'branch_name': '', 'bank_name': '', 'account_id': 'RR'}, {'branch_name': '', 'bank_name': '', 'account_id': 'RR'}, {'branch_name': '', 'bank_name': '', 'account_id': 'RR'}], 'backoffice_enabled': True}}
Instrument(exchange='CDS', token=3244, symbol='USDINR NOV FUT', name='', expiry=datetime.date(2021, 11, 26), lot_size=None)
{'status': 'success', 'message': '', 'data': {'cash_positions': [{'utilized': {'var_margin': '0.00', 'unrealised_m2m': '-0.00', 'span_margin': '0.00', 'realised_m2m': '-0.00', 'premium_present': '0', 'pay_out': '0.00', 'multiplier': '1.00', 'exposure_margin': '0.00', 'elm': '0.00', 'debits': '0.00'}, 'segment': 'ALL', 'net': '0.00', 'category': 'EQUITY', 'available': {'pay_in': '0', 'notionalCash': '0.000000', 'direct_collateral_value': '0.00', 'credits': '0.00', 'collateral_value': '0.00', 'cashmarginavailable': '0.00', 'adhoc_margin': '0.000000'}}, {'utilized': {'var_margin': '0.00', 'unrealised_m2m': '-0.00', 'span_margin': '0.00', 'realised_m2m': '-0.00', 'premium_present': '0', 'pay_out': '0.00', 'multiplier': '1.00', 'exposure_margin': '0.00', 'elm': '0.00', 'debits': '0.00'}, 'segment': 'COM', 'net': '0.00', 'category': 'COMMODITY_OPTIONS', 'available': {'pay_in': '0', 'notionalCash': '0.000000', 'direct_collateral_value': '0.00', 'credits': '0.00', 'collateral_value': '0.00', 'cashmarginavailable': '0.00', 'adhoc_margin': '0.000000'}}]}}
hi ,
I ran all the times, during market hours and after market hours... but still an issue. even now, it failed.
Do you mind a quick look to have real understanding..
Taking the liberty to open a google meet.. if u can quickly join to see the real issue is.. that would be very helpful.
https://meet.google.com/qax-evdf-cxy
Apologies if I am bothering much or intruding your space...
hi ,
I ran all the times, during market hours and after market hours... but still an issue. even now, it failed.
Do you mind a quick look to have real understanding..
Taking the liberty to open a google meet.. if u can quickly join to see the real issue is.. that would be very helpful.
https://meet.google.com/qax-evdf-cxy
Apologies if I am bothering much or intruding your space...
I had given everything even sample workspace, remove existing module and try reinstall. When you open issue make sure you provide details about python version, alphatrade version, platform, etc. This is open source stuff not my regular job, so can't connect using google meet.
@ramakrishna-goli you might be doing some minor mistake, check login manually in web platform. Launch Chrome DevTools and check Network logs.
@ramakrishna-goli join Telegram channel - Algo Trade Analysis (Python) , some people might help you there.
thanks .. will try my luck there... any ways, thanks for the contribution bro.. appreciate it.
This is the issue that I have encountered. what I did?
1) created config.py in the same folder as sas_login_eg.py and gave credentials loginid, password,twofa(being same for all questions) 2) ran sas_login_eg.py 3) I am not using access_token
Below is the errorI encountered. Please help.
C:\AlgoTrade\venv\Scripts\python.exe C:/AlgoTrade/alphatrade-main/examples/sas_login_eg.py Exception occurred :: [Errno 2] No such file or directory: 'access_token.txt' Exception occurred :: [Errno 2] No such file or directory: 'access_token.txt' {'status': 'error', 'message': 'Please Enter Valid Password', 'data': {}} Traceback (most recent call last): File "C:\AlgoTrade\alphatrade-main\examples\sas_login_eg.py", line 24, in
sas = AlphaTrade(login_id=config.login_id, password=config.password, twofa=config.twofa)
File "C:\AlgoTrade\venv\lib\site-packages\alphatrade\alphatrade.py", line 233, in init
self.get_question_ids()
File "C:\AlgoTrade\venv\lib\site-packages\alphatrade\alphatrade.py", line 287, in get_question_ids
raise requests.HTTPError(response.text)
requests.exceptions.HTTPError: {"status":"error","message":"Please Enter Valid Password","data":{}}
Process finished with exit code 1