Currently showing posts tagged elecktron

  • Expanding Thomson Reuters Elektron Chain RICs with PyRFA

    We got an inquiry today regarding using our PyRFA to expand chain RICs. Here is the methods of expanding chain RICs that we delivered for a bank who used TREP-RT. Chains are comprised of RICs put in a FID LINK_ or LONGLINK divided into pages. Keep looking at NEXT_LR FID for the next chain RIC page and continue extracting actual RIC. Here are some Python code we used:

    def expandChainRIC(self, chainRIC):
            expanded = []
            done = False
            snapshot = self.snapshotRequest([chainRIC])
            while not done:
                if not snapshot:
                    break
                for i in ['LINK_1', 'LINK_2', 'LINK_3', 'LINK_4', 'LINK_5', 'LINK_6', 'LINK_7', 'LINK_8', 'LINK_9', 'LINK_10', 'LINK_11', 'LINK_12', 'LINK_13', 'LINK_14', 'LONGLINK1', 'LONGLINK2', 'LONGLINK3', 'LONGLINK4', 'LONGLINK5', 'LONGLINK6', 'LONGLINK7', 'LONGLINK8', 'LONGLINK9', 'LONGLINK10', 'LONGLINK11', 'LONGLINK12', 'LONGLINK13', 'LONGLINK14']:
                    if snapshot[0][2].has_key(i) and snapshot[0][2][i]:
                        expanded.append(snapshot[0][2][i])
                if snapshot[0][2].has_key('NEXT_LR') and snapshot[0][2]['NEXT_LR']:
                    snapshot = self.snapshotRequest([snapshot[0][2]['NEXT_LR']])
                elif snapshot[0][2].has_key('LONGNEXTLR') and snapshot[0][2]['LONGNEXTLR']:
                    snapshot = self.snapshotRequest([snapshot[0][2]['LONGNEXTLR']])
                else:
                    done = True
            # if chainRIC is not a chain, return itself back
            if not expanded:
                expanded.append(chainRIC)
            if self.debug:
                print "[debug] Expand chain " + chainRIC + " -> " + str(expanded)
            return expanded


    And

    def snapshotRequest(self, ricList):
            snaphots = ()
            self.pyrfa.log("Subscribing items: " + str(ricList) + " (total: " + str(len(ricList)) + " )")
            for ric in ricList:
                self.pyrfa.marketPriceRequest(ric)
            global end
            end = False
            t = threading.Timer(10, stop)
            t.start()
            imageReceived = 0
            while not end and imageReceived < len(ricList):
                images = self.pyrfa.dispatchEventQueue()
                if images:
                    for i in images:
                        if type(i[2]) is dict:
                            imageReceived += 1
                            snaphots += (i,)
                            t.cancel()
                            t = threading.Timer(10, stop)
                            t.start()
            self.pyrfa.log("Snapshots received: " + str(imageReceived))
            t.cancel()
            return snaphots