Skip to main content

概述

Following 模块提供关注组的管理功能,包括创建、查询、更新和删除关注组,以及管理组内的关注项。

create_follow_group()

创建一个新的关注组。
result = client.following.create_follow_group(
    name="My Stocks",
    follow_values=[
        {"follow_type": "company", "follow_value": "US:AAPL"},
        {"follow_type": "company", "follow_value": "HK:00700"}
    ]
)
print(f"创建成功: {result['group_id']}")
name
str
组名称
follow_values
list[dict]
关注项列表,每个元素包含 follow_type(str: “company”, “channel”)和 follow_value(str)
返回值
dict
包含 group_id, name, count 的字典
API 路径POST /v1/following/groups

get_follow_groups()

获取当前用户的所有关注组。
groups = client.following.get_follow_groups()
for group in groups:
    print(f"{group['name']}: {group['count']} items")
返回值
list[dict]
关注组列表,每个元素包含 group_id, name, count
API 路径GET /v1/following/groups

get_follow_group()

根据 ID 获取一个关注组的详细信息。
group = client.following.get_follow_group("group_123")
print(f"{group['name']}: {group['count']} items")
for fv in group.get('follow_values', []):
    print(f"  - {fv['follow_type']}: {fv['follow_value']}")
group_id
str
关注组 ID
返回值
dict
包含 group_id, name, count, follow_values 的字典
API 路径GET /v1/following/groups/{group_id}

update_follow_group()

更新一个关注组的名称。
result = client.following.update_follow_group("group_123", name="new name")
print(f"更新成功: {result['name']}")
group_id
str
关注组 ID
name
str
新的组名称
返回值
dict
包含 group_id, name, count 的字典
API 路径POST /v1/following/groups/{group_id}

delete_follow_group()

删除一个关注组。
result = client.following.delete_follow_group("group_123")
print(result.get('message', 'deleted'))
group_id
str
关注组 ID
返回值
dict
操作结果
API 路径DELETE /v1/following/groups/{group_id}

add_follows_to_group()

向关注组添加关注项。
result = client.following.add_follows_to_group(
    "group_123",
    follow_values=[{"follow_type": "company", "follow_value": "US:TSLA"}]
)
print(result.get('message', 'Added'))
group_id
str
关注组 ID
follow_values
list[dict]
要添加的关注项列表,每个元素包含 follow_type(str: “company”, “channel”)和 follow_value(str)
返回值
dict
操作结果
API 路径POST /v1/following/groups/{group_id}/follows

remove_follows_from_group()

从关注组中移除关注项。
result = client.following.remove_follows_from_group("group_123", ["AAPL", "MSFT"])
print(result.get('message', 'Removed'))
group_id
str
关注组 ID
follow_values
list[str]
要删除的关注值列表(如股票代码、频道 ID)
返回值
dict
操作结果
API 路径DELETE /v1/following/groups/{group_id}/follows

set_group_follows()

设置关注组的关注项(替换所有现有关注项)。
result = client.following.set_group_follows(
    "group_123",
    follow_values=[
        {"follow_type": "company", "follow_value": "US:AAPL"},
        {"follow_type": "company", "follow_value": "HK:00700"}
    ]
)
print(result.get('message', 'Set'))
group_id
str
关注组 ID
follow_values
list[dict]
新的关注项列表,每个元素包含 follow_type(str: “company”, “channel”)和 follow_value(str)
返回值
dict
操作结果
API 路径PUT /v1/following/groups/{group_id}/follows

get_follow_group_docs()

获取关注组的文档列表。
result = client.following.get_follow_group_docs("group_123", page_num=1, page_size=20)
print(f"total reports: {result['total_count']}")
for item in result['items']:
    print(f"  - {item.get('title', 'Untitled')}")
group_id
str
关注组 ID
page_num
int
页码,默认值为 1
page_size
int
每页条目数,默认值为 10
返回值
dict
包含 items, total_count, page_num, page_size 的字典
API 路径GET /v1/following/groups/{group_id}/docs