Alice Blue Utilize Free of Cost API to Automate Trades in Python





Open Alice Blue Trading Account Please Click Here.



CMD pip Installation Type and Enter: pip install alice_blue



Please Follow the Above Video then go for the Code Below for generation of access token and Programmatic Trading:



from alice_blue import *
import csv
access_token=AliceBlue.login_and_get_access_token(username='username',password='password',twoFA='twoFA',api_secret='api_secret')
print(access_token)
with open('access_token.txt','w') as wr1:
    wr=csv.writer(wr1)
    wr.writerow([access_token])
access_token=open('access_token.txt','r').read().strip()   
alice=AliceBlue(username='username',password='password',access_token=access_token, master_contracts_to_download=['NSE', 'BSE'])
tatasteel_nse_eq = alice.get_instrument_by_symbol('NSE', 'TATASTEEL')
print(tatasteel_nse_eq)


Search Instruments Fetch Symbol,Expiry and Lot Size for that Follow Below Video then Go for the Code.



from alice_blue import *
import pandas as pd
username=open('username.txt','r').read().strip()
password=open('password.txt','r').read().strip()
access_token=open('access_token.txt','r').read().strip()
alice=AliceBlue(username,password,access_token,['NFO','NSE'])
instruments=alice.search_instruments('NFO','BANKNIFTY')
instruments=pd.DataFrame(instruments)
tradingsymbol=instruments[0:1]['symbol'].to_string(index=False)
print(tradingsymbol)