aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/api_quotes/api.py7
-rw-r--r--python/api_quotes/quotes.py7
2 files changed, 9 insertions, 5 deletions
diff --git a/python/api_quotes/api.py b/python/api_quotes/api.py
index 1857a3ac..60fce5e6 100644
--- a/python/api_quotes/api.py
+++ b/python/api_quotes/api.py
@@ -30,17 +30,20 @@ class MarkitAPI:
"limit": 1000,
"sortBy": "receivedDateTime",
"descending": "true",
+ "dateformat": "MILLISECONDSSINCEEPOCH",
}
if after:
- params["after"] = f'1653286316000,"{asset_class}-9480-{after}"'
+ params["after"] = after
path = posixpath.join("parsing", "Quote", service)
url = urljoin(cls.base_url, path)
r = requests.get(url, params)
+ print(params)
return cls.read_api(r)
@staticmethod
def read_api(r):
df = pd.DataFrame.from_dict(json.loads(r.text))
+ if df.empty:
+ return
df.columns = df.columns.str.lower()
- df[df["confidence"] == 10]
return df.to_dict(orient="records")
diff --git a/python/api_quotes/quotes.py b/python/api_quotes/quotes.py
index bc951aa8..dc5d856c 100644
--- a/python/api_quotes/quotes.py
+++ b/python/api_quotes/quotes.py
@@ -3,6 +3,7 @@ from dataclasses import dataclass, field
import datetime
from typing import Literal
from serenitas.utils.db2 import dbconn
+import datetime
firmness = Literal["FIRM", "INDICATIVE"]
asset_class = Literal["CD"]
@@ -33,7 +34,7 @@ class Quote(Deal, table_name="markit_quotes", deal_type=None):
asksize: float
firmness: firmness
msg_id: str
- quotedate: datetime
+ quotedate: datetime.datetime
quotesource: str
@classmethod
@@ -43,7 +44,7 @@ class Quote(Deal, table_name="markit_quotes", deal_type=None):
int(d["maturityyear"]), int(d["maturitymonth"]), int(d["maturityday"])
),
"msg_id": d["message"]["id"],
- "quotedate": d["receiveddatetime"],
+ "quotedate": datetime.datetime.fromtimestamp(d["receiveddatetime"] / 1000),
"quotesource": d["sourceshortname"],
"tenor": f"{d['tenor']}Y",
}
@@ -57,5 +58,5 @@ class Quote(Deal, table_name="markit_quotes", deal_type=None):
Quote.init_dbconn(dbconn("serenitasdb"))
Quote._sql_insert = Quote._sql_insert.replace(
- "RETURNING *", "ON CONFLICT DO NOTHING RETURNING *"
+ "RETURNING *", "ON CONFLICT (quoteid) DO NOTHING RETURNING *"
)