Пример #1
0
 def show_big_dia(self, step):
     if self.wtf1.cnt + step > len(
             self.tester.date_list) - 1 or self.wtf1.cnt + step < 0:
         return
     self.wtf1.add_x(step)
     day = self.tester.date_list[self.wtf1.cnt]
     dayk = dayk_handler()
     dayk.init_db()
     dayk.import_dayk_from_DB(day)
     self.all_plot.clear()
     self.all_plot.plot(dayk.day_1ktable.iloc[19:, COL_END])
     self.all_plot.plot(dayk.day_1ktable.iloc[19:, COL_MA5])
     self.all_plot.plot(dayk.day_1ktable.iloc[19:, COL_MA10])
     self.all_plot.plot(dayk.day_1ktable.iloc[19:, COL_MA20])
     for i in range(19, dayk.length - dayk.inspect_bars):
         if dayk.day_1ktable.iloc[i, COL_RET] == self.tester.distance_t:
             self.all_plot.annotate(
                 "BUY",
                 xy=(i + dayk.inspect_bars,
                     dayk.day_1ktable.iloc[i + dayk.inspect_bars, COL_END]),
                 xytext=(
                     i + dayk.inspect_bars,
                     dayk.day_1ktable.iloc[i + dayk.inspect_bars, COL_END] +
                     50),
                 arrowprops=dict(arrowstyle="->",
                                 connectionstyle="arc3,rad=.2"))
     self.canvs.draw()
Пример #2
0
 def plot_unit_quo(self, day, num):
     dayk = dayk_handler(day)
     dayk.prepare_dayk()
     self.plot_small_quo.clear()
     self.plot_small_quo.plot(dayk.day_1ktable.iloc[num + 2:num + 7 + 10, COL_END ])
     self.plot_small_quo.plot(dayk.day_1ktable.iloc[num + 2:num + 7 + 10, COL_MA5 ])
     self.plot_small_quo.plot(dayk.day_1ktable.iloc[num + 2:num + 7 + 10, COL_MA10])
     self.plot_small_quo.plot(dayk.day_1ktable.iloc[num + 2:num + 7 + 10, COL_MA20])
     self.plot_small_quo.annotate(
         "BUY " + str(self.ui_ret[self.wtf2.cnt][2]),
         xy=(self.ui_ret[self.wtf2.cnt][1] + dayk.inspect_bars,
             dayk.day_1ktable.iloc[self.ui_ret[self.wtf2.cnt][1] + dayk.inspect_bars, COL_END]),
         xytext=(self.ui_ret[self.wtf2.cnt][1] + dayk.inspect_bars,
                 dayk.day_1ktable.iloc[self.ui_ret[self.wtf2.cnt][1] + dayk.inspect_bars, COL_END] + 5),
         arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.1")
     )
     self.canvs.draw()
     return
Пример #3
0
 def __show_unit_plot(self, day, num):
     dayk = dayk_handler()
     dayk.init_db()
     dayk.import_dayk_from_DB(day)
     comp = inter_comparer(dayk, dayk)
     comp.init_compare_data()
     comp.move_data(num)
     comp.sudo_move(1)
     self.f_plot.clear()
     self.f_plot.plot(comp.close_list_show)
     self.f_plot.plot(comp.ma5_list_show)
     self.f_plot.plot(comp.ma10_list_show)
     self.f_plot.plot(comp.ma20_list_show)
     self.f_plot.annotate("BUY",
                          xy=(num + dayk.inspect_bars - 1, 10),
                          xytext=(num + dayk.inspect_bars - 1, 10 + 50),
                          arrowprops=dict(arrowstyle="->",
                                          connectionstyle="arc3,rad=.2"))
     self.f_plot.set_ylim(0, 100)
     self.canvs.draw()
Пример #4
0
    def plot_day_quo(self, day):
        dayk = dayk_handler(day)
        dayk.prepare_dayk()
        self.plot_big_quo.clear()
        self.plot_big_quo.plot(dayk.day_1ktable.iloc[19:, COL_END])
        self.plot_big_quo.plot(dayk.day_1ktable.iloc[19:, COL_MA5])
        self.plot_big_quo.plot(dayk.day_1ktable.iloc[19:, COL_MA10])
        self.plot_big_quo.plot(dayk.day_1ktable.iloc[19:, COL_MA20])

        for i in range(0, len(self.ui_ret)):
            if day == self.ui_ret[i][0]:
                self.plot_big_quo.annotate(
                    "BUY " +  str(self.ui_ret[i][2]),
                    xy=(self.ui_ret[i][1] + dayk.inspect_bars,
                        dayk.day_1ktable.iloc[self.ui_ret[i][1] + dayk.inspect_bars, COL_END]),
                    xytext=(self.ui_ret[i][1] + dayk.inspect_bars,
                            dayk.day_1ktable.iloc[self.ui_ret[i][1] + dayk.inspect_bars, COL_END] + 50),
                    arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.1")
                )
        self.canvs.draw()
        return
Пример #5
0
    def auto_test_sample(self):
        test_ret = []
        samp_h = sample_handler()
        samp_h.prepare_samples()

        for date in self.date_list:
            dayk = dayk_handler(date)
            dayk.prepare_dayk()
            dayk.reset_ret()
            sp_comp = sample_dayk_comparer(dayk, samp_h)
            sp_comp.init_compare_data()
            sp_comp.get_sample(2)

            for i in range(0, samp_h.length):
                for j in range(19, dayk.length - sp_comp.inspect_bars):
                    if sp_comp.distance < self.distance_t:
                        sp_comp.set_ret(self.distance_t)
                        print("set: ", date, " num:", sp_comp.point)
                        test_ret.append(
                            [date, sp_comp.point, sp_comp.distance, 0, 0])
                    sp_comp.get_data(1)
                #sp_comp.get_sample(1)
        self.test_ret = test_ret
Пример #6
0
from strategies.ml.data_handler.dayk_handler import *

if __name__ == "__main__":
    date = "20171121"
    dayk_h = dayk_handler()
    dayk_h.init_db()
    dayk_h.import_dayk2db(date)
Пример #7
0
 def __init_dayk_data(self):
     self.dayk_handler = dayk_handler(self.date)
     self.dayk_handler.prepare_dayk()
     self.dayk_handler.reset_ret()