diff options
Diffstat (limited to 'python/api_quotes/__main__.py')
| -rw-r--r-- | python/api_quotes/__main__.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/python/api_quotes/__main__.py b/python/api_quotes/__main__.py index 4342c0bb..98655762 100644 --- a/python/api_quotes/__main__.py +++ b/python/api_quotes/__main__.py @@ -1,5 +1,6 @@ import logging import argparse + from json.decoder import JSONDecodeError import datetime @@ -28,14 +29,19 @@ if __name__ == "__main__": while True: try: if data := MarkitAPI.get_data(asset_class, after): - for row in data: - try: - quote = MarkitQuoteKind[asset_class].from_markit_line(row) - except ValueError as e: - logger.error(f"Couldn't parse {row['quoteid']}: {e}") - else: - quote.stage() - quote.commit() + for msg_id, quotes in data: + for row in quotes: + try: + quote = MarkitQuoteKind[asset_class].from_markit_line( + row + ) + except ValueError as e: + MarkitQuoteKind[asset_class].clear() + logger.error(f"Couldn't parse {msg_id}: {e}") + continue + else: + quote.stage() + quote.commit() # The after is specific so that we can avoid skipping any quotes # We would also get stuck sometimes without the quoteid being specified last_val = ( |
