Esempio n. 1
0
    def get_latest_rebalance_date(self) -> dt.date:
        """
        Retrieve the most recent rebalance date for a basket

        :return: dictionary

        **Usage**

        Retrieve the most recent rebalance date for a basket

        **Examples**

        Retrieve the most recent rebalance date for a basket

        >>> from gs_quant.markets.baskets import Basket
        >>>
        >>> basket = Basket.get("GSMBXXXX")
        >>> basket.get_latest_rebalance_date()

        **See also**

        :func:`get_latest_rebalance_data`
        """
        last_rebalance = GsIndexApi.last_rebalance_data(self.id)
        return dt.datetime.strptime(last_rebalance['date'], '%Y-%m-%d').date()
Esempio n. 2
0
def test_basket_last_rebalance_data(mocker):
    # construct mock response
    mock_response = {'reportId': report_id, 'assetId': basket_id}

    # setup mock session and api response
    mock_session()
    mocker.return_value = mock_response

    # run test
    response = GsIndexApi.last_rebalance_data(basket_id)
    assert response == mock_response
Esempio n. 3
0
    def get_latest_rebalance_data(self) -> Dict:
        """
        Retrieve the most recent rebalance data for a basket

        **Usage**

        Retrieve the most recent rebalance data for a basket

        **Examples**

        Retrieve the most recent rebalance data for a basket

        >>> from gs_quant.markets.baskets import Basket
        >>>
        >>> basket = Basket.get("GSMBXXXX")
        >>> basket.get_latest_rebalance_data()

        **See also**

        :func:`get_latest_rebalance_date`
        """
        return GsIndexApi.last_rebalance_data(self.id)
Esempio n. 4
0
    def get_last_rebalance_date(self) -> dt.date:
        if not self.id:
            self.__raise_initialization_error('retrieve latest rebalance date')

        last_rebalance = GsIndexApi.last_rebalance_data(self.id)
        return dt.datetime.strptime(last_rebalance['date'], '%Y-%m-%d').date()
Esempio n. 5
0
    def get_last_rebalance_data(self) -> Dict:
        if not self.id:
            self.__raise_initialization_error('retrieve latest rebalance data')

        return GsIndexApi.last_rebalance_data(self.id)