|
|
@ -58,7 +58,10 @@ def get_last_red_delta(_last_red): |
|
|
|
|
|
|
|
|
|
|
|
def get_index_from_db(_index_type): |
|
|
|
def get_index_from_db(_index_type): |
|
|
|
index_list = db_index_get_index_group(_index_type) |
|
|
|
index_list = db_index_get_index_group(_index_type) |
|
|
|
return random.choice(index_list) |
|
|
|
if len(index_list) > 0: |
|
|
|
|
|
|
|
return random.choice(index_list) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
return get_random_index_group() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_random_index_group(): |
|
|
|
def get_random_index_group(): |
|
|
@ -72,10 +75,10 @@ def get_random_index_group(): |
|
|
|
|
|
|
|
|
|
|
|
def get_random_index(_mode='history', _index_type='history'): |
|
|
|
def get_random_index(_mode='history', _index_type='history'): |
|
|
|
# 产生随机数 |
|
|
|
# 产生随机数 |
|
|
|
if _mode == 'random': |
|
|
|
if _mode == 'history': |
|
|
|
random_high, random_middle, random_low = get_random_index_group() |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
random_high, random_middle, random_low = get_index_from_db(_index_type) |
|
|
|
random_high, random_middle, random_low = get_index_from_db(_index_type) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
random_high, random_middle, random_low = get_random_index_group() |
|
|
|
print('分布区间(高概率区,中概率区,低概率区):', random_high, random_middle, random_low) |
|
|
|
print('分布区间(高概率区,中概率区,低概率区):', random_high, random_middle, random_low) |
|
|
|
red_index_group = [int(random_high), int(random_middle), int(random_low)] |
|
|
|
red_index_group = [int(random_high), int(random_middle), int(random_low)] |
|
|
|
high_red_index_list = [(n[0] - 1) for n in new_num(1, 11, random_high)[0:random_high]] |
|
|
|
high_red_index_list = [(n[0] - 1) for n in new_num(1, 11, random_high)[0:random_high]] |
|
|
@ -86,7 +89,7 @@ def get_random_index(_mode='history', _index_type='history'): |
|
|
|
print(low_red_index_list) |
|
|
|
print(low_red_index_list) |
|
|
|
red_index_list = sorted(high_red_index_list + middle_red_index_list + low_red_index_list) |
|
|
|
red_index_list = sorted(high_red_index_list + middle_red_index_list + low_red_index_list) |
|
|
|
red_index_list = [int(n) for n in red_index_list] |
|
|
|
red_index_list = [int(n) for n in red_index_list] |
|
|
|
print(f"排序后结果") |
|
|
|
print(f"排序后索引") |
|
|
|
print(red_index_list) |
|
|
|
print(red_index_list) |
|
|
|
return red_index_group, red_index_list |
|
|
|
return red_index_group, red_index_list |
|
|
|
|
|
|
|
|
|
|
@ -104,8 +107,6 @@ def get_forecast_red(_red_data, _index_type): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def insert_red_data(_all_data, _history, _history_random, _last, _last_random): |
|
|
|
def insert_red_data(_all_data, _history, _history_random, _last, _last_random): |
|
|
|
print(_history_random) |
|
|
|
|
|
|
|
print(_last_random) |
|
|
|
|
|
|
|
_insert_data = dict() |
|
|
|
_insert_data = dict() |
|
|
|
_insert_data['dateId'] = _all_data[-1]['dateId'] |
|
|
|
_insert_data['dateId'] = _all_data[-1]['dateId'] |
|
|
|
_insert_data['history'] = json.dumps(_history) |
|
|
|
_insert_data['history'] = json.dumps(_history) |
|
|
@ -116,15 +117,17 @@ def insert_red_data(_all_data, _history, _history_random, _last, _last_random): |
|
|
|
_insert_data['last_random'] = json.dumps(_last_random['forecast']) |
|
|
|
_insert_data['last_random'] = json.dumps(_last_random['forecast']) |
|
|
|
_insert_data['last_random_index'] = json.dumps(_last_random['index']) |
|
|
|
_insert_data['last_random_index'] = json.dumps(_last_random['index']) |
|
|
|
_insert_data['last_random_index_group'] = json.dumps(_last_random['group']) |
|
|
|
_insert_data['last_random_index_group'] = json.dumps(_last_random['group']) |
|
|
|
print(_insert_data) |
|
|
|
|
|
|
|
result = db_red_insert(_insert_data) |
|
|
|
result = db_red_insert(_insert_data) |
|
|
|
|
|
|
|
print('预测红球数据:') |
|
|
|
|
|
|
|
print(_insert_data['history_random']) |
|
|
|
|
|
|
|
print(_insert_data['last_random']) |
|
|
|
if result > 0: |
|
|
|
if result > 0: |
|
|
|
print(f"输入数据成功,插入{result}条数据") |
|
|
|
print(f"输入数据成功,插入{result}条数据") |
|
|
|
else: |
|
|
|
else: |
|
|
|
print("数据插入失败") |
|
|
|
print("数据插入失败") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
def red_forecast(): |
|
|
|
all_data = get_all_data() |
|
|
|
all_data = get_all_data() |
|
|
|
history_red_delta = get_all_red_delta(all_data) |
|
|
|
history_red_delta = get_all_red_delta(all_data) |
|
|
|
# print(all_red_delta) |
|
|
|
# print(all_red_delta) |
|
|
@ -135,3 +138,16 @@ if __name__ == "__main__": |
|
|
|
forecast_red_last_data = get_forecast_red(last_red_delta, 'last') |
|
|
|
forecast_red_last_data = get_forecast_red(last_red_delta, 'last') |
|
|
|
insert_red_data(all_data, history_red_delta, forecast_red_history_data, last_red_delta, forecast_red_last_data) |
|
|
|
insert_red_data(all_data, history_red_delta, forecast_red_history_data, last_red_delta, forecast_red_last_data) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
|
|
|
|
# all_data = get_all_data() |
|
|
|
|
|
|
|
# history_red_delta = get_all_red_delta(all_data) |
|
|
|
|
|
|
|
# # print(all_red_delta) |
|
|
|
|
|
|
|
# last_red_delta = get_last_red_delta(get_all_red_in_last(all_data)) |
|
|
|
|
|
|
|
# # print(last_red_delta) |
|
|
|
|
|
|
|
# print_data([history_red_delta, last_red_delta]) |
|
|
|
|
|
|
|
# forecast_red_history_data = get_forecast_red(history_red_delta, 'history') |
|
|
|
|
|
|
|
# forecast_red_last_data = get_forecast_red(last_red_delta, 'last') |
|
|
|
|
|
|
|
# insert_red_data(all_data, history_red_delta, forecast_red_history_data, last_red_delta, forecast_red_last_data) |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|