aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics/__init__.py')
-rw-r--r--python/analytics/__init__.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/python/analytics/__init__.py b/python/analytics/__init__.py
index ccb135f0..849c1d04 100644
--- a/python/analytics/__init__.py
+++ b/python/analytics/__init__.py
@@ -1,10 +1,18 @@
import sys
+
sys.path.append("..")
from utils.db import serenitas_engine, dawn_engine, dbconn, DataError, serenitas_pool
from .index import CreditIndex, ForwardIndex
-from .option import (BlackSwaption, Swaption, ATMstrike, ProbSurface,
- QuoteSurface, VolSurface, BlackSwaptionVolSurface)
+from .option import (
+ BlackSwaption,
+ Swaption,
+ ATMstrike,
+ ProbSurface,
+ QuoteSurface,
+ VolSurface,
+ BlackSwaptionVolSurface,
+)
from .portfolio import Portfolio
from .basket_index import MarkitBasketIndex
from .tranche_basket import DualCorrTranche, TrancheBasket
@@ -12,15 +20,18 @@ from .ir_swaption import IRSwaption
import datetime
+
def on_the_run(index, value_date=datetime.date.today()):
- r = serenitas_engine.execute("SELECT max(series) FROM index_maturity WHERE index=%s "
- "and issue_date <= %s",
- (index, value_date))
+ r = serenitas_engine.execute(
+ "SELECT max(series) FROM index_maturity WHERE index=%s " "and issue_date <= %s",
+ (index, value_date),
+ )
series, = r.fetchone()
return series
+
def init_ontr(value_date=datetime.date.today()):
global _ontr, _beta
- _ontr = CreditIndex('HY', on_the_run("HY", value_date), '5yr', value_date)
+ _ontr = CreditIndex("HY", on_the_run("HY", value_date), "5yr", value_date)
_ontr.mark()
- _beta = {'HY': 1, 'IG': .3, 'EU': .22, "BS": 0.5}
+ _beta = {"HY": 1, "IG": 0.3, "EU": 0.22, "BS": 0.5}