Skip to content

Commit

Permalink
add example for adding block to eastmoney group
Browse files Browse the repository at this point in the history
  • Loading branch information
foolcage committed Oct 26, 2021
1 parent 56c13cd commit 1b36876
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
22 changes: 21 additions & 1 deletion examples/recorders/block_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import logging
import time

import eastmoneypy
from apscheduler.schedulers.background import BackgroundScheduler

from zvt import init_log, zvt_config
from zvt.domain import Block, Block1dKdata, BlockCategory
from zvt.informer.informer import EmailInformer
from zvt.utils import current_date, next_date

logger = logging.getLogger(__name__)

Expand All @@ -22,10 +24,28 @@ def record_block():
try:
Block.record_data(provider='eastmoney')

# 只抓去概念行情
# 只抓取概念行情
df = Block.query_data(filters=[Block.category == BlockCategory.concept.value], index='entity_id')
entity_ids = df.index.tolist()
Block1dKdata.record_data(provider='em', entity_ids=entity_ids)

# 报告新概念
list_date = next_date(current_date(), -90)
df = Block.query_data(filters=[Block.category == BlockCategory.concept.value, Block.list_date >= list_date],
index='entity_id')

# add them to eastmoney
try:
try:
eastmoneypy.create_group('概念')
except:
pass
for code in df['code']:
eastmoneypy.add_to_group(code, group_name='概念', entity_type='block')
except Exception as e:
email_action.send_message(zvt_config['email_username'], f'report_concept error',
'report_concept error:{}'.format(e))

email_action.send_message(zvt_config['email_username'], 'record block finished', '')
break
except Exception as e:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
zvt >= 0.9.0
apscheduler >= 3.4.0
eastmoneypy >= 0.0.6
eastmoneypy >= 0.0.8
tabulate>=0.8.8
4 changes: 2 additions & 2 deletions zvt/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
SAMPLE_ETF_CODES = ['510300', '512880', '510500', '510050', '159915', '512660', '512980', '510410']

# 上证指数 上证50 沪深300 中证500 中证1000 科创50
# 深证成指 国证成长(399370)国证价值(399371)国证基金(399379) 国证ETF(399380)
# 深证成指(399001) 创业板指(399006) 国证成长(399370)国证价值(399371)国证基金(399379) 国证ETF(399380)
IMPORTANT_INDEX = ['000001', '000016', '000300', '000905', '000852', '000688',
'399001', '399370', '399371', '399379', '399380']
'399001', '399006', '399370', '399371', '399379', '399380']

0 comments on commit 1b36876

Please sign in to comment.