Kernel: Python 3 (Anaconda)
In [1]:
import veky_runner import utility import copy from sklearn import preprocessing # get file list with xsls extension root = "/projects/3572606d-aafc-4285-a345-c223c56d1457/ML/Main/Dionice/" extension = ".xlsx" file_list = utility.get_file_list_from_root_dir(root, extension) # print(file_list) # collect data from files sheet_name = 'Povijesni podaci' data = utility.collect_data_from_file_list(file_list, sheet_name) data_c = copy.deepcopy(data) # parse data and use only specific data for stock_name in data_c: for time_stamp in data_c[stock_name]: if data_c[stock_name][time_stamp][u'Vrsta prometa'] != 'N' or time_stamp.year <= 2010: del data[stock_name][time_stamp] del data_c # print(data) # get file list with index information # root = "/projects/d2e32407-baf4-4631-8512-ce12e859eb9c/Priprema DataSeta" # index_file_list = utility.get_file_list_from_root_dir(root, extension) # print(index_file_list) # collect stock index data # sheet_name = "Sheet1" # stock_num = utility.collect_data_from_file_list(index_file_list, sheet_name)["dionice"] # print(stock_num) # define stock_names and (stock_name, time_stamp) from data, mapping stock_names with time_stamp stock_names = data.keys() stock_name_time_stamps = [(stock_name, sorted(list(data[stock_name].keys()))) for stock_name in stock_names] # print(stock_name_time_stamps) # define vectors of date, high, low, close and volume prices for each stock_index_num high_prices_vecs = utility.extract_vectors_of_specific_data(data, stock_name_time_stamps, u"Najviša") # print(high_prices_vecs) low_prices_vecs = utility.extract_vectors_of_specific_data(data, stock_name_time_stamps, u"Najniža") # print(low_prices_vecs) close_prices_vecs = utility.extract_vectors_of_specific_data(data, stock_name_time_stamps, u"Zadnja") # print(close_prices_vecs) volume_prices_vecs = utility.extract_vectors_of_specific_data(data, stock_name_time_stamps, u"Broj transakcija") # print(volume_prices_vecs) # define features default_period = 14 # rsi_vecs rsi_vecs = utility.relative_strength_index(close_prices_vecs, default_period) # plot rsi_vecs # [utility.plot_data(date_vec[1][default_period:], rsi_vec, stock_name,"date" "rsi") # for date_vec, rsi_vec, stock_name in zip(stock_name_time_stamps, rsi_vecs, stock_names)] # typical_prices_vecs typical_prices_vecs = utility.typical_prices_vecs(high_prices_vecs, low_prices_vecs, close_prices_vecs) # mfi_vecs mfi_vecs = utility.money_flow_index(typical_prices_vecs, volume_prices_vecs, default_period) # plot mfi_vecs # [utility.plot_data(date_vec[1][default_period:], mfi_vec, stock_name, "date", "mfi") # for date_vec, mfi_vec, stock_name in zip(stock_name_time_stamps, mfi_vecs, stock_names)] # ema_vecs ema_vecs = utility.exponential_moving_average(close_prices_vecs, default_period) # plot ema_vecs # [utility.plot_data(date_vec[1][default_period:], ema_vec, stock_name, "date", "ema") # for date_vec, ema_vec, stock_name in zip(stock_name_time_stamps, ema_vecs, stock_names)] # so_vecs so_vecs = utility.stochastic_oscillator(high_prices_vecs, low_prices_vecs, close_prices_vecs, default_period) # plot so_vecs # [utility.plot_data(date_vec[1][default_period:], so_vec, stock_name, "date", "so") # for date_vec, so_vec, stock_name in zip(stock_name_time_stamps, so_vecs, stock_names)] # macd_vecs macd_vecs = utility.moving_average_convergence_divergence(close_prices_vecs, slow_period=26, fast_period=12) # [utility.plot_data(date_vec[1][len(date_vec[1]) - len(macd_vec):], macd_vec, stock_name, "date", "macd") # for date_vec, macd_vec, stock_name in zip(stock_name_time_stamps, macd_vecs, stock_names)] # sl_vecs sl_vecs = utility.signal_line(macd_vecs, 9) # [utility.plot_data(date_vec[1][len(date_vec[1]) - len(sl_vec):], sl_vec, stock_name, "date", "sl") # for date_vec, sl_vec, stock_name in zip(stock_name_time_stamps, sl_vecs, stock_names)] del data, sheet_name, file_list scaler = preprocessing.StandardScaler()
In [0]:
# veky_runner.runner("KNR", close_prices_vecs, stock_name_time_stamps, rsi_vecs, mfi_vecs, ema_vecs, so_vecs, macd_vecs, sl_vecs, scaler)
In [0]:
# veky_runner.runner("DTR", close_prices_vecs, stock_name_time_stamps, rsi_vecs, mfi_vecs, ema_vecs, so_vecs, macd_vecs, sl_vecs, scaler)
In [2]:
veky_runner.runner("KRR", close_prices_vecs, stock_name_time_stamps, rsi_vecs, mfi_vecs, ema_vecs, so_vecs, macd_vecs, sl_vecs, scaler)
Out[2]:
Analysis for: zse_export_DLKV-R-A
In [0]:
veky_runner.runner("SVR", close_prices_vecs, stock_name_time_stamps, rsi_vecs, mfi_vecs, ema_vecs, so_vecs, macd_vecs, sl_vecs, scaler)
In [0]: