The opinions expressed in these forums do not represent those of C2, and any discussion of profit/loss is not indicative of future performance or success. There is a substantial risk of loss in trading. You should therefore carefully consider whether such trading is suitable for you in light of your financial condition. You should read, understand, and consider the Risk Disclosure Statement that is provided by your broker before you consider trading. Most people who trade lose money.

API setDesiredPositions

#1

I have a couple questions about setDesiredPositions API call:

  1. Does each call override the previous if it has not been executed?
  2. To go flat on a symbol can you just leave it out of the call or do you have to specify 0 shares?
#2

Hi,

did you figure this out? I have the same question…

#3
  1. Does each call override the previous if it has not been executed?

Yes.

  1. To go flat on a symbol can you just leave it out of the call or do you have to specify 0 shares?

You can either specify that you want a flat quantity or you can leave the symbol out of the call entirely. However this second choice (leaving symbol out entirely) only works if your call to setDesiredPositions contains other valid desired positions. So it’s probably a good idea to specify “0” quantities as a best practice.

One note that is not obvious from the docs: when C2 determines “current” positions (in order to synchronize with your desired positions), it includes pending but not execute market orders in the current quantities.

This is the link to the API documentation for setDesiredPositions.

#4

Thanks!

Do you know if there is a shortcut to set a desired position to 100% of the portfolio?

Btw, I can’t find the API sandbox… is there one? Or how do you test?

Thanks for your help!

Back to C2 Platform