aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/risk/forwards.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/python/risk/forwards.py b/python/risk/forwards.py
new file mode 100644
index 00000000..727551b6
--- /dev/null
+++ b/python/risk/forwards.py
@@ -0,0 +1,15 @@
+from serenitas.analytics import Portfolio, FxForward
+import logging
+
+logger = logging.getLogger(__name__)
+
+
+def get_forward_portfolio(date, conn, fund="SERCGMAST", **kwargs):
+ sql_str = "SELECT dealid FROM spots where settle_date > %s and fund = %s"
+ with conn.cursor() as c:
+ c.execute(sql_str, (date, fund))
+ trade_ids = [tid for (tid,) in c]
+
+ portf = Portfolio([FxForward.from_tradeid(tid) for tid in trade_ids], trade_ids)
+ portf.value_date = date
+ return portf