示例#1
0
    def save_as_quote(self, overwrite: Optional[bool] = False):
        if self.portfolios:
            raise ValueError('Cannot save portfolios with nested portfolios')

        pricing_context = self._pricing_context

        request = RiskRequest(
            tuple(
                RiskPosition(instrument=i, quantity=i.instrument_quantity)
                for i in self.instruments), (ResolvedInstrumentValues, ),
            pricing_and_market_data_as_of=(PricingDateAndMarketDataAsOf(
                pricing_date=pricing_context.pricing_date,
                market=pricing_context.market), ))

        if self.__id:
            if not overwrite:
                raise ValueError(
                    f'Quote with id {id} already exists. Use overwrite=True to overwrite'
                )
            else:
                GsPortfolioApi.update_quote(self.__id, request)
                _logger.info(f'Updated Structuring with id {self.__id}')
        else:
            self.__id = GsPortfolioApi.save_quote(request)
            _logger.info(f'Created Structuring with id {self.__id}')
示例#2
0
    def save_to_shadowbook(self, name: str):
        if self.portfolios:
            raise ValueError('Cannot save portfolios with nested portfolios')

        request = RiskRequest(
            tuple(RiskPosition(instrument=i, quantity=i.instrument_quantity) for i in self.instruments),
            (ResolvedInstrumentValues,),
            pricing_and_market_data_as_of=(PricingDateAndMarketDataAsOf(pricing_date=self._pricing_context.pricing_date,
                                                                        market=self._pricing_context.market),)
        )
        status = GsPortfolioApi.save_to_shadowbook(request, name)
        print(f'Save to shadowbook status - {status}')