Ejemplo n.º 1
0
    def test_quote_processor(self):
        config = SimConfig()
        processor = QuoteProcessor()

        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(bid=18, ask=19, bid_size=200, ask_size=500)

        self.assertEqual(19, processor.get_price(order, quote, config))
        self.assertEqual(500, processor.get_qty(order, quote, config))

        order2 = NewOrderRequest(cl_id='test',
                                 cl_ord_id=2,
                                 inst_id=1,
                                 action=OrdAction.SELL,
                                 type=OrdType.LIMIT,
                                 qty=1000,
                                 limit_price=18.5)
        self.assertEqual(18, processor.get_price(order2, quote, config))
        self.assertEqual(200, processor.get_qty(order2, quote, config))
    def test_quote_processor(self):
        config = SimConfig()
        processor = QuoteProcessor()

        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)

        self.assertEqual(19, processor.get_price(order, quote, config))
        self.assertEqual(500, processor.get_qty(order, quote, config))

        order2 = ModelFactory.build_new_order_request(timestamp=0, cl_id='test', cl_ord_id="2", inst_id="1",
                                                      action=Sell, type=Limit,
                                                      qty=1000,
                                                      limit_price=18.5)
        self.assertEqual(18, processor.get_price(order2, quote, config))
        self.assertEqual(200, processor.get_qty(order2, quote, config))
Ejemplo n.º 3
0
 def __init__(self, config):
     self._config = config
     self._bar_processor = BarProcessor()
     self._trade_processor = TradeProcessor()
     self._quote_processor = QuoteProcessor()