def test_multiple_securities_and_fields(): message = Message({ "securityData": List([ Map({ "security": "L Z7 Comdty", "fieldData": Map({ "PX_LAST": "90.00", "ASK": "90.00", "BID": "90.00" }) }), Map({ "security": "L Z6 Comdty", "fieldData": Map({ "PX_LAST": "90.00", "ASK": "90.00" }) }) ]) }) response = extractReferenceSecurityPricing(message) assert len(response) == 2 fields = response[0]["fields"] assert len(response[0]["fields"]) == 3 assert len(response[1]["fields"]) == 2
def test_simple(): message = Message({ "securityData": List([ Map({ "security": "L Z7 Comdty", "fieldData": Map({"PX_LAST": "90.00"}) }) ]) }) response = extractReferenceSecurityPricing(message) assert len(response) == 1 assert response[0]["security"] == "L Z7 Comdty" fields = response[0]["fields"] assert len(fields) == 1 assert fields[0]["name"] == "PX_LAST" assert fields[0]["value"] == "90.00"
def test_response_error_no_subcategory(): message = Message( {"responseError": Map({ "category": "CATEGORY", "message": "MESSAGE" })}) response = extractReferenceSecurityPricing(message) errors = extractErrors(message) assert len(response) == 0 assert len(errors) == 1 assert errors[0] == "CATEGORY/None MESSAGE"
def test_extract_multiple_fields(): message = Message({ "securityData": Map({ "security": "L Z7 Comdty", "fieldData": List([ Map({ "date": datetime.date(2006, 1, 31), "PX_LAST": 90, "ASK": 90 }) ]) }) }) response = extractHistoricalSecurityPricing(message) print(response) assert len(response) == 1 assert len(response[0]["values"][0]["fields"]) == 2
def test_simple(): message = Message({ "barData": Map({ "barTickData": List([ Map({ "time": Element(6), "open": Element(5), "high": Element(4), "low": Element(3), "close": Element(2), "volume": Element(100), "numEvents": Element(10) }) ]) }) }) response = extractIntradaySecurityPricing("L Z7 Comdty", message) assert response["security"] == "L Z7 Comdty" assert response["values"][0]["high"] == "4" assert response["values"][0]["low"] == "3"
def test_simple(): message = Message({ "securityData": Map({ "security": "L Z7 Comdty", "fieldData": List([ Map({ "date": datetime.date(2006, 1, 31), "PX_LAST": 90 }), Map({ "date": datetime.date(2006, 2, 1), "PX_LAST": 90.05 }) ]) }) }) response = extractHistoricalSecurityPricing(message) assert len(response) == 2 assert response[0]["date"] == "2006-01-31" assert response[1]["date"] == "2006-02-01"
def test_response_error(): message = Message({ "responseError": Map({ "category": "CATEGORY", "subcategory": "SUBCATEGORY", "message": "MESSAGE" }) }) response = extractHistoricalSecurityPricing(message) errors = extractErrors(message) assert len(response) == 0 assert len(errors) == 1 assert errors[0] == "CATEGORY/SUBCATEGORY MESSAGE"