blob: a0e066fecd3ee71ccbc3be5fdc3d4de34317a078 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import logging
from json.decoder import JSONDecodeError
from .api import MarkitAPI
from .quotes import MarkitQuoteKind
logger = logging.getLogger(__name__)
if __name__ == "__main__":
for asset_class in (
"ABS",
"CD",
"TRS",
):
after = "1670330509000"
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 pase {row['quoteid']}: {e}")
else:
quote.stage()
quote.commit()
after = (
f"{row['receiveddatetime']},{asset_class}-9480-{row['quoteid']}"
)
else:
break
except JSONDecodeError:
print(f"Issue with {asset_class}: {after}")
except AttributeError:
MarkitAPI.update_api_key()
|