def test_edit_instrument_property(self): property_value = models.PropertyValue(label_value="Insurance") property_key = f"Instrument/{TestDataUtilities.tutorials_scope}/CustomSector" identifier_type = "Figi" identifier = "BBG00KTDTF73" # update the instrument self.instruments_api.upsert_instruments_properties( upsert_instrument_property_request=[ models.UpsertInstrumentPropertyRequest( identifier_type=identifier_type, identifier=identifier, properties=[ models.ModelProperty(key=property_key, value=property_value) ]) ]) # get the instrument with value instrument = self.instruments_api.get_instrument( identifier_type=identifier_type, identifier=identifier, property_keys=[property_key]) self.assertGreaterEqual(len(instrument.properties), 1) prop = list( filter( lambda p: p.key == property_key and p.value.label_value == property_value.label_value, instrument.properties)) self.assertEqual( len(prop), 1, f"cannot find property key=${property_key} value={property_value}")
def upsert_ratings_property(self, figi, fitch_value=None, moodys_value=None): properties = { f"Instrument/{scope}/FitchRating": fitch_value, f"Instrument/{scope}/MoodysRating": moodys_value, } # upsert property definition for key in properties: if properties[key] is not None: property_request = [ models.UpsertInstrumentPropertyRequest( identifier_type="Figi", identifier=figi, properties=[ models.ModelProperty( key=key, value=models.PropertyValue( metric_value=models.MetricValue( value=properties[key] ) ), ) ], ) ] self.instruments_api.upsert_instruments_properties( upsert_instrument_property_request=property_request )