예제 #1
0
 def process(data):
     if 'rates' in data:
         self.rates = data['rates']
         self.last_updated = utils.now_in_utc_secs()
         return self.rates
     else:
         log.info("Could not retrieve ECB forex data")
예제 #2
0
 def process(data):
     if "rates" in data:
         self.rates = data["rates"]
         self.last_updated = utils.now_in_utc_secs()
         return self.rates
     else:
         log.info("Could not retrieve ECB forex data")
예제 #3
0
 def process(data):
     rates = dict()
     for quote in data['list']['resources']:
         quote = quote['resource']['fields']
         currency = quote['symbol'].split('=')[0]
         rates[currency] = Decimal(quote['price'])
     self.rates = rates
     self.last_updated = utils.now_in_utc_secs()
     return rates
예제 #4
0
 def process(data):
     rates = dict()
     for quote in data["list"]["resources"]:
         quote = quote["resource"]["fields"]
         currency = quote["symbol"].split("=")[0]
         rates[currency] = Decimal(quote["price"])
     self.rates = rates
     self.last_updated = utils.now_in_utc_secs()
     return rates
예제 #5
0
        def process(data):
            rates = dict()
            tree = ElementTree.ElementTree(ElementTree.fromstring(data))
            for el in tree.iterfind('Rate'):
                pair = el.get('Symbol')
                bid = Decimal(el[0].text)
                ask = Decimal(el[1].text)
                rate = (bid + ask) / 2

                if pair == 'Copper':
                    pair = 'XCPUSD'
                if len(pair) == 6 and pair.startswith('USD'):
                    rates[pair[3:]] = rate
                elif len(pair) == 6 and pair.endswith('USD'):
                    rates[pair[:3]] = 1 / rate
                else:
                    # these are indicies/natural gas/oil/etc. Could include if I really wanted to.
                    pass
            self.rates = rates
            self.last_updated = utils.now_in_utc_secs()
            return rates
예제 #6
0
        def process(data):
            rates = dict()
            tree = ElementTree.ElementTree(ElementTree.fromstring(data))
            for el in tree.iterfind("Rate"):
                pair = el.get("Symbol")
                bid = Decimal(el[0].text)
                ask = Decimal(el[1].text)
                rate = (bid + ask) / 2

                if pair == "Copper":
                    pair = "XCPUSD"
                if len(pair) == 6 and pair.startswith("USD"):
                    rates[pair[3:]] = rate
                elif len(pair) == 6 and pair.endswith("USD"):
                    rates[pair[:3]] = 1 / rate
                else:
                    # these are indicies/natural gas/oil/etc. Could include if I really wanted to.
                    pass
            self.rates = rates
            self.last_updated = utils.now_in_utc_secs()
            return rates
예제 #7
0
 def _should_update(self):
     if self.last_updated and utils.now_in_utc_secs(
     ) - self.last_updated < self.update_freq:
         return False
     return True
예제 #8
0
 def _should_update(self):
     if self.last_updated and utils.now_in_utc_secs() - self.last_updated < self.update_freq:
         return False
     return True