Пример #1
0
def test_swaption_premium_throws_for_unsupported_ccy():
    replace = Replacer()
    replace('gs_quant.timeseries.measures.Asset.get_identifier',
            Mock()).return_value = "ZAR"
    with pytest.raises(NotImplementedError):
        tm_rates.swaption_premium(Currency("KRW", name="KRW"))
    replace.restore()
Пример #2
0
def test_swaption_premium_return_data():
    replace = Replacer()
    test_data = dict(swaptionPremium=[1, 2, 3])
    df = MarketDataResponseFrame(data=test_data, index=[dt.date(2019, 1, 1), dt.date(2019, 1, 2),
                                                        dt.date(2019, 1, 3)])

    replace('gs_quant.timeseries.measures.Asset.get_identifier', Mock()).return_value = "GBP"
    replace('gs_quant.timeseries.measures_rates._get_tdapi_rates_assets', Mock(),
            Mock()).return_value = "MADWG3WHCKNE1DJA"
    replace('gs_quant.timeseries.measures_rates._range_from_pricing_date', Mock(), Mock()).return_value = [
        dt.date(2019, 1, 2), dt.date(2019, 1, 5)]
    replace('gs_quant.timeseries.measures_rates._market_data_timed', Mock()).return_value = df

    actual = tm_rates.swaption_premium(Currency("GBP", name="GBP"))
    assert_series_equal(tm._extract_series_from_df(df, QueryType.SWAPTION_PREMIUM), actual)
    replace.restore()
Пример #3
0
def test_swaption_premium_throws_for_unsupported_ccy():
    with pytest.raises(NotImplementedError):
        tm_rates.swaption_premium(Currency("KRW", name="KRW"))
Пример #4
0
def test_swaption_premium_throws_for_realtime():
    with pytest.raises(NotImplementedError):
        tm_rates.swaption_premium(Currency("GBP", name="GBP"), real_time=True)