Пример #1
0
def iter_history(code, handler, count=30, period=30):
    """判断是否中奖
    code: 彩票类别
    handler: 处理函数
    count: 每个待处理数据的数量
    period: 处理多长时间的数据
    e.g.:
        historys = [[1,2],[1,3],[2,3],[2,4],[3,5],[4,5]]
        count = 3, period = 2
        1st:
            latest = [1,2]
            past = [[1,3],[2,3],[2,4]]
        2nd:
            latest = [1,3]
            past = [[2,3],[2,4],[3,5]]
        3rd:
            latest = [2,3]
            past = [[2,4],[3,5],[4,5]]
    """
    history = get_history(code, count + period)
    assert (len(history) == (count + period))
    out = list()
    idx = 0
    while idx < period:
        latest = history[idx]
        past = history[idx + 1:idx + 1 + count]
        idx += 1
        ret = handler(code, latest, past)
        if ret:
            out.append(ret)
    return out
Пример #2
0
def iter_history(code, handler, count=30, period=30):
    history = get_history(code, count+period)
    assert(len(history) == (count+period))
    out = list()
    idx = 0
    while idx < period:
        latest = history[idx]
        past = history[idx+1:idx+1+count]
        idx += 1
        ret = handler(code, latest, past)
        if ret:
            out.append(ret)
    return out
Пример #3
0
def rand_select(code, count=30):
    # get history
    historys = get_history(code, count)
    one = _rand_select(code, historys)
    print("{0}\r\n  {1}\r\n  {2:.2f}%\r\n".format(code, one[0], one[1]*100))
Пример #4
0
        1st:
            latest = [1,2]
            past = [[1,3],[2,3],[2,4]]
        2nd:
            latest = [1,3]
            past = [[2,3],[2,4],[3,5]]
        3rd:
            latest = [2,3]
            past = [[2,4],[3,5],[4,5]]
    """
    history = get_history(code, count + period)
    assert (len(history) == (count + period))
    out = list()
    idx = 0
    while idx < period:
        latest = history[idx]
        past = history[idx + 1:idx + 1 + count]
        idx += 1
        ret = handler(code, latest, past)
        if ret:
            out.append(ret)
    return out


if __name__ == "__main__":
    from ticket import get_history

    data = get_history('3D', count=10)
    exp = expected_value(data)
    print(exp)
Пример #5
0
        datas2.append(data)

    app = dash.Dash()
    app.layout = html.Div(children=[
        html.H1(children='大乐透分析'),
        html.Div(children='数学期望值趋势'),
        dcc.Graph(id='red-exp-val-graph',
                  figure={
                      'data': datas1,
                      'layout': {
                          'title': '红球趋势'
                      }
                  }),
        dcc.Graph(id='blue-exp-val-graph',
                  figure={
                      'data': datas2,
                      'layout': {
                          'title': '蓝球趋势'
                      }
                  }),
    ])

    app.run_server(debug=True)


if __name__ == '__main__':
    historys = get_history(CODE, COUNT)
    #gen_xls(historys)
    gen_html(historys)
Пример #6
0
绘制期望值
"""
import dash
import dash_html_components as html
import dash_core_components as dcc

from lottery import get_history, expected_value

codes = ['双色球', '七乐彩', '3D', '大乐透', '排列三', '排列五', '七星彩']
count = 20

datas = []
for c in codes:
    print('Get %s data...' % c)
    try:
        his = get_history(c, count)
    except AttributeError:
        print('Fail to get history')
        continue
    exp = expected_value(his)

    data = {'type': 'line', 'name': c}
    data['x'] = [d for (d, e) in exp]
    data['y'] = [e for (d, e) in exp]

    datas.append(data)

app = dash.Dash()
app.layout = html.Div(children=[
    html.H1(children='期望值对比'),
    html.Div(children='''