Beispiel #1
0
	def get_i24_combined(self):
		#return list containing combined result for i24
		i24 = []
		for each in self.result_combined:
			new =  num_cat_sort_module.get_i24(each)
			i24.append(new)
		return i24
def get_winning_data(begin_date, end_date):
    ## ========== GET DATA FROM WEBSITE ========== ##
    date_begin = begin_date
    date_end = end_date
    print "Parsing data from " + date_begin + " to " + date_end
    raw_data = get_data(date_begin, date_end)


    ## ========== CONVERT RAW DATA INTO USABLE FORM  ==========##
    combined_data = combine(raw_data)
            #combine separated data for one number into one element

    i24 = num_cat_sort_module.get_i24(combined_data)
    i12 = num_cat_sort_module.get_i12(combined_data)
    i6 = num_cat_sort_module.get_i6(combined_data)
    i4 = num_cat_sort_module.get_i4(combined_data)
            #separate combined_data into respective num_cat

    i24_num = []
    for each in i24:
        i24_num.append(each[0])
    i12_num = []
    for each in i12:
        i12_num.append(each[0])
    i6_num = []
    for each in i6:
        i6_num.append(each[0])
    i4_num = []
    for each in i4:
        i4_num.append(each[0])
            # we extract 4D number from each num_cat
    
    i24_winnings = analyze_num_bought(i24_num[20:30])
    i12_winnings = analyze_num_bought(i12_num[:10])
    i6_winnings = analyze_num_bought(i6_num[:10])
    i4_winnings = analyze_num_bought(i4_num[:10])
            #put each num_cat into calculator to get
            #[total_winning, draw_count, sorted_num_hit]

    return [i24_winnings,i12_winnings,i6_winnings,i4_winnings]
Beispiel #3
0
              result_19m_raw,result_18m_raw,result_17m_raw,result_16m_raw,result_15m_raw,
              result_14m_raw,result_13m_raw,result_12m_raw,result_11m_raw,result_10m_raw,
              result_9m_raw,result_8m_raw,result_7m_raw,result_6m_raw,result_5m_raw,
              result_4m_raw,result_3m_raw,result_2m_raw,result_1m_raw]


## ===== Number Analysis ===== ##
result_combined = []
for each in result_raw:
    new = combine(each)
    result_combined.append(new)

     ## each num cat gets its own list
i24 = []
for each in result_combined:
    new =  num_cat_sort_module.get_i24(each)
    i24.append(new)
i12 = []
for each in result_combined:
    new = num_cat_sort_module.get_i12(each)
    i12.append(new)
i6 = []
for each in result_combined:
    new =  num_cat_sort_module.get_i6(each)
    i6.append(new)
i4 = []
for each in result_combined:
    new = num_cat_sort_module.get_i4(each)
    i12.append(new)

def analyze_num_bought(num_bought):

        
    ## ========== WEB PARSING STAGE ========== ##
    start = "2015/08/01"
    end = "2015/08/31"
    print "Getting winnings data: " + start + " - " + end

    raw_result = get_data(start, end)

    combined_result = combine(raw_result)

    i24 = num_cat_sort_module.get_i24(combined_result)
    i12 = num_cat_sort_module.get_i12(combined_result)
    i6 = num_cat_sort_module.get_i6(combined_result)
    i4 = num_cat_sort_module.get_i4(combined_result)



    ## ========== CALCULATE THE NUM OF DRAW WITHIN STIPULATED RANGE ==========#

    draw_count = 0
    for each_draw in combined_result:
        draw_count += each_draw[3]

    ## ========== GET WINNING FOR EACH NUM ========== ##

    i24_num_winning = {}
    for each_draw in i24:
        num = each_draw[0]
        amount = prize_calc.i24_prize_calc(each_draw)

        if num in i24_num_winning:
            i24_num_winning[num] += amount
        else:
            i24_num_winning[num] = amount

    i12_num_winning = {}
    for each_draw in i12:
        num = each_draw[0]
        amount = prize_calc.i12_prize_calc(each_draw)

        if num in i12_num_winning:
            i12_num_winning[num] += amount
        else:
            i12_num_winning[num] = amount
    
    i6_num_winning = {}
    for each_draw in i6:
        num = each_draw[0]
        amount = prize_calc.i6_prize_calc(each_draw)

        if num in i6_num_winning:
            i6_num_winning[num] += amount
        else:
            i6_num_winning[num] = amount

    i4_num_winning = {}
    for each_draw in i4:
        num = each_draw[0]
        amount = prize_calc.i4_prize_calc(each_draw)

        if num in i4_num_winning:
            i4_num_winning[num] += amount
        else:
            i4_num_winning[num] = amount

    ## ========== CHECK NUM-WINNING DICT AGAINST GIVEN NUM LIST ========== ##

    num_hit = []    #list of num that hit
    total_winning = 0        # store total winning
    all_num_cat_winning = {24:i24_num_winning,12:i12_num_winning,6:i6_num_winning,4:i4_num_winning}
            #dict mapping each num_cat to its winning
    
    for each_num in num_bought:
        each_num_perm = gen_perm(each_num)    # generate all possible permutations for num bought
        num_cat = check_num_cat(each_num)    
        num_winning = all_num_cat_winning[num_cat]
        for each_perm in each_num_perm:
            str_each_num = str(each_perm)
            if str_each_num in num_winning:
                total_winning += num_winning[str_each_num]
                new = [str_each_num, num_winning[str_each_num]]
                num_hit.append(new)

    sorted_num_hit = sorted(num_hit, key=getKey, reverse=True)

    return_lst = [total_winning, draw_count, sorted_num_hit]

    return return_lst