Пример #1
0
	def get_executions(self, reqId=MEANINGLESS_NUMBER):
		"""
		Returns a list of all executions done today
		"""
		assert type(reqId) is int
		if reqId==FILL_CODE:
			raise Exception("Can't call get_executions with a reqId of %d as this is reserved for fills %d" % reqId)

		self.cb.init_fill_data()
		self.cb.init_error()
		
		## We can change ExecutionFilter to subset different orders
		
		self.tws.reqExecutions(reqId, ExecutionFilter())

		iserror=False
		finished=False
		
		start_time=time.time()
		
		while not finished and not iserror:
			finished=self.cb.flag_fill_data_finished
			iserror=self.cb.flag_iserror
			if (time.time() - start_time) > MAX_WAIT_SECONDS:
				finished=True
			pass

		if iserror:
			print self.cb.error_msg
			print "Problem getting executions"

		execlist=self.cb.data_fill_data[reqId]
		
		return execlist
Пример #2
0
    def get_fills(self, reqId=MEANINGLESS_NUMBER):
        print("Getting fills...")
        assert type(reqId) is int

        self.cb.init_fill_data()
        self.cb.init_error()
        self.cb.init_time()

        self.tws.reqExecutions(reqId, ExecutionFilter())

        start_time = time.time()
        iserror = False
        finished = False

        while not finished and not iserror:
            finished = self.cb.flag_fill_data_finished
            iserror = self.cb.flag_iserror
            if (time.time() - start_time) > MAX_WAIT:
                finished = True
            pass

        if iserror:
            print("Error happened")
            print(self.cb.error_msg)

        execlist = self.cb.data_fill_data[reqId]
        commlist = 1  #self.cb.data_comm_data[reqId]
        return (execlist, commlist)
Пример #3
0
    def get_executions(self, reqId=MEANINGLESS_NUMBER):
        try:
            """
            Returns a list of all executions done today
            """
            assert type(reqId) is int
            if reqId == FILL_CODE:
                raise Exception(
                    "Can't call get_executions with a reqId of %d as this is reserved for fills %d"
                    % reqId)

            self.cb.init_fill_data()
            self.cb.init_error()

            ## We can change ExecutionFilter to subset different orders
            ef = ExecutionFilter()
            #ef.m_time="20160101"
            #ef.client_id=0;
            t = 2

            while t > 1:
                reqId = reqId + 1
                self.tws.reqExecutions(reqId, ef)

                iserror = False
                finished = False

                start_time = time.time()

                while not finished and not iserror:
                    finished = self.cb.flag_fill_data_finished
                    iserror = self.cb.flag_iserror
                    if (time.time() - start_time) > MAX_WAIT_SECONDS:
                        finished = True
                    pass

                if iserror:
                    print self.cb.error_msg
                    print "Problem getting executions"

                t = t - 1

            execlist = self.cb.data_fill_data.values()

            return execlist
        except Exception as e:
            logging.error("get_execution", exc_info=True)
Пример #4
0
    def get_executions(self):
        """
        Returns a list of all executions done today
        """

        global finished
        global iserror
        global execlist
        global getting_executions

        iserror = False
        finished = False
        execlist = []

        ## Tells the wrapper we are getting executions, not expecting fills
        ## Note that if you try and get executions when fills should be coming will be confusing!
        ## BE very careful with fills code

        getting_executions = True

        start_time = time.time()

        ## We can change ExecutionFilter to subset different orders

        self.tws.reqExecutions(MEANINGLESS_NUMBER, ExecutionFilter())

        while not finished:
            if (time.time() - start_time) > MAX_WAIT_SECONDS:
                finished = True
                iserror = True
            pass

        ## Change this flag back so that the process gets fills properly
        getting_executions = False

        if iserror:
            raise Exception("Problem getting executions")

        return execlist