diff --git a/ejtraderCT/api/ctrader.py b/ejtraderCT/api/ctrader.py index 42f97ae..af77580 100644 --- a/ejtraderCT/api/ctrader.py +++ b/ejtraderCT/api/ctrader.py @@ -324,12 +324,15 @@ def position_list_callback(self, data: dict, price_data: dict, client_id: str): self.client.update(positions = positions) logging.debug("client_id %s positions: %s", client_id, positions) - def getPositionIdByOriginId(self, posId: str): + def getPositionIdByOriginId(self, posId: str, client_id: str): if posId in self.fix.origin_to_pos_id: return self.fix.position_list[self.fix.origin_to_pos_id[posId]] def getOrdersIdByOriginId(self, ordId: str, client_id: str): - return self.fix.origin_to_ord_id[ordId] + if ordId in self.fix.origin_to_ord_id: # Verifique se a chave existe antes de acessá-la + return self.fix.origin_to_ord_id[ordId] + else: + return None # Retorne None ou outro valor padrão quando a chave não existir def cancelOrdersByOriginId(self, clIdArr, client_id: str): if clIdArr == None: diff --git a/ejtraderCT/api/fix.py b/ejtraderCT/api/fix.py index e7aae12..aff94bd 100644 --- a/ejtraderCT/api/fix.py +++ b/ejtraderCT/api/fix.py @@ -435,6 +435,7 @@ def get_origin_from_pos_id(self, pos_id): return None def process_position_list(self, msg): + if msg[Field.PosReqResult] == "2": return name = self.sec_id_table[int(msg[Field.Symbol])]["name"] diff --git a/setup.py b/setup.py index 3b5c7c3..5a78e47 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ def requirements(filename): setup( name='ejtraderCT', - version='1.0.6', + version='1.0.7', packages=find_packages(), url='https://ejtraderCT.readthedocs.io/', download_url='https://ejtrader.com',