def __hold_fetch_current_positions(self) -> pd.DataFrame: # GET ATTRIBUTES trading_api = self.__trading_api # FETCH HELD PRODUCTS request_list = Update.RequestList() request_list.values.extend([ Update.Request( option=Update.Option.PORTFOLIO, last_updated=0, ), ]) update_pb = trading_api.get_update( request_list=request_list, raw=False, ) # CHECK EMPTINESS if len(update_pb.portfolio.values) == 0: return pd.DataFrame() else: positions_partial = self.__hold_filter_current_positions( portfolio=update_pb.portfolio, ) # FETCH ADDITIONAL DATA ON PRODUCTS positions = self.__hold_fetch_additional_information( positions=positions_partial, ) return positions
def pending(self) -> Update.Orders: trading_api = self.__trading_api request_list = Update.RequestList() request_list.values.extend([ Update.Request(option=Update.Option.ORDERS, last_updated=0), ]) update = trading_api.get_update(request_list=request_list) return update.orders
def update_pending_order(self, order_id: str) -> Union[None, Order]: trading_api = self.__trading_api request_list = Update.RequestList() request_list.values.extend([ Update.Request(option=Update.Option.ORDERS, last_updated=0), ]) update = trading_api.get_update(request_list=request_list) if len(update.orders.values) > 0: for order in update.orders.values: if order.id == order_id: return order return None else: return None