| | |
| | | symbol = symbol.split(".")[1] |
| | | |
| | | |
| | | # 设置收盘价 |
| | | def re_set_price_pre(code): |
| | | codes = [code] |
| | | re_set_price_pres(codes) |
| | | |
| | | |
| | | def re_set_price_pres(codes, force=False): |
| | | result = HistoryKDatasUtils.get_gp_latest_info(codes) |
| | | for item in result: |
| | | symbol = item['symbol'] |
| | | symbol = symbol.split(".")[1] |
| | | pre_close = tool.to_price(decimal.Decimal(str(item['pre_close']))) |
| | | gpcode_manager.CodePrePriceManager.set_price_pre(symbol, pre_close, force) |
| | | |
| | | |
| | | __prices_now = {} |
| | | |
| | | |
| | | # 获取近90天的最大量与最近的量 |
| | | # 获取最近一次涨停/涨停下一个交易日的最大值 |
| | | def get_volumns_by_code(code, count=60) -> object: |
| | | datas = HistoryKDatasUtils.get_history_tick_n(code, count, "open,high,low,close,volume,pre_close,bob,amount") |
| | | # 计算 |
| | | datas.sort(key=lambda x: x["bob"], reverse=True) |
| | | return datas |
| | | |
| | | |
| | | # 解析最大量 |
| | | def parse_max_volume(datas, is_new_top=False): |
| | | max_volume = 0 |
| | | |
| | | max_volume_date = None |
| | | if is_new_top: |
| | | # 如果是突破前高就取最大量 |
| | | for item in datas: |
| | | if max_volume < item["volume"]: |
| | | max_volume = item["volume"] |
| | | max_volume_date = item["bob"] |
| | | return max_volume, max_volume, max_volume_date.strftime("%Y-%m-%d") |
| | | else: |
| | | |
| | | date = None |
| | | target_volume = None |
| | | for i in range(len(datas)): |
| | | # 查询涨停 |
| | | item = datas[i] |
| | | volume = item["volume"] |
| | | if max_volume < volume: |
| | | max_volume = volume |
| | | max_volume_date = item['bob'] |
| | | # 是否有涨停 |
| | | limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(item["pre_close"])) |
| | | if abs(limit_up_price - item["high"]) < 0.01: |
| | | # 涨停 |
| | | next_volume = 0 |
| | | if i > 0: |
| | | next_volume = datas[i - 1]["volume"] |
| | | date = datas[i]["bob"] |
| | | if volume < next_volume: |
| | | volume = next_volume |
| | | date = datas[i - 1]["bob"] |
| | | target_volume = (volume, date) |
| | | break |
| | | if not target_volume: |
| | | target_volume = (max_volume, max_volume_date) |
| | | |
| | | # --判断近60天无涨停的最大量 |
| | | max_60_volume_info = [0, None] |
| | | # 60天内是否有涨停 |
| | | has_60_limit_up = False |
| | | for i in range(60): |
| | | if i >= len(datas): |
| | | break |
| | | item = datas[i] |
| | | volume = item["volume"] |
| | | if max_60_volume_info[0] < volume: |
| | | max_60_volume_info = [volume, item["bob"]] |
| | | limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(item["pre_close"])) |
| | | if abs(limit_up_price - item["high"]) < 0.01: |
| | | has_60_limit_up = True |
| | | break |
| | | |
| | | if not has_60_limit_up and target_volume[0] > max_60_volume_info[0] * 3: |
| | | # 60天内无涨停,且60天内最大量小于最大量的1/3,判断为地量,返回近60个交易日的最大量 |
| | | return max_60_volume_info[0], max_60_volume_info[0], max_60_volume_info[1].strftime("%Y-%m-%d") |
| | | else: |
| | | return target_volume[0], target_volume[0], target_volume[1].strftime("%Y-%m-%d") |
| | | |
| | | |
| | | # 保存运行时数据 |