aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/api_quotes/__main__.py29
1 files changed, 16 insertions, 13 deletions
diff --git a/python/api_quotes/__main__.py b/python/api_quotes/__main__.py
index 7bf3be69..4a6060f0 100644
--- a/python/api_quotes/__main__.py
+++ b/python/api_quotes/__main__.py
@@ -31,20 +31,23 @@ if __name__ == "__main__":
try:
if data := MarkitAPI.get_data(asset_class, after):
for key, quotes in data:
+ quotes = list(quotes)
+ # Don't try to insert into DB if already uploaded
if key["id"] in already_uploaded:
- continue
- 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()
+ row = quotes[-1]
+ else:
+ 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 = (