Source code for derivitec.core.client

from derivitec.core.client_base import ClientBase
from derivitec.core.dict_builder_abstract import DictBuilderAbstract


class DerivitecClient(ClientBase):
    """
    The Derivitec client.

    >>> from derivitec import *
    >>> client = DerivitecClient(dev)
    """

[docs] def get_bond_futures_series(self, futures_prefix, roll_days, start_date, end_date): """ Get a bond futures data time series for a given futures prefix and a specified offset to the expiry between two dates. :param futures_prefix: The futures prefix. :type futures_prefix: str :param roll_days: The roll days. :type roll_days: int :param start_date: The start date. :type start_date: datetime.datetime :param end_date: The end date. :type end_date: datetime.datetime :rtype: :class:`derivitec.market_data.response.ApiGetBondFuturesSeriesResponse` **Code** >>> from datetime import datetime >>> bond_futures_series = client.get_bond_futures_series( ... futures_prefix="FV", ... roll_days = 5, ... start_date = datetime(2016, 6, 26), ... end_date = datetime(2016, 12, 26)) """ wrapper = self._get_wrapper('get_bond_futures_series') return wrapper( futures_prefix=futures_prefix, roll_days=roll_days, start_date=start_date, end_date=end_date)
[docs] def get_calendars(self, calendars): """ Get calendars :param calendars: The calendar codes. :type calendars: list of str :rtype: `list` of `derivitec.market_data.types.Calendar` **Code** >>> client.get_calendars( ["USD"] ) """ wrapper = self._get_wrapper('get_calendars') return wrapper(identifiers=calendars)
[docs] def get_convertible_bonds(self, identifiers, market_data_environment_name=None): """ Get convertible bonds for some identifier. :param identifiers: The identifiers. :type identifiers: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: dict[:class:`derivitec.misc.types.InstrumentIdentifier`, :class:`derivitec.tradables.types.ConvertibleBond`] **Code** >>> identifiers = [isin("US912810FB99")] >>> market_data_environment_name = "Example Market Data Environment" >>> client.get_convertible_bonds(identifiers, market_data_environment_name) """ wrapper = self._get_wrapper('get_convertible_bonds') return wrapper(identifiers=identifiers, market_data_environment_name=market_data_environment_name)
[docs] def get_flattened_convertible_bonds(self, identifiers, market_data_environment_name=None): """ Get convertible bonds for some identifier. :param identifiers: The identifiers. :type identifiers: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.tradables.response.ApiGetFlattenedConvertibleBondsResponse` **Code** >>> identifiers = [isin("US912810FB99")] >>> market_data_environment_name = "Example Market Data Environment" >>> client.get_flattened_convertible_bonds(identifiers, market_data_environment_name) """ wrapper = self._get_wrapper('get_flattened_convertible_bonds') return wrapper(identifiers=identifiers, market_data_environment_name=market_data_environment_name)
[docs] def get_convertible_bonds_grid_pricer_details(self, identifiers, as_of_date, market_data_override, market_data_environment_name=None): """ Get convertible bonds for some identifier. :param identifiers: The identifiers. :type identifiers: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :param as_of_date: The as of date. :type as_of_date: datetime.datetime :param market_data_override: The market data override. :type market_data_override: MarketDataOverride class instance :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: dictionaries keyed by InstrumentIdentifier **Code** >>> identifiers = [isin("US912810FB99")] >>> market_data_environment_name = "Example Market Data Environment" >>> client.get_convertible_bonds_grid_pricer_details(identifiers, as_of_date, market_data_override, market_data_environment_name) """ wrapper = self._get_wrapper('get_convertible_bonds_grid_pricer_details') return wrapper(identifiers=identifiers, as_of_date=as_of_date, market_data_override=market_data_override, market_data_environment_name=market_data_environment_name)
[docs] def get_fx_data(self, fx_pairs, start_date, end_date, market_data_environment_name=None): """ Get FX data for some FX pairs between two dates. :param fx_pairs: The FX pairs. :type fx_pairs: list of str :param start_date: The start date. :type start_date: datetime.datetime :param end_date: The end date. :type end_date: datetime.datetime :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: `list` of :class:`derivitec.market_data.types.FxData` **Code** >>> fx_pairs = ["GBPUSD"] >>> start_date = datetime(2017, 6, 1) >>> end_date = datetime(2017, 6, 7) >>> market_data_environment_name = "Example Market Data Environment" >>> fx_data = client.get_fx_data(fx_pairs, start_date, end_date, market_data_environment_name) """ wrapper = self._get_wrapper('get_fx_data') return wrapper(fx_pairs=fx_pairs, start_date=start_date, end_date=end_date, market_data_environment_name=market_data_environment_name)
[docs] def get_fx_futures(self, identifiers): """ Get fx futures. :param identifiers: The identifiers :type identifiers: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :rtype: dict[:class:`derivitec.misc.types.InstrumentIdentifier`, :class:`derivitec.tradables.types.FxFuture`] **Code** >>> identifiers = [bbg("KGBZ7")] >>> client.get_fx_futures(identifiers) """ wrapper = self._get_wrapper('get_fx_futures') return wrapper(identifiers=identifiers)
[docs] def get_crypto_coin_data(self, codes, start_date, end_date): """ Get crypto coin data for some crypto currencies between two dates. :param codes: The crypto codes. :type codes: list of str :param start_date: The start date. :type start_date: datetime.datetime :param end_date: The end date. :type end_date: datetime.datetime :rtype: `list` of :class:`derivitec.market_data.types.FxData` **Code** >>> codes = ["BTC"] >>> start_date = datetime(2022, 11, 15) >>> end_date = datetime(2022, 11, 15) >>> fx_data = client.get_crypto_coin_data(codes, start_date, end_date) """ wrapper = self._get_wrapper('get_crypto_coin_data') return wrapper(codes=codes, start_date=start_date, end_date=end_date)
[docs] def get_stock_data(self, identifiers, start_date, end_date, market_data_environment_name=None): """ Get stock data for some identifiers between two dates. :param identifiers: The identifiers. :type identifiers: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :param start_date: The start date. :type start_date: datetime.datetime :param end_date: The end date. :type end_date: datetime.datetime :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiGetStockDataResponse` **Code** >>> from datetime import datetime >>> identifiers = [ric("MSFT.OQ")] >>> start_date = datetime(2017, 6, 1) >>> end_date = datetime(2017, 6, 7) >>> market_data_environment_name = "Example Market Data Environment" >>> response = client.get_stock_data(identifiers, start_date, end_date, market_data_environment_name) """ wrapper = self._get_wrapper('get_stock_data') return wrapper(identifiers=identifiers, start_date=start_date, end_date=end_date, market_data_environment_name=market_data_environment_name)
[docs] def get_cmdty_futures_data(self, identifiers, start_date, end_date, market_data_environment_name=None): """ Get cmdty futures data for some identifiers between two dates. :param identifiers: The identifiers. :type identifiers: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :param start_date: The start date. :type start_date: datetime.datetime :param end_date: The end date. :type end_date: datetime.datetime :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiGetCmdtyFuturesDataResponse` **Code** >>> from datetime import datetime >>> identifiers = [bbg("CLK5 Comdty"), bbg("CLM5 Comdty")] >>> start_date = datetime(2025, 1, 1) >>> end_date = datetime(2025, 5, 1) >>> market_data_environment_name = "Example Market Data Environment" >>> response = client.get_stock_data(identifiers, start_date, end_date, market_data_environment_name) """ wrapper = self._get_wrapper('get_cmdty_futures_data') return wrapper(identifiers=identifiers, start_date=start_date, end_date=end_date, market_data_environment_name=market_data_environment_name)
[docs] def get_etf_premiums(self, identifiers, start_date, end_date, market_data_environment_name=None): """ Get ETF premiums for some identifiers between two dates. :param identifiers: The identifiers. :type identifiers: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :param start_date: The start date. :type start_date: datetime.datetime :param end_date: The end date. :type end_date: datetime.datetime :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiGetEtfPremiumsResponse` **Code** >>> from datetime import datetime >>> identifiers = [ric("MSFT.OQ")] >>> start_date = datetime(2017, 6, 1) >>> end_date = datetime(2017, 6, 7) >>> market_data_environment_name = "Example Market Data Environment" >>> response = client.get_etf_premiums(identifiers, start_date, end_date, market_data_environment_name) """ wrapper = self._get_wrapper('get_etf_premiums') return wrapper(identifiers=identifiers, start_date=start_date, end_date=end_date, market_data_environment_name=market_data_environment_name)
[docs] def get_dividend_curve(self, identifier, market_date, provider_id=None, market_data_environment_name=None): """ Get dividend curve data for an given equity, provider and market date. :param provider_id: The provider id (optional with default Derivitec) :type provider_id: str :param identifier: The identifier. :type identifier: `derivitec.misc.types.InstrumentIdentifier` :param market_date: The market reference date. :type market_date: datetime.datetime :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiGetDividendCurveResponse` **Code** >>> from datetime import datetime >>> provider_id = "Derivitec" >>> identifiers = ric("MSFT.OQ") >>> market_date = datetime(2017, 6, 1) >>> market_data_environment_name = "Example Market Data Environment" >>> response = client.get_stock_data(identifier, market_date, provider_id, market_data_environment_name) """ wrapper = self._get_wrapper('get_dividend_curve') return wrapper(identifier=identifier, market_date=market_date, provider_id=provider_id, market_data_environment_name=market_data_environment_name)
[docs] def get_projected_dividends_for_env(self, market_date, identifiers=None, market_data_environment_names=None): """ Get projected dividends for env. :param market_date: The market date. :type market_date: datetime :param identifiers: The identifiers. :type identifiers: List of InstrumentIdentifier (if not supplied all dividends are queried) :param market_data_environment_name: The market data environment names (if none supplied all org environments are used) :type market_data_environment_name: List of str :rtype: **Code** Get dividend data for SPX. >>> identifier = [ric(".SPX")] >>> market_data_environment_name = "Example Market Data Environment" >>> client.get_dividend_data(datetime(2024, 8, 1), identifiers, market_data_environment_name) """ wrapper = self._get_wrapper('get_projected_dividends_for_env') return wrapper(identifiers=identifiers, market_date=market_date, market_data_environment_names=market_data_environment_names)
[docs] def delete_projected_dividends(self, identifiers, market_date, market_data_environment_name, ): """ Delete projected dividends. :param identifiers: The identifiers. :type identifiers: List of InstrumentIdentifier :param market_date: The market date. :type market_date: datetime :param market_data_environment_name: The market data environment name :type market_data_environment_name: str :rtype: **Code** Delete projected dividends for SPX. >>> identifier = [ric(".SPX")] >>> market_data_environment_name = "Example Market Data Environment" >>> client.delete_projected_dividends(identifiers, datetime(2024, 8, 1), market_data_environment_name) """ wrapper = self._get_wrapper('delete_projected_dividends') return wrapper(identifiers=identifiers, market_date=market_date, market_data_environment_name=market_data_environment_name)
[docs] def upload_cmdty_futures_data(self, cmdty_futures_data, market_data_environment_name=None): """ Upload Cmdty futures data :param cmdty_futures_data: The cmdty futures data :type cmdty_futures_data: list of :class:`derivitec.market_data.types.CmdtyFuturesData` :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.core.response.ApiBaseResponse` **Code** >>> from datetime import datetime >>> cmdty_futures_data = [CmdtyFuturesData(identifier=bbg("ALEZ25"), date=datetime(2025, 5, 1), close=2000, settle=2000)] >>> market_data_environment_name = "Example Market Data Environment" >>> response = client.upload_cmdty_futures_data(cmdty_futures_data=cmdty_futures_data, market_data_environment_name=market_data_environment_name) """ wrapper = self._get_wrapper('upload_cmdty_futures_data') return wrapper(cmdty_futures_data=cmdty_futures_data, market_data_environment_name=market_data_environment_name)
[docs] def upload_etf_premiums(self, etf_premiums, market_data_environment_name=None): """ Upload ETF premiums :param etf_premiums: The ETF premiums :type etf_premiums: list of :class:`derivitec.market_data.types.EtfPremium` :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.core.response.ApiBaseResponse` **Code** >>> from datetime import datetime >>> etf_premiums = [EtfPremium(identifier=bbg("MSFT US"), date=datetime(2017, 6, 1), premium=0.02)] >>> market_data_environment_name = "Example Market Data Environment" >>> response = client.upload_etf_premiums(etf_premiums=etf_premiums, market_data_environment_name=market_data_environment_name) """ wrapper = self._get_wrapper('upload_etf_premiums') return wrapper(etf_premiums=etf_premiums, market_data_environment_name=market_data_environment_name)
[docs] def upload_stock_data(self, stock_data, market_data_environment_name=None): """ Upload stock data :param stock_data: The stock data :type stock_data: list of :class:`derivitec.market_data.types.StockData` :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.core.response.ApiBaseResponse` **Code** >>> from datetime import datetime >>> stock_data = [StockData(identifier=bbg("MSFT US"), date=datetime(2017, 6, 1), close=100.0, currency="USD")] >>> market_data_environment_name = "Example Market Data Environment" >>> response = client.upload_stock_data(stock_data=stock_data, market_data_environment_name=market_data_environment_name) """ wrapper = self._get_wrapper('upload_stock_data') return wrapper(stock_data=stock_data, market_data_environment_name=market_data_environment_name)
[docs] def get_stock_info(self, identifiers, market_data_environment_name=None): """ Get stock info for some identifiers. :param identifiers: The identifiers. :type identifiers: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiGetStockInfoResponse` **Code** >>> from datetime import datetime >>> identifiers = [ric("MSFT.OQ")] >>> market_data_environment_name = "Example Market Data Environment" >>> fx_data = client.get_stock_info(identifiers, market_data_environment_name) """ wrapper = self._get_wrapper('get_stock_info') return wrapper(identifiers=identifiers, market_data_environment_name=market_data_environment_name)
[docs] def get_bond_data(self, identifiers, start_date, end_date, return_contributed_data=False, market_data_environment_name=None): """ Get bond data. :param identifiers: The instrument identifiers. :type identifiers: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :param start_date: The start date. :type start_date: datetime.datetime :param end_date: The end date. :type end_date: datetime.datetime :param return_contributed_data: The return contributed data flag. :type return_contributed_data: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: dict[:class:`derivitec.misc.types.InstrumentIdentifier`, list[:class:`derivitec.market_data.types.BondData`]] **Code** >>> bond_isin = isin("TESTISIN1") >>> identifiers = [bond_isin] >>> start_date = datetime(2017, 6, 1) >>> end_date = datetime(2017, 6, 7) >>> return_contributed_data = True >>> market_data_environment_name = "Example Market Data Environment" >>> bond_data = client.get_bond_data(identifiers, start_date, end_date, return_contributed_data, market_data_environment_name) """ wrapper = self._get_wrapper('get_bond_data') return wrapper( identifiers=identifiers, start_date=start_date, end_date=end_date, return_contributed_data=return_contributed_data, market_data_environment_name=market_data_environment_name)
[docs] def get_bond_infos(self, identifiers): """ Get bond info. :param identifiers: The identifiers (e.g. isins) :type identifiers: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: dict[:class:`derivitec.misc.types.InstrumentIdentifier`, :class:`derivitec.market_data.types.BondInfo`] **Code** >>> bond_isin = isin("TESTISIN1") >>> identifiers = [bond_isin] >>> market_data_environment_name = "Example Market Data Environment" >>> bond_infos = client.get_bond_infos(identifiers, market_data_environment_name) """ wrapper = self._get_wrapper('get_bond_infos') return wrapper(identifiers=identifiers)
[docs] def get_cds_data(self, identifiers, start_date, end_date, market_data_environment_name=None): """ Get cds data. :param identifiers: The issuer identifiers. :type identifiers: list[:class:`derivitec.misc.types.IssuerIdentifier`] :param start_date: The start date. :type start_date: datetime.datetime :param end_date: The end date. :type end_date: datetime.datetime :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: dict[:class:`derivitec.misc.types.IssuerIdentifier`, list[:class:`derivitec.market_data.types.CdsData`]] **Code** >>> issuer_identifier = shortname("ARGV") >>> identifiers = [issuer_identifier] >>> start_date = datetime(2017, 6, 1) >>> end_date = datetime(2017, 6, 7) >>> market_data_environment_name = "Example Market Data Environment" >>> bond_data = client.get_cds_data(identifiers, start_date, end_date, market_data_environment_name) """ wrapper = self._get_wrapper('get_cds_data') return wrapper( identifiers=identifiers, start_date=start_date, end_date=end_date, market_data_environment_name=market_data_environment_name)
[docs] def get_cmdty_vol_surfaces(self, commodity_ids, market_dates, provider_id=None, market_data_environment_name=None, market_data_environment_names=None): """ Get commodity vol surfaces. :param commodity_ids: The commodity ids. :type commodity_ids: list of CommodityId :param market_dates: The market dates. :type market_dates: list of datetime :param provider_id: The provider id (optional with default Derivitec) :type provider_id: str :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :param market_data_environment_names: The market data environment names (optional with default Organisation Level Environment) :type market_data_environment_names: list of str :rtype: `list` of :class:`derivitec.market_data.types.CmdtyVolSurface` **Code** >>> commodity_id = CommodityId(Name="Aluminium", Exchange="LME") >>> commodity_ids = [commodity_id] >>> market_dates = [datetime(2017, 10, 2)] >>> market_data_environment_name = "Example Market Data Environment" >>> cmdty_vol_surfaces = client.get_cmdty_vol_surfaces(commodity_ids, market_dates, market_data_environment_name) """ wrapper = self._get_wrapper('get_cmdty_vol_surfaces') return wrapper(commodity_ids=commodity_ids, market_dates=market_dates, provider_id=provider_id, market_data_environment_name=market_data_environment_name, market_data_environment_names=market_data_environment_names)
[docs] def get_discount_curves(self, currencies=None, market_dates=None, market_data_environment_name=None, descriptors=None): """ Get discount curves for some currencies and market dates. :param currencies: The currencies :type currencies: list of str :param market_dates: The market dates. :type market_dates: list of datetime.datetime :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :param descriptors: The descriptors :type descriptors: list of :class:`derivitec.market_data.types.DiscountCurveDescriptor` :rtype: :class:`derivitec.market_data.response.ApiGetDiscountCurvesResponse` **Code** >>> descriptors = [DiscountCurveDescriptor(currency="USD", curve_name="Fx")] >>> market_data_environment_name = "Example Market Data Environment" >>> discount_curves = client.get_discount_curves(descriptors=descriptors, market_dates=market_dates, market_data_environment_name= market_data_environment_name) """ wrapper = self._get_wrapper('get_discount_curves') return wrapper(currencies=currencies, market_dates=market_dates, descriptors=descriptors, market_data_environment_name=market_data_environment_name)
[docs] def upload_discount_curves(self, discount_curves, market_data_environment_name=None): """ Upload discount curves. :param discount_curves: The discount curves :type discount_curves: list of DiscountCurve :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str **Code** >>> mats = [ 365, 730 ] >>> discount_factors = [ 0.9, 0.8 ] >>> val_date = datetime(2017, 10, 13) >>> discount_curves = [ DiscountCurve(currency="USD", discount_factors=discount_factors, extrapolate=True,maturities=mats, value_date=val_date) ] >>> market_data_environment_name = "Example Market Data Environment" >>> client.upload_discount_curves(discount_curves, market_data_environment_name) """ wrapper = self._get_wrapper('upload_discount_curves') return wrapper(discount_curves=discount_curves, market_data_environment_name=market_data_environment_name)
[docs] def upload_vol_surface_spot_model_definitions(self, spot_model_definitions, market_data_environment_name=None): """Upload a batch of beta-adjusted ATMF spot model definitions. Each definition carries its own asset identifier, reference date, model ID, tenors and betas. The server resolves identifiers and fixes the model type to BetaAdjustedATMF. Invalid rows, unknown identifiers and duplicate resolved asset/model/date identities reject the batch before saving. Persistence is not transactional. Requires edit access to the selected market-data environment. Omitting market_data_environment_name uses the caller's organisation scope. The API resolves and stamps the authorized provider onto every row. Upload provenance is server-managed and Rolled is false. Existing records with the same asset/model/date/provider identity are replaced. :param spot_model_definitions: Nonempty list of model definitions. :type spot_model_definitions: list[derivitec.market_data.types.VolSurfaceSpotModelDefinition] :param market_data_environment_name: Destination market-data environment name. :type market_data_environment_name: str :rtype: derivitec.market_data.response.ApiUploadVolSurfaceSpotModelDefinitionsResponse **Code** >>> client.upload_vol_surface_spot_model_definitions(spot_model_definitions, market_data_environment_name=market_data_environment_name) """ wrapper = self._get_wrapper('upload_vol_surface_spot_model_definitions') return wrapper(vol_surface_spot_model_definitions=spot_model_definitions, market_data_environment_name=market_data_environment_name)
[docs] def upload_borrow_curves(self, borrow_rates_by_identifiers=None, market_date=None, use_best_effort=True, upload_zero_rates=False, market_data_environment_name=None, borrow_curves=None): """ Upload borrow curves. :param borrow_rates_by_identifiers: The borrow curves by identifiers :type borrow_rates_by_identifiers: dict[:class:`derivitec.misc.types.InstrumentIdentifier`, dict[str, float]] :param market_date: The market date :type market_date: datetime.datetime :param upload_zero_rates: The upload zero rates flag (otherwise treats uploaded rates as forward rates) :type upload_zero_rates: bool :param use_best_effort: The use best effort flag :type use_best_effort: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :param borrow_curves: The borrow curve data :type borrow_curves: list[:class:`derivitec.market_data.types.BorrowCurveData`] :rtype: :class:`derivitec.market_data.response.ApiUploadBorrowCurvesResponse` **Code** >>> market_data_environment_name = "Example Market Data Environment" >>> borrow_curves = [BorrowCurveData(asset_name=ric('MSFT.OQ'), value_date=datatime.datetime(2020, 4, 1), maturities=[365, 365*2], rates=[0.05, 0.04], use_zero_rates=False)] >>> client.upload_borrow_curves(market_data_environment_name=market_data_environment_name, borrow_curves=borrow_curves) """ wrapper = self._get_wrapper('upload_borrow_curves') return wrapper(borrow_rates_by_identifiers=borrow_rates_by_identifiers, market_date=market_date, upload_zero_rates=upload_zero_rates, use_best_effort=use_best_effort, market_data_environment_name=market_data_environment_name, borrow_curves=borrow_curves)
[docs] def get_borrow_curves(self, identifiers, market_date, return_forward_rates=True, market_data_environment_name=None): """ Get borrow curves. :param identifiers: The borrow curves by identifiers :type identifiers: `list` of :class:`derivitec.misc.types.InstrumentIdentifier` :param market_date: The market date :type market_date: datetime.datetime :param return_forward_rates: The return forward rates flag (otherwise returns zero rates) :type return_forward_rates: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: `derivitec.market_data.response.ApiGetBorrowCurvesDataResponse` **Code** >>> identifiers = [ric('MSFT.OQ')] >>> market_date = datetime(2020, 4, 11) >>> return_forward_rates = False >>> market_data_environment_name = "Example Market Data Environment" >>> client.get_borrow_curve_data(identifiers, market_date, return_forward_rates, market_data_environment_name) """ wrapper = self._get_wrapper('get_borrow_curves') return wrapper(identifiers=identifiers, market_date=market_date, return_forward_rates=return_forward_rates, market_data_environment_name=market_data_environment_name)
[docs] def get_borrow_curves_for_env(self, market_date, identifiers=None, market_data_environment_names=None): """ Get borrow curves for env. :param market_date: The market date. :type market_date: datetime :param identifiers: The identifiers. :type identifiers: List of InstrumentIdentifier (if not supplied all borrow curves are queried) :param market_data_environment_name: The market data environment names (if none supplied all org environments are used) :type market_data_environment_name: List of str :rtype: **Code** Get borrow curve data for SPX. >>> identifier = [ric(".SPX")] >>> market_data_environment_name = "Example Market Data Environment" >>> client.get_borrow_curves_for_env(datetime(2024, 8, 1), identifiers, market_data_environment_name) """ wrapper = self._get_wrapper('get_borrow_curves_for_env') return wrapper(identifiers=identifiers, market_date=market_date, market_data_environment_names=market_data_environment_names)
[docs] def get_equity_vol_surfaces_for_env(self, market_date, identifiers=None, market_data_environment_names=None): """ Get equity vol surfaces for env. :param market_date: The market date. :type market_date: datetime :param identifiers: The identifiers. :type identifiers: List of InstrumentIdentifier (if not supplied all equity vol surfaces are queried) :param market_data_environment_names: The market data environment names (if none supplied all org environments are used) :type market_data_environment_names: List of str :rtype: """ wrapper = self._get_wrapper('get_equity_vol_surfaces_for_env') return wrapper(identifiers=identifiers, market_date=market_date, market_data_environment_names=market_data_environment_names)
[docs] def delete_borrow_curves(self, identifiers, market_date, market_data_environment_name, ): """ Delete borrow curves. :param identifiers: The identifiers. :type identifiers: List of InstrumentIdentifier :param market_date: The market date. :type market_date: datetime :param market_data_environment_name: The market data environment name :type market_data_environment_name: str :rtype: **Code** Delete borrow curve for SPX. >>> identifier = [ric(".SPX")] >>> market_data_environment_name = "Example Market Data Environment" >>> client.delete_borrow_curves(identifiers, datetime(2024, 8, 1), market_data_environment_name) """ wrapper = self._get_wrapper('delete_borrow_curves') return wrapper(identifiers=identifiers, market_date=market_date, market_data_environment_name=market_data_environment_name)
[docs] def delete_equity_vol_surfaces(self, identifiers, market_date, market_data_environment_name): """ Delete equity vol surfaces. :param identifiers: The identifiers. :type identifiers: List of InstrumentIdentifier :param market_date: The market date. :type market_date: datetime :param market_data_environment_name: The market data environment name. :type market_data_environment_name: str :rtype: **Code** Delete the equity vol surface for SPX. >>> identifiers = [ric(".SPX")] >>> market_data_environment_name = "Example Market Data Environment" >>> client.delete_equity_vol_surfaces(identifiers, datetime(2024, 8, 1), market_data_environment_name) """ wrapper = self._get_wrapper('delete_equity_vol_surfaces') return wrapper(identifiers=identifiers, market_date=market_date, market_data_environment_name=market_data_environment_name)
[docs] def upload_projected_dividends(self, dividends, use_best_effort, market_data_environment_name=None): """ Upload projected dividends. :param dividends: The list of dividend :type dividends: list :param use_best_effort: The use best effort flag :type use_best_effort: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str **Code** >>> asset_id = bbg("MSFT US") >>> reference_date = datetime(2017, 10, 13) >>> all_in_rate = 0.95 >>> cash_dividend = 3 >>> confirmed = True >>> declared_date = datetime(2017, 9, 14) >>> dividend_type = Dividend.Type.Regular >>> dividend_yield = 0.02 >>> ex_date = datetime(2017, 10, 14) >>> pay_date = datetime(2017, 11, 14) >>> record_date = datetime(2017, 10, 16) >>> dividend = Dividend( ... asset_id = asset_id, ... reference_date = reference_date, ... all_in_rate = all_in_rate, ... cash_dividend = cash_dividend, ... confirmed = confirmed, ... declared_date = declared_date, ... dividend_type = dividend_type, ... dividend_yield = dividend_yield, ... ex_date = ex_date, ... pay_date = pay_date, ... record_date = record_date) >>> dividends = [dividend] >>> use_best_effort = True >>> market_data_environment_name = "Example Market Data Environment" >>> client.upload_projected_dividends(dividends, use_best_effort, market_data_environment_name) """ wrapper = self._get_wrapper('upload_projected_dividends') return wrapper(dividends=dividends, use_best_effort=use_best_effort, market_data_environment_name=market_data_environment_name)
[docs] def upload_bond_price_data(self, bond_data, use_best_effort, trigger_immediate_bootstrap, market_data_environment_name=None): """ Upload bond price data. :param bond_data: The list of bond data :type bond_data: list of bond_data :param use_best_effort: The best effort flag :type use_best_effort: bool :param trigger_immediate_bootstrap: The trigger immediate bootstrap flag. :type trigger_immediate_bootstrap: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str **Code** >>> bond_identifier = InstrumentIdentifier(code = "DE0001135390", identifier_type = InstrumentIdentifierType.Isin) >>> currency = "EUR" >>> traded_price = 100.05 >>> date = dateTime(2019,12,18) >>> is_percentage_of_par = True >>> is_currency_per_bond_unit = False >>> bond_data = [BondDataExternal(bond_identifier = bond_identifier, currency = currency, traded_price = traded_price, date = date, is_percentage_of_par = is_percentage_of_par, is_currency_per_bond_unit = is_currency_per_bond_unit)] >>> use_best_effort = False >>> trigger_immediate_bootstrap = True >>> market_data_environment_name = "Example Market Data Environment" >>> client.upload_bond_data(bond_data, use_best_effort, trigger_immediate_bootstrap, market_data_environment_name) """ wrapper = self._get_wrapper('upload_bond_price_data') return wrapper(bond_data=bond_data, use_best_effort=use_best_effort, trigger_immediate_bootstrap=trigger_immediate_bootstrap, market_data_environment_name=market_data_environment_name)
[docs] def upload_bond_issuer_credit_spreads(self, credit_spreads_by_bond_identifier=None, market_dates=None, bond_issuer_credit_spreads=None, market_data_environment_name=None): """ UploadBondIssuerCreditSpreads. :param credit_spreads_by_bond_identifier: credit spreads by bond identifier :type credit_spreads_by_bond_identifier: dict[:class:`derivitec.misc.types.InstrumentIdentifier`, float] :param market_dates: list of market dates for yield curve re-fitting :type market_dates: list[datetime.datetime] :param bond_issuer_credit_spreads: list of credit spread data :type bond_issuer_credit_spreads: list[:class:`derivitec.market_data.BondIssuerCreditSpreadData`] :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: `derivitec.market_data.response.ApiBaseResponse` **Code** >>> bond_issuer_credit_spreads = [BondIssuerCreditSpreadData(bond_identifier=isin("DE0001135390"), date=datetime.datetime(2024, 9, 20), spread=400/10000.0)] >>> market_data_environment_name = "Example Market Data Environment" >>> client.upload_bond_issuer_credit_spreads(bond_issuer_credit_spreads=bond_issuer_credit_spreads, market_data_environment_name=market_data_environment_name) """ wrapper = self._get_wrapper('upload_bond_issuer_credit_spreads') return wrapper(credit_spreads_by_bond_identifier=credit_spreads_by_bond_identifier, market_dates=market_dates, bond_issuer_credit_spreads=bond_issuer_credit_spreads, market_data_environment_name=market_data_environment_name)
[docs] def upload_bond_infos(self, bond_infos, market_data_environment_name=None): """ Upload bond infos. :param bond_infos: The list of bond_info :type bond_infos: list of bond_info :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str **Code** """ wrapper = self._get_wrapper('upload_bond_infos') return wrapper(bond_infos=bond_infos, market_data_environment_name=market_data_environment_name)
[docs] def get_bond_yield_curves(self, bond_yield_curve_ids, market_dates, fallback_on_derivitec_data, market_data_environment_name=None): """ Get bond yield curves. :param bond_yield_curve_ids: The list of bond yield curve ids. :type bond_yield_curve_ids: list of bond_yield_curve_id :param market_dates: The list of market dates. :type market_dates: list of datetime.datetime :param fallback_on_derivitec_data: The fallback on Derivitec data flag :type fallback_on_derivitec_data: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str **Code** >>> bond_yield_curve_ids = [BondYieldCurveId(issuer = "CNGV", currency = "CNY")] >>> market_dates = [dateTime(2019,12,18)] >>> fallback_on_derivitec_data = True >>> market_data_environment_name = "Example Market Data Environment" """ wrapper = self._get_wrapper('get_bond_yield_curves') return wrapper(bond_yield_curve_ids=bond_yield_curve_ids, market_dates=market_dates, fallback_on_derivitec_data=fallback_on_derivitec_data, market_data_environment_name=market_data_environment_name)
[docs] def upload_bond_yield_curves(self, bond_yield_curves, market_data_environment_name=None): """ Upload bond yield curves. :param bond_yield_curves: The list of bond yield curves. :type bond_yield_curves: list of :class:`derivitec.market_data.types.BondYieldCurve` :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiUploadBondYieldCurvesResponse` **Code** >>> reference_bond_yield_curve = BondYieldCurve( ... issuer_identifier = IssuerIdentifier.FromShortName("UST"), ... currency = 'USD', ... seniority = 'Other', ... reference_date = datetime(2017, 10, 14), ... extrapolate = True, ... maturities = [365, 365 * 5, 365 * 10], ... discount_factors = [0.95, 0.9, 0.85]) >>> bond_yield_curve = BondYieldCurve( ... issuer_identifier = IssuerIdentifier.FromShortName("ETSY"), ... currency = 'USD', ... seniority = 'Senior', ... reference_date = datetime(2017, 10, 14), ... extrapolate = True, ... maturities = [365, 365 * 10], ... discount_factors = [0.65, 0.45], ... reference_bond_yield_curve = reference_bond_yield_curve) >>> bond_yield_curves = [bond_yield_curve] >>> market_data_environment_name = "Example Market Data Environment" """ wrapper = self._get_wrapper('upload_bond_yield_curves') return wrapper(bond_yield_curves=bond_yield_curves, market_data_environment_name=market_data_environment_name)
[docs] def get_bond_yield_curve_maturity_buckets(self, bond_yield_curve_ids, market_date, market_data_environment_name=None): """ Get bond yield curve maturity buckets constituents. :param bond_yield_curve_ids: The list of bond yield curve ids. :type bond_yield_curve_ids: list of bond_yield_curve_id :param market_date: The list of market dates. :type market_date: datetime :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str **Code** >>> bond_yield_curve_ids = [BondYieldCurveId(issuer = "CNGV", currency = "CNY")] >>> market_date = DateTime(2019,12,18) >>> market_data_environment_name = "Example Market Data Environment" """ wrapper = self._get_wrapper('get_bond_yield_curve_maturity_buckets') return wrapper(bond_yield_curve_ids=bond_yield_curve_ids, market_date=market_date, market_data_environment_name=market_data_environment_name)
[docs] def upload_survival_curves(self, survival_curves, market_data_environment_name=None): """ Upload survival curves. :param survival_curves: The list of survival curves. :type survival_curves: list of :class:`derivitec.market_data.types.SurvivalCurve` :rtype: :class:`derivitec.market_data.response.ApiUploadSurvivalCurvesResponse` :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str **Code** >>> survival_curve = SurvivalCurve( ... issuer_identifier = IssuerIdentifier.FromShortName("ETSY"), ... currency = 'USD', ... debt_type = 'Senior', ... default_type = 'Bankruptcy', ... reference_date = datetime(2017, 10, 14), ... extrapolate = True, ... maturities = [365, 365 * 10], ... urvival_probabilities = [0.65, 0.45]) >>> survival_curves = [survival_curve] >>> market_data_environment_name = "Example Market Data Environment" """ wrapper = self._get_wrapper('upload_survival_curves') return wrapper(survival_curves=survival_curves, market_data_environment_name=market_data_environment_name)
[docs] def upload_index_component_data(self, index_component_data, use_best_effort, market_data_environment_name=None): """ Upload index component data. :param index_component_data: The list of index components :type index_component_data: list[:class:`derivitec.market_data.types.IndexComponentData`] :param use_best_effort: The best effort flag :type use_best_effort: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiUploadIndexComponentDataResponse` **Code** >>> index_component_data = [IndexComponentData(date=datetime(2019,12,18), index_identifier=InstrumentIdentifier.FromBbg("SPX Index"), stock_identifier=InstrumentIdentifier.FromBbg("AAPL OQ"), weight = .5), IndexComponentData(date=datetime(2019,12,18), index_identifier=InstrumentIdentifier.FromBbg("SPX Index"), stock_identifier=InstrumentIdentifier.FromBbg("TSLA OQ"), weight = .5)] >>> use_best_effort = True >>> market_data_environment_name = "Example Market Data Environment" >>> client.upload_index_component_data(index_component_data, use_best_effort, market_data_environment_name) """ wrapper = self._get_wrapper('upload_index_component_data') return wrapper(index_component_data=index_component_data, use_best_effort=use_best_effort, market_data_environment_name=market_data_environment_name)
[docs] def upload_rate_assets(self, rate_assets, market_data_environment_name=None): """ Upload rate assets. :param rate_assets: The rate assets :type rate_assets: list of RateAsset :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str **Code** >>> val_date = datetime(2017, 10, 13) >>> index_curve = DiscountCurve(currency="USD", discount_factors=discount_factors, extrapolate=True,maturities=mats, value_date=val_date) >>> rate_asset = RateAsset( ... business_day_convention=BusinessDayConvention.ModifiedFollowing, ... currency="USD", ... currency_calendar= Calendar(name="USA"), ... day_count_convention=Actual365(), ... end_to_end=True, ... fixing_calendar=Calendar(name="UK"), ... fixing_to_value_date_offset=2, ... index_curve=index_curve, ... name="USDLibor3M", ... rate_tenor=Tenor("3m"), ... reference_date=val_date, ... type="Libor3M") >>> rate_assets = [rate_asset] >>> market_data_environment_name = "Example Market Data Environment" >>> result = client.upload_rate_assets(rate_assets, market_data_environment_name) """ wrapper = self._get_wrapper('upload_rate_assets') return wrapper(rate_assets=rate_assets, market_data_environment_name=market_data_environment_name)
[docs] def get_discount_factors(self, curve, start_mat, end_mats): """ Get discount factors from a curve. This can be called from the client or it can be called directly from any `DiscountFactorCallable` derived class instance with discount_curve.DiscountFactor(start_mat, end_mats). :param curve: The discount curve. :type curve: :class:`derivitec.market_data.types.DiscountCurve` :param start_mat: The starting maturity. :type start_mat: int :param end_mats: The end maturities. :type end_mats: list of int :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiGetDiscountFactorsResponse` **Code** >>> currencies = ["USD"] >>> discount_curves = client.get_discount_curves(currencies, market_dates) >>> curve = discount_curves[0] >>> start_mat = 10 >>> end_mats = [10, 20, 30] >>> client.get_discount_factors(curve, start_mat, end_mats) >>> curve.DiscountFactor(start_mat, end_mats) """ wrapper = self._get_wrapper('get_discount_factors') return wrapper(curve=curve, start_mat=start_mat, end_mats=end_mats)
[docs] def get_equity_vols(self, identifier, strike_type, strikes, maturity, start_date, end_date, market_data_environment_name=None): """ Get equity vol surface vols between two dates. :param identifier: The identifiers. :type identifier: :class:`derivitec.misc.types.InstrumentIdentifier` :param strike_type: The strike type :type strike_type: :class:`derivitec.market_data.types.EquityVolSurface.StrikeType` :param strikes: The strikes in the format of `strike_type`. :type strikes: list of float :param maturity: The maturity. :type maturity: int :param start_date: The start date. :type start_date: datetime.datetime :param end_date: The end date. :type end_date: datetime.datetime :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiGetEquityVolsResponse` **Code** The strike is defined :math:`z ~ := ~ log(K/F)` when `strike_type` is `StrikeType.Logarithmic` we can get 95% and 105% moneyness as follows: >>> import math >>> strikes = [math.log(0.95), math.log(1.05)] >>> identifier = ric("MSFT.OQ") >>> start_date = datetime(2017, 6, 1) >>> end_date = datetime(2017, 7, 1) >>> strike_type = StrikeType.Logarithmic >>> maturity = 30 >>> market_data_environment_name = "Example Market Data Environment" >>> equity_vols = client.get_equity_vols(identifier, strike_type, strikes, maturity, start_date, end_date, market_data_environment_name) Then we can manipulate the returned vol >>> map(lambda x: x.Vols[1] - x.Vols[0], equity_vols.VolatilityData) """ wrapper = self._get_wrapper('get_equity_vols') return wrapper( identifier=identifier, strike_type=strike_type, strikes=strikes, maturity=maturity, start_date=start_date, end_date=end_date, market_data_environment_name=market_data_environment_name)
[docs] def get_equity_vol_index_vols(self, identifier, strike_type, strikes, maturity, start_date, end_date, market_data_environment_name=None): """ Get equity vol index vol surface vols between two dates. :param identifiers: The identifiers. :type identifiers: list of InstrumentIdentifier :param strike_type: The strike type :type strike_type: StrikeType :param strikes: The strikes in the format of `strike_type`. :type strikes: list of floats :param maturity: The maturity. :type maturity: int :param start_date: The start date. :type start_date: datetime :param end_date: The end date. :type end_date: datetime :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiGetEquityVolIndexVolsResponse` **Code** The strike is defined :math:`z ~ := ~ log(K/F)` when `strike_type` is `StrikeType.Logarithmic` we can get 95% and 105% moneyness as follows: >>> import math >>> strikes = [math.log(0.95), math.log(1.05)] >>> identifier = ric(".VIX") >>> start_date = datetime(2017, 6, 1) >>> end_date = datetime(2017, 7, 1) >>> strike_type = StrikeType.Logarithmic >>> maturity = 30 >>> market_data_environment_name = "Example Market Data Environment" >>> equity_vols = client.get_equity_vols(identifier, strike_type, strikes, maturity, start_date, end_date, market_data_environment_name) Then we can manipulate the returned vol >>> map(lambda x: x.Vols[1] - x.Vols[0], equity_vols.VolatilityData) """ wrapper = self._get_wrapper('get_equity_vol_index_vols') return wrapper( identifier=identifier, strike_type=strike_type, strikes=strikes, maturity=maturity, start_date=start_date, end_date=end_date, market_data_environment_name=market_data_environment_name)
[docs] def get_equity_vol_grid(self, vol_surface, maturities, strikes, strike_type, market_data_environment_name=None): """ Get equity vol grid from a vol surface :param vol_surface: The vol surface :type vol_surface: :class:`derivitec.market_data.EquityVolSurface` :param maturities: The maturities :type maturities: list of int :param strikes: The strikes in the format of `strike_type`. :type strikes: list of list :param strike_type: The strike type :type strike_type: :class:`derivitec.market_data.VolGrid.StrikeType` :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiGetEquityVolGridResponse` **Code** >>> import datetime >>> vol_surface = EquityVolSurface( ... asset_name=ric("MSFT.OQ"), ... reference_date=datetime.datetime(2017, 10, 13), ... benchmark_maturities=[365, 365 * 5], ... benchmark_fwd_factors=[1.0, 1.0], ... vols=[0.5, 0.7], ... smiles=[0.0, 0.0], ... skews=[0.0, 0.0], ... call_wings=[0.0, 0.0], ... put_wings=[0.0, 0.0], ... strike_type=VolatilitySurfaceSvi.StrikeType.Logarithmic, ... spot_ref=100) >>> maturities = [365, 365 * 3] >>> strikes = [[1.0], [0.5, 1.2]] >>> strike_type = VolGrid.StrikeType.PercentSpot >>> market_data_environment_name = "Example Market Data Environment" >>> response = client.get_equity_vol_grid(vol_surface, maturities, strikes, strike_type, market_data_environment_name) """ wrapper = self._get_wrapper('get_equity_vol_grid') return wrapper(vol_surface=vol_surface, maturities=maturities, strikes=strikes, strike_type=strike_type, market_data_environment_name=market_data_environment_name)
[docs] def get_convenience_yield(self, curve, start_mat, end_mats): """ Get the convenience yield. This can be called from the client or it can be called directly from any `DiscountFactorCallable` derived class instance with discount_curve.DiscountFactor(start_mat, end_mats). **Code** :param curve: The convenience curve. :type curve: DiscountCurve :param start_mat: The start maturity. :type start_mat: int :param end_mats: The end maturities. :type end_mats: list of ints :rtype: `list` of `float` """ wrapper = self._get_wrapper('get_convenience_yield') return wrapper( curve=curve, start_mat=start_mat, end_mats=end_mats)
[docs] def get_equities(self, identifiers, descriptors, market_dates, provider_id=None, market_data_environment_name=None): """ Get equities. :param identifiers: The equity instrument identifiers. :type identifiers: list of :class:`derivitec.misc.types.InstrumentIdentifier` :param descriptors: The equity descriptors. :type descriptors: dict[:class:`derivitec.misc.types.InstrumentIdentifier`, :class:`derivitec.market_data.types.EquityDescriptor`] :param market_dates: The market dates :type market_dates: list of datetime.datetime :param provider_id: The provider id (optional) :type provider_id: str :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiGetEquitiesResponse` **Code** >>> identifiers = [bbg("MSFT US")] >>> descriptor = EquityDescriptor() >>> descriptors = {identifiers[0] : descriptor} >>> market_dates = [datetime(2017, 10, 2)] >>> market_data_environment_name = "Example Market Data Environment" >>> equities = client.get_equities(descriptors, identifiers, market_dates, market_data_environment_name) """ wrapper = self._get_wrapper('get_equities') return wrapper( identifiers=identifiers, descriptors=descriptors, market_dates=market_dates, provider_id=provider_id, market_data_environment_name=market_data_environment_name)
[docs] def get_equity_forwards(self, identifier, market_date, expiration_dates=None, market_data_environment_names=None, include_ex_dates=False): """ Get equity forwards :param identifier: The equity instrument identifier. :type identifier: :class:`derivitec.misc.types.InstrumentIdentifier` :param market_date: The market date :type market_date: datetime.datetime :param expiration_dates: The expiration dates :type expiration_dates: list of datetime.datetime :param market_data_environment_name: The market data environment names (if none supplied all org environments are used) :type market_data_environment_name: List of str :param include_ex_dates: The include ex dates flag :type include_ex_dates: list of datetime.datetime :rtype: :class:`derivitec.market_data.response.ApiGetEquityForwardsResponse` **Code** >>> identifier = bbg("MSFT US") >>> market_date = datetime(2017, 10, 2) >>> equity_forwards = client.get_equities(identifiers market_dates) """ wrapper = self._get_wrapper('get_equity_forwards') return wrapper( identifier=identifier, market_date=market_date, expiration_dates=expiration_dates, market_data_environment_names=market_data_environment_names, include_ex_dates=include_ex_dates )
[docs] def get_equity_vol_surfaces(self, identifiers, market_dates, provider_id=None, market_data_environment_name=None): """ Get equity vol surfaces. :param identifiers: The identifiers for the underlying equities :type identifiers: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :param market_dates: The market dates for the surfaces. :type market_dates: list[datetime.datetime] :param provider_id: The provider id (optional) :type provider_id: str :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiGetEquityVolSurfacesResponse` **Code** >>> identifiers = [bbg("MSFT US")] >>> market_dates = [datetime(2017, 10, 2)] >>> market_data_environment_name = "Example Market Data Environment" >>> equity_vol_surfaces = client.get_equity_vol_surfaces(identifiers, market_dates, market_data_environment_name) """ wrapper = self._get_wrapper('get_equity_vol_surfaces') return wrapper( identifiers=identifiers, market_dates=market_dates, provider_id=provider_id, market_data_environment_name=market_data_environment_name)
[docs] def get_equity_vol_index_vol_surfaces( self, identifiers, market_dates, provider_id=None, market_data_environment_name=None): """ Get equity vol index vol surfaces. :param identifiers: The identifiers for the equity vol indices :type identifiers: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :param market_dates: The market dates for the surfaces. :type market_dates: list[datetime.datetime] :param provider_id: The provider id (optional) :type provider_id: str :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiGetEquityVolIndexVolSurfacesResponse` **Code** >>> identifiers = [ric(".VIX")] >>> market_dates = [datetime(2017, 10, 2)] >>> market_data_environment_name = "Example Market Data Environment" >>> equity_vol_index_vol_surfaces = client.get_equity_vol_index_vol_surfaces(identifiers, market_dates, market_data_environment_name) """ wrapper = self._get_wrapper('get_equity_vol_index_vol_surfaces') return wrapper( identifiers=identifiers, market_dates=market_dates, provider_id=provider_id, market_data_environment_name=market_data_environment_name)
[docs] def get_dividend_index_vol_surfaces( self, dividend_index_ids=None, futures_codes=None, market_dates=None, provider_id=None, market_data_environment_names=None): """ Get dividend index vol surfaces. :param dividend_index_ids: The dividend index identifiers :type dividend_index_ids: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :param futures_codes: the futures code identifiers :type futures_codes: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :param market_dates: The market dates for the surfaces. :type market_dates: list[datetime.datetime] :param provider_id: The provider id (optional) :type provider_id: str :param market_data_environment_names: The market data environment names (optional) :type market_data_environment_names: list[str] :rtype: ApiGetDividendIndexVolSurfacesResponse """ wrapper = self._get_wrapper('get_dividend_index_vol_surfaces') return wrapper( dividend_index_ids=dividend_index_ids, futures_codes=futures_codes, market_dates=market_dates, provider_id=provider_id, market_data_environment_names=market_data_environment_names)
[docs] def get_spider_rock_vol_data(self, market_date, provider_id=None, market_data_environment_name=None): """ Get spider rock vol data. :param market_date: The market date :type market_date: datetime.datetime :param provider_id: The provider id (optional) :type provider_id: str :param market_data_environment_name: The market data environment name (optional) :type market_data_environment_name: str :rtype: ApiGetSpiderRockVolDataResponse """ wrapper = self._get_wrapper('get_spider_rock_vol_data') return wrapper(market_date=market_date, provider_id=provider_id, market_data_environment_name=market_data_environment_name)
[docs] def upload_eq_vol_of_var_curves(self, eq_vol_of_var_curves, market_data_environment_name=None): """Upload equity volatility-of-variance curves for analytic vol swaps. :param eq_vol_of_var_curves: Non-empty list of EquityVolOfVarCurve objects. :type eq_vol_of_var_curves: list[:class:`derivitec.market_data.types.EquityVolOfVarCurve`] :param market_data_environment_name: Writable destination; omitted means organisation scope. :rtype: ApiUploadEqVolOfVarCurvesResponse Each curve replaces the mark for its underlying and reference date in that environment. Maturities are positive calendar-day offsets and vols are positive decimals. Inspect is_success and error_messages. This is a persistent upload, not a request-level MarketDataOverride. """ wrapper = self._get_wrapper('upload_eq_vol_of_var_curves') return wrapper(eq_vol_of_var_curves=eq_vol_of_var_curves, market_data_environment_name=market_data_environment_name)
[docs] def get_eq_vol_of_var_curves(self, identifiers, market_date, market_data_environment_name=None, market_data_environment_names=None): """Download vol-of-variance nodes using the pricing environment fallback. :param identifiers: List of underlying equity/index InstrumentIdentifier objects. :param market_date: Exact reference date as datetime.datetime at midnight. :param market_data_environment_name: Single preferred source, as an alternative to the list. :param market_data_environment_names: Preferred environments in priority order; do not combine with the single name. :type market_data_environment_names: list[str] :rtype: ApiGetEqVolOfVarCurvesResponse Like get_equity_vol_surfaces, this always tries the selected environments in order, then organisation data, then default data. Omitting both environment options starts at organisation scope. Each returned curve's provider_id identifies the source actually selected. Missing curves are omitted only when no provider has a mark on the requested date; unsupported identifiers return errors. There is no historical-date fallback. Environment-only retrieval is not supported by this method. """ wrapper = self._get_wrapper('get_eq_vol_of_var_curves') return wrapper(identifiers=identifiers, market_date=market_date, market_data_environment_name=market_data_environment_name, market_data_environment_names=market_data_environment_names)
[docs] def upload_equity_vol_curves(self, equity_vol_curves, use_best_effort, market_data_environment_name=None): """ Upload equity vol curves. :param eq_vol_curves: The equity vol curves :type eq_vol_curves: list of EquityVolCurve :param use_best_effort: The best effort flag :type use_best_effort: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str **Code** >>> provider_id = "Derivitec" >>> asset_id = bbg("MSFT US") >>> maturities = [ 365, 730 ] >>> reference_date = datetime(2017, 10, 13) >>> vols = [ 0.3, 0.25 ] >>> equity_vol_curve = EquityVolCurve( ... asset_id = asset_id, ... benchmark_maturities = benchmark_maturities, ... reference_date = reference_date, ... vols = vols) >>> equity_vol_curves = [equity_vol_curve] >>> use_best_effort = False >>> market_data_environment_name = "Example Market Data Environment" >>> client.upload_equity_vol_curves(equity_vol_curves, use_best_effort, market_data_environment_name) """ wrapper = self._get_wrapper('upload_equity_vol_curves') return wrapper(equity_vol_curves=equity_vol_curves, use_best_effort=use_best_effort, market_data_environment_name=market_data_environment_name)
[docs] def upload_equity_vol_grids(self, equity_vol_grids, use_best_effort, market_data_environment_name=None): """ Upload equity vol grids. :param equity_vol_grids: The equity vol grids :type equity_vol_grids: list[:class:`derivitec.market_data.EquityVolGrid`] :param use_best_effort: The best effort flag :type use_best_effort: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiBaseResponse` **Code** >>> provider_id = "Derivitec" >>> asset_id = bbg("MSFT US") >>> reference_date = datetime(2017, 10, 13) >>> maturities = [ 365, 730 ] >>> strikes = [[80, 100, 120], [80, 100, 120, 140]] >>> vols = [[0.3, 0.25, 0.4], [0.4, 0.3, 0.35, 0.45]] >>> equity_vol_grid = EquityVolGrid( ... asset_id = asset_id, ... reference_date = reference_date, ... maturities = maturities, ... strikes = strikes, ... vols = vols) >>> equity_vol_grids = [equity_vol_grid] >>> use_best_effort = False >>> market_data_environment_name = "Example Market Data Environment" >>> client.upload_equity_vol_grids(equity_vol_grids, use_best_effort, market_data_environment_name) """ wrapper = self._get_wrapper('upload_equity_vol_grids') return wrapper(equity_vol_grids=equity_vol_grids, use_best_effort=use_best_effort, market_data_environment_name=market_data_environment_name)
[docs] def upload_equity_vol_surfaces(self, vol_surfaces, market_data_environment_name=None): """ Upload equity vol surfaces. :param vol_surfaces: The equity vol surfaces :type vol_surfaces: list of :class:`derivitec.market_data.EquityVolSurface` :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiBaseResponse` **Code** >>> import datetime >>> vol_surface = EquityVolSurfaceSvi( ... asset_name=ric("MSFT.OQ"), ... reference_date=datetime.datetime(2017, 10, 13), ... benchmark_maturities=[365, 365 * 5], ... benchmark_fwd_factors=[1.0, 1.0], ... vols=[0.5, 0.7], ... smiles=[0.0, 0.0], ... skews=[0.0, 0.0], ... call_wings=[0.0, 0.0], ... put_wings=[0.0, 0.0], ... strike_type=EquityVolSurface.StrikeType.Logarithmic, ... spot_ref=100) >>> vol_surfaces = [vol_surface] >>> market_data_environment_name = "Example Market Data Environment" >>> client.upload_equity_vol_surface(vol_surfacse) """ wrapper = self._get_wrapper('upload_equity_vol_surfaces') return wrapper(vol_surfaces=vol_surfaces, market_data_environment_name=market_data_environment_name)
[docs] def upload_fx_vol_grids(self, fx_vol_grids, use_best_effort, market_data_environment_name=None): """ Upload fx vol grids. :param fx_vol_grids: The fx vol grids :type fx_vol_grids: list of FxVolGrids :param use_best_effort: The best effort flag :type use_best_effort: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str **Code** >>> fx_pair = "USD/GBP" >>> reference_date = datetime(2017, 10, 13) >>> tenors = ["ON", "3M"] >>> deltas = [["10P", "15P", "20P", "25P", "30P", "35P", "40P", "45P", "ATM", "45C", "40C", "35C", "30C", "25C", "20C", "15C", "10C"], ... ["10P", "15P", "20P", "25P", "30P", "35P", "40P", "45P", "ATM", "45C", "40C", "35C", "30C", "25C", "20C", "15C", "10C"]] >>> vols = [[0.096, 0.094, 0.092, 0.09, 0.088, 0.086, 0.084, 0.082, 0.081, 0.0815, 0.083, 0.083, 0.0845, 0.086, 0.0875, 0.089, 0.0905], ... [0.097, 0.095, 0.093, 0.091, 0.089, 0.087, 0.085, 0.083, 0.082, 0.0825, 0.084, 0.084, 0.0855, 0.087, 0.0885, 0.09, 0.0915]] >>> fx_vol_grid = FxVolGrid( ... fx_pair = fx_pair, ... reference_date = reference_date, ... tenors = tenors, ... deltas = deltas, ... vols = vols) >>> fx_vol_grids = [fx_vol_grid] >>> use_best_effort = True >>> market_data_environment_name = "Example Market Data Environment" >>> client.upload_fx_vol_grids(fx_vol_grids, use_best_effort, market_data_environment_name) """ wrapper = self._get_wrapper('upload_fx_vol_grids') return wrapper(fx_vol_grids=fx_vol_grids, use_best_effort=use_best_effort, market_data_environment_name=market_data_environment_name)
[docs] def upload_dividend_index_vol_surfaces(self, vol_surfaces, market_data_environment_name=None): """ Upload dividend index vol surfaces. :param vol_surfaces: The dividend index vol surfaces :type vol_surfaces: list of :class:`derivitec.market_data.DividendIndexVolSurface` :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiBaseResponse` **Code** >>> import datetime >>> vol_surface = DividendIndexVolSurface( ... dividend_index_id=ric(".SX7ED"), ... reference_date=datetime.datetime(2017, 10, 13), ... benchmark_maturities=[365, 365 * 5], ... benchmark_fwd_factors=[1.0, 1.0], ... vols=[0.5, 0.7], ... smiles=[0.0, 0.0], ... skews=[0.0, 0.0], ... call_wings=[0.0, 0.0], ... put_wings=[0.0, 0.0], ... strike_type=VolatilitySurfaceSvi.StrikeType.Logarithmic, ... spot_ref=100) >>> vol_surfaces = [vol_surface] >>> market_data_environment_name = "Example Market Data Environment" >>> client.upload_dividend_index_vol_surfaces(vol_surfaces) """ wrapper = self._get_wrapper('upload_dividend_index_vol_surfaces') return wrapper(vol_surfaces=vol_surfaces, market_data_environment_name=market_data_environment_name)
[docs] def adjust_business_day(self, calendar, dt, bdc): """ Adjust a date to a business day using a calendar and business day convention. :param calendar: The calendar used for adjusting. :type calendar: Calendar :param date: The date to adjust. :type date: datetime :param bdc: The business day convention. :type bdc: BusinessDayConvention :rtype: :class:`derivitec.market_data.response.ApiAdjustBusinessDayResponse` **Code** >>> calendars = client.get_calendars( ["USD"] ) >>> calendar = calendars[0] >>> dt = datetime(2017, 7, 15) >>> bdc = BusinessDayConvention.ModifiedFollowing >>> response = client.adjust_business_day(calendar, dt, bdc) >>> response.Date """ wrapper = self._get_wrapper('adjust_business_day') return wrapper(calendar=calendar, date=dt, bdc=bdc)
[docs] def add_business_days(self, calendar, dt, days): """ Add business days. :param calendar: The calendar to use. :type calendar: Calendar :param dt: The date to add to. :type dt: datetime.datetime :param days: The number of days to add. :type days: int :rtype: :class:`derivitec.market_data.response.ApiAddBusinessDaysResponse` **Code** >>> calendars = client.get_calendars( ["USD"] ) >>> calendar = calendars[0] >>> dt = datetime(2017, 7, 14) >>> response = client.add_business_days(calendar, dt, 37 ) >>> response.Date datetime.datetime(2017, 9, 6, 0, 0) """ wrapper = self._get_wrapper('add_business_days') return wrapper(calendar=calendar, date=dt, days=days)
[docs] def get_fx_crosses(self, fx_pairs, market_dates, descriptors): """ Get FX crosses. :param fx_pairs: The FX pairs. :type fx_pairs: list of str :param market_dates: The market dates. :type market_dates: list of datetime. :param descriptors: The descriptors {str : `FxDescriptor`} :type descriptors: dict :rtype: `list` of :class:`derivitec.market_data.types.FxCross` **Code** >>> desc = FxCrossDescriptor() >>> desc.FixingStartDate = desc.HighLowFixingStartDate = datetime(2017, 1, 1) >>> desc.FixingEndDate = desc.HighLowFixingEndDate = datetime(2017, 5, 31) >>> descs = {"GBPUSD":desc} >>> date_list = [datetime(2017, 1, 10), datetime(2017, 1, 11)] >>> client.get_fx_crosses(["GBPUSD"], date_list, descs) """ wrapper = self._get_wrapper('get_fx_crosses') return wrapper(fx_pairs=fx_pairs, market_dates=market_dates, descriptors=descriptors)
[docs] def get_fx_vol_surfaces(self, fx_pairs, market_dates, provider_id=None, market_data_environment_name=None): """ Get FX vol surfaces. :param fx_pairs: The FX pairs. :type fx_pairs: list of str :param market_dates: The market dates. :type market_dates: list of datetime.datetime :param provider_id: The provider id (optional) :type provider_id: str :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: `list` of :class:`dervitec.market_data.types.FxVolSurface` **Code** >>> date_list = (datetime(2017, 5, 31), datetime(2017, 5, 30)) >>> market_data_environment_name = "Example Market Data Environment" >>> fx_vol_surfaces = client.get_fx_vol_surfaces(["GBPUSD"], date_list, market_data_environment_name) """ wrapper = self._get_wrapper('get_fx_vol_surfaces') return wrapper(fx_pairs=fx_pairs, market_dates=market_dates, provider_id=provider_id, market_data_environment_name=market_data_environment_name)
[docs] def get_index_component_data(self, identifiers, market_date, fallback_on_derivitec_data, market_data_environment_name=None, include_constituent_spot=False): """ Get index compenent data. :param identifiers: The identifiers. :type identifiers: List of InstrumentIdentifier :param market_date: The market date. :type market_date: datetime.datetime :param fallback_on_derivitec_data: The fallback on derivitec data. :type fallback_on_derivitec_data: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: **Code** Get index component data for SPX. >>> identifier = [ric(".SPX")] >>> market_data_environment_name = "Example Market Data Environment" >>> client.get_index_component_data(identifiers, datetime(2024, 8, 1), True, market_data_environment_name) """ wrapper = self._get_wrapper('get_index_component_data') return wrapper(identifiers=identifiers, market_date=market_date, fallback_on_derivitec_data=fallback_on_derivitec_data, market_data_environment_name=market_data_environment_name, include_constituent_spot=include_constituent_spot)
[docs] def get_index_component_data_for_env(self, market_date, identifiers=None, market_data_environment_names=None): """ Get index compenent data for env. :param market_date: The market date. :type market_date: datetime :param identifiers: The identifiers. :type identifiers: List of InstrumentIdentifier (if not supplied all indices are queried) :param market_data_environment_name: The market data environment names (if none supplied all org environments are used) :type market_data_environment_name: List of str :rtype: **Code** Get index component data for SPX. >>> identifier = [ric(".SPX")] >>> market_data_environment_name = "Example Market Data Environment" >>> client.get_index_component_data(datetime(2024, 8, 1), identifiers, market_data_environment_name) """ wrapper = self._get_wrapper('get_index_component_data_for_env') return wrapper(identifiers=identifiers, market_date=market_date, market_data_environment_names=market_data_environment_names)
[docs] def delete_index_component_data(self, identifiers, market_date, market_data_environment_name, ): """ Delete index compenent data. :param identifiers: The identifiers. :type identifiers: List of InstrumentIdentifier :param market_date: The market date. :type market_date: datetime :param market_data_environment_name: The market data environment name :type market_data_environment_name: str :rtype: **Code** Delete index component data for SPX. >>> identifier = [ric(".SPX")] >>> market_data_environment_name = "Example Market Data Environment" >>> client.delete_index_component_data(identifiers, datetime(2024, 8, 1), market_data_environment_name) """ wrapper = self._get_wrapper('delete_index_component_data') return wrapper(identifiers=identifiers, market_date=market_date, market_data_environment_name=market_data_environment_name)
[docs] def get_ir_bump_mkt_data(self, bumps, mkt_data_container): """ Get back a new market data container with interest rate bumps applied. The returned type is a dictionary mapping the bumps (in string form) to a bumped container. :param bumps: The bumps to apply :type bumps: list of float :param mkt_data_container: The market data container :type mkt_data_container: MktDataContainer :rtype: `dict` of { str : :class:`derivitec.market_data.types.MktDataContainer` } **Code** Bump some market data with a single 1bp shock. >>> bumps = [0.0001] >>> client.get_ir_bump_mkt_data(bumps, mkt_data) {u'0.0001': <derivitec.market_data.types.MktDataContainer object at 0x0000000007BC1108>} """ wrapper = self._get_wrapper('get_ir_parallel_bump_mkt_data') return wrapper(bumps=bumps, mkt_data_container=mkt_data_container)
[docs] def get_commodities(self, commodity_ids, descriptors, market_dates, provider_id=None, market_data_environment_name=None): """ Get commodities :param commodity_ids: The commodity ids. :type commodity_ids: list of CommodityId :param descriptors: The descriptors. :type descriptors: dict :param market_dates: The market dates. :type market_dates: list of datetime.datetime :param provider_id: The provider ID (optional) :type provider_id: str :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: list of Commodity **Code** Get the Aluminium commodity from LME exchange. >>> commodity_id = CommodityId(Name="Aluminium", Exchange="LME") >>> commodity_ids = [commodity_id] >>> descriptors = { commodity_id : CommodityDescriptor() } >>> market_date = datetime(2017, 8, 14) >>> market_dates = [market_date] >>> market_data_environment_name = "Example Market Data Environment" >>> client.get_commodities(commodity_ids, descriptors, market_dates, market_data_environment_name) """ wrapper = self._get_wrapper('get_commodities') return wrapper(commodity_ids=commodity_ids, descriptors=descriptors, market_dates=market_dates, provider_id=provider_id, market_data_environment_name=market_data_environment_name)
[docs] def get_mkt_data(self, contracts, pricing_date=None, mkt_data_date=None, reporting_currency=None, market_data_environment_name=None): """ Gets a market data container required for pricing a list of contracts. :param contracts: The contracts :type contracts: list of Contract :param pricing_date: The pricing date. :type pricing_date: datetime.datetime :param mkt_data_date: The market date date :type mkt_data_date: datetime.datetime :param reporting_currency: The reporting currency :type reporting_currency: str :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.types.MktDataContainer` **Code** Create a bond future and pull back the market data required to price it. >>> bond_future = BondFutureByCode(code=bbg("FVM7")) >>> bond_futures = [bond_future] >>> market_date = datetime(2017, 5, 31) >>> market_data_environment_name = "Example Market Data Environment" >>> mkt_data = client.get_mkt_data(bond_futures, market_date, market_date, "USD", market_data_environment_name) """ wrapper = self._get_wrapper('get_mkt_data_container') return wrapper(contracts=contracts, pricing_date=pricing_date, mkt_data_date=mkt_data_date, reporting_currency=reporting_currency, market_data_environment_name=market_data_environment_name)
[docs] def get_bond_futures(self, identifiers): """ Get bond futures. :param identifiers: The bond future instrument identifiers. :type identifiers: list of InstrumentIdentifier :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: `dict` of { `InstrumentIdentifier` : `BondFuture` } **Code** >>> identifiers = [ric("FVZ7")] >>> client.get_bond_futures(identifiers) """ wrapper = self._get_wrapper('get_bond_futures') return wrapper(identifiers=identifiers)
[docs] def get_bonds(self, identifiers): """ Get bonds. :param identifiers: The bond instrument identifiers :type identifiers: list of InstrumentIdentifier :rtype: `dict` of { `InstrumentIdentifier` : `Bond` } **Code** >>> identifiers = [isin("US912810FB99")] >>> client.get_bonds(identifiers) """ wrapper = self._get_wrapper('get_bonds') return wrapper(identifiers=identifiers)
[docs] def get_cmdty_futures(self, identifiers): """ Get commodity futures. :param identifiers: The commodity future instrument identifiers :type identifiers: list of InstrumentIdentifier :rtype: `dict` of { `InstrumentIdentifier` : `CmdtyFuture` } **Code** >>> identifiers = [ric("CLZ7")] >>> client.get_cmdty_futures(identifiers) """ wrapper = self._get_wrapper('get_cmdty_futures') return wrapper(identifiers=identifiers)
[docs] def get_ir_futures(self, identifiers, as_of_date=None): """ Get ir futures. :param identifiers: The ir future instrument identifiers :type identifiers: list of :class:`derivitec.misc.types.InstrumentIdentifier` :param as_of_date: The as of date :type as_of_date: datetime :rtype: `dict` **Code** >>> identifiers = [bbg("FFU3")] >>> as_of_date = datetime(2017, 10, 12) >>> client.get_ir_futures(identifiers=identifiers, as_of_date=as_of_date) """ wrapper = self._get_wrapper('get_ir_futures') return wrapper(identifiers=identifiers, as_of_date=as_of_date)
[docs] def get_date_coupon_map(self, bond, mkt_data, start_date, end_date, market_data_environment_name=None): """ Get a map of dates to coupons for a bond. :param bond: The bond. :type bond: Bond :param mkt_data: The market data. :type mkt_data: MktDataContainer :param start_date: The start date. :type start_date: datetime :param end_date: The end date. :type end_date: datetime :rtype: `dict` :param market_data_environment_name: The market data environment name. :type market_data_environment_name: str **Code** >>> bond = BondByCode(code=isin("US912810FB99")) >>> pricing_date = datetime(2017, 1, 14) >>> mkt_data_date = datetime(2017, 1, 14) >>> reporting_currency = "USD" >>> mkt_data = client.get_mkt_data( ... [bond], ... pricing_date, ... mkt_data_date, ... reporting_currency) >>> start_date = datetime(2017, 1, 1) >>> end_date = datetime(2017, 2, 1) >>> market_data_environment_name = "Example Market Data Environment" >>> client.get_date_coupon_map(bond, mkt_data, start_date, end_date) """ wrapper = self._get_wrapper('get_date_coupon_map') return wrapper(bond=bond, mkt_data=mkt_data, start_date=start_date, end_date=end_date, market_data_environment_name=market_data_environment_name)
[docs] def get_eq_futures(self, identifiers): """ Get equity futures. :param identifiers: The identifiers :type identifiers: InstrumentIdentifier :rtype: `dict` of { `InstrumentIdentifier` : `EqFuture` } **Code** >>> identifiers = [ric("SPZ7")] >>> client.get_eq_futures(identifiers) """ wrapper = self._get_wrapper('get_eq_futures') return wrapper(identifiers=identifiers)
[docs] def get_forward(self, underlyer, expiries): """ Get forward of an asset at a set of expiries. :param underlyer: The underlyer. :type underlyer: :class:`derivitec.market_data.types.Asset` :param expiries: The expiries. :type expiries: list of datetime.datetime :rtype: :class:`derivitec.tradables.response.ApiGetForwardResponse` **Code** First get any asset, say, a commodity as in the `get_commodities` example. >>> commodity_id = CommodityId(Name="Aluminium", Exchange="LME") >>> commodities = client.get_commodities([commodity_id], {commodity_id : CommodityDescriptor()}, [datetime(2017, 8, 14)]) >>> commodity = commodities[0] Then use this to call `get_forward`. >>> client.get_forward(commodity, [datetime(2017, 9, 14)] ) """ wrapper = self._get_wrapper('get_forward') return wrapper(underlyer=underlyer, expiries=expiries)
[docs] def futures_price(self, contracts, reporting_currency, pricing_date=None, mkt_data_date=None, mkt_data=None): """ Get the futures price of contracts for a market data date and pricing date or for some predefined market data. :param contracts: The contracts. :type contracts: list of Contract :param reporting_currency: The reporting currency. :type reporting_currency: str :param pricing_date: The pricing date. (optional, provided mkt_data supplied) :type pricing_date: datetime :param mkt_data_date: The market data date. (optional, provided mkt_data supplied) :type mkt_data_date: datetime :param mkt_data: The market date :type mkt_data: MktDataContainer (optional, provided pricing_date and mkt_data_date supplied) :rtype: :class:`derivitec.tradables.response.ApiGetFuturesPriceResponse` **Code** Either supply a pricing date with a market data date or supply the market data container. >>> contracts = [BondFutureByCode(code=ric("FVZ7"))] >>> reporting_currency = "USD" >>> mkt_data_date = datetime(2017, 11, 1) >>> pricing_date = datetime(2017, 11, 1) >>> client.get_futures_price(contracts, reporting_currency, ... mkt_data_date=mkt_data_date, pricing_date=pricing_date) """ wrapper = self._get_wrapper('get_futures_price') return wrapper(contracts=contracts, reporting_currency=reporting_currency, pricing_date=pricing_date, mkt_data_date=mkt_data_date, mkt_data_container=mkt_data)
[docs] def price(self, contracts, reporting_currency, pricing_date=None, mkt_data_date=None, mkt_data=None, market_data_environment_name=None): """ Get the prices of contracts for a market data date and pricing date or for some predefined market data. :param contracts: The contracts. :type contracts: list of Contract :param reporting_currency: The reporting currency. :type reporting_currency: str :param pricing_date: The pricing date. :type pricing_date: datetime :param mkt_data_date: The market data date. :type mkt_data_date: datetime :param mkt_data: The market data :type mkt_data: MktDataContainer :param market_data_environment_name: The market data environment name. :type market_data_environment_name: str :rtype: :class:`derivitec.tradables.response.ApiGetPriceResponse` **Code** >>> contracts = [BondByCode(code=isin("US912810FB99"))] >>> reporting_currency = "USD" >>> mkt_data_date = datetime(2017, 11, 1) >>> pricing_date = datetime(2017, 11, 1) >>> market_data_environment_name = "Example Market Data Environment" >>> client.price(contracts, ... reporting_currency, ... mkt_data_date=mkt_data_date, ... pricing_date=pricing_date) """ wrapper = self._get_wrapper('get_price') return wrapper(contracts=contracts, reporting_currency=reporting_currency, pricing_date=pricing_date, mkt_data_date=mkt_data_date, mkt_data_container=mkt_data, market_data_environment_name=market_data_environment_name)
[docs] def bond_futures_prices_from_repo_rates(self, bond_future, eligible_bonds, repo_rates, pricing_date, mkt_data_date, market_data_environment_name=None): """ Get the implied futures prices of bonds, given a bond future and repo rates. :param bond_future: The bond future. :type bond_future: BondFutureByCode :param eligible_bonds: The bonds. :type eligible_bonds: BondByCode :param repo_rates: The repo rates in % (in the same order as eligible_bonds) :type repo_rates: list of float :param pricing_date: The pricing date :type pricing_date: datetime :param mkt_data_date: The market data date :type mkt_data_date: datetime :param market_data_environment_name: The market data environment name. :type market_data_environment_name: str :rtype: :class:`derivitec.tradables.response.ApiGetBondFuturesPricesFromRepoRatesResponse` **Code** >>> bond_future = BondFutureByCode(code=ric("FVZ7")) >>> eligible_bonds = ( BondByCode(code=isin("US912828U659")), ... BondByCode(code=isin("US912828U816")) ) >>> repo_rates = [-4.54, 0.90] >>> mkt_data_date = datetime(2017, 11, 1) >>> pricing_date = datetime(2017, 11, 1) >>> market_data_environment_name = "Example Market Data Environment" >>> client.bond_futures_prices_from_repo_rates( ... bond_future, eligible_bonds, repo_rates, pricing_date, mkt_data_date) """ wrapper = self._get_wrapper('get_bond_futures_prices_from_repo_rates') return wrapper( bond_future=bond_future, eligible_bonds=eligible_bonds, repo_rates=repo_rates, pricing_date=pricing_date, mkt_data_date=pricing_date, market_data_environment_name=market_data_environment_name)
[docs] def get_vol(self, surface, maturity, strikes, strike_type): """ Get vol from a volatility surface at a fixed maturity for a set of strikes. This can be called with any SVI surface i.e. `EquityVolSurface`, `CmdtyVolSurface` and `FxVolSurface`. :param surface: :type surface: :class:`derivitec.market_data.types.VolatilitySurfaceSvi` :param maturity: The maturity. :type maturity: int :param strikes: :type strikes: list of float :param strike_type: The strike type. :type strike_type: :class:`derivitec.market_data.types.VolatilitySurfaceSvi.StrikeType` :rtype: `list` of `float` **Code** Query for ATM 30 day maturity vol >>> commodity_id = CommodityId(Name="Aluminium", Exchange="LME") >>> commodity_ids = [commodity_id] >>> market_dates = [datetime(2017, 10, 2)] >>> cmdty_vol_surfaces = client.get_cmdty_vol_surfaces(commodity_ids, market_dates) >>> client.get_vol(cmdty_vol_surfaces[0], 30, [0], StrikeType.Logarithmic) """ wrapper = self._get_wrapper('get_vol') return wrapper( surface=surface, maturity=maturity, strikes=strikes, strike_type=strike_type)
[docs] def get_blackscholes_implied_vol(self, spot, forward, strike, maturity, discount_factor, claim_type, price): """ Get Black Scholes implied vol for european option :param spot: the underling spot :type spot: float :param forward: the forward :type forward: float :param strike: the strike :type strike: float :param maturity: The maturity in days :type maturity: int :param discount_factor: :type discount_factor: float :param claim_type: option claim type :type claim_type: str :param price: option price :type price: float :rtype: :class:`derivitec.tradables.response.ApiGetDiscountFactorsResponse` **Code** >>> spot = 100 >>> forward = 100 >>> strike = 100 >>> maturity = 365 >>> discount_factor = 0.9 >>> claim_type = 'C' >>> price = 5.4 >>> client.get_blackscholes_implied_vol(spot, forward, strike, maturity, discount_factor, claim_type, price) """ wrapper = self._get_wrapper('get_blackscholes_implied_vol') return wrapper( spot=spot, forward=forward, strike=strike, maturity=maturity, discount_factor=discount_factor, claim_type=claim_type, price=price)
[docs] def get_coupons(self, bond, mkt_data_date, pricing_date, start_date, end_date): """ Get bounds for a bond between two dates. :param bond: The bond. :type bond: Bond :param mkt_data_date: The market data date. :type mkt_data_date: datetime :param pricing_date: The pricing date. :type pricing_date: datetime :param start_date: The start date. :type start_date: datetime :param end_date: The end date. :type end_date: datetime :rtype: :class:`derivitec.tradables.response.ApiGetCouponsResponse` **Code** >>> mkt_data_date = datetime(2017, 8, 14) >>> pricing_date = datetime(2017, 8, 14) >>> start_date = datetime(2000, 7, 14) >>> end_date = datetime(2017, 9, 14) >>> bond = BondByCode(code=isin("US912810FB99")) >>> client.get_coupons(bond, mkt_data_date, pricing_date, start_date, end_date) """ wrapper = self._get_wrapper('get_coupons') return wrapper(bond=bond, mkt_data_date=mkt_data_date, pricing_date=pricing_date, start_date=start_date, end_date=end_date)
[docs] def get_cash_flows(self, contracts, mkt_data_date, pricing_date, start_date, end_date, include_projected=True, market_data_environment_name=None): """ Get cash flows for a bond between two dates. :param contracts: The contracts. :type contracts: list of Contract :param mkt_data_date: The market data date. :type mkt_data_date: datetime :param pricing_date: The pricing date. :type pricing_date: datetime :param start_date: The start date. :type start_date: datetime :param end_date: The end date. :type end_date: datetime :param include_projected: The include projected cash flow flag. :type include_projected: bool :param market_data_environment_name: The market data environment name. :type market_data_environment_name: str :rtype: :class:`derivitec.tradables.response.ApiGetCashFlowsResponse` **Code** >>> mkt_data_date = datetime(2017, 8, 14) >>> pricing_date = datetime(2017, 8, 14) >>> start_date = datetime(2000, 7, 14) >>> end_date = datetime(2017, 9, 14) >>> contracts = [ BondByCode(code=isin("US912810FB99")) ] >>> market_data_environment_name = "Example Market Data Environment" >>> client.get_cash_flows(bonds, mkt_data_date, pricing_date, start_date, end_date) """ wrapper = self._get_wrapper('get_cash_flows') return wrapper(contracts=contracts, mkt_data_date=mkt_data_date, pricing_date=pricing_date, start_date=start_date, end_date=end_date, include_projected=include_projected, market_data_environment_name=market_data_environment_name)
[docs] def get_tradable_ids_from_portfolio(self, portfolio_name, as_of_date_time, portfolio_type=None): """ Get tradable ids from portfolio as of a date time. :param portfolio_name: The portfolio name. :type portfolio_name: str :param as_of_datetime: The datetime in UTC to retrieve tradable ids *as of*. :type as_of_datetime: datetime :param portfolio_type: The portfolio type i.e Derivitec or other external portfolio management system name - required if you have a matching portfolio name in more than one provider. :type portfolio_type: str :rtype: :class:`derivitec.tradables.response.ApiGetTradableIdsFromPortfolioResponse` **Code** >>> client.get_tradable_ids_from_portfolio("Portfolio 4", datetime(2017, 11, 1)) """ wrapper = self._get_wrapper('get_tradable_ids_from_portfolio') return wrapper(portfolio_name=portfolio_name, as_of_date_time=as_of_date_time, portfolio_type=portfolio_type)
[docs] def get_tradable_ids_from_contracts(self, contracts, as_of_date, market_data_environment_name=None): """ Get tradable ids from a list of a contracts as of a given date. The date is significant in determining the identifier of the tradable and in general there is a one-to-one mapping between the contract-date pair and a tradable id. :param contracts: The contracts :type contracts: list of Contract :param as_of_date: The *as of* date supplied with the contracts to generate the tradable ids. :type as_of_date: datetime :param market_data_environment_name: The market data environment name. :type market_data_environment_name: str :rtype: :class:`derivitec.tradables.response.ApiGetTradableIdsFromContractsResponse` **Code** >>> bonds = [ BondByCode(code=isin("US912810FB99")) ] >>> market_data_environment_name = "Example Market Data Environment" >>> client.get_tradable_ids_from_contracts(bonds, datetime(2017, 11, 1) ) """ wrapper = self._get_wrapper('get_tradable_ids_from_contracts') return wrapper(contracts=contracts, as_of_date=as_of_date, market_data_environment_name=market_data_environment_name)
[docs] def get_contracts_from_tradable_ids(self, tradable_ids): """ Get contracts from a list of tradable ids. :param tradable_ids: The tradable ids. :type tradable_ids: list of str **Code** For this example we need some valid tradable ids which can be obtained quite easily with the `get_tradable_ids_from_contracts` function. >>> pricing_date = datetime(2017, 11, 1) >>> bonds = [ BondByCode(code=isin("US912810FB99")) ] >>> tradable_ids = client.get_tradable_ids_from_contracts(bonds, pricing_date) >>> client.get_contracts_from_tradable_ids(tradable_ids) """ wrapper = self._get_wrapper('get_contracts_from_tradable_ids') return wrapper(tradable_ids=tradable_ids)
[docs] def get_flattened_contracts_from_tradable_ids(self, tradable_ids): """ Get contracts from a list of tradable ids. :param tradable_ids: The tradable ids. :type tradable_ids: list of str **Code** For this example we need some valid tradable ids which can be obtained quite easily with the `get_tradable_ids_from_contracts` function. >>> pricing_date = datetime(2017, 11, 1) >>> bonds = [ BondByCode(code=isin("US912810FB99")) ] >>> tradable_ids = client.get_tradable_ids_from_contracts(bonds, pricing_date) >>> client.get_flattened_contracts_from_tradable_ids(tradable_ids) """ wrapper = self._get_wrapper('get_flattened_contracts_from_tradable_ids') return wrapper(tradable_ids=tradable_ids)
[docs] def get_contracts_from_portfolio(self, portfolio_name, as_of_date_time, portfolio_type=None): """ Get contracts from a portfolio :param portfolio_name: The portfolio name. :type portfolio_name: str :param portfolio_type: The portfolio type i.e Derivitec or other external portfolio management system name - required if you have a matching portfolio name in more than one provider. :type portfolio_type: str :param as_of_datetime: Get contracts from the portfolio *as of* this datetime. :type as_of_datetime: datetime :rtype: :class:`derivitec.tradables.response.ApiGetContractsFromPortfolioResponse` **Code** >>> from datetime import datetime >>> as_of = datetime(2017, 8, 14, 17, 0, 0) # 5pm UTC on 14/8/2017 >>> portfolio_name = "Portfolio 4" >>> client.get_contracts_from_portfolio(portfolio_name, as_of) """ wrapper = self._get_wrapper('get_contracts_from_portfolio') return wrapper(portfolio_name=portfolio_name, as_of_date_time=as_of_date_time, portfolio_type=portfolio_type)
[docs] def get_contracts_from_client_tradable_id(self, portfolio_name, client_tradable_id, market_data_environment_name=None, portfolio_type=None, as_of_date_time=None): """ Get contracts from a portfolio :param portfolio_name: The portfolio name. :type portfolio_name: str :param portfolio_type: The portfolio type i.e Derivitec or other external portfolio management system name - required if you have a matching portfolio name in more than one provider. :type portfolio_type: str :param client_tradable_id: The client tradable id. :type client_tradable_id: string :param market_data_environment_name: The market data environment name. :type market_data_environment_name: str :param as_of_date_time: The datetime in UTC to retrieve tradable ids *as of*. :type as_of_date_time: dateTime :rtype: :class:`derivitec.tradables.response.ApiGetContractsFromTradableIdsResponse` **Code** >>> from datetime import datetime >>> client_tradable_id = "Test Id" >>> portfolio_name = "Portfolio 4" >>> market_data_environment_name = "My Example Environment" >>> client.get_contracts_from_client_tradable_id(portfolio_name, client_tradable_id, market_data_environment_name) """ wrapper = self._get_wrapper('get_contracts_from_client_tradable_id') return wrapper(portfolio_name=portfolio_name, client_tradable_id=client_tradable_id, market_data_environment_name=market_data_environment_name, as_of_date_time=as_of_date_time)
[docs] def get_pricing_details(self, contract, pricing_date, mkt_data_date, reporting_currency, market_data_override=None, market_data_environment_name=None, market_data_environment_names=None, equity_indices_to_decompose=None): """ Get pricing details from a contract :param contract: The contract. :type contract: :class:`derivitec.tradables.types.Contract` :param pricing_date: The pricing date. :type pricing_date: datetime.datetime :param mkt_data_date: The market data date. :type mkt_data_date: datetime.datetime :param reporting_currency: The reporting currency. :type reporting_currency: str :param market_data_override: The market data override. :type market_data_override: :class:`derivitec.market_data.types.MarketDataOverride` :param market_data_environment_name: The market data environment name. :type market_data_environment_name: str :param equity_indices_to_decompose: The equity indices to decompose with flag to control spot calculation of index. {InstrumentIdenfitifer : bool} :type equity_indices_to_decompose: dict[:class:`derivitec.misc.types.InstrumentIdentifier`,bool] :rtype: :class:`derivitec.tradables.response.ApiPricingDetailsForContractResponse` **Code** >>> from datetime import datetime >>> contract = ContractBuilder.CreateCash(), >>> pricing_date = datetime(2016, 10, 13) >>> mkt_data_date = datetime(2016, 10, 13) >>> reporting_currency = "USD" >>> market_data_override = MarketDataOverride(equity_spot_overrides = {ric(".SPX"):3000}) >>> market_data_environment_name = "Example Market Data Environment" >>> client.get_pricing_details(contract, pricing_date, mkt_data_date, reporting_currency, market_data_override) """ wrapper = self._get_wrapper('get_pricing_details') return wrapper(contract=contract, pricing_date=pricing_date, mkt_data_date=mkt_data_date, reporting_currency=reporting_currency, market_data_override=market_data_override, market_data_environment_name=market_data_environment_name, market_data_environment_names=market_data_environment_names, equity_indices_to_decompose=equity_indices_to_decompose)
[docs] def get_pricing_details_for_contracts(self, contracts, pricing_date, mkt_data_date, reporting_currency, market_data_override=None, market_data_environment_name=None, market_data_environment_names=None, equity_indices_to_decompose=None): """ Get pricing details from a contract :param contracts: The contract. :type contracts: list[:class:`derivitec.tradables.types.Contract`] :param pricing_date: The pricing date. :type pricing_date: datetime.datetime :param mkt_data_date: The market data date. :type mkt_data_date: datetime.datetime :param reporting_currency: The reporting currency. :type reporting_currency: str :param market_data_override: The market data override. :type market_data_override: :class:`derivitec.market_data.types.MarketDataOverride` :param market_data_environment_name: The market data environment name. :type market_data_environment_name: str :param market_data_environment_names: The market data environment names :type market_data_environment_names: list[str] :param equity_indices_to_decompose: The equity indices to decompose with flag to control spot calculation of index. {InstrumentIdentifier : bool} :type equity_indices_to_decompose: dict[:class:`derivitec.misc.types.InstrumentIdentifier`,bool] :rtype: :class:`derivitec.tradables.response.ApiPricingDetailsForContractsResponse` **Code** >>> from datetime import datetime >>> contract = [ ContractBuilder.CreateCash() ] >>> pricing_date = datetime(2016, 10, 13) >>> mkt_data_date = datetime(2016, 10, 13) >>> reporting_currency = "USD" >>> market_data_override = MarketDataOverride(equity_spot_overrides = {ric(".SPX"):3000.0}) >>> market_data_environment_name = "Example Market Data Environment" >>> client.get_pricing_details_for_contracts(contracts, pricing_date, mkt_data_date, reporting_currency, market_data_override) """ wrapper = self._get_wrapper('get_pricing_details_for_contracts') return wrapper(contracts=contracts, pricing_date=pricing_date, mkt_data_date=mkt_data_date, reporting_currency=reporting_currency, market_data_override=market_data_override, market_data_environment_name=market_data_environment_name, market_data_environment_names=market_data_environment_names, equity_indices_to_decompose=equity_indices_to_decompose)
[docs] def position_upload(self, positions): """ Position upload. :param positions: :type positions: list of Position :rtype: :class:`derivitec.positions.types.ApiPositionUploadResponse` What follows is an example of booking a new bond future. See :class:`derivitec.positions.position.Position` for more information about the `Position` class. **Code** >>> import uuid >>> contract = BondFutureByCode(code=ric("FVZ8")) >>> book = "Book 1" >>> position = Position( ... book=book, ... trade_action="NEW", ... quantity=1, ... trade_date = datetime(2017, 12, 7), ... contract = contract, ... client_transaction_id = str(uuid.uuid4()))) >>> positions = [position] >>> response = client.position_upload(position) We can check the status of the request >>> response.IsSuccess True `response.Results` has a list of :class:`derivitec.positions.types.PositionUploadResult` with additional information of each attempted upload. """ wrapper = self._get_wrapper('position_upload') return wrapper(positions=positions)
[docs] def legacy_position_upload(self, positions, create_missing_books=None, use_best_effort=None): """ Legacy Position upload. :param positions: :type positions: list of Position :type create_missing_books: the create missing books :type use_best_effort: the use best effort :rtype: :class:`derivitec.positions.types.ApiPositionUploadResponse` `response.Results` has a list of :class:`derivitec.positions.types.PositionUploadResult` with additional information of each attempted upload. """ wrapper = self._get_wrapper('legacy_position_upload') return wrapper(positions=positions, create_missing_books=create_missing_books, use_best_effort=use_best_effort)
[docs] def create_books(self, create_book_requests): """ Create books. :param create_book_requests: :type: list of ApiCreateBookRequest :rtype: :class:`derivitec.core.response.ApiBaseResponse` What follows is an example of creating new books. See :class:`derivitec.positions.request.ApiCreateBookRequest` for more information about the `ApiCreateBookRequest` class. **Code** >>> import uuid >>> create_book_requests = [ ... ApiCreateBookRequest("TestApiBook1", "TestApiBook1", ["Portfolio 18", "Portfolio 13"], ["testuser.api@derivitec.com"]), ... ApiCreateBookRequest("TestApiBook2", "TestApiBook2", ["Portfolio 10"], ["testuser.api@derivitec.com"]) ... ] >>> response = client.create_books(create_book_requests) We can check the status of the request >>> response.IsSuccess True """ wrapper = self._get_wrapper('create_books') return wrapper(create_book_requests=create_book_requests)
[docs] def calculate_risk_on_contracts(self, contracts, risk_measures, pricing_date, market_date, market_data_override=None, reporting_currency=None, risk_scenarios=None, exclude_historically_derived_vol_surfaces=False, include_contract_data_in_response=True, consolidate_error_messages=True, use_real_time_eq_spot=False, use_real_time_fx_spot=False, pricing_model_manager=None, market_data_environment_name=None, equity_indices_to_decompose=None, pricing_environment_name=None): """ Calculate risk on a set of contracts. :param contracts: The contracts. :type contracts: list[:class:`derivitec.tradables.types.Contract`] :param risk_measures: The risk measures. :type risk_measures: list[:class:`derivitec.risk_engine.types.RiskMeasure`] :param pricing_date: The pricing date. :type pricing_date: datetime.datetime :param market_date: The market date. :type market_date: datetime.datetime :param market_data_override: The market data override (optional) :type market_data_override: :class:`derivitec.market_data.types.MarketDataOverride` :param reporting_currency: The reporting currency. (optional; default local currency except for FX contracts) `reporting_currency == None` is forbidden) :type reporting_currency: str :param risk_scenarios: The risk scenarios (optional) :type risk_scenarios: list[:class:`derivitec.risk_engine.types.RiskScenario`] :param exclude_historically_derived_vol_surfaces: The exclude historically derived vol surfaces flag :type exclude_historically_derived_vol_surfaces: bool :param include_contract_data_in_response: The include contract data in unit risk flag :type include_contract_data_in_response: bool :param consolidate_error_messages: True to consolidate error messages :type consolidate_error_messages: bool :param use_real_time_eq_spot: The use real time eq spot flag :type use_real_time_eq_spot: bool :param use_real_time_fx_spot: The use real time fx spot flag :type use_real_time_fx_spot: bool :param pricing_model_manager: The pricing model manager :type pricing_model_manager: :class:`derivitec.tradables.types.PricingModelManager` :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :param equity_indices_to_decompose: The equity indices to decompose with flag to control spot calculation of index. {InstrumentIdenfitifer : bool} :type equity_indices_to_decompose: dict[:class:`derivitec.misc.types.InstrumentIdentifier`,bool] :param pricing_environment_name: The pricing environment name (optional, defaults to None) :type pricing_environment_name: str :rtype: :class:`derivitec.risk_engine.types.RiskCalculationResult` **Code** >>> risk_measures = [Npv(), EqDelta()] >>> pricing_date = market_date = datetime(2017, 11, 1) >>> contracts = [EqFutureByCode(code=ric("SPZ7"))] >>> exclude_historically_derived_vol_surfaces = True >>> risk = client.calculate_risk_on_contracts( ... contracts, ... risk_measures, ... pricing_date, ... market_date, ... exclude_historically_derived_vol_surfaces ... include_contract_data_in_response) Now we can see the contents of the risk results. >>> for res in risk.RiskResults: ... print "{0}: {1} {2}".format(res.MeasureName, res.UnitValue, res.UnitValueCurrency) ... NPV: 0.0 USD EqDelta: 2583.13 USD The EqDelta risk result has the relevant equity asset information on it. See :class:`derivitec.risk_engine.types.RiskResult` >>> for res in filter(lambda x: x.MeasureName == "EqDelta", risk.RiskResults): ... print res.EquityAsset ... <ric:.SPX> **Market data overrides** The :class:`derivitec.risk_engine.types.MarketDataOverride` class can be used to override a number of parameters: >>> market_data_override = MarketDataOverride( ... equity_spot_overrides = {ric(".SPX"):3000.0}) >>> risk = client.calculate_risk_on_contracts( ... contracts, ... risk_measures, ... pricing_date, ... market_date, ... market_data_override=market_data_override, ... market_data_environment_name="My Example Environment") """ wrapper = self._get_wrapper('calculate_risk_for_contracts') return wrapper(contracts=contracts, risk_measures=risk_measures, pricing_date=pricing_date, market_date=market_date, market_data_override=market_data_override, reporting_currency=reporting_currency, risk_scenarios=risk_scenarios, exclude_historically_derived_vol_surfaces=exclude_historically_derived_vol_surfaces, include_contract_data_in_response=include_contract_data_in_response, consolidate_error_messages=consolidate_error_messages, use_real_time_eq_spot=use_real_time_eq_spot, use_real_time_fx_spot=use_real_time_fx_spot, pricing_model_manager=pricing_model_manager, market_data_environment_name=market_data_environment_name, pricing_environment_name=pricing_environment_name, equity_indices_to_decompose=equity_indices_to_decompose)
[docs] def calculate_risk_on_tradables(self, tradable_ids, risk_measures, pricing_date=None, market_date=None, market_data_override=None, reporting_currency=None, risk_scenarios=None, exclude_historically_derived_vol_surfaces=None, use_real_time_eq_spot=False, use_real_time_fx_spot=False, pricing_model_manager=None, market_data_environment_name=None, equity_indices_to_decompose=None, pricing_environment_name=None): """ Calculate risk on a set of tradable ids. :param tradable_ids: The tradable ids. :type tradable_ids: list of str :param risk_measures: The risk measures. :type risk_measures: list[:class:`derivitec.risk_engine.types.RiskMeasure`] :param pricing_date: The pricing date. :type pricing_date: datetime.datetime :param market_date: The market date. :type market_date: datetime.datetime :param market_data_override: The market data override. :type market_data_override: :class:`derivitec.market_data.types.MarketDataOverride` :param reporting_currency: The reporting currency. :type reporting_currency: str :param risk_scenarios: The risk scenarios :type risk_scenarios: list[:class:`derivitec.risk_engine.types.RiskScenario`] :param exclude_historically_derived_vol_surfaces: The exclude historically derived vol surfaces flag :type exclude_historically_derived_vol_surfaces: bool :param use_real_time_eq_spot: The use real time eq spot flag :type use_real_time_eq_spot: bool :param use_real_time_fx_spot: The use real time fx spot flag :type use_real_time_fx_spot: bool :param pricing_model_manager: The pricing model manager :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :param equity_indices_to_decompose: The equity indices to decompose with flag to control spot calculation of index. {InstrumentIdenfitifer : bool} :type equity_indices_to_decompose: dict[:class:`derivitec.misc.types.InstrumentIdentifier`,bool] :type pricing_model_manager: :class:`derivitec.tradables.types.PricingModelManager` :param pricing_environment_name: The pricing environment name (optional, defaults to None) :type pricing_environment_name: str :rtype: :class:`derivitec.risk_engine.response.ApiCalculateRiskResponse` **Code** See :class:`derivitec.client.client.DerivitecClient.calculate_risk_on_contracts` """ wrapper = self._get_wrapper('calculate_risk_for_tradable_ids') return wrapper(tradable_ids=tradable_ids, risk_measures=risk_measures, pricing_date=pricing_date, market_date=market_date, market_data_override=market_data_override, reporting_currency=reporting_currency, risk_scenarios=risk_scenarios, exclude_historically_derived_vol_surfaces=exclude_historically_derived_vol_surfaces, use_real_time_eq_spot=use_real_time_eq_spot, use_real_time_fx_spot=use_real_time_fx_spot, pricing_model_manager=pricing_model_manager, market_data_environment_name=market_data_environment_name, pricing_environment_name=pricing_environment_name, equity_indices_to_decompose=equity_indices_to_decompose)
[docs] def calculate_risk_on_portfolio(self, portfolio_name, risk_measures, pricing_date=None, market_date=None, market_data_override=None, reporting_currency=None, risk_scenarios=None, exclude_historically_derived_vol_surfaces=None, use_real_time_eq_spot=False, use_real_time_fx_spot=False, pricing_model_manager=None, market_data_environment_name=None, equity_indices_to_decompose=None, portfolio_type=None, pricing_environment_name=None): """ Calculate risk on a portfolio. :param portfolio_name: The portfolio name. :type portfolio_name: str :param portfolio_type: The portfolio type i.e Derivitec or other external portfolio management system name - required if you have a matching portfolio name in more than one provider. :type portfolio_type: str :param risk_measures: The risk measures. :type risk_measures: list of RiskMeasure :param pricing_date: The pricing date. :type pricing_date: datetime :param market_date: The market date. :type market_date: datetime :param market_data_override: The market data override. :type market_data_override: MarketDataOverride :param reporting_currency: The reporting currency. :type reporting_currency: str :param risk_scenarios: The risk scenarios :type risk_scenarios: list of RiskScenario :param exclude_historically_derived_vol_surfaces: The exclude historically derived vol surfaces flag :type exclude_historically_derived_vol_surfaces: bool :param use_real_time_eq_spot: The use real time eq spot flag :type use_real_time_eq_spot: bool :param use_real_time_fx_spot: The use real time fx spot flag :type use_real_time_fx_spot: bool :param pricing_model_manager: The pricing model manager :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :param equity_indices_to_decompose: The equity indices to decompose with flag to control spot calculation of index. {InstrumentIdenfitifer : bool} :type equity_indices_to_decompose: dictionary :type pricing_model_manager: :class:`derivitec.tradables.types.PricingModelManager` :param pricing_environment_name: The pricing environment name (optional, defaults to None) :type pricing_environment_name: str :rtype: :class:`derivitec.risk_engine.response.ApiCalculateRiskResponse` **Code** See `calculate_risk_on_portfolio` """ wrapper = self._get_wrapper('calculate_risk_for_portfolio') return wrapper(portfolio_name=portfolio_name, risk_measures=risk_measures, pricing_date=pricing_date, market_date=market_date, market_data_override=market_data_override, reporting_currency=reporting_currency, risk_scenarios=risk_scenarios, exclude_historically_derived_vol_surfaces=exclude_historically_derived_vol_surfaces, use_real_time_eq_spot=use_real_time_eq_spot, use_real_time_fx_spot=use_real_time_fx_spot, pricing_model_manager=pricing_model_manager, market_data_environment_name=market_data_environment_name, pricing_environment_name=pricing_environment_name, equity_indices_to_decompose=equity_indices_to_decompose, portfolio_type=portfolio_type)
[docs] def calculate_historical_price_series_on_contracts(self, contracts, run_date=None, reporting_currency=None, market_data_override=None, first_observation_date=None, historical_start_date_rule=None, horizon=None, market_data_environment_name=None, last_observation_date=None, historical_end_date_rule=None): """ Calculate historical price series on a set of contracts. :param contracts: The contracts. :type contracts: list[:class:`derivitec.tradables.types.Contract`] :param run_date: The run date. :type run_date: datetime.datetime :param reporting_currency: The reporting currency. (optional; default local currency except for FX contracts) `reporting_currency == None` is forbidden) :type reporting_currency: str :param market_data_override: The market data override (optional) :type market_data_override: :class:`derivitec.market_data.types.MarketDataOverride` :param first_observation_date: The first observation date :type first_observation_date: datetime.datetime :param historical_start_date_rule: The historical start date rule :type historical_start_date_rule: str :param horizon: The horizon :type horizon: int :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :param last_observation_date: The last observation date :type last_observation_date: datetime.datetime :param historical_end_date_rule: The historical end date rule :type historical_end_date_rule: str :rtype: :class:`derivitec.risk_engine.types.VarResult` **Code** >>> var_results = client.calculate_historical_price_series_on_contracts( ... contracts=[EqFutureByCode(code=ric("SPZ7"))], ... run_date=datetime.datetime(2017, 11, 1), ... reporting_currency='USD', ... historical_start_date_rule='-6m', ... horizon=1, ... market_data_environment_name="My Example Environment") """ wrapper = self._get_wrapper('calculate_historical_price_series_on_contracts') return wrapper(contracts=contracts, run_date=run_date, reporting_currency=reporting_currency, market_data_override=market_data_override, first_observation_date=first_observation_date, historical_start_date_rule=historical_start_date_rule, horizon=horizon, market_data_environment_name=market_data_environment_name, last_observation_date=last_observation_date, historical_end_date_rule=historical_end_date_rule)
[docs] def run_report(self, report_name, portfolio_name, run_date, market_data_override, reporting_currency, market_data_environment_names=None, pricing_date=None, market_date=None, portfolio_date_time=None, report_cutoff=None): """ Trigger a report run. :param report_name: The report name. :type report_name: str :param portfolio_name: The portfolio name. :type portfolio_name: str :param run_date: The run date. :type run_date: datetime.datetime :param market_data_override: The market data override. :type market_data_override: :class:`derivitec.market_data.types.MarketDataOverride` :param reporting_currency: The reporting currency. :type reporting_currency: str :param market_data_environment_names: The market data environment names in order of preference (optional: any items in this list will be followed by Organisation Level then Derivitec Data) :type market_data_environment_names: list of str :param pricing_date: The pricing date. :type pricing_date: datetime.datetime :param market_date: The market_date. :type market_date: datetime.datetime :param portfolio_date_time: The portfolio date time. :type portfolio_date_time: datetime.datetime :param report_cutoff: The fx cutoff to be used. :type report_cutoff: str :rtype: :class:`derivitec.reports.response.ApiReportJobResponse` **Code** See `run_report` """ wrapper = self._get_wrapper('run_report') return wrapper( id=None, market_data_override=market_data_override, portfolio_name=portfolio_name, report_name=report_name, reporting_currency=reporting_currency, run_date=run_date, market_data_environment_names=market_data_environment_names, pricing_date=pricing_date, market_date=market_date, portfolio_date_time=portfolio_date_time, report_cutoff=report_cutoff)
[docs] def run_risk_report(self, report_name, portfolio_name, run_date, market_data_override, reporting_currency, market_data_environment_names=None, real_time_market_data=False, portfolio_type=None, pricing_date=None, market_date=None, portfolio_date_time=None, position_filter_name=None, position_filter=None): """ Trigger a report run. :param report_name: The report name. :type report_name: str :param portfolio_name: The portfolio name. :type portfolio_name: str :param run_date: The run date. :type run_date: datetime.datetime :param market_data_override: The market data override. :type market_data_override: :class:`derivitec.market_data.types.MarketDataOverride` :param real_time_market_data: The realtime flag :type real_time_market_data: bool :param reporting_currency: The reporting currency. :type reporting_currency: str :param market_data_environment_names: The market data environment names in order of preference (optional: any items in this list will be followed by Organisation Level then Derivitec Data) :type market_data_environment_names: list of str :param portfolio_type: The portfolio type i.e Derivitec or other external portfolio management system name - required if you have a matching portfolio name in more than one provider. :type portfolio_type: str :param pricing_date: The pricing date. :type pricing_date: datetime.datetime :param market_date: The market_date. :type market_date: datetime.datetime :param portfolio_date_time: The portfolio date time. :type portfolio_date_time: datetime.datetime :param position_filter_name: Optional - The position filter name - either referencing one saved or supply to tag with the provided position_filter :type position_filter_name: str :param position_filter: Optional - The position filter :type position_filter: FilterBase - can be StringFilter or MultiFilter containing StringFilters :rtype: :class:`derivitec.reports.response.ApiRiskReportJobResponse` **Code** See `run_report` """ wrapper = self._get_wrapper('run_risk_report') return wrapper( id=None, market_data_override=market_data_override, portfolio_name=portfolio_name, real_time_market_data=real_time_market_data, report_name=report_name, reporting_currency=reporting_currency, run_date=run_date, market_data_environment_names=market_data_environment_names, portfolio_type=portfolio_type, pricing_date=pricing_date, market_date=market_date, portfolio_date_time=portfolio_date_time, position_filter_name=position_filter_name, position_filter=position_filter)
[docs] def get_report_data_by_id(self, report_id, data_table_query=None): """ Get report data by report id. :param report_id: The report id :type report_id: str :param data_table_query: Optional DataTableQuery for selecting rows & columns :rtype: **Code** """ wrapper = self._get_wrapper('get_report_data_by_id') return wrapper(report_id=report_id, data_table_query=data_table_query)
[docs] def get_report_infos(self, report_name, portfolio_name, pricing_date, market_data_environment_names=None, run_by_user_emails=None): """ Get report infos. :param report_name: The report name. :type report_name: str :param portfolio_name: The portfolio name. :type portfolio_name: str :param pricing_date: The pricing date. :type pricing_date: datetime.datetime :param market_data_environment_names: List of market data environment names to filter by (optional). :type market_data_environment_names: list of str :param run_by_user_emails: List of user emails to filter by (optional). :type run_by_user_emails: list of str :rtype: :class:`derivitec.reports.response.ApiGetReportInfosResponse` **Code** >>> client.get_report_infos("Equity Risk (Derivitec)", "Demo Portfolio", datetime(2017, 11, 1), ["Example Market Data Environment"], ["Example.User@ExampleOrg.com"]) """ wrapper = self._get_wrapper('get_report_infos') return wrapper(report_name=report_name, portfolio_name=portfolio_name, pricing_date=pricing_date, market_data_environment_names=market_data_environment_names, run_by_user_emails=run_by_user_emails)
[docs] def get_var_report_infos(self, portfolio_name=None, pricing_date=None, portfolio_names=None, pricing_dates=None): """ Get report infos. :param portfolio_name: The portfolio name. :type portfolio_name: str :param pricing_date: The pricing date. :type pricing_date: datetime.datetime :param portfolio_names: The portfolio names. :type portfolio_names: list of str :param pricing_dates: The pricing dates. :type pricing_dates: list[datetime.datetime] :rtype: :class:`derivitec.reports.response.ApiGetVarReportInfosResponse` **Code** >>> client.get_var_report_infos("Portfolio 4", datetime(2017, 10, 13)) """ wrapper = self._get_wrapper('get_var_report_infos') return wrapper(portfolio_name=portfolio_name, pricing_date=pricing_date, portfolio_names=portfolio_names, pricing_dates=pricing_dates)
[docs] def get_time_series(self, series_name, filter, start_date, end_date): """ Get a time series. :param series_name: The name of the series. :type series_name: str :param filter: The filter. :type filter: Filter :param start_date: The start date :type start_date: datetime :param end_date: The end date :type end_date: datetime :rtype: :class:`derivitec.reports.response.ApiGetTimeSeriesResponse` **Code** >>> filter_def = Equal(ColumnName="Account", Value="AccountNumber123") >>> client.get_time_series( ... "Limit Utilisation", ... filter_def, ... datetime(2017, 1, 1), ... datetime(2017, 8, 23)) """ wrapper = self._get_wrapper('get_time_series') return wrapper(series_name=series_name, filter=filter, start_date=start_date, end_date=end_date)
[docs] def run_var_report(self, portfolio_name, reporting_currency, run_date, market_data_override, confidence_level, horizon, historical_start_date_rule, market_data_environment_names=None, pricing_date=None, market_date=None, portfolio_date_time=None, first_observation_date=None, report_name="Historical VaR Report", historical_end_date_rule=None, last_observation_date=None): """ Trigger a var report run. :param portfolio_name: The portfolio name. :type portfolio_name: str :param reporting_currency: The reporting currency. :type reporting_currency: str :param run_date: The run date. :type run_date: datetime.datetime :param market_data_override: The market data override. :type market_data_override: :class:`derivitec.market_data.types.MarketDataOverride` :param confidence_level: The confidence level. :type confidence_level: float :param horizon: The horizon :type horizon: int :param historical_start_date_rule: The historical start date rule. :type historical_start_date_rule: str :param market_data_environment_names: The market data environment names in order of preference (optional: any items in this list will be followed by Organisation Level then Derivitec Data) :type market_data_environment_names: list of str :param first_observation_date: The first observation date. :type first_observation_date: datetime.datetime :param pricing_date: The pricing date. :type pricing_date: datetime.datetime :param market_date: The market_date. :type market_date: datetime.datetime :param portfolio_date_time: The portfolio date time. :type portfolio_date_time: datetime.datetime :param report_name: The report name :type report_name: str :param historical_end_date_rule: The historical end date rule :type historical_end_date_rule: str :param last_observation_date: The last observation date :type last_observation_date: datetime.datetime :rtype: :class:`derivitec.reports.response.ApiVarReportJobResponse` **Code** See `run_var_report` """ wrapper = self._get_wrapper('run_var_report') return wrapper( portfolio_name=portfolio_name, reporting_currency=reporting_currency, run_date=run_date, market_data_override=market_data_override, confidence_level=confidence_level, horizon=horizon, historical_start_date_rule=historical_start_date_rule, historical_end_date_rule=historical_end_date_rule, last_observation_date=last_observation_date, market_data_environment_names=market_data_environment_names, pricing_date=pricing_date, market_date=market_date, portfolio_date_time=portfolio_date_time, report_name=report_name, first_observation_date=first_observation_date)
[docs] def get_var_report_data_by_id(self, report_id): """ Get var report data by report id. :param report_id: The report id :type report_id: str :rtype: **Code** """ wrapper = self._get_wrapper('get_var_report_data_by_id') return wrapper(report_id=report_id)
[docs] def get_var_reports_data_by_id(self, report_ids=None, return_raw_data=False): """ Get var report data by report ids. :param report_ids: The report ids :type report_ids: list of str :param return_raw_data: The flag indicating return raw report data or not :type return_raw_data: bool :rtype: :class:`derivitec.reports.response.ApiGetVarReportsDataByIdResponse` **Code** """ wrapper = self._get_wrapper('get_var_reports_data_by_id') return wrapper(report_ids=report_ids, return_raw_data=return_raw_data)
[docs] def get_var_report_time_series_data_by_id(self, report_id): """ Get var report time series data by report id. :param report_id: The report id :type report_id: str :rtype: **Code** """ wrapper = self._get_wrapper('get_var_report_time_series_data_by_id') return wrapper(report_id=report_id)
[docs] def get_var_report_status_by_id(self, report_id): """ Get var report status by report id. :param report_id: The report id :type report_id: str :rtype: **Code** """ wrapper = self._get_wrapper('get_var_report_status_by_id') return wrapper(report_id=report_id)
[docs] def get_pnl_reports_data_by_id(self, report_ids=None): """ Get var report data by report ids. :param report_ids: The report ids :type report_ids: list of str :rtype: :class:`derivitec.reports.response.ApiGetPnlReportsDataByIdResponse` **Code** """ wrapper = self._get_wrapper('get_pnl_reports_data_by_id') return wrapper(report_ids=report_ids)
[docs] def get_pnl_report_infos(self, portfolio_names=None, initial_date_time=None, final_date_time=None): """ Get pnl report infos :param portfolio_names: The report ids :type portfolio_names: list of str :param initial_date_time: The initial date time :type initial_date_time: datetime.datetime :param final_date_time: The final date time :type final_date_time: datetime.datetime :rtype: :class:`derivitec.reports.response.ApiGetPnlReportInfosResponse` **Code** """ wrapper = self._get_wrapper('get_pnl_report_infos') return wrapper(portfolio_names=portfolio_names, initial_date_time=initial_date_time, final_date_time=final_date_time)
[docs] def get_risk_report_meta_data(self, report_id=None): """ Get risk report metadata :param report_id: The report id :type report_id: str :rtype: :class:`derivitec.reports.response.ApiReportMetaDataResponse` **Code** """ wrapper = self._get_wrapper('get_report_metadata_by_id') return wrapper(report_id=report_id, report_type='risk')
[docs] def get_pnl_report_meta_data(self, report_id=None): """ Get pnl report meta data :param report_id: The report id :type report_id: str :rtype: :class:`derivitec.reports.response.ApiReportMetaDataResponse` **Code** """ wrapper = self._get_wrapper('get_report_metadata_by_id') return wrapper(report_id=report_id, report_type='pnl')
[docs] def get_active_user_portfolios(self): """ Get active user portfolio :rtype: dict **Code** >>> client.get_active_user_portfolios() {u'11': u'Portfolio 11', u'15': u'Portfolio 15', u'16': u'Portfolio 16'} """ return self._get_api_content("api/Report/GetActiveUserPortfolios")
[docs] def get_available_currency_isos(self): """ Get available currencies :rtype: list of str **Code** >>> client.get_available_currency_isos() ['AUD', 'CHF', 'EUR', 'GBP', 'JPY', 'SEK', 'USD', 'HKD', 'TWD', 'SGD'] """ return self._get_api_content("api/Report/GetAvailableCurrencyIsos")
[docs] def get_available_risk_reports(self): """ Get available risk reports. :rtype: dict **Code** >>> client.get_available_risk_reports() {'IrParallelShockReport': 'Interest Rate Shocks', 'FxVegaReport': 'FX Vega'} """ return self._get_api_content("api/Report/GetAvailableRiskReports")
[docs] def get_report_excel_export(self, report_id, file_name): """ Get the report excel export from its id. :param report_id: The report id. :type report_id: str :param report_id: The output file name. :type report_id: str """ try: wrapper = self._get_wrapper('export_to_excel') export_request = wrapper(report_id=report_id, include_pivot_table=False) url = export_request.__getattribute__('download_url') if url is not None: url = url.replace(self._client_settings.api_url, "") req_stream = self._get_api_content_raw(url) with open(file_name, 'wb') as xfile: for chunk in req_stream.iter_content(chunk_size=32 * 1024): xfile.write(chunk) xfile.close() return file_name else: return None except: return None
[docs] def get_report_result(self, id): """ Get the report result from its id. :param id: The report id. :type id: str """ return DictBuilderAbstract.rebuild(self._get_api_content("/api/ReportView/" + id))
[docs] def get_portfolio_table(self, portfolio_name, portfolio_date, portfolio_type=None): """ Get portfolio table for the specified portfolio. :param portfolio_name: The portfolio name :type portfolio_name: str :param portfolio_type: The portfolio type i.e Derivitec or other external portfolio management system name - required if you have a matching portfolio name in more than one provider. :type portfolio_type: str :param portfolio_date: The portfolio date :type portfolio_date: datetime :rtype: list of dicts, one for each table row **Code** """ wrapper = self._get_wrapper('get_portfolio_table') return wrapper(portfolio_name=portfolio_name, portfolio_date=portfolio_date, portfolio_type=portfolio_type)
[docs] def get_transaction_table(self, portfolio_name, start_date, end_date, include_zero_quantities, counterparties=None, portfolio_type=None): """ Get portfolio table for the specified portfolio. :param portfolio_name: The portfolio name :type portfolio_name: str :param portfolio_type: The portfolio type i.e Derivitec or other external portfolio management system name - required if you have a matching portfolio name in more than one provider. :type portfolio_type: str :param start_date: Include all transactions from this date :type start_date: datetime :param end_date: Include all transactions up to this date :type end_date: datetime :param include_zero_quantities: If false all transactions that sum to zero quantity are excluded :type include_zero_quantities: bool :param counterparties: If set only transactions for these counterparties are included :type counterparties: list of strs **Code** """ wrapper = self._get_wrapper('get_transaction_table') return wrapper( portfolio_name=portfolio_name, start_date=start_date, end_date=end_date, include_zero_quantities=include_zero_quantities, counterparties=counterparties, portfolio_type=portfolio_type)
[docs] def get_swaption_vol_cube_data(self, rate_asset_name, market_date, strike_spreads=None, include_market_quotes=None, include_sabr_parameters=None, bump=None, market_data_environment_name=None): """ Get swaption vol cube data for rate asset and optional flags. :param rate_asset_name: The rate asset name. :param market_date: The market date. :param strike_spreads: The list of strike spreads vs atm fwd. :param include_market_quotes: The include market quotes flag. :param include_sabr_parameters: The include sabr parameters flag. :param bump: The bump value. :type rate_asset_name: str :type market_date: datetime :type include_market_quotes: bool :type include_sabr_parameters: bool :type bump: float :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: """ wrapper = self._get_wrapper('get_swaption_vol_cube_data') return wrapper(rate_asset_name=rate_asset_name, market_date=market_date, strike_spreads=strike_spreads, include_market_quotes=include_market_quotes, include_sabr_parameters=include_sabr_parameters, bump=bump)
[docs] def get_credit_swaption_vol_cube_data(self, credit_index_identifier, market_date, strike_spreads=None, strike_prices=None, include_sabr_parameters=None, market_data_environment_name=None): """ Get credit swaption vol cube data for credit index and optional flags. :param credit_index_identifier: The credit index identifier :param market_date: The market date. :param strike_spreads: The list of strike spreads vs atm fwd. :param strike_prices: The list of price based strikes :param include_sabr_parameters: The include sabr parameters flag. :type credit_index_identifier: InstrumentIdentifer :type market_date: datetime :type include_sabr_parameters: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: """ wrapper = self._get_wrapper('get_credit_swaption_vol_cube_data') return wrapper(credit_index_identifier=credit_index_identifier, market_date=market_date, strike_spreads=strike_spreads, strike_prices=strike_prices, include_sabr_parameters=include_sabr_parameters)
[docs] def upload_entity_custom_data(self, entity_custom_datas, use_best_effort, market_data_environment_name=None): """ Upload entity custom data. :param entity_custom_datas: list of entity custom data. :param use_best_effort: The use best effort flag. :type entity_custom_datas: list of EntityCustomData :type use_best_effort: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: list of str **Code** >>> entity_custom_datas = [ ... EntityCustomData( ... instrument_identifier = ric("MSFT.OQ"), ... country_of_risk = "USA", ... region_of_risk = "North America", ... sector = "Technology", ... credit_rating = "AA+"), ... EntityCustomData( ... instrument_identifier = isin("XS1253550641"), ... country_of_risk = "Japan", ... region_of_risk = "APAC", ... sector = "Pharmaceutical"), ... EntityCustomData( ... issuer_identifier = reutersorgid("19775"), ... country_of_risk = "USA", ... region_of_risk = "North America", ... sector = "Electronics")] >>> market_data_environment_name = "Example Market Data Environment" >>> client.upload_entity_custom_data( ... entity_custom_datas, ... True, ... market_data_environment_name) """ wrapper = self._get_wrapper('upload_entity_custom_data') return wrapper(entity_custom_datas=entity_custom_datas, use_best_effort=use_best_effort, market_data_environment_name=market_data_environment_name)
[docs] def upload_credit_swaption_vol_cube_data(self, credit_swaption_vol_cube_datas, use_best_effort, market_data_environment_name=None): """ Upload credit swaption vol cube data. :param credit_swaption_vol_cube_datas: The credit swaption vol cube datas. :param use_best_effort: The use best effort flag. :type credit_swaption_vol_cube_datas: list of CreditSwaptionVolCubeData :type use_best_effort: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: """ wrapper = self._get_wrapper('upload_credit_swaption_vol_cube_data') return wrapper(credit_swaption_vol_cube_datas=credit_swaption_vol_cube_datas, use_best_effort=use_best_effort, market_data_environment_name=market_data_environment_name)
[docs] def fit_bond_yield_curves_to_bond_data(self, data, market_data_override=None, pricing_model_manager=None, use_best_effort=True, individual_curve_per_bond_flag=False, market_data_environment_name=None): """ Fit bond yield curves to bond data. :param data: The bond price data :type data: list of :class:`derivitec.market_data.types.BondDataExternal` :param market_data_override: The market data override :type market_data_override: :class:`derivitec.market_data.types.MarketDataOverride` :param pricing_model_manager: The pricing model manager :type pricing_model_manager: :class:`derivitec.tradables.types.PricingModelManager` :param use_best_effort: The use best effort flag :type use_best_effort: bool :param individual_curve_per_bond_flag: The individual curve per bond flag :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :type individual_curve_per_bond_flag: bool :rtype: :class:`derivitec.market_data.response.ApiFitBondYieldCurvesToBondDataResponse` """ wrapper = self._get_wrapper('fit_bond_yield_curves_to_bond_data') return wrapper(data=data, market_data_override=market_data_override, pricing_model_manager=pricing_model_manager, use_best_effort=use_best_effort, individual_curve_per_bond_flag=individual_curve_per_bond_flag, market_data_environment_name=market_data_environment_name)
[docs] def fit_equity_vol_surfaces_to_convertible_bond_data(self, bond_price_data, market_data_override=None, pricing_model_manager=None, initial_atm_vol=0.3, min_vol_bump=-0.9, max_vol_bump=1.0, market_data_environment_name=None): """ Fit equity vol surfaces to convertible bond data. :param bond_price_data: The bond price data :type bond_price_data: list of :class:`derivitec.market_data.types.BondDataExternal` :param market_data_override: The market data override :type market_data_override: :class:`derivitec.market_data.types.MarketDataOverride` :param pricing_model_manager: The pricing model manager :type pricing_model_manager: :class:`derivitec.tradables.types.PricingModelManager` :param initial_atm_vol: The initial atm vol level :type initial_atm_vol: float :param min_vol_bump: The min vol bump for root searching bracket :type min_vol_bump: float :param max_vol_bump: The max vol bump for root searching bracket :type max_vol_bump: float :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiFitEquityVolSurfacesToConvertibleBondDataResponse` """ wrapper = self._get_wrapper('fit_equity_vol_surfaces_to_convertible_bond_data') return wrapper(bond_price_data=bond_price_data, market_data_override=market_data_override, pricing_model_manager=pricing_model_manager, initial_atm_vol=initial_atm_vol, min_vol_bump=min_vol_bump, max_vol_bump=max_vol_bump, market_data_environment_name=market_data_environment_name)
[docs] def upload_equity_fx_correlation_data(self, equity_fx_correlation_data, market_data_environment_name=None): """ Upload equity-fx correlation data. :param equity_fx_correlation_data: The equity-fx correlation data :type equity_fx_correlation_data: list[:class:`derivitec.market_data.types.EquityFxCorrelationData`] :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiBaseResponse` """ wrapper = self._get_wrapper('upload_equity_fx_correlation_data') return wrapper(equity_fx_correlation_data=equity_fx_correlation_data, market_data_environment_name=market_data_environment_name)
[docs] def get_equity_fx_correlation_data(self, correlation_descriptors, market_dates, market_data_environment_name=None): """ Get equity-fx correlation data. :param correlation_descriptors: The equity-fx pairs :param market_dates: The market dates :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type correlation_descriptors: list[:class:`derivitec.market_data.types.EquityFxCorrelationDescriptor`] :type market_dates: list[datetime.datetime] :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiGetEquityFxCorrelationResponse` """ wrapper = self._get_wrapper('get_equity_fx_correlation_data') return wrapper(correlation_descriptors=correlation_descriptors, market_dates=market_dates, market_data_environment_name=market_data_environment_name)
[docs] def upload_equity_dividend_correlation_data(self, correlation_by_equity_id_and_dividend_id, market_date, use_best_effort, market_data_environment_name=None): """ Upload equity-dividend correlation data. :param correlation_by_equity_id_and_dividend_id: The equity-dividend correlation data :type correlation_by_equity_id_and_dividend_id: list[EquityDividendCorrelationData] :param market_date: The market date :type market_date: datetime :param use_best_effort: The use best effort flag. :type use_best_effort: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiUploadEquityDividendCorrelationResponse` """ wrapper = self._get_wrapper('upload_equity_dividend_correlation_data') return wrapper( correlation_by_equity_id_and_dividend_id=correlation_by_equity_id_and_dividend_id, market_date=market_date, use_best_effort=use_best_effort, market_data_environment_name=market_data_environment_name)
[docs] def upload_equity_equity_correlation_data( self, equity_equity_correlation_data, use_best_effort, market_data_environment_name=None): """ Upload equity-equity correlation data. :param equity_equity_correlation_data: The equity-equity correlation data :type equity_equity_correlation_data: list[EquityEquityCorrelationData] :param use_best_effort: The use best effort flag. :type use_best_effort: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiUploadEquityEquityCorrelationResponse` """ wrapper = self._get_wrapper('upload_equity_equity_correlation_data') return wrapper( equity_equity_correlation_data=equity_equity_correlation_data, use_best_effort=use_best_effort, market_data_environment_name=market_data_environment_name)
[docs] def get_equity_equity_correlation_data(self, correlation_descriptors, market_dates, market_data_environment_name=None): """ Get equity-equity correlation data. :param correlation_descriptors: The equity-equity pairs :param market_dates: The market dates :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type correlation_descriptors: list[:class:`derivitec.market_data.types.EquityEquityCorrelationDescriptor`] :type market_dates: list[datetime.datetime] :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiGetEquityEquityCorrelationResponse` """ wrapper = self._get_wrapper('get_equity_equity_correlation_data') return wrapper(correlation_descriptors=correlation_descriptors, market_dates=market_dates, market_data_environment_name=market_data_environment_name)
[docs] def upload_equity_ir_correlation_data(self, equity_ir_correlations, market_date, use_best_effort, market_data_environment_name=None): """ Upload equity ir correlation data. :param equity_ir_correlations: The equity ir correlation data :type equity_ir_correlations: list[:class:`derivitec.market_data.types.EquityIrCorrelationData`] :param market_date: The market date :type market_date: datetime.datetime :param use_best_effort: The use best effort flag. :type use_best_effort: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiUploadEquityIrCorrelationResponse` """ wrapper = self._get_wrapper('upload_equity_ir_correlation_data') return wrapper( equity_ir_correlations=equity_ir_correlations, market_date=market_date, use_best_effort=use_best_effort, market_data_environment_name=market_data_environment_name)
[docs] def upload_fx_ir_correlation_data(self, fx_ir_correlations, market_date, use_best_effort, market_data_environment_name=None): """ Upload fx ir correlation data. :param fx_ir_correlations: The fx ir correlation data :type fx_ir_correlations: list[:class:`derivitec.market_data.types.FxIrCorrelationData`] :param market_date: The market date :type market_date: datetime.datetime :param use_best_effort: The use best effort flag. :type use_best_effort: bool :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiUploadFxIrCorrelationResponse` """ wrapper = self._get_wrapper('upload_fx_ir_correlation_data') return wrapper( fx_ir_correlations=fx_ir_correlations, market_date=market_date, use_best_effort=use_best_effort, market_data_environment_name=market_data_environment_name)
[docs] def upload_probability_of_default(self, probability_of_default_data, market_data_environment_name=None): """ Upload probability of default data. :param probability_of_default_data: The probability of default data :type probability_of_default_data: list[:class:`derivitec.market_data.types.ProbabilityOfDefaultData`] :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiUploadProbabilityOfDefaultResponse` """ wrapper = self._get_wrapper('upload_probability_of_default') return wrapper( probability_of_default_data=probability_of_default_data, market_data_environment_name=market_data_environment_name)
[docs] def upload_amortisation_rates(self, amortisation_rate_data, market_data_environment_name=None): """ Upload amortisation rate data. :param amortisation_rate_data: The amortisation rate data :type amortisation_rate_data: list[:class:`derivitec.market_data.types.AmortisationRateData`] :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiUploadAmortisationRatesResponse` """ wrapper = self._get_wrapper('upload_amortisation_rates') return wrapper( amortisation_rate_data=amortisation_rate_data, market_data_environment_name=market_data_environment_name)
[docs] def upload_recovery_rates(self, recovery_rate_data, market_data_environment_name=None): """ Upload recovery of default data. :param recovery_rate_data: The recovery rate data :type recovery_rate_data: list[:class:`derivitec.market_data.types.RecoveryRateData`] :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.market_data.response.ApiUploadRecoveryRatesResponse` """ wrapper = self._get_wrapper('upload_recovery_rates') return wrapper( recovery_rate_data=recovery_rate_data, market_data_environment_name=market_data_environment_name)
[docs] def upload_dividend_index_fixings(self, dividend_index_fixings, market_data_environment_name=None): """ Upload stock data :param dividend_index_fixings: The dividend index fixings :type dividend_index_fixings: list of :class:`derivitec.market_data.types.DividendIndexFixing` :param market_data_environment_name: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_name: str :rtype: :class:`derivitec.core.response.ApiBaseResponse` """ wrapper = self._get_wrapper('upload_dividend_index_fixings') return wrapper(dividend_index_fixings=dividend_index_fixings, market_data_environment_name=market_data_environment_name)
[docs] def get_dividend_index_fixings(self, dividend_index_ids, start_date, end_date, market_data_environment_names=None): """ Get dividend index fixings for some identifiers between two dates. :param dividend_index_ids: The identifiers. :type dividend_index_ids: list[:class:`derivitec.misc.types.InstrumentIdentifier`] :param start_date: The start date. :type start_date: datetime.datetime :param end_date: The end date. :type end_date: datetime.datetime :param market_data_environment_names: The market data environment name (optional with default Organisation Level Environment) :type market_data_environment_names: list[:str] :rtype: :class:`derivitec.market_data.response.ApiGetDividendIndexFixingsResponse` """ wrapper = self._get_wrapper('get_dividend_index_fixings') return wrapper(dividend_index_ids=dividend_index_ids, start_date=start_date, end_date=end_date, market_data_environment_names=market_data_environment_names)