Reply

Enforcing FIFO Rules in Combined Strategies

7 replies

kainc301

Customer, bbp_participant, community, 54 replies.

Visit profile

4 years ago #250153

Typically, I build one long only and one short only strategy. It would be great to then recombine them together but the problem I run into is that I can only use them with FIFO brokers. So because I cannot risk the trades overlapping, I need to separate the strategies into two different accounts. Is there any current way to force no trades from one side when another side is in a trade if I were to combine both the long and short side back into one strategy and then run a backtest with this rule in place? Would this need to be a new feature request?

0

kainc301

Customer, bbp_participant, community, 54 replies.

Visit profile

4 years ago #250155

I would assume the only thing you need to do is disable trades from the other side when a trade was entered and also cancel any limit/stop limit orders that may have been entered from the other side once a trade was entered. Am I mistaken? Or is this more complicated to implement than imagined?

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

4 years ago #250157

Hello,

do the strategies use market orders or limit orders? When market orders are used for long / short it could be easily done by adding a moving average (context filter) …. if Close > MA 200 take longs only / if Close < 200 take shorts only

When limit orders are placed you will need to add condition to check whether an opposing existing order is placed into the market.

0

kainc301

Customer, bbp_participant, community, 54 replies.

Visit profile

4 years ago #250158

I use a variety of different order types. I believe it would be necessary to check for existing orders but I do not know how to do that in SQX. The problem is automatically canceling orders/preventing orders from the other side. This should be fairly easy to implement in SQX with the two following rules:

1. While a trade is open (an order was filled), prevent any further orders (from either side) from being submitted.

2. Stop limit and limit orders from either side can be submitted simultaneously as long as no trade is open however, when a trade is open (an order was filled), cancel any pending limit/stop limit orders that did not originate from the open trade.

You can have a FIFO mode for the build process and strategy testing that is set to off by default but when set to on, it follows those two rules when trading. I submitted an edit for this in the task here: https://roadmap.strategyquant.com/tasks/sq4_3775

Please let me know if you can implement this. It seems pretty simple to do but I cannot assume. It would help a GREAT deal as splitting strategies between accounts is highly annoying. Its really small but it would make a world of a difference from people who have to deal with these nonsensical broker rules.

0

kainc301

Customer, bbp_participant, community, 54 replies.

Visit profile

4 years ago #250192

I saw that SQ is now providing data for futures, including micro futures. For US traders to use this, FIFO definitely needs to be implemented. Any thoughts as to the ease of implementing these two rules as they seem like simple order logic to implement?

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

4 years ago #250209

Hello,

I am not sure if I understand now. If you have two strategies one long and one short and you need to ensure they never interfere with each other by editing the strategies code directly. This is something SQX cannot do for you. If we consider a single strategy then it already works as expected – a strategy waits for flat position before a new trade is placed into the market

0

kainc301

Customer, bbp_participant, community, 54 replies.

Visit profile

4 years ago #250213

Right SQX does not currently have this capability. There was a feature request submitted for it. I am asking how feasible is it to implement these two rules to force orders to never interfere in a “FIFO mode” option for all strategies built and tested with SQX. Doing this manually is doable but difficult to work with in the SQX workflow of combining strategies and trying to assess the backtests of these strategies within a portfolio. For implementation, all a FIFO mode would require is the blocking of new orders  of any type and the canceling of any hanging limit/ stop limit orders. Would a FIFO mode be hard to implement into SQX to do this automatically when selected?

When doing this manually, I would not for instance be able to reimport these strategies into SQX and get stats for a portfolio with these rules in place which is exactly what I need.

0

kainc301

Customer, bbp_participant, community, 54 replies.

Visit profile

4 years ago #250215

Right SQX does not currently have this capability. There was a feature request submitted for it. I am asking how feasible is it to implement these two rules to force orders to never interfere in a “FIFO mode” option for all strategies built and tested with SQX. Doing this manually is doable but difficult to work with in the SQX workflow of combining strategies and trying to assess the backtests of these strategies within a portfolio. For implementation, all a FIFO mode would require is the blocking of new orders of any type and the canceling of any hanging limit/ stop limit orders. Would a FIFO mode be hard to implement into SQX to do this automatically when selected? When doing this manually, I would not for instance be able to reimport these strategies into SQX and get stats for a portfolio with these rules in place which is exactly what I need. This would be extremely helpful for anyone in the US trading micro futures as well.

0

Viewing 7 replies - 1 through 7 (of 7 total)