Skip to content

Commit

Permalink
improve examples
Browse files Browse the repository at this point in the history
  • Loading branch information
foolcage committed Jul 31, 2022
1 parent 46fabf8 commit 2486622
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
36 changes: 12 additions & 24 deletions examples/report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def report_top_entities(

logger.info(f"{entity_type} filter_entity_ids size: {len(filter_entity_ids)}")
filters = [kdata_schema.entity_id.in_(filter_entity_ids)]
selected = []
for i, period in enumerate(periods):
interval = period
if target_date.weekday() + 1 < interval:
Expand All @@ -240,34 +241,21 @@ def report_top_entities(
)

if return_type == TopType.positive:
tag = "最靓仔"
df = positive_df
else:
tag = "谁有我惨"
df = negative_df
selected = selected + df.index[:top_count].tolist()

if i == 0:
inform(
informer,
entity_ids=df.index[:top_count].tolist(),
target_date=target_date,
title=f"{entity_type} {period}日内 {tag}",
entity_provider=entity_provider,
entity_type=entity_type,
em_group=em_group,
em_group_over_write=em_group_over_write,
)
else:
inform(
informer,
entity_ids=df.index[:top_count].tolist(),
target_date=target_date,
title=f"{entity_type} {period}日内 {tag}",
entity_provider=entity_provider,
entity_type=entity_type,
em_group=em_group,
em_group_over_write=False,
)
inform(
informer,
entity_ids=selected,
target_date=target_date,
title=f"{entity_type} {em_group}({len(selected)})",
entity_provider=entity_provider,
entity_type=entity_type,
em_group=em_group,
em_group_over_write=em_group_over_write,
)
break
except Exception as e:
logger.exception("report error:{}".format(e))
Expand Down
14 changes: 7 additions & 7 deletions examples/reports/report_tops.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def report_top_stocks():
entity_type="stock",
entity_provider="em",
data_provider="em",
periods=[2, 3, 8, 15],
periods=[*range(2, 16)],
ignore_new_stock=True,
ignore_st=True,
adjust_type=None,
Expand All @@ -40,7 +40,7 @@ def report_top_stocks():
entity_type="stock",
entity_provider="em",
data_provider="em",
periods=[30, 60],
periods=[30, 45, 60],
ignore_new_stock=True,
ignore_st=True,
adjust_type=None,
Expand Down Expand Up @@ -80,7 +80,7 @@ def report_top_blocks():
entity_type="block",
entity_provider="em",
data_provider="em",
periods=[3, 8, 30],
periods=[3, 5, 8, 30],
ignore_new_stock=False,
ignore_st=False,
adjust_type=None,
Expand Down Expand Up @@ -120,11 +120,11 @@ def report_top_stockhks():
entity_provider="em",
data_provider="em",
top_count=10,
periods=[2, 3, 8, 15],
ignore_new_stock=True,
periods=[*range(2, 10)],
ignore_new_stock=False,
ignore_st=False,
adjust_type=None,
turnover_threshold=50000000,
turnover_threshold=30000000,
turnover_rate_threshold=0.001,
informer=email_informer,
em_group="短期最强",
Expand All @@ -141,7 +141,7 @@ def report_top_stockhks():
ignore_new_stock=True,
ignore_st=False,
adjust_type=None,
turnover_threshold=50000000,
turnover_threshold=30000000,
turnover_rate_threshold=0.001,
informer=email_informer,
em_group="中期最强",
Expand Down

0 comments on commit 2486622

Please sign in to comment.