Ejemplo n.º 1
0
def test_vol_swap_strike_matches_no_assets_when_expiry_tenor_is_not_none():
    with pytest.raises(MqValueError):
        replace = Replacer()
        base = Cross('MA667', 'EURUSD')
        xrefs = replace('gs_quant.timeseries.measures.Asset.get_identifier', Mock())
        xrefs.return_value = 'EURUSD'

        mock_asset_1 = GsAsset(asset_class='FX', id='MA123', type_='VolatilitySwap', name='Test_asset',
                               parameters={"lastFixingDate": "1y"})

        mock_asset_2 = GsAsset(asset_class='FX', id='MA123', type_='VolatilitySwap', name='Test_asset',
                               parameters={"lastFixingDate": "1y"})

        assets = replace('gs_quant.timeseries.measures.GsAssetApi.get_many_assets', Mock())
        assets.return_value = [mock_asset_1, mock_asset_2]

        tm_fxo.vol_swap_strike(base, "10m", location=PricingLocation.LDN, real_time=False)
    replace.restore()
Ejemplo n.º 2
0
def test_vol_swap_strike_matches_multiple_assets():
    with pytest.raises(MqValueError):
        replace = Replacer()
        base = Cross('MA667', 'EURUSD')
        xrefs = replace('gs_quant.timeseries.measures.Asset.get_identifier',
                        Mock())
        xrefs.return_value = 'EURUSD'
        mock_asset_1 = GsAsset(asset_class='FX',
                               id='MA123',
                               type_='VolatilitySwap',
                               name='Test_asset')
        assets = replace(
            'gs_quant.timeseries.measures.GsAssetApi.get_many_assets', Mock())
        assets.return_value = [mock_asset_1, mock_asset_1]
        tm_fxo.vol_swap_strike(base,
                               None,
                               location=PricingLocation.LDN,
                               real_time=False)
Ejemplo n.º 3
0
def test_vol_swap_strike():
    replace = Replacer()
    base = Cross('MA667', 'EURUSD')
    xrefs = replace('gs_quant.timeseries.measures.Asset.get_identifier', Mock())
    xrefs.return_value = 'EURUSD'

    mock_asset_1 = GsAsset(asset_class='FX', id='MA123', type_='VolatilitySwap', name='Test_asset',
                           parameters={"lastFixingDate": "1y"})
    mock_asset_2 = GsAsset(asset_class='FX', id='MA123', type_='VolatilitySwap', name='Test_asset',
                           parameters={"lastFixingDate": "2y"})

    assets = replace('gs_quant.timeseries.measures.GsAssetApi.get_many_assets', Mock())
    assets.return_value = [mock_asset_1, mock_asset_2]
    mock_data = replace('gs_quant.timeseries.measures.GsDataApi.get_market_data', Mock())
    mock_data.return_value = mock_df()
    actual = tm_fxo.vol_swap_strike(base, "1y", location=PricingLocation.LDN, real_time=False)
    assert_series_equal(tm_rates._extract_series_from_df(mock_df(), QueryType.STRIKE_VOL), actual)

    actual = tm_fxo.vol_swap_strike(base, "1y", None, real_time=False)
    assert_series_equal(tm_rates._extract_series_from_df(mock_df(), QueryType.STRIKE_VOL), actual)
    replace.restore()
Ejemplo n.º 4
0
def test_vol_swap_strike_raises_exception():
    with pytest.raises(NotImplementedError):
        mock_asset_1 = GsAsset(asset_class='FX', id='MAW8SAXPSKYA94E2', type_='Option', name='Test_asset')
        tm_fxo.vol_swap_strike(mock_asset_1, "none", "none", location=PricingLocation.LDN, real_time=True)