コード例 #1
0
 def __init__(self, app_context=None, sim_config=None, slippage=None):
     self.app_context = app_context
     self.__sim_config = sim_config if sim_config else SimConfig()
     self.__slippage = slippage if slippage else NoSlippage()
     self.__market_ord_handler = MarketOrderHandler(self.__sim_config, self.__slippage)
     self.__limit_ord_handler = LimitOrderHandler(self.__sim_config)
     self.__stop_limit_ord_handler = StopLimitOrderHandler(self.__sim_config)
     self.__stop_ord_handler = StopOrderHandler(self.__sim_config, self.__slippage)
     self.__trailing_stop_ord_handler = TrailingStopOrderHandler(self.__sim_config, self.__slippage)
コード例 #2
0
    def test_market_order_handler(self):
        handler = MarketOrderHandler(self.config)

        order = NewOrderRequest(cl_id='test', cl_ord_id=1, inst_id=1, action=OrdAction.BUY, type=OrdType.LIMIT,
                                qty=1000, limit_price=18.5)

        quote = Quote(inst_id=1, bid=18, ask=19, bid_size=200, ask_size=500)
        trade = Trade(inst_id=1, price=20, size=200)

        fill_info = handler.process_w_price_qty(order, 18, 500)
        self.assertEquals(18, fill_info.fill_price)
        self.assertEquals(500, fill_info.fill_qty)
コード例 #3
0
    def test_market_order_handler(self):
        handler = MarketOrderHandler(self.config)

        order = ModelFactory.build_new_order_request(timestamp=0, cl_id='test', cl_ord_id="1", inst_id="1", action=Buy,
                                                     type=Limit,
                                                     qty=1000, limit_price=18.5)

        quote = ModelFactory.build_quote(timestamp=0, inst_id="1", bid=18, ask=19, bid_size=200, ask_size=500)
        trade = ModelFactory.build_trade(timestamp=0, inst_id="1", price=20, size=200)

        fill_info = handler.process_w_price_qty(order, 18, 500)
        self.assertEquals(18, fill_info.fill_price)
        self.assertEquals(500, fill_info.fill_qty)