SmartQuant Discussion

How to handle order created by broker
Page 1 of 1

Author:  yk126 [ Wed Mar 13, 2013 11:22 am ]
Post subject:  How to handle order created by broker

I have been running a strategy as follows for a while now:
    a. Send a limit order (long or short)
    b. If the limit order is not filled within a time amount, then cancel the limit order.
    c. If the limit order is filled and the position is opened. No more new limit order. The position would be
    close as soon as it was first opened. The position closing price is highly depends on ticker trade price.
    d.Once the position is closed. Strategy able to send out limit order again

Logicwise the strategy is running fine. However, the ticker update is slightly delay to reach my strategy as exchange send out the ticker to my broker server and the broker server in return send it to OQ. This delay can cause quite a few slippage as this strategy is fairly high frequent.

Now my broker offer me a new order type it’s called bull/bear order type that can cut down the ticker delay issues. It work like this

    a. Send a limit order with a stop loss and stop gain price as well. (It’s similar to OCA). I can code this stop loss/gain no problem on my userprovider.The stop loss/gain price are set in the order send method.

    b. If bull/bear order is not filled within a certain time amount, the strategy can cancel this order.

    c. The stop loss/gain would be executed by the broker server and trade reports would be send to userProvider on callback.
Doing this can cut down the slippage as both the gain/loss orders are rest on the broker server. If either the gain/loss is executed by the broker, it would cancel the other order as well. My question is how can I handle those trade reports for either the gain/loss orders which wasn’t created by OQ strategy in the first place. The strategy only knows the position was opened when the limit order was filled. Once this gain/loss order executed, the position is closed on the broker server. The userprovider would be able to receive the callback for the gain/loss order trade report, can I create those gain/loss order in the userprovider once it receive the trade report ? and the strategy would be able to match it with the limit order so that the position would be closed and recognized by the strategy ?

Let me know your insights/comments. Thanks

Author:  Dr. Anton Fokin [ Wed Mar 13, 2013 12:17 pm ]
Post subject:  Re: How to handle order created by broker


I think you can create and send stop loss and take profit orders in your strategy right before you send limit order. You can mark stop loss and take profit orders somehow (for example add "bullbear stoploss", "bullbear takeprofit" to order text field). Then you can identify and store these orders in your user provider. Accept these orders but don't send them to the broker. Then emit execution report for corresponding order when you get execution callback from the broker. Group these orders in one OCA group in your strategy and I think this idea is going to work in the simulation mode as well.


Author:  yk126 [ Wed Mar 13, 2013 12:34 pm ]
Post subject:  Re: How to handle order created by broker

Sounds good. Thanks for suggestion.

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group