1.how can I get orderA,orderB,orderC Index? I want to see their cost(order.executed.value)
notify_order, method of
Strategy to receive the notifications for each order.
2.how can I close orderB only? I want to close order by order.ref
That's an impossible. Here and in real life. Let me say it loud and clear: ORDERS ARE NOT POSITIONS, because an order is not open or closed. An order can be pending execution, partially executed, cancelled, rejected, but IT IS NOT YOUR POSITION in the market. The exchange does not keep track of which orders opened your position. Your orders are instructions to do something.
You can use
tradeid to simulate trades which logically group orders. But you have to remember, that the EXCHANGE won't do that for you.