From bf3740cd0d7f3293a15020bbc6d5e18ea15749cd Mon Sep 17 00:00:00 2001 From: Julien Rossow-Greenberg Date: Sat, 17 Feb 2024 09:29:23 -0500 Subject: [PATCH] fix attr patch --- pytdx/tdx.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pytdx/tdx.py b/pytdx/tdx.py index 212f5d4..b022eb2 100644 --- a/pytdx/tdx.py +++ b/pytdx/tdx.py @@ -129,7 +129,15 @@ def __to_patch_payload( payload = [] for attr_name, attr_value in data_dict.items(): if attr_value is not None: - payload.append({"op": op, "path": f"/{attr_name}", "value": attr_value}) + # Attributes require a different format, you have to spell each one out + # Attributes should be represented as a List of Dicts + if attr_name == "Attributes": + # Iterate through list + for item in attr_value: + # Append to payload, accessing item ID and Value k,vs. + payload.append({"op": op, "path": f"/attributes/{item["ID"]}", "value": item["Value"]}) + else: + payload.append({"op": op, "path": f"/{attr_name}", "value": attr_value}) return payload def __request(self, method: str, url: str, data=False):