From bd4f10b6f2891805d57e7116e56d376dd86be307 Mon Sep 17 00:00:00 2001 From: foolcage <5533061@qq.com> Date: Wed, 14 Aug 2024 23:20:20 +0800 Subject: [PATCH] Improve add_to_eastmoney function to add only the entities that are not in the group. --- src/zvt/informer/inform_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/zvt/informer/inform_utils.py b/src/zvt/informer/inform_utils.py index a99f0459..5777adb8 100644 --- a/src/zvt/informer/inform_utils.py +++ b/src/zvt/informer/inform_utils.py @@ -32,11 +32,15 @@ def add_to_eastmoney(codes, group, entity_type="stock", over_write=True): eastmoneypy.del_group(group_name=group, session=session) need_create_group = True + codes = set(codes) if need_create_group: result = eastmoneypy.create_group(group_name=group, session=session) group_id = result["gid"] + else: + current_codes = eastmoneypy.list_entities(group_id=group_id, session=session) + if current_codes: + codes = codes - set(current_codes) - codes = list(set(codes)) for code in codes: eastmoneypy.add_to_group(code=code, entity_type=entity_type, group_id=group_id, session=session)