You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.4 KiB
71 lines
2.4 KiB
from blue_forecast import dict_sort, dict_rate |
|
import pymysql |
|
import json |
|
from functools import reduce |
|
from pymysql.cursors import DictCursor |
|
|
|
db = { |
|
'host': 'home.rogersun.cn', |
|
'user': 'root', |
|
'password': 'Sxzgx1209', |
|
'database': 'lottery' |
|
} |
|
|
|
d1 = {"06": 18, "08": 16, "10": 15, "16": 15, "04": 13, "15": 13, "01": 13, "11": 12, "09": 11, "13": 10, "14": 10, |
|
"05": 10, "12": 10, "03": 8, "07": 7, "02": 6} |
|
d2 = {"09": 45, "01": 44, "07": 43, "14": 43, "15": 42, "12": 42, "02": 38, "04": 37, "10": 37, "11": 35, "05": 31, |
|
"16": 31, "03": 29, "08": 28, "06": 28, "13": 24} |
|
d3 = {"01": 93, "09": 80, "10": 75, "15": 72, "16": 71, "03": 70, "08": 65, "11": 64, "06": 63, "02": 62, "04": 62, |
|
"14": 61, "12": 61, "05": 61, "07": 55, "13": 55} |
|
d4 = {"15": 126, "01": 121, "05": 116, "14": 112, "16": 112, "09": 111, "06": 108, "11": 107, "08": 106, "07": 106, |
|
"10": 106, "04": 103, "13": 97, "02": 96, "12": 96, "03": 83} |
|
d5 = {"15": 185, "16": 165, "11": 165, "06": 164, "05": 160, "14": 153, "08": 152, "12": 152, "07": 149, "09": 148, |
|
"10": 147, "02": 145, "01": 144, "13": 142, "04": 141, "03": 131} |
|
|
|
data_list = [d1, d2, d3, d4, d5] |
|
|
|
|
|
def get_history_date_id(): |
|
conn = pymysql.Connect(**db) |
|
cursor = conn.cursor(DictCursor) |
|
cursor.execute("SELECT dateId FROM lottery.blue_forecast GROUP BY dateId ") |
|
result = cursor.fetchall() |
|
date_id_list = [] |
|
for d in result: |
|
date_id_list.append(d['dateId']) |
|
return sorted(date_id_list, reverse=True)[0:5] |
|
|
|
|
|
def get_forecast_blue(_date_id_list): |
|
conn = pymysql.Connect(**db) |
|
cursor = conn.cursor(DictCursor) |
|
n = 1 |
|
_blue_list = [] |
|
for _id in _date_id_list: |
|
cursor.execute("SELECT blue FROM lottery.blue_forecast WHERE dateId = %s AND params = %s", (_id, n)) |
|
r = cursor.fetchone() |
|
_blue = json.loads(r['blue']) |
|
_blue_list.append(_blue) |
|
n += 1 |
|
return _blue_list |
|
|
|
|
|
def new_blue_forecast(_blue_list): |
|
result = {} |
|
|
|
for d in _blue_list: |
|
for k, v in d.items(): |
|
if k in result.keys(): |
|
result[k] += v |
|
else: |
|
result[k] = v |
|
|
|
print("新算法") |
|
for k, v in dict_rate(dict_sort(result, 'val', True)).items(): |
|
print(f"{k} - {v}") |
|
|
|
|
|
if __name__ == "__main__": |
|
date_id_list = get_history_date_id() |
|
blue_list = get_forecast_blue(date_id_list) |
|
new_blue_forecast(blue_list)
|
|
|