How do you deal with self-trading issue?

Discussion in 'Automated Trading' started by Chronos.Phenomena, Oct 10, 2010.

  1. Especially in high frequency trading, you may have a situation where you have a buy limit order @ $100, but a split of the second later, you place a sell limit order @ $100.

    Your order would cross, and the exchanges complain about that... some brokers as well.

    How do you deal with this issue?

    My current approach is via priority stack. Orders to get into the position are always of lower priority comparing to orders to take profit or cut the loss. If self-trading scenario happens.... I prevent it by canceling entry order and going ahead with stop loss or take profit orders.... this seems messy to me... any bright ideas out there?
     
  2. LeeD

    LeeD

    In a single strategy this situation shouldn't happen if you wait for confirmed cancellation of a buy order before placing a sell order at the same price.

    If you have a few independent strategies trading concurrently, perhaps, it's a good idea to add internal order matching logic so that if you have a buy and a sell order at the same level you just move a position between the strategies without any actuial trading... again wait for order cancellation first.
     
  3. actually, I run a portfolio of strategies...

    I like your local execution idea
     
  4. always trying to game a rathole..

    never learned to trade by set of your pants...feel sorry for you
     
  5. Hmm it would be something like...

    1. Strategy A is short, it placed buy order to cover at 100 (order O1)
    2. Strategy B is long, it placed sell order to close at 100 (order O2)

    Strategy A placed the order first, so if B places the order it would result in self trading.

    3. Simulate "order filled" feedback for that order O1. So that strategy A will think that order was executed.

    4. Simulate "order filled" feedback for order O2. So that strategy B will think that order was executed.

    Now we have situation where both strategies "virtually" traded. But we still have a order outstanding in the real world?!?! How to deal with that?
     
  6. killthesunshine,

    I missed your point?! completely...
     
  7. LeeD,

    What do you mean by move the position?

    If I mach locally, then both strategies trade but there is a live order outstanding.... in the real world... to cancel it?
     
  8. LeeD

    LeeD

    Suppose
    1. Strategy A is short, it has a buy order in the market to cover at 100 (order O1)
    2. Strategy B wants to go long long, it places sell order to close at 100 (order O2)

    The key here is teh 2 orders are not placed simultaneously. The strategies generate them in some order.

    In teh above case the buy orde ris already in the market. In order to internally match orders you need to: cancell the buy order, what till the cancellation is confirmed, wait for the fill info. Now that that there are no orders in the market the buy order froms strategy A and the sell order from strategy B can be internally matched (as you pput it, "logiocally"). Things to watch out for: the buy order could have been partially or fully executed. So, the strategy B may need a sell order to cover teh difference; the strategies may have orders in different sizes.
     
  9. psrexp

    psrexp

    I'm wondering why a short strategy would place buy to cover order and a long strategy would place sell to close order, because both closes out existing positions and it doesn't make sense to have both short and long positions of the same size simultaneously. And why would there be outstanding orders when you simulate feedback? Orders should be either placed live or not.

    If you are going to be running multiple independent strategies on a single account, you got to have something that centralizes order handling, so that multiple (which may or may not be conflicting) buy/sell requests can be resolved. You can implement OCO (order cancels other) functionality, or risk-averse strategy (which is what you are doing, by favoring signals to close positions over initiating positions), or some other algorithm to priortize signals.
     
  10. psrexp

    psrexp

    Your example doesn't make sense to me. Both strategies are placing orders to close out existing positions, but why would long and short positions exist at the same time? Also, if the execution feedback were simulated, then why would there be outstanding real orders? Do you mean the live orders are placed, but execution responses are simulated by you? Why would you do something like that?

    If you have multiple strategies running on a single account, I think it's necessary to have something that would handle all order/position management. You can implement OCO (order cancels other) functionality (if not supported server side), an algorithm that would prioritize signals from different strategy, or the risk-averse strategy that favors closing positions over initiating new ones when conflicts arise. In most cases, this would also require strategy evaluations be synchronized.
     
    #10     Oct 11, 2010