Skip to content

Commit b013f9c

Browse files
committed
Null check fix
1 parent ab0542c commit b013f9c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

upstox_api/api.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,15 @@ def _on_data (self, ws, message, data_type, continue_flag):
216216
i += 3
217217
j += 3
218218

219-
# append instrument object
220-
quote_object["instrument"] = self.get_instrument_by_symbol(fields[1], fields[2])
221-
222-
223219
if quote_object is None:
224-
logging.warning('Quote object was not mapped to any subscription. Length: %s, Values: %s' % (str(len(fields)), str(fields)))
220+
logging.warning('Quote object was not mapped to any subscription. Length: %s, Values: %s' % (str(len(fields)), quote))
225221
continue
226-
elif self.on_quote_update:
222+
else:
223+
# append instrument object
224+
if self.get_instrument_by_symbol(fields[1], fields[2]) is not None:
225+
quote_object["instrument"] = self.get_instrument_by_symbol(fields[1], fields[2])
226+
227+
if self.on_quote_update:
227228
self.on_quote_update(quote_object)
228229

229230
def _on_error (self, ws, error):

0 commit comments

Comments
 (0)