def test_lmt_order_update_cancel(broker, inst_id=3, qty=1000, limit_price=100): print "### testing limit order" cl_ord_id = next_cl_ord_id() order = NewOrderRequest(cl_id=1, cl_ord_id=1, inst_id=inst_id, action=OrdAction.BUY, type=OrdType.LIMIT, qty=qty, limit_price=limit_price) broker.on_new_ord_req(order) time.sleep(5) print "### testing order update" order = OrderReplaceRequest(cl_id=1, cl_ord_id=1, type=OrdType.LIMIT, qty=qty * 2, limit_price=limit_price * 1.2) broker.on_ord_replace_req(order) time.sleep(5) print "### testing order cancel" broker.on_ord_cancel_req(order) time.sleep(5)
def test_order_replace_request(self, name, serializer): item = OrderReplaceRequest(timestamp=datetime.datetime.now(), cl_id=1, cl_ord_id=1, type=OrdType.LIMIT, qty=12, limit_price=13.2, stop_price=13.5, tif=TIF.DAY, oca_tag="WTF", params=None) SerializerTest.ser_deser(name, serializer, item)
def test_order_replace_request(self, name, datastore): persistable = OrderReplaceRequest(timestamp=clock.now(), cl_id=1, cl_ord_id=1, type=OrdType.LIMIT, qty=12, limit_price=13.2, stop_price=13.5, tif=TIF.DAY, oca_tag="WTF", params=None) DataStoreTest.save_load(name, persistable, datastore, datastore.save_ord_replace_req, 'ord_replace_reqs')
def replace_order(self, cl_ord_id=None, type=None, qty=None, limit_price=None, stop_price=None, tif=None): req = OrderReplaceRequest(timestamp=self.clock.now(), cl_id=self.stg_id, cl_ord_id=cl_ord_id, type=type, qty=qty, limit_price=limit_price, stop_price=stop_price, tif=tif) order = self.portfolio.replace_order(req) return order