| | |
| | | from __future__ import print_function, absolute_import, unicode_literals |
| | | |
| | | import decimal |
| | | |
| | | from log_module.log import logger_common |
| | | # from datetime import datetime |
| | | from strategy import data_cache |
| | | from strategy.logging_config import get_logger |
| | | from utils import hx_qc_value_util |
| | | |
| | | # 获取logger实例 |
| | | logger = get_logger() |
| | | logger = logger_common |
| | | |
| | | |
| | | # 将纯数字代码转化为=》掘金格式股票代码 |
| | |
| | | # print(f"open_growth=={open_growth}") |
| | | |
| | | |
| | | # 计算瞬时涨幅公式 |
| | | # 初始化历史价格 |
| | | price_history = {} |
| | | # # 计算瞬时涨幅公式 |
| | | # # 初始化历史价格 |
| | | # price_history = {} |
| | | # |
| | | # |
| | | # def calculate_growth(symbol, price): |
| | | # try: |
| | | # if symbol not in price_history: |
| | | # return 0 # 不足两个历史价格,无法计算涨幅 |
| | | # last_price = price_history[symbol] |
| | | # # print(f"price_history[symbol]~~~~~~~~~{price_history[symbol]}") |
| | | # if last_price != 0: |
| | | # growth = (price - last_price) / last_price * 100 # 计算涨幅百分比 |
| | | # return growth |
| | | # finally: |
| | | # price_history[symbol] = price |
| | | # # print(f"price======={price}") |
| | | # # print(f"price_history=={price_history}") |
| | | # # print(f"price_history[symbol]=={price_history[symbol]}") |
| | | |
| | | |
| | | def calculate_growth(symbol, price): |
| | | try: |
| | | if symbol not in price_history: |
| | | return 0 # 不足两个历史价格,无法计算涨幅 |
| | | last_price = price_history[symbol] |
| | | # print(f"price_history[symbol]~~~~~~~~~{price_history[symbol]}") |
| | | if last_price != 0: |
| | | growth = (price - last_price) / last_price * 100 # 计算涨幅百分比 |
| | | return growth |
| | | finally: |
| | | price_history[symbol] = price |
| | | # print(f"price======={price}") |
| | | # print(f"price_history=={price_history}") |
| | | # print(f"price_history[symbol]=={price_history[symbol]}") |
| | | |
| | | |
| | | # 计算tick涨幅公式【为卖出策略单独创建函数】 |
| | | # # 计算瞬时间隔涨幅公式【为卖出策略单独创建函数】 |
| | | # 初始化历史价格 |
| | | history_price = {} |
| | | |
| | |
| | | frying_plate_day_min_index = next((i for i, d in enumerate(k_line_data[0:7]) if 'attribute' in d and d['attribute'] in data_cache.frying_plate_type), None) # 如果没有找到,返回None |
| | | # 找到最近7日内的有跌停的序号 |
| | | limit_down_day_min_index = next((i for i, d in enumerate(k_line_data[0:7]) if 'attribute' in d and d['attribute'] in data_cache.limit_down_type), None) # 如果没有找到,返回None |
| | | |
| | | # 最近的涨停序号存在 且 非昨日 |
| | | if limit_up_day_min_index is not None and limit_up_day_min_index > 0: |
| | | # 开盘价 < 涨停当日最高价 <= 今日涨停价 |