def test_market_data_object():
    coord_val_pair = [
        {
            'coordinate': {
                'mkt_type': 'IR',
                'mkt_asset': 'USD',
                'mkt_class': 'Swap',
                'mkt_point': ('5y', ),
                'mkt_quoting_style': 'ATMRate'
            },
            'value': 0.9973194889
        },
        {
            'coordinate': {
                'mkt_type': 'IR',
                'mkt_asset': 'USD',
                'mkt_class': 'Swap',
                'mkt_point': ('40y', ),
                'mkt_quoting_style': 'ATMRate'
            },
            'value': 'redacted'
        },
    ]
    coordinates = {
        MarketDataCoordinate.from_dict(dic['coordinate']): dic['value']
        for dic in coord_val_pair
    }
    overlay_market = OverlayMarket(base_market=CloseMarket(
        market_data=coordinates))

    assert overlay_market.coordinates[0] == MarketDataCoordinate.from_dict(
        coord_val_pair[0]['coordinate'])
    assert overlay_market.redacted_coordinates[
        0] == MarketDataCoordinate.from_dict(coord_val_pair[1]['coordinate'])
Example #2
0
            def extract_market_data(this_result: DataFrameWithInfo):
                market_data = {}

                for _, row in result.iterrows():
                    coordinate_values = {p: row.get(p) for p in properties}
                    if 'mkt_point' in coordinate_values:
                        coordinate_values['mkt_point'] = tuple(
                            coordinate_values['mkt_point'].split(';'))
                    market_data[MarketDataCoordinate.from_dict(
                        coordinate_values)] = row['value']

                return market_data
Example #3
0
            def extract_market_data(this_result: DataFrameWithInfo):
                market_data = {}

                for _, row in this_result.iterrows():
                    coordinate_values = {p: row.get(p) for p in properties}
                    mkt_point = coordinate_values.get('mkt_point')
                    if mkt_point is not None:
                        coordinate_values['mkt_point'] = tuple(coordinate_values['mkt_point'].split(';'))

                    # return 'redacted' as coordinate value if its a redacted coordinate
                    market_data[MarketDataCoordinate.from_dict(coordinate_values)] = row['value'] if \
                        row['permissions'] == 'Granted' else 'redacted'

                return market_data