import json import os import sys import pandas as pd import numpy as np from datetime import datetime, timedelta current_dir = os.path.dirname(os.path.abspath(__file__)) # 如果当前目录不在sys.path中,就添加进去(避免重复添加) if current_dir not in sys.path: sys.path.append(current_dir) import argparse from predict_model_v14_profit_maximizer import LotteryPredictorV14Profit SUM12_ODDS = { 3: 41.9, 4: 41.9, 18: 41.9, 19: 41.9, 5: 20.38, 6: 20.38, 16: 20.38, 17: 20.38, 7: 13.51, 8: 13.51, 14: 13.51, 15: 13.51, 9: 9.7, 10: 9.7, 12: 9.7, 13: 9.7, 11: 8.1 } # 玩法1.1 赔率映射 SIZE_ODDS = {"冠亚大": 2.1, "冠亚小": 1.7} ODD_EVEN_ODDS = {"冠亚单": 1.7, "冠亚双": 2.1} NUM_DETAIL_ODDS = 1.9199 * 20 # NUM_DETAIL_ODDS = {"大": 1.9199, "小": 1.9199, "单": 1.9199, "双": 1.9199} # 玩法2.1/2.2/3 固定赔率 RANK_GLH_ODDS = 1.9199 * 10 # 玩法2.2 NUM_POS_ODDS = 9.599 * 10 # 玩法3 # 总赔率 TOTAL_ODDS = 0 SUM12_ODDS_TOTAL = sum(SUM12_ODDS.values()) SIZE_ODDS_TOTAL = sum(SIZE_ODDS.values()) ODD_EVEN_ODDS_TOTAL = sum(ODD_EVEN_ODDS.values()) TOTAL_ODDS += SUM12_ODDS_TOTAL + SIZE_ODDS_TOTAL + ODD_EVEN_ODDS_TOTAL TOTAL_ODDS += round(NUM_DETAIL_ODDS + RANK_GLH_ODDS + NUM_POS_ODDS, 4) # TOTAL_ODDS += round(NUM_DETAIL_ODDS * 20 + RANK_GLH_ODDS * 10 + NUM_POS_ODDS * 10, 4) EMPTY_TIME_WINDOWS = [ "06:05:00", "06:10:00", "06:15:00", "06:20:00", "06:25:00", "06:30:00", "06:35:00", "06:40:00", "06:45:00", "06:50:00", "06:55:00", "07:00:00", ] # print(f"总赔率: {TOTAL_ODDS}") # 1. 加载数据 def get_history_records(data_dirs): all_records = [] for d in data_dirs: if not os.path.exists(d): continue for f in os.listdir(d): if f.endswith('.json') and f != 'stat_result.json': with open(os.path.join(d, f), 'r', encoding='utf-8') as file: try: content = json.load(file) if isinstance(content, list): all_records.extend([item for item in content if isinstance(item, dict)]) except: continue return all_records def main(next_period_time, df): entry = { "id": next_period_time.strftime('%Y%m%d%H%M'), "time": next_period_time.strftime('%Y-%m-%d %H:%M:%S'), "result": {i: {n: None for n in range(1, 11)} for i in range(10)}, "result_detail": {i: {"单": None, "双": None, "大": None, "小": None} for i in range(10)}, "winner": {}, "GD1": {"冠亚大": None, "冠亚小": None}, "GD2": {"冠亚单": None, "冠亚双": None}, "GLH_result": {} } if next_period_time.strftime('%H:%M:%S') in EMPTY_TIME_WINDOWS: return entry predictor = LotteryPredictorV14Profit() next_period_time = pd.to_datetime(next_period_time) recent_x = df[df['time'] < next_period_time].tail(10000) predictor.check_init_daily_pnl_tracker(next_period_time) predictions = predictor.predict(next_period_time, recent_x) for pos, nums_bet in predictions.items(): if not nums_bet: continue entry['result'][pos] = nums_bet last_result = df[df['time'] == next_period_time] if last_result.size != 0: predictor.update_result(last_result, entry) return entry if __name__ == "__main__": data_dirs = ["./history_data", "./current_data"] all_records = get_history_records(data_dirs) parser = argparse.ArgumentParser(description="下一期时间 next_period_time, 例: 2026-01-02 06:00:00") # 必选位置参数(直接传入值,无需前缀) parser.add_argument("--next_period_time", type=str, help="下一期时间, 例: 2026-01-02 06:00:00", default="2026-01-02 06:00:00") args = parser.parse_args() fmt = "%Y-%m-%d %H:%M:%S" next_period_time = datetime.strptime(args.next_period_time, fmt) df = pd.DataFrame(all_records).drop_duplicates(subset=['id']).sort_values('time') df['time'] = pd.to_datetime(df['time']) result = main(next_period_time, df) print(json.dumps(result, ensure_ascii=False))