def _cancel(self, account, order): if not isinstance(account, StockAccount): # 不是股票账户的 Cancel Event 忽略 return order_id = order.order_id try: if order_id in self._order_id_map: self._shipane_client.cancel(self._mod_config.client, self._order_id_map[order_id]) else: user_log.warning('[实盘易] 未找到对应的委托编号') except Exception as e: user_log.error("[实盘易] 撤单异常:" + str(e))
def _cancel(self, account, order): if account.type != DEFAULT_ACCOUNT_TYPE.STOCK.name: # 不是股票账户的 Cancel Event 忽略 return order_id = order.order_id try: if order_id in self._order_id_map: self._shipane_client.cancel(self._mod_config.client, self._order_id_map[order_id]) else: user_log.warning('[实盘易] 未找到对应的委托编号') except Exception as e: user_log.error("[实盘易] 撤单异常:" + str(e))
def _submit_by_trade(self, trade): if self._is_expired(trade): user_log.info('[实盘易] 委托已过期,忽略下单请求') return try: price_type = 0 if trade.order.type == ORDER_TYPE.LIMIT else 4 order = trade.order actual_order = self._shipane_client.execute( self._mod_config.client, action=order.side.name, symbol=order.order_book_id, type=order.type.name, priceType=price_type, price=order.price, amount=trade.last_quantity) return actual_order except Exception as e: user_log.error("[实盘易] 下单异常:" + str(e))
def _submit_by_order(self, order): """ 对于 响应 ORDER_CREATION_PASS 事件,已经经过了事前风控,所以比如资金不足,下单手数为0等无效订单已经排除,这里不需要额外处理。 :param order: :return: """ if self._is_expired(order): user_log.info('[实盘易] 委托已过期,忽略下单请求') return try: price_type = 0 if order.type == ORDER_TYPE.LIMIT else 4 actual_order = self._shipane_client.execute( self._mod_config.client, action=order.side.name, symbol=order.order_book_id, type=order.type.name, priceType=price_type, price=order.price, amount=order.quantity) self._order_id_map[order.order_id] = actual_order['id'] return actual_order except Exception as e: user_log.error("[实盘易] 下单异常:" + str(e))