<jupyter_start><jupyter_text>Risk calculation results in gs_quant extend the ResultInfo Class, which contain helpful information about the risk calculations themselves. While you don't need to use these datatypes directly, they contain information about the returned result that might be useful to you. One of these datatypes is 'FloatWithInfo'.<jupyter_code>from gs_quant.session import Environment, GsSession
from gs_quant.common import PayReceive, Currency
from gs_quant.instrument import IRSwap
# external users should substitute their client id and secret; please skip this step if using internal jupyterhub
GsSession.use(Environment.PROD, client_id=None, client_secret=None, scopes=('run_analytics',))
swap_5y = IRSwap(PayReceive.Receive, '5y', Currency.EUR, fixed_rate='atm+10')
swap_10y = IRSwap(PayReceive.Receive, '10y', Currency.EUR, fixed_rate='atm+10')
#When 'price' is called on an instrument, a 'FloatWithInfo' is returned
res_5y = swap_5y.price()
type(res_5y)
#This datatype has a few members - most simply, the raw value:
res_5y.raw_value
#The risk unit
res_5y.unit
# The risk_key, which helpfully provides information of what market, date, scenario and risk_measure were used
# to produce the results
res_5y.risk_key
# You can add two instances of FloatWithInfo together when units are consistent
res_10y = swap_10y.price()
res_total=res_5y+res_10y
type(res_total)
# You can also add FloatWithInfo and other types of objects, but units won't be checked\n",
# For example, adding a FloatWithInfo and float returns a float\n",
res_total=res_5y+res_10y.raw_value
type(res_total)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07270486752926679, 'fraction_numerical': 0.016019716574245224, 'mean_word_length': 6.553488372093023, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '559968', 'license': 'Apache-2.0', 'n_tokens_mistral': 518, 'n_tokens_neox': 500, 'n_words': 183, 'path': 'gs_quant/documentation/02_pricing_and_risk/00_instruments_and_measures/examples/00_instrument_basics/0006_float-with-info.ipynb', 'repo_name': 'webclinic017/gs-quant', 'size': '1623'}