コード例 #1
0
ファイル: core.py プロジェクト: stephen-183/gs-quant
    def _scenario(self) -> Optional[MarketDataScenario]:
        scenarios = Scenario.path
        if not scenarios:
            return None

        return MarketDataScenario(scenario=scenarios[0] if len(scenarios) == 1 else
                                  CompositeScenario(scenarios=tuple(reversed(scenarios))))
コード例 #2
0
ファイル: historical.py プロジェクト: trohatgi12/gs-quant
    def calc(self, priceable: Priceable,
             risk_measure: RiskMeasure) -> PricingFuture:
        futures = []

        provider = priceable.provider
        base_scenario = self._scenario
        parameters = self._parameters
        location = self.market.location
        base_market = self.market
        for date in self.__date_range:
            if date > self.pricing_date:
                scenario = MarketDataScenario(
                    CarryScenario(
                        int(
                            business_day_count(dt.datetime.today().date(),
                                               date)), self._roll_to_fwds))
                risk_key = RiskKey(provider, date, base_market, parameters,
                                   scenario, risk_measure)
                futures.append(self._calc(priceable, risk_key))
            else:
                market = CloseMarket(location=location,
                                     date=close_market_date(location, date))
                risk_key = RiskKey(provider, date, market, parameters,
                                   base_scenario, risk_measure)
                futures.append(self._calc(priceable, risk_key))

        return HistoricalPricingFuture(futures)
コード例 #3
0
ファイル: historical.py プロジェクト: wechen1/gs-quant
    def calc(self, instrument: InstrumentBase, risk_measure: RiskMeasure) -> PricingFuture:
        futures = []

        provider = instrument.provider
        base_scenario = self._scenario
        parameters = self._parameters
        location = self.market.location
        base_market = self.market
        for date in self.__date_range:
            if date > self.pricing_date:
                scenario = MarketDataScenario(CarryScenario(date=date, roll_to_fwds=self._roll_to_fwds))
                risk_key = RiskKey(provider, date, base_market, parameters, scenario, risk_measure)
                futures.append(self._calc(instrument, risk_key))
            else:
                market = CloseMarket(location=location, date=close_market_date(location, date))
                risk_key = RiskKey(provider, date, market, parameters, base_scenario, risk_measure)
                futures.append(self._calc(instrument, risk_key))

        return HistoricalPricingFuture(futures)
コード例 #4
0
 def __scenario(self) -> MarketDataScenario:
     return MarketDataScenario(scenario=Scenario.current) if Scenario.current_is_set else None