Use market order to exit immediate after market-on-open order still get the open price ?

If I buy market on open, and immediate sell it to exit use market order right after the buy order got filled, what's the fill price for the sell market order ? open price ?? I got the open price as fill price on cloudquant.

Here is an example for symbol MTD on 2015-05-08:

from cloudquant.interfaces import Strategy, Event
import ktgfunc

#
class debug(Strategy):

    @classmethod
    def is_symbol_qualified(cls, symbol, md, service, account):
        return symbol =='MTD' #2015-05-08

    def on_start(self, md, order, service, account):
        service.add_time_trigger(service.time(9, 29))
        self.entry_fill_price = 0
        self.exit_fill_price = 0
        self.state = 0


    def on_fill(self, event, md, order, service, account):

        if self.state ==0:
            self.entry_fill_price = event.price
            cur_pos = account[self.symbol].position.shares
            if cur_pos > 0:
                order.algo_sell(self.symbol, "a5a329d1-f81e-4d4b-99c3-dfff4053e09f", intent='exit')
                # print 'sell to close'
            else:
                # print 'buy to close'
                order.algo_buy(self.symbol, "96c01190-bbcc-40c2-b3c1-d645e3dff215", intent='exit')
            self.state = 1

        if self.state == 1:
            self.exit_fill_price = event.price


    def on_timer(self, event, md, order, service, account):
        NYSE_MOO_BUY = "7933f7c8-2561-4665-a51d-f67df4eb9fac"
        order.algo_sell(self.symbol, NYSE_MOO_BUY, intent='init', order_quantity=10)

    def on_finish(self,md, order, service, account):
        print self.symbol, 'entry at: ',self.entry_fill_price,' exit : ', self.exit_fill_price , ' open at:', md.L1.opening_trade
Tagged:

Comments

  • shayneshayne Posts: 70

    yikang622,

    That looks like a bug. I will fill a bug report. Thanks for providing a sample script. That really speeds up testing.

    -Shayne

Sign In or Register to comment.