gs_quant.markets.core.PricingContext¶
- class PricingContext(pricing_date=None, market_data_location=None, is_async=None, is_batch=None, use_cache=None, visible_to_gs=None, request_priority=None, csa_term=None, timeout=None, market=None, show_progress=None, use_server_cache=None, market_behaviour='ContraintsBased', set_parameters_only=False)[source]¶
A context for controlling pricing and market data behaviour
- __init__(pricing_date=None, market_data_location=None, is_async=None, is_batch=None, use_cache=None, visible_to_gs=None, request_priority=None, csa_term=None, timeout=None, market=None, show_progress=None, use_server_cache=None, market_behaviour='ContraintsBased', set_parameters_only=False)[source]¶
The methods on this class should not be called directly. Instead, use the methods on the instruments, as per the examples
- Parameters:
pricing_date (
Optional[date]) – the date for pricing calculations. Default is todaymarket_data_location (
Union[PricingLocation,str,None]) – the location for sourcing market data (‘NYC’, ‘LDN’ or ‘HKG’ (defaults to LDN)is_async (
Optional[bool]) – if True, return (a future) immediately. If False, block (defaults to False)is_batch (
Optional[bool]) – use for calculations expected to run longer than 3 mins, to avoid timeouts. It can be used with is_async=True|False (defaults to False)use_cache (
Optional[bool]) – store results in the pricing cache (defaults to False)visible_to_gs (
Optional[bool]) – are the contents of risk requests visible to GS (defaults to False)request_priority (
Optional[int]) – the priority of risk requestscsa_term (
Optional[str]) – the csa under which the calculations are made. Default is local ccy ois indextimeout (
Optional[int]) – the timeout for batch operationsmarket (
Optional[Market]) – a Market objectshow_progress (
Optional[bool]) – add a progress bar (tqdm)use_server_cache (
Optional[bool]) – cache query results on the GS serversmarket_behaviour (
Optional[str]) – the behaviour to build the curve for pricing (‘ContraintsBased’ or ‘Calibrated’ (defaults to ContraintsBased))set_parameters_only (
bool) – if true don’t stop embedded pricing contexts submitting their jobs.
Examples
To change the market data location of the default context:
>>> from gs_quant.markets import PricingContext >>> >>> PricingContext.current = PricingContext(market_data_location='LDN')
For a blocking, synchronous request:
>>> from gs_quant.instrument import IRCap >>> cap = IRCap('5y', 'GBP') >>> >>> with PricingContext(): >>> price_f = cap.dollar_price() >>> >>> price = price_f.result()
For an asynchronous request:
>>> with PricingContext(is_async=True): >>> price_f = cap.dollar_price() >>> >>> while not price_f.done: >>> ...
Methods
__init__([pricing_date, ...])The methods on this class should not be called directly.
calc(instrument, risk_measure)Calculate the risk measure for the instrument.
clone(**kwargs)default_value()- rtype:
object
Attributes
active_contextcsa_termis_asyncis_batchis_currentis_enteredmarketmarket_behaviourmarket_data_locationpricing_datePricing date
request_priorityset_parameters_onlyshow_progresstimeoutuse_cacheCache results
use_server_cachevisible_to_gsRequest contents visible to GS