Risk Package¶
Functions¶
- aggregate_risk(results, threshold=None, allow_heterogeneous_types=False)[source]¶
Combine the results of multiple InstrumentBase.calc() calls, into a single result
- Parameters:
results (
Iterable
[Union
[DataFrameWithInfo
,Future
]]) – An iterable of Dataframes and/or Futures (returned by InstrumentBase.calc())threshold (
Optional
[float
]) – exclude values whose absolute value falls below this thresholdallow_heterogeneous_types (
bool
) – allow Series to be converted to DataFrames before aggregating
- Return type:
DataFrame
- Returns:
A Dataframe with the aggregated results
Examples
>>> from gs_quant.instrument import IRCap, IRFloor >>> from gs_quant.markets import PricingContext >>> from gs_quant.risk import IRDelta, IRVega >>> >>> cap = IRCap('5y', 'GBP') >>> floor = IRFloor('5y', 'GBP') >>> instruments = (cap, floor) >>> >>> with PricingContext(): >>> delta_f = [inst.calc(IRDelta) for inst in instruments] >>> vega_f = [inst.calc(IRVega) for inst in (cap, floor)] >>> >>> delta = aggregate_risk(delta_f, threshold=0.1) >>> vega = aggregate_risk(vega_f)
delta_f and vega_f are lists of futures, where the result will be a Dataframe delta and vega are Dataframes, representing the merged risk of the individual instruments
- subtract_risk(left, right)[source]¶
Subtract bucketed risk. Dimensions must be identical
- Parameters:
left (
DataFrameWithInfo
) – Results to substract fromright (
DataFrameWithInfo
) – Results to substract
- Return type:
DataFrame
Examples
>>> from gs_quant.datetime.date import business_day_offset >>> from gs_quant.instrument IRSwap >>> from gs_quant.markets import PricingContext >>> from gs_quant.risk import IRDelta >>> import datetime as dt >>> >>> ir_swap = IRSwap('Pay', '10y', 'USD') >>> delta_today = ir_swap.calc(IRDelta) >>> >>> with PricingContext(pricing_date=business_day_offset(dt.date.today(), -1, roll='preceding')): >>> delta_yday_f = ir_swap.calc(IRDelta) >>> >>> delta_diff = subtract_risk(delta_today, delta_yday_f.result())
Measures¶
- DollarPrice = DollarPrice¶
Price of the instrument in US Dollars
- Price(currency=None, name=None) = Price¶
Present Value
- ForwardPrice = ForwardPrice¶
Price of the instrument at expiry in the local currency
- Theta = Theta¶
Theta
- BaseCPI = BaseCPI¶
Base CPI
- CommodDelta = CommodDelta¶
Commod Delta
- CommodTheta = CommodTheta¶
Commod Theta
- CommodVega = CommodVega¶
Commod Vega
- EqDelta(currency=None, name=None) = EqDelta¶
Change in Dollar Price (USD present value) due to individual 1% move in the spot price of underlying equity security
- EqGamma(currency=None, name=None) = EqGamma¶
Change in EqDelta for a 1% move in the price of the underlying equity security
- EqVega(currency=None, name=None) = EqVega¶
Change in Dollar Price (USD present value) due to individual 1bp moves in the implied volatility of the underlying equity security
- EqSpot = EqSpot¶
Equity Spot
- EqAnnualImpliedVol = EqAnnualImpliedVol¶
Equity Annual Implied Volatility (%)
- FairVarStrike = FairVarStrike¶
Fair Variance Strike Value of a Variance Swap
- FairVolStrike = FairVolStrike¶
Fair Volatility Strike Value of a Variance Swap
- FXDelta(aggregation_level=None, bump_size=None, currency=None, finite_difference_method=None, local_curve=None, mkt_marking_options=None, scale_factor=None, name=None) = FXDelta¶
Dollar Price sensitivity of the instrument to a move in the underlying spot such that dSpot * FXDelta = PnL
- FXGamma = FXGamma¶
FXDelta sensitivity of the instrument to a move in the underlying spot such that dSpot * FXGamma = dDelta
- FXVega(aggregation_level=None, bump_size=None, currency=None, finite_difference_method=None, local_curve=None, mkt_marking_options=None, scale_factor=None, name=None) = FXVega¶
Change in Dollar Price due to a 1 vol move in the implied volatility of ATM instruments used to build the volatility surface
- FXSpot = FXSpot¶
FX spot reference
- FXAnnualImpliedVol = FXAnnualImpliedVol¶
FX Annual Implied Volatility
- FXAnnualATMImpliedVol = FXAnnualATMImpliedVol¶
FX Annual ATM Implied Volatility
- InflationDelta(aggregation_level=None, bump_size=None, currency=None, finite_difference_method=None, local_curve=None, mkt_marking_options=None, scale_factor=None, name=None) = InflationDelta¶
Change in Price due to 1bp move in inflation curve.
- InflationDeltaParallel(aggregation_level=None, bump_size=None, currency=None, finite_difference_method=None, local_curve=None, mkt_marking_options=None, scale_factor=None, name=None) = InflationDeltaParallel(aggregation_level:Type)¶
Change in Price due to 1bp move in inflation curve.
- IRBasis(aggregation_level=None, bump_size=None, currency=None, finite_difference_method=None, local_curve=None, mkt_marking_options=None, scale_factor=None, name=None) = IRBasis¶
Change in Dollar Price (USD present value) due to individual 1bp moves in the interest rate instruments used to build the basis curve(s)
- IRDelta(aggregation_level=None, bump_size=None, currency=None, finite_difference_method=None, local_curve=None, mkt_marking_options=None, scale_factor=None, name=None) = IRDelta¶
Change in Dollar Price (USD present value) due to individual 1bp moves in the interest rate instruments used to build the underlying discount curve
- IRDeltaParallel(aggregation_level=None, bump_size=None, currency=None, finite_difference_method=None, local_curve=None, mkt_marking_options=None, scale_factor=None, name=None) = IRDeltaParallel(aggregation_level:Asset)¶
Change in Dollar Price (USD present value) due to individual 1bp moves in the interest rate instruments used to build the underlying discount curve
- IRDeltaLocalCcy(aggregation_level=None, bump_size=None, currency=None, finite_difference_method=None, local_curve=None, mkt_marking_options=None, scale_factor=None, name=None) = IRDeltaLocalCcy(currency:local)¶
Change in Dollar Price (USD present value) due to individual 1bp moves in the interest rate instruments used to build the underlying discount curve
- IRXccyDelta(aggregation_level=None, bump_size=None, currency=None, finite_difference_method=None, local_curve=None, mkt_marking_options=None, scale_factor=None, name=None) = IRXccyDelta¶
Change in Price due to 1bp move in cross currency rates.
- IRXccyDeltaParallel(aggregation_level=None, bump_size=None, currency=None, finite_difference_method=None, local_curve=None, mkt_marking_options=None, scale_factor=None, name=None) = IRXccyDeltaParallel(aggregation_level:Type)¶
Change in Price due to 1bp move in cross currency rates.
- IRGammaParallel = IRGammaParallel¶
Change in aggregated IRDelta for a aggregated 1bp shift in the interest rate instruments used to build the underlying discount curve
- IRGammaParallelLocalCcy = IRGammaParallelLocalCcy¶
Interest Rate Parallel Gamma (Local Ccy)
- IRVega(aggregation_level=None, bump_size=None, currency=None, finite_difference_method=None, local_curve=None, mkt_marking_options=None, scale_factor=None, name=None) = IRVega¶
Change in Dollar Price (USD present value) due to individual 1bp moves in the implied volatility (IRAnnualImpliedVol) of instruments used to build the volatility surface
- IRVegaParallel(aggregation_level=None, bump_size=None, currency=None, finite_difference_method=None, local_curve=None, mkt_marking_options=None, scale_factor=None, name=None) = IRVegaParallel(aggregation_level:Asset)¶
Change in Dollar Price (USD present value) due to individual 1bp moves in the implied volatility (IRAnnualImpliedVol) of instruments used to build the volatility surface
- IRVegaLocalCcy(aggregation_level=None, bump_size=None, currency=None, finite_difference_method=None, local_curve=None, mkt_marking_options=None, scale_factor=None, name=None) = IRVegaLocalCcy(currency:local)¶
Change in Dollar Price (USD present value) due to individual 1bp moves in the implied volatility (IRAnnualImpliedVol) of instruments used to build the volatility surface
- IRAnnualImpliedVol = IRAnnualImpliedVol¶
Interest rate annual implied volatility (in percent)
- IRAnnualATMImpliedVol = IRAnnualATMImpliedVol¶
Interest rate annual implied at-the-money volatility (in percent)
- IRDailyImpliedVol = IRDailyImpliedVol¶
Interest rate daily implied volatility (in basis points)
- IRSpotRate = IRSpotRate¶
Interest rate at-the-money spot rate (in percent)
- IRFwdRate = IRFwdRate¶
Interest rate par rate (in percent)