Ejemplo n.º 1
0
    def get_all_current_positions_as_list_with_contract_objects(self, account_id=arg_not_supplied):
        all_positions = self._get_all_futures_positions_as_raw_list(account_id=account_id)
        current_positions = []
        for position_entry in all_positions:
            ib_code =  position_entry['symbol']
            instrument_code = self.futures_contract_data.get_instrument_code_from_broker_code(ib_code)
            expiry = position_entry['expiry']
            position = position_entry['position']
            if position==0:
                continue
            contract_position_object = contractPosition(position, instrument_code, expiry)
            current_positions.append(contract_position_object)

        list_of_contract_positions = listOfContractPositions(current_positions)

        return list_of_contract_positions
Ejemplo n.º 2
0
    def get_all_current_positions_as_list_with_contract_objects(self):
        all_positions_dict = self._get_list_of_args_dict()
        current_positions = []
        for dict_entry in all_positions_dict:
            contractid = self._contract_tuple_given_keyname(
                dict_entry['contractid'])
            instrument_code = contractid[0]
            contract_date = contractid[1]
            position = self.get_current_position_for_instrument_and_contract_date(
                instrument_code, contract_date).position
            if position == 0:
                continue
            position_object = contractPosition(position, instrument_code,
                                               contract_date)
            current_positions.append(position_object)

        list_of_current_positions = listOfContractPositions(current_positions)

        return list_of_current_positions