Alessandro.Carioni
I have tried to index via [] and methods like getValuePos(0) but the response is just None even though I can get a value from getValue("BID") from the same response.
market_subscription = Subscription(mode="DISTINCT",
items=[f"CHART:{ticker}:TICK" for ticker in tickers],
fields=["BID", "OFR", "UTM"])
class MarketListener(SubscriptionListener):
def __init__(self, q, info_dict={}):
super().__init__()
self.q = q
self.info_dict = info_dict
@profile
def onItemUpdate(self, update: ItemUpdate, *args):
epic_name = update.getItemName()
_, instrument_id, _ = epic_name.split(':')
epic = self.info_dict[instrument_id]
timestamp = update.getValue('UTM')
print("New Response")
print("getValue:")
bid = update.getValue('BID')
print(bid) # Gives float output and is correct
print("getValuePos:")
bid = update.getValuePos(0)
print(bid) # prints blanks (is None)
The listed methods for the update (ItemUpdate) are:
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '_getValueAsJSONPatchIfAvailable', '_hx_class', '_hx_class_name', '_hx_fields', '_hx_interfaces', '_hx_is_interface', '_hx_methods', '_hx_statics', '_hx_super', 'getChangedFields', 'getChangedFieldsByPosition', 'getFieldIdxFromName', 'getFieldNameOrNullFromIdx', 'getFields', 'getFieldsByPosition', 'getItemName', 'getItemPos', 'getValue', 'getValueAsJSONPatchIfAvailable', 'getValueName', 'getValuePos', 'isSnapshot', 'isValueChanged', 'isValueChangedName', 'isValueChangedPos', 'm_changedFields', 'm_fields', 'm_isSnapshot', 'm_itemIdx', 'm_items', 'm_jsonPatches', 'm_nFields', 'm_newValues', 'toString']
typical output:
New Response
getValue:
5933.83
getValuePos:
New Response
getValue:
None
getValuePos:
New Response
getValue:
5934.08
getValuePos:
New Response
getValue:
None
getValuePos:
New Response
getValue:
5933.95
getValuePos:
New Response
getValue:
5933.83
getValuePos:
New Response
getValue:
5933.95
getValuePos:
New Response
getValue:
5934.08