Place Bracket Order and Cover Order Utilizing Alice Blue Free API in Python







Open Alice Blue Trading Account Please Click Here.



Please Follow the Above Videos for Proper Instructions then go for the Code:


from login import *
from alice_blue import *

access_token=open('C:/Users/VIKASH/Desktop/alice/access_token.txt','r').read().strip()
alice=AliceBlue(username,password,access_token,['NSE'])
order_id=alice.place_order(TransactionType.Buy,alice.get_instrument_by_symbol('NSE','RELIANCE'),1,OrderType.Limit,
                        ProductType.BracketOrder,1440.0,None,5.0,3.0,None,None)
print(order_id)
#Cancel Bracket Order
cancel_order_id=order_id['data'][oms_order_id']
print(alice.cancel_order(cancel_order_id))

Place Cover Order:




from alice_blue import *
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'])
order_id=alice.place_order(TransactionType.Buy,alice.get_instrument_by_symbol('NSE','MARUTI'),
                           1,OrderType.Market,ProductType.CoverOrder,0.0,
6420.0)
print(order_id)
#Cancel Cover Order
cancel_order_id=order_id['data'][oms_order_id']
print(alice.cancel_order(cancel_order_id))