Do all orders inside a Basket order have same order id. I am asking in context of closing basket order positions using order id in fyers api. Thanks in advance.

Do all orders inside a Basket order have same order id. I am asking in context of closing basket order positions using order id in fyers api. Thanks in advance.

Hi,

Basket Order is a group of individual orders that are submitted together as a single order. Each individual order within the Basket Order will have its own unique order ID. Therefore, each order within a Basket Order will have a different order ID.

Hi,

Basket Order is a group of individual orders that are submitted together as a single order. Each individual order within the Basket Order will have its own unique order ID. Therefore, each order within a Basket Order will have a different order ID.

Thank u for ur prompt reply. Can u tell me how to fetch the two ids. Thanks in advance

Thank u for ur prompt reply. Can u tell me how to fetch the two ids. Thanks in advance

Fetch the basket order details

basket_order_id = ‘YOUR_BASKET_ORDER_ID’
basket_order_details = fyers.get_basket_order_history(basket_order_id)

Loop through the individual orders within the basket order and fetch their Order IDs

for order in basket_order_details[‘data’][0][‘orders’]:
order_id = order[‘order_id’]
print(f"Order ID: {order_id}")

In this example, We fetch the details of the basket order using its ID and loop through the individual orders within it. For each order, we fetch its Order ID and print it. You can modify this example to suit your specific use case.

Hope this helps.

Fetch the basket order details

basket_order_id = ‘YOUR_BASKET_ORDER_ID’
basket_order_details = fyers.get_basket_order_history(basket_order_id)

Loop through the individual orders within the basket order and fetch their Order IDs

for order in basket_order_details[‘data’][0][‘orders’]:
order_id = order[‘order_id’]
print(f"Order ID: {order_id}")

In this example, We fetch the details of the basket order using its ID and loop through the individual orders within it. For each order, we fetch its Order ID and print it. You can modify this example to suit your specific use case.

Hope this helps.

Fetch the basket order details

basket_order_id = ‘YOUR_BASKET_ORDER_ID’
basket_order_details = fyers.get_basket_order_history(basket_order_id)

Loop through the individual orders within the basket order and fetch their Order IDs

for order in basket_order_details[‘data’][0][‘orders’]:
order_id = order[‘order_id’]
print(f"Order ID: {order_id}")

In this example, We fetch the details of the basket order using its ID and loop through the individual orders within it. For each order, we fetch its Order ID and print it. You can modify this example to suit your specific use case.

Hope this helps.

Thank u brother. will give it a try.

Thank u brother. will give it a try.

What if there are multiple basket orders of different symbols?

What if there are multiple basket orders of different symbols?

If you have multiple basket orders with different symbols, you can use the get_basket_order_history to fetch the details of each basket order.

Once you have the details of each basket order, you can loop through the individual orders within each basket order to fetch their Order IDs. You can then use these Order IDs to close the positions for each individual order.

Set the basket order IDs for the symbols you want to close positions for

basket_order_ids = {
‘symbol_1’: ‘YOUR_BASKET_ORDER_ID_1’,
‘symbol_2’: ‘YOUR_BASKET_ORDER_ID_2’,
‘symbol_3’: ‘YOUR_BASKET_ORDER_ID_3’
}

Loop through the basket order IDs and fetch the individual order IDs for each symbol

for symbol, basket_order_id in basket_order_ids.items():
print(f"Fetching orders for symbol {symbol}")
basket_order_details = fyers.get_basket_order_history(basket_order_id)

# Loop through the individual orders within the basket order and fetch their Order IDs
for order in basket_order_details['data'][0]['orders']:
    order_id = order['order_id']
    print(f"Order ID: {order_id}")
    # Use the order ID to close the position for this individual order

PS: I am still learning and experimenting!

If you have multiple basket orders with different symbols, you can use the get_basket_order_history to fetch the details of each basket order.

Once you have the details of each basket order, you can loop through the individual orders within each basket order to fetch their Order IDs. You can then use these Order IDs to close the positions for each individual order.

Set the basket order IDs for the symbols you want to close positions for

basket_order_ids = {
‘symbol_1’: ‘YOUR_BASKET_ORDER_ID_1’,
‘symbol_2’: ‘YOUR_BASKET_ORDER_ID_2’,
‘symbol_3’: ‘YOUR_BASKET_ORDER_ID_3’
}

Loop through the basket order IDs and fetch the individual order IDs for each symbol

for symbol, basket_order_id in basket_order_ids.items():
print(f"Fetching orders for symbol {symbol}")
basket_order_details = fyers.get_basket_order_history(basket_order_id)

# Loop through the individual orders within the basket order and fetch their Order IDs
for order in basket_order_details['data'][0]['orders']:
    order_id = order['order_id']
    print(f"Order ID: {order_id}")
    # Use the order ID to close the position for this individual order

PS: I am still learning and experimenting!

If you have multiple basket orders with different symbols, you can use the get_basket_order_history to fetch the details of each basket order.

Once you have the details of each basket order, you can loop through the individual orders within each basket order to fetch their Order IDs. You can then use these Order IDs to close the positions for each individual order.

Set the basket order IDs for the symbols you want to close positions for

basket_order_ids = {
‘symbol_1’: ‘YOUR_BASKET_ORDER_ID_1’,
‘symbol_2’: ‘YOUR_BASKET_ORDER_ID_2’,
‘symbol_3’: ‘YOUR_BASKET_ORDER_ID_3’
}

Loop through the basket order IDs and fetch the individual order IDs for each symbol

for symbol, basket_order_id in basket_order_ids.items():
print(f"Fetching orders for symbol {symbol}")
basket_order_details = fyers.get_basket_order_history(basket_order_id)

# Loop through the individual orders within the basket order and fetch their Order IDs
for order in basket_order_details['data'][0]['orders']:
    order_id = order['order_id']
    print(f"Order ID: {order_id}")
    # Use the order ID to close the position for this individual order

PS: I am still learning and experimenting!

Hello! Sorry to barge in with unrelated question. But, you seem to have gotten past the authentication steps. Could you tell me what is app_secret that is used in generating sha256 in authentication step 2. How to get that?