def Alice_place_order_BUY(Instrument,Quantity,OrderType,ProductType,Price,TransactionType):
for i in range(0,3):
while True:
try:
print('Params:',Instrument,Quantity,OrderType,ProductType,Price,TransactionType);
order_id = None ;#TransactionType=eval('{"Sell":"Sell","Buy":"Buy"}');print(TransactionType) #;exit()
order_id = alice.place_order(transaction_type = TransactionType.Buy, #TransactionType,
instrument = Instrument,
quantity = Quantity,
order_type = OrderType.Market, #OrderType, #'MARKET', #
product_type = ProductType.Delivery, #ProductType.Intraday, #'I',# #ProductType,
price = Price,
trigger_price = None,
stop_loss = None,
square_off = None,
trailing_sl = None,
is_amo = False)
return order_id
except Exception as e:
print("exception occured place_order:" + str(e))
time.sleep(2)
if i == 2:
return ''
break
Ret = Alice_main()
##ALICE
instrument = None;instrument = Alice_get_instrument('BANKNIFTY','2021-08-05',35700,False,'CE')
print('Received instrument:',instrument)
if instrument != None :
order_id = Alice_place_order_BUY(instrument,25,'MARKET','D',0.0,'BUY')
print('Received order_id:',order_id)
This has to be encapsulated within str() function -
str(ProductType)
str(OrderType)
Right?
Also just do
print(e)
Or, use traceback
import traceback
try:
#add your code
except:
printtraceback.format_exc())