Sorry for multiple posts - but another issue relating to API.
We run a hedged strategy trading SP500 stocks. Inevitably our Longs-Shorts of individual stocks is never flat, so we dollar hedge (as opposed to beta hedge) with the SPY.
Every day we get new buys and sells in individual SP500 stocks, which are held open for predetermined periods (typically 5 days).
We enter the exit trade and the enter trade using the API and then park the orders until 15:59 ET. Ideally I would like to enter a hedge for each trade using the SPY (and match the dollar value and duration of each trade).
I realise this is not the most efficient in terms of commission, since if we could net off our SPY hedges each day, very often only a single small adjustment SPY trade would be necessary in order to remain hedged.
That may be stage 2, but stage 1 will be to hedge all individual positions.
We have been executing this trading system manually for about 6 weeks, and are now working on automating it with the API.
Now to the problem.
If on day 1 we have a SPY hedge of Short 200 shares, and then on day 2 we get a new sell signal on an individual share we will need to enter a Buy signal in the SPY.
The problem is that the new Buy order in SPY is a BTO, but since the pre-existing SPY position is Short, C2 requires that new SPY purchases are BTC instead of BTO.
This makes automatic generation of orders through the API tricky (but not impossible).
Could you pos give us a pointer?
I am in a very similar situation. Have been manually entering orders for last 3 months. Manual entering of orders is very inefficient and prone to errors. However, the necessity to close a BTO using a STC instead of opening another using STO causes difficulty in implementation. I am sure however that other developers must have overcome this difficulty. I am also interested in getting an answer to this conundrum.
In most markets and regulatory regimes, unless you are making a market, you can’t “hedge” a position by taking the opposite side of the trade. In other words, you can’t be long and short the same exact instrument simultaneously… not strictly speaking.
I say “not strictly speaking” because of course “hedging” is the same thing as offsetting your position, mathematically, which is perfectly fine and easy to do.
For example, if you are long 300 quantity of something, and you want to “hedge” 200 units by going short 200 units at the same time you are long… well, of course that is the same as partially closing 200 of your 300 long. There is no difference mathematically, and no difference in terms of your performance stats (since C2 marks everything to market anyway, as any reputable platform working under generally accepted accounting practices should).
I may misunderstand your complaint (and John’s, below), but the simple solutions is to offset your position. It’s very important for C2 to receive directional intent along with order quantities (in other words, it’s important that you tell C2 “buy to close” or “but to open” … and not only “buy”) because of the nature of C2 AutoTrading: that anyone can start and stop trading at any time, can change quantities, can mix systems together in one account, etc.
But this should not be a limitation or problem of any kind. Nor should it change your strategy in any way. If your strategy tells you to “hedge your long position by opening another simultaneous short position” …it is actually telling you to offset your position by selling-to-close a portion of your long. It’s the same exact thing, and there’s no reason you can’t enter these kind of orders.
Thanks for the detailed explanation - I completely agree - the issue for us is that we would need to keep a tally of our global net position in order to offset as you suggest.
Happy to do so, just thought was worth asking the question.