32
32
FinFXDeltaMethod
33
33
from financepy .market .volatility .fx_vol_surface_plus import vol_function
34
34
from financepy .market .volatility .fx_vol_surface_plus import \
35
- VolFunctionTypes
35
+ VolFuncTypes
36
36
37
37
from financepy .utils .global_types import FinSolverTypes
38
38
except :
@@ -142,17 +142,17 @@ def __init__(self, market_df=None, asset=None, field="close",
142
142
[asset + "10R" + t + field for t in tenors ]].values
143
143
144
144
if vol_function_type == "CLARK" :
145
- self ._vol_function_type = VolFunctionTypes .CLARK
145
+ self ._vol_function_type = VolFuncTypes .CLARK
146
146
elif vol_function_type == "CLARK5" :
147
- self ._vol_function_type = VolFunctionTypes .CLARK5
147
+ self ._vol_function_type = VolFuncTypes .CLARK5
148
148
elif vol_function_type == "BBG" :
149
- self ._vol_function_type = VolFunctionTypes .BBG
149
+ self ._vol_function_type = VolFuncTypes .BBG
150
150
151
151
# Note: currently SABR isn"t fully implemented in FinancePy
152
152
elif vol_function_type == "SABR" :
153
- self ._vol_function_type = VolFunctionTypes .SABR
153
+ self ._vol_function_type = VolFuncTypes .SABR
154
154
elif vol_function_type == "SABR3" :
155
- self ._vol_function_type = VolFunctionTypes .SABR3
155
+ self ._vol_function_type = VolFuncTypes .SABR3
156
156
157
157
# What does ATM mean? (for most
158
158
if atm_method == "fwd-delta-neutral" : # ie. strike such that a straddle would be delta neutral
@@ -246,10 +246,10 @@ def build_vol_surface(self, value_date):
246
246
self ._risk_reversal10DeltaVols [
247
247
date_index ][0 ],
248
248
self ._alpha ,
249
- atmMethod = self ._atm_method ,
250
- deltaMethod = self ._delta_method ,
251
- volatility_function_type = self ._vol_function_type ,
252
- finSolverType = self ._solver ,
249
+ atm_method = self ._atm_method ,
250
+ delta_method = self ._delta_method ,
251
+ vol_func_type = self ._vol_function_type ,
252
+ fin_solver_type = self ._solver ,
253
253
tol = self ._tol ) # TODO add tol
254
254
255
255
def calculate_vol_for_strike_expiry (self , K , expiry_date = None , tenor = "1M" ):
@@ -335,21 +335,21 @@ def extract_vol_surface(self, num_strike_intervals=60, low_K_pc=0.95,
335
335
336
336
# columns = tenors
337
337
df_vol_surface_strike_space = pd .DataFrame (
338
- columns = self ._fin_fx_vol_surface ._tenors )
338
+ columns = self ._fin_fx_vol_surface .tenors )
339
339
df_vol_surface_delta_space = pd .DataFrame (
340
- columns = self ._fin_fx_vol_surface ._tenors )
340
+ columns = self ._fin_fx_vol_surface .tenors )
341
341
342
342
# columns = tenors
343
343
df_vol_surface_implied_pdf = pd .DataFrame (
344
- columns = self ._fin_fx_vol_surface ._tenors )
344
+ columns = self ._fin_fx_vol_surface .tenors )
345
345
346
346
# Conversion between main deltas and strikes
347
347
df_deltas_vs_strikes = pd .DataFrame (
348
- columns = self ._fin_fx_vol_surface ._tenors )
348
+ columns = self ._fin_fx_vol_surface .tenors )
349
349
350
350
# ATM, 10d + 25d market strangle and 25d risk reversals
351
351
df_vol_surface_quoted_points = pd .DataFrame (
352
- columns = self ._fin_fx_vol_surface ._tenors )
352
+ columns = self ._fin_fx_vol_surface .tenors )
353
353
354
354
# Note, at present we"re not using 10d strikes
355
355
quoted_strikes_names = ["ATM" , "STR_25D_MS" , "RR_25D_P" , "STR_10D_MS" ,
@@ -359,8 +359,8 @@ def extract_vol_surface(self, num_strike_intervals=60, low_K_pc=0.95,
359
359
"K_10D_C_MS" ]
360
360
361
361
# Get max/min strikes to interpolate (from the longest dated tenor)
362
- low_K = self ._fin_fx_vol_surface ._K_25D_P [- 1 ] * low_K_pc
363
- high_K = self ._fin_fx_vol_surface ._K_25D_C [- 1 ] * high_K_pc
362
+ low_K = self ._fin_fx_vol_surface .k_25d_p [- 1 ] * low_K_pc
363
+ high_K = self ._fin_fx_vol_surface .k_25d_c [- 1 ] * high_K_pc
364
364
365
365
if num_strike_intervals is not None :
366
366
# In case using old version of FinancePy
@@ -370,19 +370,19 @@ def extract_vol_surface(self, num_strike_intervals=60, low_K_pc=0.95,
370
370
except :
371
371
pass
372
372
373
- for tenor_index in range (0 , self ._fin_fx_vol_surface ._num_vol_curves ):
373
+ for tenor_index in range (0 , self ._fin_fx_vol_surface .num_vol_curves ):
374
374
375
375
# Get the quoted vol points
376
- tenor_label = self ._fin_fx_vol_surface ._tenors [tenor_index ]
376
+ tenor_label = self ._fin_fx_vol_surface .tenors [tenor_index ]
377
377
378
- atm_vol = self ._fin_fx_vol_surface ._atm_vols [tenor_index ] * 100
379
- ms_25d_vol = self ._fin_fx_vol_surface ._mktStrangle25DeltaVols [
378
+ atm_vol = self ._fin_fx_vol_surface .atm_vols [tenor_index ] * 100
379
+ ms_25d_vol = self ._fin_fx_vol_surface .ms_25_delta_vols [
380
380
tenor_index ] * 100
381
- rr_25d_vol = self ._fin_fx_vol_surface ._riskReversal25DeltaVols [
381
+ rr_25d_vol = self ._fin_fx_vol_surface .rr_25_delta_vols [
382
382
tenor_index ] * 100
383
- ms_10d_vol = self ._fin_fx_vol_surface ._mktStrangle10DeltaVols [
383
+ ms_10d_vol = self ._fin_fx_vol_surface .ms_10_delta_vols [
384
384
tenor_index ] * 100
385
- rr_10d_vol = self ._fin_fx_vol_surface ._riskReversal10DeltaVols [
385
+ rr_10d_vol = self ._fin_fx_vol_surface .rr_10_delta_vols [
386
386
tenor_index ] * 100
387
387
388
388
df_vol_surface_quoted_points [tenor_label ] = pd .Series (
@@ -416,19 +416,19 @@ def extract_vol_surface(self, num_strike_intervals=60, low_K_pc=0.95,
416
416
417
417
# Extract strikes for the quoted points (ie. 10d, 25d and ATM)
418
418
key_strikes = []
419
- key_strikes .append (self ._fin_fx_vol_surface ._K_10D_P [tenor_index ])
419
+ key_strikes .append (self ._fin_fx_vol_surface .k_10d_p [tenor_index ])
420
420
key_strikes .append (
421
- self ._fin_fx_vol_surface ._K_10D_P_MS [tenor_index ])
422
- key_strikes .append (self ._fin_fx_vol_surface ._K_25D_P [tenor_index ])
421
+ self ._fin_fx_vol_surface .k_10d_p_ms [tenor_index ])
422
+ key_strikes .append (self ._fin_fx_vol_surface .k_25d_p [tenor_index ])
423
423
key_strikes .append (
424
- self ._fin_fx_vol_surface ._K_25D_P_MS [tenor_index ])
425
- key_strikes .append (self ._fin_fx_vol_surface ._K_ATM [tenor_index ])
426
- key_strikes .append (self ._fin_fx_vol_surface ._K_25D_C [tenor_index ])
424
+ self ._fin_fx_vol_surface .k_25d_p_ms [tenor_index ])
425
+ key_strikes .append (self ._fin_fx_vol_surface .k_atm [tenor_index ])
426
+ key_strikes .append (self ._fin_fx_vol_surface .k_25d_c [tenor_index ])
427
427
key_strikes .append (
428
- self ._fin_fx_vol_surface ._K_25D_C_MS [tenor_index ])
429
- key_strikes .append (self ._fin_fx_vol_surface ._K_10D_C [tenor_index ])
428
+ self ._fin_fx_vol_surface .k_25d_c_ms [tenor_index ])
429
+ key_strikes .append (self ._fin_fx_vol_surface .k_10d_c [tenor_index ])
430
430
key_strikes .append (
431
- self ._fin_fx_vol_surface ._K_10D_C_MS [tenor_index ])
431
+ self ._fin_fx_vol_surface .k_10d_c_ms [tenor_index ])
432
432
433
433
df_deltas_vs_strikes [tenor_label ] = pd .Series (
434
434
index = key_strikes_names , data = key_strikes )
@@ -467,9 +467,9 @@ def get_vol_from_quoted_tenor(self, K, tenor, gaps=None):
467
467
if gaps is None :
468
468
gaps = np .array ([0.1 ])
469
469
470
- params = self ._fin_fx_vol_surface ._parameters [tenor_index ]
471
- t = self ._fin_fx_vol_surface ._texp [tenor_index ]
472
- f = self ._fin_fx_vol_surface ._F0T [tenor_index ]
470
+ params = self ._fin_fx_vol_surface .parameters [tenor_index ]
471
+ t = self ._fin_fx_vol_surface .t_exp [tenor_index ]
472
+ f = self ._fin_fx_vol_surface .fwd [tenor_index ]
473
473
474
474
return vol_function (self ._vol_function_type .value , params ,
475
475
np .array ([K ]), gaps , f , K , t )
0 commit comments