Skip to content

Commit

Permalink
Improve add_to_eastmoney function to add only the entities that are n…
Browse files Browse the repository at this point in the history
…ot in the group.
  • Loading branch information
foolcage committed Aug 14, 2024
1 parent 6f10f54 commit bd4f10b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/zvt/informer/inform_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit bd4f10b

Please sign in to comment.