aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/api_quotes/__main__.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/python/api_quotes/__main__.py b/python/api_quotes/__main__.py
index 69bfdd4e..4342c0bb 100644
--- a/python/api_quotes/__main__.py
+++ b/python/api_quotes/__main__.py
@@ -11,9 +11,9 @@ logger = logging.getLogger(__name__)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
- "--start_from",
+ "start_from",
type=datetime.date.fromisoformat,
- default=None,
+ default=datetime.date.today(),
nargs="?",
)
args = parser.parse_args()
@@ -22,14 +22,9 @@ if __name__ == "__main__":
"CD",
"TRS",
):
- # We must add one day to include the day we start from
- if args.start_from:
- after = (
- int((args.start_from + datetime.timedelta(days=1)).strftime("%s"))
- * 1000
- )
- else:
- after = None
+ after = (
+ int((args.start_from + datetime.timedelta(days=1)).strftime("%s")) * 1000
+ )
while True:
try:
if data := MarkitAPI.get_data(asset_class, after):
@@ -43,9 +38,13 @@ if __name__ == "__main__":
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
- after = (
+ last_val = (
f"{row['receiveddatetime']},{asset_class}-9480-{row['quoteid']}"
)
+ if after == last_val:
+ break
+ else:
+ after = last_val
else:
break
except JSONDecodeError: