Exemple #1
0
    def on_ord_upd(self, ord_upd):
        super(OrderManager, self).on_ord_upd(ord_upd)

        # persist
        if hasattr(self, "store") and self.store and self.persist_mode != PersistenceMode.RealTime:
            self.store.save_ord_status_upd(ord_upd)

        # update order
        order = self.order_dict["%s.%s" % (ord_upd.cl_id, ord_upd.cl_ord_id)]
        order.on_ord_upd(ord_upd)

        # enrich the cl_id and cl_ord_id
        ord_upd.cl_id = order.cl_id
        ord_upd.cl_ord_id = order.cl_ord_id

        # notify portfolio
        portfolio = self.app_context.portf_mgr.get_portfolio(order.portf_id)
        if portfolio:
            portfolio.on_ord_upd(ord_upd)
        else:
            logger.warn("portfolio [%s] not found for order cl_id [%s] cl_ord_id [%s]" % (
                order.portf_id, order.cl_id, order.cl_ord_id))

        # notify stg
        stg = self.app_context.stg_mgr.get(order.cl_id)
        if stg:
            stg.oon_ord_upd(ord_upd)
        else:
            logger.warn(
                "stg [%s] not found for order cl_id [%s] cl_ord_id [%s]" % (order.cl_id, order.cl_id, order.cl_ord_id))

        # persist
        self._save_order(order)
Exemple #2
0
    def send_order(self, new_ord_req):
        if new_ord_req.id() in self.order_dict:
            raise Exception(
                "ClientOrderId has been used!! cl_id = %s, cl_ord_id = %s" %
                (new_ord_req.cl_id, new_ord_req.cl_ord_id))

        # persist
        if hasattr(
                self, "store"
        ) and self.store and self.persist_mode != PersistenceMode.RealTime:
            self.store.save_new_order_req(new_ord_req)

        order = Order(new_ord_req)
        self.order_dict[order.id()] = order

        if order.broker_id:
            broker = self.app_context.provider_mgr.get(order.broker_id)
            if broker:
                broker.on_new_ord_req(new_ord_req)
            else:
                logger.warn(
                    "broker [%s] not found for order cl_id [%s] cl_ord_id [%s]"
                    % (order.broker_id, order.cl_id, order.cl_ord_id))

        # persist
        self._save_order(order)

        return order
Exemple #3
0
    def on_ord_upd(self, ord_upd):
        super(OrderManager, self).on_ord_upd(ord_upd)

        # persist
        if hasattr(self, "store") and self.store and self.persist_mode != PersistenceMode.RealTime:
            self.store.save_ord_status_upd(ord_upd)

        # update order
        order = self.order_dict["%s.%s" % (ord_upd.cl_id, ord_upd.cl_ord_id)]
        order.on_ord_upd(ord_upd)

        # enrich the cl_id and cl_ord_id
        ord_upd.cl_id = order.cl_id
        ord_upd.cl_ord_id = order.cl_ord_id

        # notify portfolio
        portfolio = self.app_context.portf_mgr.get_portfolio(order.portf_id)
        if portfolio:
            portfolio.on_ord_upd(ord_upd)
        else:
            logger.warn("portfolio [%s] not found for order cl_id [%s] cl_ord_id [%s]" % (
                order.portf_id, order.cl_id, order.cl_ord_id))

        # notify stg
        stg = self.app_context.stg_mgr.get(order.cl_id)
        if stg:
            stg.oon_ord_upd(ord_upd)
        else:
            logger.warn(
                "stg [%s] not found for order cl_id [%s] cl_ord_id [%s]" % (order.cl_id, order.cl_id, order.cl_ord_id))

        # persist
        self._save_order(order)
Exemple #4
0
    def send_order(self, new_ord_req):
        if new_ord_req.id() in self.order_dict:
            raise Exception(
                "ClientOrderId has been used!! cl_id = %s, cl_ord_id = %s" % (new_ord_req.cl_id, new_ord_req.cl_ord_id))

        # persist
        if hasattr(self, "store") and self.store and self.persist_mode != PersistenceMode.RealTime:
            self.store.save_new_order_req(new_ord_req)

        order = Order(new_ord_req)
        self.order_dict[order.id()] = order

        if order.broker_id:
            broker = self.app_context.provider_mgr.get(order.broker_id)
            if broker:
                broker.on_new_ord_req(new_ord_req)
            else:
                logger.warn("broker [%s] not found for order cl_id [%s] cl_ord_id [%s]" % (
                    order.broker_id, order.cl_id, order.cl_ord_id))

        # persist
        self._save_order(order)

        return order
Exemple #5
0
 def connectionClosed(self):
     logger.warn("connectionClosed")
Exemple #6
0
 def connectionClosed(self):
     logger.warn("connectionClosed")