I am facing an issue when placing a sell order with hedged positions. When I try to place a sell order along with hedges, I receive an error message indicating insufficient margin requirements. However, when I first place a hedge buy order and then place the sell order separately, it works correctly without any margin error, despite the fact that the required margin appears to be the same in both cases.
I believe there may be a delay in the system when updating positions after placing hedge orders. Could you confirm if there’s any lag or delay from your side in reflecting the updated margin after placing the hedge buy order? If so, is there a recommended solution or best practice to handle this?
For the hedging process, I am placing API calls as follows:
await Promise.all(hedgeOrderPromises);
await Promise.all(orderPromises);
But this approach does not seem to work correctly, and I continue to get the margin error when placing the sell order immediately after the hedge orders.