Ejemplo n.º 1
0
def getAllData(start, rows):
    _list = model.select('trade', limit=str(start) + ',' + str(rows))
    step = 10
    tmpList = []
    for row in _list:
        if row[0] % step == 1:
            amount = 0
            start_time = row[2]
            buy = 0
            start_price = row[4]

        amount += row[1]
        buy += row[3]
        if (row[0] % step) == 0:
            #成交量,时间,买入占比,价格涨跌,价变速度
            tmpList.append([
                amount, (row[2] - start_time) * 1.0 / 1000, buy * 1.0 / step,
                (row[4] - start_price) * 1.0 / start_price,
                (row[4] - start_price) * 1.0 / max(1, (row[2] - start_time)) *
                1000
            ])
    y_data = []
    x_data = []
    for key, row in enumerate(tmpList):
        if (key + 2) > len(tmpList):
            break
        x_data.append(row)
        if tmpList[key + 1][3] > 0:
            y_data.append([1, 0])
        else:
            y_data.append([0, 1])
    x_data = np.array(x_data)
    y_data = np.array(y_data)
    return x_data, y_data
Ejemplo n.º 2
0
def get_object_or_404(model, *criterion):
    output = model.select().where(*criterion).get()
    if output is None:
        abort(404)
    else:
        return output
Ejemplo n.º 3
0
batch_size = 256

start_epochs = 0
epochs = 35
batch_epochs = 5

word_index, entity_indices, word_ebd, entity_ebd = tools.load_matrices()
save_path = './model/origin_rl_model.ckpt'
save_path2 = './model/origin_rl_entity_model.ckpt'

test_dataset_2013 = './data/2013_prepare_filled.txt'
test_X1, test_Y1 = tools.test_data_extraction(test_dataset_2013,
                                              training=False)
model.select(save_path,
             save_path2,
             word_ebd,
             entity_ebd,
             test_X1,
             training_able=False)

context = np.load('data/test_word_context.npy')
test_entity_list = np.load('data/test_entity_list.npy')
entity_description = np.load('data/test_entity_description.npy')

left_context, right_context = model.data_divided(context, context_length)
test_X1 = [left_context, right_context, test_entity_list, entity_description]
'''
test_dataset_2014 = './data/2014_prepare_filled.txt'
test_X2, test_Y2 = test_data_extraction(test_dataset_2014, training=False)
'''
seg_2013 = tools.load_test2013()
seg_2014 = tools.load_test2014()
Ejemplo n.º 4
0
 def test_select(self):
     i = [-3, -2, -1, 0, 1, 2, 3]
     o = [1, 2, 3]
     self.assertListEqual(me.select(lambda x: x > 0, i), o)
Ejemplo n.º 5
0
def main_menu():
    while True:
        view.show_main_menu()
        option = input()
        if re.match(r'^[1-5]{1}$', option):
            while True:
                view.tables_names()
                chosen_table = input()
                if re.match(r'^[1-6]{1}$', chosen_table):
                    table = view.tables[chosen_table]
                    if option == '1':
                        table = tables[chosen_table]
                        table_columns = columns[table]
                        notes = model.select(table, table_columns[0])
                        view.print_table(chosen_table, notes)
                    elif option == '2':
                        res = insert_into_table(chosen_table)
                        if not res:
                            print("Data wasn't inserted")
                        else:
                            print("Successfully inserted")
                    elif option == '3':
                        res = update_table(chosen_table)
                        if not res:
                            print("Data wasn't updated")
                        else:
                            print("Operation successfull")
                    elif option == '4':
                        res = delete_from_table(chosen_table)
                        if not res:
                            print("Data wasn't deleted")
                        else:
                            print("Operation successfull")
                    elif option == '5':
                        text = input("Input text to search: ")
                        view.fts_mode()
                        mode = input()
                        if re.match(r'^[1,2]{1}$', mode):
                            notes = fts_table(text, mode, chosen_table)
                            view.print_table(chosen_table, notes)
                        elif back_to_menu == '1':
                            break
                        else:
                            print("No such option. Check your input")
                elif chosen_table == '0':
                    break
                else:
                    print("No such option. Check your input")
                view.back_to_menu()
                back_to_menu = input()
                if back_to_menu == '0':
                    continue
                elif back_to_menu == '1':
                    break
                else:
                    print("No such option. Check your input")
        elif option == '6':
            view.print_table('3', game_price_range())
        elif option == '7':
            dev = input("Input authors names separated with comma: ")
            dev = dev.split(', ')
            for dev_list in game_of_developers(dev):
                view.print_table('3', dev_list)

        elif option == '8':
            num_of_rand = input("Number of random players\n")
            res = model.random_author(num_of_rand)
            if not res:
                print("Data wasn't updated")
            else:
                print("Successfully updated")
        elif option == '9':
            os.system("cls")
        elif option == '0':
            exit()
        else:
            print("No such option. Check your input")