"""
|
首板代码评分管理
|
"""
|
|
# bidding 是否满足竞价
|
# deal_big_money 成交大金额是否满足
|
# code_nature = (是否有涨停,是否有溢价)
|
# hot_block(板块中涨停票个数(包含自己),板块炸板票个数)
|
# zyltgb自由流通市值是否大于250亿
|
# limit_price 涨停价是否大于100块
|
# limit_up_time 是否10点之前涨停
|
# k_form(15个交易日是否涨幅24.9%,是否破前高,是否超跌,是否接近前高,是否N,是否V,是否有形态)
|
import code_nature_analyse
|
import global_data_loader
|
import global_util
|
import gpcode_manager
|
import tool
|
from third_data import hot_block_data_process
|
from trade import l2_trade_factor, deal_big_money_manager, bidding_money_manager
|
|
|
def __get_score(zyltgb, limit_price, bidding, k_form, code_nature, hot_block, volume_rate, limit_up_time,
|
deal_big_money):
|
score_list = []
|
if zyltgb:
|
zyltgbs = [0, 10, 31, 51, 101, 150, 250, 1000000]
|
zyltgb_score = [20, 30, 20, 10, 0, -10, -20]
|
for i in range(1, len(zyltgbs)):
|
if zyltgbs[i - 1] <= zyltgb / 100000000 < zyltgbs[i]:
|
score_list.append(zyltgb_score[i - 1])
|
else:
|
score_list.append(0)
|
|
if limit_price:
|
score_list.append(-1000)
|
else:
|
score_list.append(0)
|
|
# 开盘前竞价
|
if bidding:
|
score_list.append(25)
|
else:
|
score_list.append(0)
|
|
k_score = []
|
# 15个交易日是否涨幅24.9%
|
if k_form[0]:
|
k_score.append(-55)
|
else:
|
k_score.append(0)
|
|
# 是否破前高
|
if k_form[1]:
|
k_score.append(65)
|
else:
|
k_score.append(0)
|
# 是否超跌
|
if k_form[2]:
|
k_score.append(45)
|
else:
|
k_score.append(0)
|
|
# 是否接近前高
|
if k_form[3]:
|
k_score.append(-25)
|
else:
|
k_score.append(0)
|
# 是否N
|
if k_form[4]:
|
k_score.append(40)
|
else:
|
k_score.append(0)
|
# 是否V
|
if k_form[5]:
|
k_score.append(35)
|
else:
|
k_score.append(0)
|
|
# 是否有形态
|
if k_form[6]:
|
k_score.append(0)
|
else:
|
k_score.append(-25)
|
|
score_list.append(k_score)
|
|
nature_score = []
|
|
if code_nature is None:
|
code_nature = [True, False]
|
|
if not code_nature[0]:
|
nature_score.append(5)
|
else:
|
nature_score.append(0)
|
if code_nature[1]:
|
nature_score.append(20)
|
else:
|
nature_score.append(0)
|
|
score_list.append(nature_score)
|
|
hot_block_score = []
|
# 板块中只有自己涨停,且无炸板
|
if hot_block[1] == 1 and hot_block[2] == 0:
|
hot_block_score.append(25)
|
elif hot_block[1] >= 2 and hot_block[2] == 0:
|
hot_block_score.append(35)
|
else:
|
hot_block_score.append(5)
|
score_list.append(hot_block_score)
|
|
# 量
|
volume_score = [0, 35, 45, 55, 45, 35, 15, -5, -30]
|
volume_rates = [0, 0.349, 0.499, 0.649, 0.799, 0.949, 1.099, 1.249, 1.399]
|
volume_add = False
|
for i in range(1, len(volume_rates)):
|
if volume_rates[i - 1] <= volume_rate < volume_rates[i]:
|
score_list.append(volume_score[i - 1])
|
volume_add = True
|
break
|
if not volume_add:
|
score_list.append(volume_score[-1])
|
|
if limit_up_time:
|
times = ["10:00:00", "11:30:00", "14:00:00", "15:00:00"]
|
time_scores = [15, 10, 5, 0]
|
for i in range(0, len(times)):
|
if int(times[i].replace(":", "")) >= int(limit_up_time.replace(":", "")):
|
score_list.append(time_scores[i])
|
break
|
else:
|
score_list.append(0)
|
|
# 大单成交
|
if deal_big_money:
|
score_list.append(30)
|
else:
|
score_list.append(0)
|
|
score = 0
|
for s in score_list:
|
if type(s) == list:
|
for ss in s:
|
score += ss
|
else:
|
score += s
|
return score, score_list
|
|
|
def get_score(code, volume_rate, limit_up_time, with_source_data=False):
|
source_datas = []
|
|
# 获取自由流通股本
|
zyltgb = global_util.zyltgb_map.get(code)
|
if zyltgb is None:
|
global_data_loader.load_zyltgb()
|
zyltgb = global_util.zyltgb_map.get(code)
|
if zyltgb is None:
|
zyltgb = 100 * 100000000
|
source_datas.append(zyltgb)
|
|
limit_price = float(gpcode_manager.get_limit_up_price(code))
|
source_datas.append(limit_price)
|
|
# 竞价金额
|
bidding_money = bidding_money_manager.get_bidding_money(code)
|
source_datas.append(bidding_money)
|
bidding = False
|
if bidding_money and bidding_money >= 5000:
|
bidding = True
|
|
k_form = code_nature_analyse.CodeNatureRecordManager.get_k_format(code)
|
if k_form is None:
|
k_form = [(True, ''), (False, ''), (False, ''), (False, ''), (False, ''), (False, ''), (True, '')]
|
source_datas.append(k_form)
|
|
code_nature = code_nature_analyse.CodeNatureRecordManager.get_nature(code)
|
source_datas.append(code_nature)
|
|
hot_block = hot_block_data_process.get_info(code)
|
if hot_block is None:
|
hot_block = ('无板块', 1, 0)
|
else:
|
# 加上自己
|
hot_block = (hot_block[0], hot_block[1] + 1, hot_block[2])
|
|
source_datas.append(hot_block)
|
|
source_datas.append(volume_rate)
|
|
source_datas.append(limit_up_time)
|
|
# 获取成交大单
|
deal_big_num = deal_big_money_manager.get_deal_big_money_num(code)
|
m = l2_trade_factor.L2TradeFactorUtil.get_base_safe_val(zyltgb)
|
source_datas.append((deal_big_num * limit_price * 100, m))
|
|
if deal_big_num * limit_price * 100 > m:
|
deal_big_num = True
|
else:
|
deal_big_num = False
|
|
k_form_1 = []
|
for d in k_form:
|
k_form_1.append(d[0])
|
|
result = __get_score(zyltgb, limit_price > 100, bidding, k_form_1, code_nature, hot_block,
|
volume_rate, limit_up_time, deal_big_num)
|
if with_source_data:
|
return result, source_datas
|
return result
|
|
|
if __name__ == "__main__":
|
global_data_loader.load_zyltgb()
|
score = get_score("603829", 1.2, "15:00:01", True)
|
print(score)
|