aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/task_server/__main__.py3
-rw-r--r--python/task_server/globeop.py50
2 files changed, 31 insertions, 22 deletions
diff --git a/python/task_server/__main__.py b/python/task_server/__main__.py
index 3f44fe87..a5ccf8a9 100644
--- a/python/task_server/__main__.py
+++ b/python/task_server/__main__.py
@@ -35,4 +35,5 @@ if args.download:
elif args.upload:
time = datetime.datetime.now().time()
date = datetime.datetime.combine(args.date, time)
- upload_data(engine, date)
+ for fund in ("SERCGMAST", "BOWDST"):
+ upload_data(engine, date, fund)
diff --git a/python/task_server/globeop.py b/python/task_server/globeop.py
index 80f79189..99ec3e45 100644
--- a/python/task_server/globeop.py
+++ b/python/task_server/globeop.py
@@ -186,50 +186,58 @@ def insert_todb(engine, workdate: datetime.date, fund="SERCGMAST"):
df.to_sql(table, conn, if_exists="append", index=False)
-def upload_bond_marks(engine, workdate: datetime.datetime):
+def upload_bond_marks(engine, workdate: datetime.datetime, fund):
+
d = workdate.date()
df = pd.read_sql_query(
"SELECT p.identifier, price from list_marks(%s) m "
- "RIGHT JOIN list_positions(%s, NULL, False) p "
+ "RIGHT JOIN list_positions(%s, NULL, False, %s) p "
"ON m.identifier=p.figi; ",
engine,
- params=(d, d),
+ params=(
+ d,
+ d,
+ fund,
+ ),
)
df.rename(columns={"identifier": "IDENTIFIER", "price": "Price"}, inplace=True)
fullpath = DAILY_DIR / str(d) / f"securitiesNpv{workdate:%Y%m%d_%H%M%S}.csv"
df.to_csv(fullpath, index=False)
- ftp = FtpClient.from_creds("globeop")
- ftp.client.cwd("incoming")
- ftp.put(fullpath)
- sftp = SftpClient.from_creds("hm_globeop")
- sftp.client.chdir("incoming/gopricing")
- sftp.put(fullpath)
+ match fund:
+ case "SERCGMAST":
+ server = FtpClient.from_creds("globeop", folder="incoming")
+ case "BOWDST":
+ server = SftpClient.from_creds("hm_globeop", folder="incoming/gopricing")
+ server.put(fullpath)
logger.info("upload bond marks done")
-def upload_cds_marks(engine, workdate: datetime.datetime):
+def upload_cds_marks(engine, workdate: datetime.datetime, fund):
d = workdate.date()
df = pd.read_sql_query(
"""SELECT cds.dealid AS "DealID", 'CREDIT_SWAP' AS "Instrument Type",
-(a.clean_nav+a.accrued) AS "NPV" from list_abscds_marks(%s) a
+(a.clean_nav+a.accrued) AS "NPV" from list_abscds_marks(%s, %s) a
JOIN cds USING (security_id)""",
engine,
- params=(d,),
+ params=(
+ d,
+ fund,
+ ),
)
fullpath = DAILY_DIR / str(d) / f"otcNpv{workdate:%Y%m%d}.csv"
df.to_csv(fullpath, index=False)
- ftp = FtpClient.from_creds("globeop")
- ftp.client.cwd("incoming")
- ftp.put(fullpath)
- sftp = SftpClient.from_creds("hm_globeop")
- sftp.client.chdir("incoming/gopricing")
- sftp.put(fullpath)
+ match fund:
+ case "SERCGMAST":
+ server = FtpClient.from_creds("globeop", folder="incoming")
+ case "BOWDST":
+ server = SftpClient.from_creds("hm_globeop", folder="incoming/gopricing")
+ server.put(fullpath)
logger.info("upload cds marks done")
-def upload_data(engine, workdate: datetime.datetime):
- upload_bond_marks(engine, workdate)
- upload_cds_marks(engine, workdate)
+def upload_data(engine, workdate: datetime.datetime, fund):
+ upload_bond_marks(engine, workdate, fund)
+ upload_cds_marks(engine, workdate, fund)
def back_fill(start_date="2017-07-20"):