Profile Picture

Stock pairs PositionManager limit order based on price delta

Posted By alpha23 4 Years Ago

Stock pairs PositionManager limit order based on price delta

Message
Posted Tuesday December 24 2013
Is there any way to execute a position based on the delta between two symbols? This is same idea as IBs spread trader. That is, when the actual delta of the 2 symbols exceeds the limit price (also specified as a delta), both orders are executed.

Without this functionality, only market orders are available which is a bad execution strategy in my opinion.

Thanks, Duane
Posted Monday January 13 2014
I'm not familiar with this type of functionality. Is this something supported natively by exchanges? If not, I think IB is probably just simulating it with market orders in the same way that you would do in a system (though if it happens on the IB servers it's a bit better).

If you really need this you could customize the IB plugin to support this, and send the extra data necessary in the order's Tag or CustomString field.

Thanks,
Daniel
Posted Monday January 13 2014
I’m referring to the functionality within RightEdge simulations. IB already supports this; the exchange does not to my knowledge. For simulations, it does not appear to be possible to place limit, stop loss, or profit target orders based on a price delta between 2 symbols because even if the delta is evaluated each bar and the order is then placed, the order would not occur until the following bar which may have a very different delta. Breaking down bars into 4 ticks does not resolve the issue.

A tick simulation would resolve the issue (IB’s spread trader is working on this basis) but there are 2 issues with tick simulations: i) tick data is expensive and often limited, and ii) the time required to run simulations can be extensive (5 minute sim runs can take several hours depending on the number of symbols/back test length) making it impractical to run tick simulations on all but a system that has already been well tested at the bar level.

Is this something that can be added for spread trading? e.g.

var settings = new PositionSettings
{
   PositionType = PositionType.Spread,
   OrderType = orderType,
   LimitPrice = priceDelta,
   Symbol = symbol,
   PairedSymbol = pairSymbol,
};

Thanks, Duane
Posted Tuesday January 14 2014
I see, that makes sense.

I think you can do this with a custom paper broker. Use the Tag field of an order to specify that it is a spread order what the paired symbol is, and any additional information needed. Then override the ShouldFill() method in the paper broker, and if it is a spread order then run your own logic instead of calling the base implementation.

The only issue I see is determining the current price for the paired symbol. You can save the current price each time SimTick() or SimBar() is called, but that will still leave you with price data from the previous tick received for the paired symbol, and the tick for the "current" time for the paired symbol may not have been sent yet.

Thanks,
Daniel
Posted Tuesday January 14 2014
Unfortunately, the above solution will not work because the comparison with a delayed tick can have unrealistic results when using bar data. For example, in an OHLC sequence, the low of one symbol will be compared with the high of another symbol which can be very different than comparing the 2 lows.

Is there some workaround that can be implemented or does this need to be added as a feature request? Without this functionality, pairs simulations using bar data will not work.

Thanks, Duane
Posted Tuesday January 14 2014
I think you can do this by batching the ticks. IE, in SimTick don't immediately call the base implementation, but store the tick data until you have received a tick with the same timestamp for all symbols. Then iterate through the ticks and call base.SimTick() for all of them, and use that price data (which will all be from the same timestamp) to determine if an order should be filled.

You would need to always have data for all the symbols for this to work (although maybe there are workarounds you could find otherwise).

Thanks,
Daniel
Posted Wednesday January 15 2014
Interesting. The above sounds like it will work.

Thanks, Duane


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems