alphatrade
alphatrade copied to clipboard
Basket order issue for FNO.... Invalid price type
Hi All, I am not able to place basket order using "sas.place_basket_order(orders)" method. Orders are sent to exchanges but they are getting rejected with error "Invalid price type". When we check order details, "Order Type" is always blank?
Attaching screenshot of order details.
Here is my sample code.
ins1 = sas.get_instrument_for_fno(symbol = "NIFTY", expiry_date=datetime.date(2021,6,24), is_fut=False, strike=16500, is_call= True)
ins2 = sas.get_instrument_for_fno(symbol = "NIFTY", expiry_date=datetime.date(2021,6,24), is_fut=False, strike=14500, is_call= False)
order1 = { "instrument" : ins1,
"order_type" : OrderType.Market,
"quantity" : 75,
"transaction_type" : TransactionType.Buy,
"product_type" : ProductType.Delivery}
order2 = { "instrument" : ins2,
"order_type" : OrderType.Market,
"quantity" : 75,
"transaction_type" : TransactionType.Buy,
"product_type" : ProductType.Delivery}
orders = [order1, order2]
print(sas.place_basket_order(orders))
I'm also facing the same issue
I will check the issue at my end never tried basket order for Delivery of FnO segment. May be you can try mentioning price as 0.0. If you are able to debug solution by yourself, do let me know I can update the same in module. This is not official module so expect some errors.
Have you checked whether this works in AliceBlue API? If yes, please report I will try to fix it here.
I have tried to apply the fixes please recheck and confirm. Thanks
I have tried to apply the fixes please recheck and confirm. Thanks
Still getting same error. Orders are getting rejected.
Hi @ravi14390 , I tried below and it seems there is some issue in SAS platform not in the API written in this framework. I will try to analyse more and update soon.
ins1 = sas.get_instrument_for_fno(symbol = "USDINR", expiry_date=datetime.date(2021,10,14), is_fut=False, strike=75.5, is_call= True, exchange='CDS')
print(ins1)
ins2 = sas.get_instrument_for_fno(symbol = "USDINR", expiry_date=datetime.date(2021,10,14), is_fut=False, strike=75.25, is_call= False, exchange='CDS')
print(ins2)
order1 = { "instrument" : ins1,
"order_type" : OrderType.Limit,
"quantity" : 1,
"price" : 0.08,
"transaction_type" : TransactionType.Buy,
"product_type" : ProductType.Intraday}
order2 = { "instrument" : ins2,
"order_type" : OrderType.Limit,
"quantity" : 1,
"price" : 0.04,
"transaction_type" : TransactionType.Buy,
"product_type" : ProductType.Intraday}
orders = [order1, order2]
print(orders)
print(sas.place_basket_order(orders))
print(sas.get_order_history())
Instrument(exchange='CDS', token=9307, symbol='USDINR 14 OCT21 75.5 CE', name='USDINR', expiry=datetime.date(2021, 10, 14), lot_size=None)
Instrument(exchange='CDS', token=9306, symbol='USDINR 14 OCT21 75.25 PE', name='USDINR', expiry=datetime.date(2021, 10, 14), lot_size=None)
[{'instrument': Instrument(exchange='CDS', token=9307, symbol='USDINR 14 OCT21 75.5 CE', name='USDINR', expiry=datetime.date(2021, 10, 14), lot_size=None), 'order_type': <OrderType.Limit: 'LIMIT'>, 'quantity': 1, 'price': 0.08, 'transaction_type': <TransactionType.Buy: 'BUY'>, 'product_type': <ProductType.Intraday: 'I'>}, {'instrument': Instrument(exchange='CDS', token=9306, symbol='USDINR 14 OCT21 75.25 PE', name='USDINR', expiry=datetime.date(2021, 10, 14), lot_size=None), 'order_type': <OrderType.Limit: 'LIMIT'>, 'quantity': 1, 'price': 0.04, 'transaction_type': <TransactionType.Buy: 'BUY'>, 'product_type': <ProductType.Intraday: 'I'>}]
{'status': 'success', 'message': 'Order placed successfully', 'data': {}}
{'status': 'success', 'message': '', 'data': {'pending_orders': [], 'completed_orders': [{'validity': 'DAY', 'user_order_id': '1', 'trigger_price': 0.0, 'transaction_type': 'BUY', 'trading_symbol': 'USDINR21O1475.5CE', 'remaining_quantity': 1, 'rejection_reason': 'Invalid price type', 'quantity': 1, 'product': 'MIS', 'price': 0.08, 'order_type': 'LIMIT', 'order_tag': '', 'order_status': 'rejected', 'order_entry_time': 1634108490, 'oms_order_id': '211013000108478', 'nest_request_id': '1', 'lotsize': 1, 'login_id': 'RR369', 'leg_order_indicator': '', 'instrument_token': '9307', 'filled_quantity': 0, 'exchange_time': 0, 'exchange_order_id': 'NA', 'exchange': 'CDS', 'disclosed_quantity': 0, 'client_id': 'RR369', 'average_price': 0.0}, {'validity': 'DAY', 'user_order_id': '1', 'trigger_price': 0.0, 'transaction_type': 'BUY', 'trading_symbol': 'USDINR21O1475.25PE', 'remaining_quantity': 1, 'rejection_reason': 'Invalid price type', 'quantity': 1, 'product': 'MIS', 'price': 0.04, 'order_type': 'LIMIT', 'order_tag': '', 'order_status': 'rejected', 'order_entry_time': 1634108490, 'oms_order_id': '211013000108479', 'nest_request_id': '1', 'lotsize': 1, 'login_id': 'RR369', 'leg_order_indicator': '', 'instrument_token': '9306', 'filled_quantity': 0, 'exchange_time': 0, 'exchange_order_id': 'NA', 'exchange': 'CDS', 'disclosed_quantity': 0, 'client_id': 'RR369', 'average_price': 0.0}, {'validity': 'DAY', 'user_order_id': '1', 'trigger_price': 0.0, 'transaction_type': 'BUY', 'trading_symbol': 'USDINR21O1475.5CE', 'remaining_quantity': 1000, 'rejection_reason': 'RMS:Margin Exceeds,Required:80000.00, Available:465.94 for entity account-RR369 across exchange across segment across product ', 'quantity': 1000, 'product': 'MIS', 'price': 0.08, 'order_type': 'LIMIT', 'order_tag': '', 'order_status': 'rejected', 'order_entry_time': 1634108456, 'oms_order_id': '211013000108144', 'nest_request_id': '1', 'lotsize': 1, 'login_id': 'RR369', 'leg_order_indicator': '', 'instrument_token': '9307', 'filled_quantity': 0, 'exchange_time': 0, 'exchange_order_id': 'NA', 'exchange': 'CDS', 'disclosed_quantity': 0, 'client_id': 'RR369', 'average_price': 0.0}, {'validity': 'DAY', 'user_order_id': '1', 'trigger_price': 0.0, 'transaction_type': 'BUY', 'trading_symbol': 'USDINR21O1475.25PE', 'remaining_quantity': 1000, 'rejection_reason': 'RMS:Margin Exceeds,Required:40000.00, Available:465.94 for entity account-RR369 across exchange across segment across product ', 'quantity': 1000, 'product': 'MIS', 'price': 0.04, 'order_type': 'LIMIT', 'order_tag': '', 'order_status': 'rejected', 'order_entry_time': 1634108456, 'oms_order_id': '211013000108145', 'nest_request_id': '1', 'lotsize': 1, 'login_id': 'RR369', 'leg_order_indicator': '', 'instrument_token': '9306', 'filled_quantity': 0, 'exchange_time': 0, 'exchange_order_id': 'NA', 'exchange': 'CDS', 'disclosed_quantity': 0, 'client_id': 'RR369', 'average_price': 0.0}]}}
PS D:\trading_st
I am also facing this issue. Specifying the price as 0 in int or float doesn't resolve the issue. Looks like F&O basket order always throws the error 'Invalid price type'. Thanks.
Any workaround for this.. send each order one by one ?