aboutsummaryrefslogtreecommitdiffstats
path: root/python/api_quotes/__main__.py
blob: ec926e8effcc3fab0ca15534e8ea22c8e4172182 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from .api import MarkitAPI
from .quotes import Quote
import pandas as pd
import logging

logger = logging.getLogger(__name__)

if __name__ == "__main__":
    asset_class = "CD"
    after = None
    for i in range(1000):
        if data := MarkitAPI.get_data(asset_class, after):
            for row in data:
                try:
                    quote = Quote.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