from collections import defaultdict, namedtuple from datetime import datetime import blpapi import pandas as pd import numpy as np import tia.util.log as log SecurityErrorAttrs = ['security', 'source', 'code', 'category', 'message', 'subcategory'] SecurityError = namedtuple('SecurityError', SecurityErrorAttrs) FieldErrorAttrs = ['security', 'field', 'source', 'code', 'category', 'message', 'subcategory'] FieldError = namedtuple('FieldError', FieldErrorAttrs) logger = log.get_logger(__name__) __all__ = ['Terminal'] class XmlHelper(object): @staticmethod def security_iter(nodearr): """ provide a security data iterator by returning a tuple of (Element, SecurityError) which are mutually exclusive """ assert nodearr.name() == 'securityData' and nodearr.isArray() for i in range(nodearr.numValues()): node = nodearr.getValue(i) err = XmlHelper.get_security_error(node) result = (None, err) if err else (node, None) yield result
"message", "subcategory", ] SecurityError = namedtuple("SecurityError", SecurityErrorAttrs) FieldErrorAttrs = [ "security", "field", "source", "code", "category", "message", "subcategory", ] FieldError = namedtuple("FieldError", FieldErrorAttrs) logger = log.get_logger(__name__) __all__ = ["Terminal"] class XmlHelper(object): @staticmethod def security_iter(nodearr): """ provide a security data iterator by returning a tuple of (Element, SecurityError) which are mutually exclusive """ assert nodearr.name() == "securityData" and nodearr.isArray() for i in range(nodearr.numValues()): node = nodearr.getValue(i) err = XmlHelper.get_security_error(node) result = (None, err) if err else (node, None) yield result