Use apiv3 to do reverse orders (long to short or short to long)

Let’s say I have long position now, I would like to do a reverse position.

  1. make a STC at certain price
  2. record the signal_id in step 1
  3. delay 1 second
  4. make a BTO at the price of step 1 with conditionalupon = signal_id

If the STC in step 1 does not fill, the I get the message below.
You are currently long, so you cannot SELL TO OPEN or SELL SHORT. First you need to STC your current position.

What is the correct way to do reverse order using apiv3? Thank you very much.

Use a conditional trade. STC the open position and condition the STO on the STC order.

Oh… Thank you for the answer. My step 4 was a typo.
Let’s say I have long position now, I would like to do a reverse position.

  1. make a STC at certain price
  2. record the signal_id in step 1
  3. delay 1 second
  4. make a STO at the price of step 1 with conditionalupon = signal_id

I did exactly what you suggest but got You are currently long, so you cannot SELL TO OPEN or SELL SHORT. First you need to STC your current position.

Is it a bug?..

If you’re receiving that error message, it means you are not creating a conditional order in a way that C2 understands. Please send me the logs of the entire API call/response sequence. Send to help@collective2.com. I’ll take a look and figure out what’s going on.

We found a bug in our script. Conditional order is working for reverse order now. Thank you very much for your support.