예제 #1
0
    def __init__(self, app):

        self.mainwindow = MyParentFrame()
        self.mainwindow.Bind(wx.EVT_MENU, self.On5MinAnalysis, id=ID_Menu_5Min)
        self.mainwindow.Bind(wx.EVT_MENU,
                             self.On30MinAnalysis,
                             id=ID_Menu_30Min)
        self.mainwindow.Bind(wx.EVT_MENU, self.OnDayAnalysis, id=ID_Menu_Day)
        self.mainwindow.Bind(wx.EVT_MENU,
                             self.OnNewRealtimeWindow,
                             id=ID_Menu_Realtime)

        self.mainwindow.Show(True)
        app.SetTopWindow(self.mainwindow)

        self.mainwindow.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        self.mainwindow.symbol_ctrl.Bind(wx.EVT_TEXT_ENTER,
                                         self.OnSymbolCtrlEnter)

        self.data_manager = DataManager()
        self.data_manager.start()
        self.symbol = '000001'
        self.data_manager.UpdateSymbol(self.symbol)
        #self.realtime_data = self.data_manager.GetQuoteData(self.symbol, 60, 1).df
        #self.analysis_data = self.data_manager.GetQuoteData(self.symbol, 1800, 30).df
        self._lastclose = self.data_manager.GetLastClose(self.symbol)
        self.realtime_data = None
        self.analysis_data = None
        #for d in self.data_manager.symbol_quote_dict.keys():
        pub.subscribe(self.AnalysisDataArrive, "ANALYSISDATA")
        pub.subscribe(self.RealtimeDataArrive, "REALTIMEDATA")
        self.mainwindow.SetFocus()
        self.realtime_window = None
        self.analysis_window = None
예제 #2
0
    def __init__(self, *args, **kwds):
        # begin wxGlade: AnalysisPanel.__init__
        kwds["style"] = wx.TAB_TRAVERSAL
        wx.Panel.__init__(self, *args, **kwds)

        self.__set_properties()
        self.__do_layout()
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBack)
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
        self.Buffer = None

        self.__stockList = []
        self.quote = '002094'
        dm = DataManager()
        q = dm.GetQuoteData(self.quote, 300, 5)
        self.df = q.df
        for bar in xrange(len(q.close)):
            a = StockData(self.quote)
            a.open = q.open[bar]
            a.close = q.close[bar]
            a.high = q.high[bar]
            a.low = q.low[bar]
            self.__stockList.append(a)
        self.timer.Start(10000)
예제 #3
0
    def __init__(self, app):

        self.mainwindow = MyParentFrame()
        self.mainwindow.Bind(wx.EVT_MENU, self.On5MinAnalysis, id=ID_Menu_5Min)
        self.mainwindow.Bind(wx.EVT_MENU, self.On30MinAnalysis, id=ID_Menu_30Min)
        self.mainwindow.Bind(wx.EVT_MENU, self.OnDayAnalysis, id=ID_Menu_Day)
        self.mainwindow.Bind(wx.EVT_MENU, self.OnNewRealtimeWindow, id=ID_Menu_Realtime)

        self.mainwindow.Show(True)
        app.SetTopWindow(self.mainwindow)

        self.mainwindow.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        self.mainwindow.symbol_ctrl.Bind(wx.EVT_TEXT_ENTER, self.OnSymbolCtrlEnter)

        self.data_manager = DataManager()
        self.data_manager.start()
        self.symbol = "000001"
        self.data_manager.UpdateSymbol(self.symbol)
        # self.realtime_data = self.data_manager.GetQuoteData(self.symbol, 60, 1).df
        # self.analysis_data = self.data_manager.GetQuoteData(self.symbol, 1800, 30).df
        self._lastclose = self.data_manager.GetLastClose(self.symbol)
        self.realtime_data = None
        self.analysis_data = None
        # for d in self.data_manager.symbol_quote_dict.keys():
        pub.subscribe(self.AnalysisDataArrive, "ANALYSISDATA")
        pub.subscribe(self.RealtimeDataArrive, "REALTIMEDATA")
        self.mainwindow.SetFocus()
        self.realtime_window = None
        self.analysis_window = None
예제 #4
0
    def OnTimer(self, evt):
        dc = wx.ClientDC(self)
        dc = wx.BufferedDC(wx.ClientDC(self))
        dc.Clear()
        q = DataManager().GetQuoteData(self.quote, 300, 10)
        self.df = q.df

        self.Refresh()
예제 #5
0
def LoadData():
    df = DataManager.getDataToDisplay(db_file_path, in_table_name)
    page, per_page, offset = get_page_args(page_parameter='page',
                                           per_page_parameter='per_page')
    pagination_employees = get_employees(df, offset=offset, per_page=per_page)
    total = 512
    pagination = Pagination(page=page,
                            per_page=per_page,
                            total=total,
                            css_framework='bootstrap3')
    return render_template('DataManager.html',
                           data=pagination_employees,
                           page=page,
                           per_page=per_page,
                           pagination=pagination,
                           count=total)
예제 #6
0
class Control:
    def __init__(self, app):

        #main window
        self.mainwindow = MyParentFrame()
        self.mainwindow.Bind(wx.EVT_MENU, self.On5MinAnalysis, id=ID_Menu_5Min)
        self.mainwindow.Bind(wx.EVT_MENU,
                             self.On30MinAnalysis,
                             id=ID_Menu_30Min)
        self.mainwindow.Bind(wx.EVT_MENU, self.OnDayAnalysis, id=ID_Menu_Day)
        self.mainwindow.Bind(wx.EVT_MENU,
                             self.OnNewRealtimeWindow,
                             id=ID_Menu_Realtime)
        self.mainwindow.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        self.mainwindow.symbol_ctrl.Bind(wx.EVT_TEXT_ENTER,
                                         self.OnSymbolCtrlEnter)
        self.mainwindow.Show(True)
        app.SetTopWindow(self.mainwindow)
        self.mainwindow.SetFocus()

        self.symbol = '000001'

        #subwindow initialize
        self._InitComponet()

        #model initialize
        self.data_manager = DataManager()
        self.data_manager.start()
        self.data_manager.UpdateSymbol(self.symbol)
        #self.realtime_data = self.data_manager.GetQuoteData(self.symbol, 60, 1).df
        #self.analysis_data = self.data_manager.GetQuoteData(self.symbol, 1800, 30).df
        #self._lastclose = self.data_manager.GetLastClose(self.symbol)
        self.realtime_data = None
        self.analysis_data = None
        #for d in self.data_manager.symbol_quote_dict.keys():
        pub.subscribe(self.AnalysisDataArrive, "ANALYSISDATA")
        pub.subscribe(self.RealtimeDataArrive, "REALTIMEDATA")
        pub.subscribe(self.Min30DataArrive, "MIN30DATA")
        pub.subscribe(self.DayDataArrive, "DAYDATA")

    def Min30DataArrive(self, message):
        self.min30_window.SetStockData(self.symbol, message.data, "30Min")

    def DayDataArrive(self, message):
        self.day_window.SetStockData(self.symbol, message.data, "Day")

    def _InitComponet(self):
        self.realtime_window = MyChildFrame(self.mainwindow, -1)
        self.realtime_window.SetStockData(self.symbol, None, "1Min")

        self.analysis_window = MyChildFrame(self.mainwindow, -1)
        self.min30_window = MyChildFrame(self.mainwindow, -1)
        self.day_window = MyChildFrame(self.mainwindow, -1)
        self.analysis_window.SetStockData(self.symbol, None, "5Min")
        self.min30_window.SetStockData(self.symbol, None, "30Min")
        self.day_window.SetStockData(self.symbol, None, "Day")

    def OnSymbolCtrlEnter(self, evt):
        sym = self.mainwindow.symbol_ctrl.GetValue()
        if sym in self.data_manager.symbol_dict:
            self.symbol = sym
            self.analysis_window.SetStockData(self.symbol, None, "5Min")
            self.min30_window.SetStockData(self.symbol, None, "30Min")
            self.day_window.SetStockData(self.symbol, None, "Day")
            self.realtime_window.SetStockData(self.symbol, None, "1Min")
            self.data_manager.UpdateSymbol(sym)
            #            self.realtime_window.SetTitle(sym)
            #            self.analysis_window.SetTitle(sym)
            self._lastclose = self.data_manager.GetLastClose(sym)

    def OnKeyDown(self, evt):
        keycode = evt.GetKeyCode()
        print keycode

    def OnAnalysisPaint(self, evt):

        dc = wx.PaintDC(self.analysis_window.main_panel)
        dc.Clear()
        draw_candle(dc, self.analysis_data)
        czsc = ChanlunCore()
        czsc.Draw(dc, self.analysis_data)
        print "refreshing analysis"

    def OnEraseBack(self, evt):
        pass

    def AnalysisDataArrive(self, message):
        #if self.analysis_window.IsShownOnScreen():
        self.analysis_data = message.data
        self.analysis_window.SetStockData(self.symbol, message.data, "5Min")
        #self.analysis_window.Refresh()
        #self.analysis_window.Refresh()
    def On5MinAnalysis(self, evt):

        self.analysis_window.Show(True)
        self.analysis_window.SetFocus()

    def On30MinAnalysis(self, evt):
        self.min30_window.Show(True)
        self.min30_window.SetFocus()

    def OnDayAnalysis(self, evt):
        self.day_window.Show(True)
        self.day_window.SetFocus()

    def OnNewRealtimeWindow(self, evt):
        self.realtime_window.Show(True)
        self.realtime_window.SetFocus()

    def OnRealtimePaint(self, evt):
        dc = wx.PaintDC(self.realtime_window.main_panel)
        #dc.DrawBitmap(self.Buffer, 0, 0)
        dc.Clear()
        draw_realtime(dc, self.realtime_data, self._lastclose)

    def RealtimeDataArrive(self, message):
        self.realtime_data = message.data
        self.realtime_window.SetStockData(self.symbol, message.data, "1Min")
예제 #7
0
class Control:
    def __init__(self, app):

        self.mainwindow = MyParentFrame()
        self.mainwindow.Bind(wx.EVT_MENU, self.On5MinAnalysis, id=ID_Menu_5Min)
        self.mainwindow.Bind(wx.EVT_MENU, self.On30MinAnalysis, id=ID_Menu_30Min)
        self.mainwindow.Bind(wx.EVT_MENU, self.OnDayAnalysis, id=ID_Menu_Day)
        self.mainwindow.Bind(wx.EVT_MENU, self.OnNewRealtimeWindow, id=ID_Menu_Realtime)

        self.mainwindow.Show(True)
        app.SetTopWindow(self.mainwindow)

        self.mainwindow.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        self.mainwindow.symbol_ctrl.Bind(wx.EVT_TEXT_ENTER, self.OnSymbolCtrlEnter)

        self.data_manager = DataManager()
        self.data_manager.start()
        self.symbol = "000001"
        self.data_manager.UpdateSymbol(self.symbol)
        # self.realtime_data = self.data_manager.GetQuoteData(self.symbol, 60, 1).df
        # self.analysis_data = self.data_manager.GetQuoteData(self.symbol, 1800, 30).df
        self._lastclose = self.data_manager.GetLastClose(self.symbol)
        self.realtime_data = None
        self.analysis_data = None
        # for d in self.data_manager.symbol_quote_dict.keys():
        pub.subscribe(self.AnalysisDataArrive, "ANALYSISDATA")
        pub.subscribe(self.RealtimeDataArrive, "REALTIMEDATA")
        self.mainwindow.SetFocus()
        self.realtime_window = None
        self.analysis_window = None

    def _InitComponet(self):
        self.Wnd30Min = wx.MDIChildFrame(self.mainwindow, -1, self.symbol + "30 Min" + self.symbol)
        self.analysis_panel_30 = AnalysisPanel(self.Wnd30Min)
        self.analysis_panel_30.Bind(wx.EVT_PAINT, self.OnAnalysisPaint)
        self.analysis_panel_30.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBack)

    def OnSymbolCtrlEnter(self, evt):
        sym = self.mainwindow.symbol_ctrl.GetValue()
        if sym in self.data_manager.symbol_dict:
            self.symbol = sym
            self.data_manager.UpdateSymbol(sym)
            self.realtime_window.SetTitle(sym)
            self.analysis_window.SetTitle(sym)
            self._lastclose = self.data_manager.GetLastClose(sym)

    def OnKeyDown(self, evt):
        keycode = evt.GetKeyCode()
        print keycode

    def OnAnalysisPaint(self, evt):
        dc = wx.PaintDC(self.analysis_panel)
        # dc.DrawBitmap(self.Buffer, 0, 0)
        dc.Clear()
        draw_candle(dc, self.analysis_data)
        czsc = ChanlunCore()
        czsc.Draw(dc, self.analysis_data)
        print "refreshing"

    def OnEraseBack(self, evt):
        pass

    def AnalysisDataArrive(self, message):
        # if self.analysis_window.IsShownOnScreen():
        self.analysis_data = message.data
        self.analysis_panel.Refresh()

    def On5MinAnalysis(self, evt):
        if self.analysis_window is None:
            self.analysis_window = wx.MDIChildFrame(self.mainwindow, -1, "Analysis Window:" + self.symbol)
            self.analysis_panel = AnalysisPanel(self.analysis_window)
            self.analysis_panel.Bind(wx.EVT_PAINT, self.OnAnalysisPaint)
            self.analysis_panel.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBack)
        else:
            self.analysis_window.Show(True)
            self.analysis_window.SetFocus()

    def On30MinAnalysis(self, evt):
        pass

    def OnDayAnalysis(self, evt):
        pass

    def OnNewRealtimeWindow(self, evt):
        if self.realtime_window is None:
            self.realtime_window = wx.MDIChildFrame(self.mainwindow, -1, "Realtime Window:" + self.symbol)
            self.realtime_panel = AnalysisPanel(self.realtime_window)
            self.realtime_panel.Bind(wx.EVT_PAINT, self.OnRealtimePaint)
            self.realtime_panel.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBack)
        else:
            self.realtime_window.Show(True)
            self.realtime_window.SetFocus()

    def OnRealtimePaint(self, evt):
        dc = wx.PaintDC(self.realtime_panel)
        # dc.DrawBitmap(self.Buffer, 0, 0)
        dc.Clear()
        draw_realtime(dc, self.realtime_data, self._lastclose)

    def RealtimeDataArrive(self, message):
        self.realtime_data = message.data
        self.realtime_panel.Refresh()
예제 #8
0
파일: run.py 프로젝트: macieg-b/k-means
import random

import numpy as np
from sklearn import linear_model
from sklearn.metrics import r2_score

from model import Calculation, DataManager, KMeans, PlotGenerator

x, y = DataManager.load_data('data/iris.arff')
# PlotGenerator.data_set_2d(x, y)
# PlotGenerator.data_set_3d(x, y)
k_means = KMeans(x, y, 3, d_function='MAH')
k_means.random_centers()
C, CX = k_means.process(x)
# PlotGenerator.clusters_2d(CX, x)
# PlotGenerator.clusters_3d(CX, x)
error = Calculation.quantization_error(x, C, CX)
CX = Calculation.proper_classes(CX, y)
accuracy = Calculation.accuracy(CX, y)
print("Error: %f" % error)
print("Accuracy: %f" % accuracy)

x = list()
y = list()
for line in open("data/banknote_authentication_set.txt"):
    tmp_array = line.split(',')
    x.append([float(i) for i in tmp_array[0:-1]])
    y.append(float(tmp_array[-1].replace('\n', '')))

# PlotGenerator.data_set_2d(x, y)
PlotGenerator.data_set_3d(x, y)
예제 #9
0
x_4, y_4 = DataGenerator.chessboard(N, 4, 0.04)
x_5, y_5 = DataGenerator.chessboard(N, 5, 0.04)

data_to_test = list()
data_to_test.append((x_1, y_1))
data_to_test.append((x_2, y_2))
data_to_test.append((x_3, y_3))
data_to_test.append((x_4, y_4))
data_to_test.append((x_5, y_5))

efficiency_list = []
for i in range(len(data_to_test)):
    x = data_to_test[i][0]
    y = data_to_test[i][1]
    PlotGenerator.show_generated_data(x, y)
    teach_data, test_data, teach_result, test_result = DataManager.split_data(
        x, y, 0.5)

    vec = range(1, len(teach_data), STEP)
    efficiency = []
    for k in vec:
        neighbour_efficiency = 0
        print("Iteration %d" % k)
        for i in range(REPETITION):
            kNeighborsClassifier = KNeighborsClassifier(k)
            kNeighborsClassifier.fit(teach_data, teach_result)
            neighbour_efficiency += kNeighborsClassifier.score(
                test_data, test_result)
        neighbour_efficiency /= REPETITION
        efficiency.append((k, neighbour_efficiency))

    efficiency_list.append(efficiency)
예제 #10
0
class Control:
    def __init__(self, app):

        self.mainwindow = MyParentFrame()
        self.mainwindow.Bind(wx.EVT_MENU, self.On5MinAnalysis, id=ID_Menu_5Min)
        self.mainwindow.Bind(wx.EVT_MENU,
                             self.On30MinAnalysis,
                             id=ID_Menu_30Min)
        self.mainwindow.Bind(wx.EVT_MENU, self.OnDayAnalysis, id=ID_Menu_Day)
        self.mainwindow.Bind(wx.EVT_MENU,
                             self.OnNewRealtimeWindow,
                             id=ID_Menu_Realtime)

        self.mainwindow.Show(True)
        app.SetTopWindow(self.mainwindow)

        self.mainwindow.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        self.mainwindow.symbol_ctrl.Bind(wx.EVT_TEXT_ENTER,
                                         self.OnSymbolCtrlEnter)

        self.data_manager = DataManager()
        self.data_manager.start()
        self.symbol = '000001'
        self.data_manager.UpdateSymbol(self.symbol)
        #self.realtime_data = self.data_manager.GetQuoteData(self.symbol, 60, 1).df
        #self.analysis_data = self.data_manager.GetQuoteData(self.symbol, 1800, 30).df
        self._lastclose = self.data_manager.GetLastClose(self.symbol)
        self.realtime_data = None
        self.analysis_data = None
        #for d in self.data_manager.symbol_quote_dict.keys():
        pub.subscribe(self.AnalysisDataArrive, "ANALYSISDATA")
        pub.subscribe(self.RealtimeDataArrive, "REALTIMEDATA")
        self.mainwindow.SetFocus()

        self.analysis_window = wx.MDIChildFrame(
            self.mainwindow, -1, "Analysis Window:" + self.symbol)
        self.analysis_panel = CandlePanel(self.analysis_window)
        self.analysis_panel.Bind(wx.EVT_PAINT, self.OnAnalysisPaint)
        self.analysis_panel.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBack)
        self.analysis_window.Show(True)
        self.analysis_window.SetFocus()

        self.realtime_window = wx.MDIChildFrame(
            self.mainwindow, -1, "Realtime Window:" + self.symbol)
        self.realtime_panel = CandlePanel(self.realtime_window)
        self.realtime_panel.Bind(wx.EVT_PAINT, self.OnRealtimePaint)
        self.realtime_panel.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBack)

    def _InitComponet(self):
        self.Wnd30Min = wx.MDIChildFrame(self.mainwindow, -1,
                                         self.symbol + "30 Min" + self.symbol)
        self.analysis_panel_30 = CandlePanel(self.Wnd30Min)
        self.analysis_panel_30.Bind(wx.EVT_PAINT, self.OnAnalysisPaint)
        self.analysis_panel_30.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBack)

    def OnSymbolCtrlEnter(self, evt):
        sym = self.mainwindow.symbol_ctrl.GetValue()
        if sym in self.data_manager.symbol_dict:
            self.symbol = sym
            self.data_manager.UpdateSymbol(sym)
            self.realtime_window.SetTitle(sym)
            self.analysis_window.SetTitle(sym)
            self._lastclose = self.data_manager.GetLastClose(sym)

    def OnKeyDown(self, evt):
        keycode = evt.GetKeyCode()
        print keycode

    def OnAnalysisPaint(self, evt):
        #dc = wx.PaintDC(self.analysis_panel)
        dc = wx.PaintDC(self.analysis_panel)
        #dc.DrawBitmap(self.Buffer, 0, 0)
        dc.Clear()
        draw_candle(dc, self.analysis_data)
        czsc = ChanlunCore()
        czsc.Draw(dc, self.analysis_data)
        print 'refreshing'
        evt.Skip()

    def OnEraseBack(self, evt):
        pass

    def AnalysisDataArrive(self, message):
        #if self.analysis_window.IsShownOnScreen():
        self.analysis_data = message.data
        self.analysis_panel.Refresh()

    def On5MinAnalysis(self, evt):

        self.analysis_window.Show(True)
        self.analysis_window.SetFocus()

    def On30MinAnalysis(self, evt):
        pass

    def OnDayAnalysis(self, evt):
        pass

    def OnNewRealtimeWindow(self, evt):
        self.realtime_window.Show(True)
        self.realtime_window.SetFocus()

    def OnRealtimePaint(self, evt):
        dc = wx.PaintDC(self.realtime_panel)
        #dc.DrawBitmap(self.Buffer, 0, 0)
        dc.Clear()
        draw_realtime(dc, self.realtime_data, self._lastclose)
        draw_realtime(dc, self.realtime_data, self._lastclose)

    def RealtimeDataArrive(self, message):
        self.realtime_data = message.data
        self.realtime_panel.Refresh()
예제 #11
0
파일: control.py 프로젝트: ongbe/TradeSoft
class Control:
    def __init__(self, app):

        # main window
        self.mainwindow = MyParentFrame()
        self.mainwindow.Bind(wx.EVT_MENU, self.On5MinAnalysis, id=ID_Menu_5Min)
        self.mainwindow.Bind(wx.EVT_MENU, self.On30MinAnalysis, id=ID_Menu_30Min)
        self.mainwindow.Bind(wx.EVT_MENU, self.OnDayAnalysis, id=ID_Menu_Day)
        self.mainwindow.Bind(wx.EVT_MENU, self.OnNewRealtimeWindow, id=ID_Menu_Realtime)
        self.mainwindow.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        self.mainwindow.symbol_ctrl.Bind(wx.EVT_TEXT_ENTER, self.OnSymbolCtrlEnter)
        self.mainwindow.Show(True)
        app.SetTopWindow(self.mainwindow)
        self.mainwindow.SetFocus()

        self.symbol = "000001"

        # subwindow initialize
        self._InitComponet()

        # model initialize
        self.data_manager = DataManager()
        self.data_manager.start()
        self.data_manager.UpdateSymbol(self.symbol)
        # self.realtime_data = self.data_manager.GetQuoteData(self.symbol, 60, 1).df
        # self.analysis_data = self.data_manager.GetQuoteData(self.symbol, 1800, 30).df
        # self._lastclose = self.data_manager.GetLastClose(self.symbol)
        self.realtime_data = None
        self.analysis_data = None
        # for d in self.data_manager.symbol_quote_dict.keys():
        pub.subscribe(self.AnalysisDataArrive, "ANALYSISDATA")
        pub.subscribe(self.RealtimeDataArrive, "REALTIMEDATA")
        pub.subscribe(self.Min30DataArrive, "MIN30DATA")
        pub.subscribe(self.DayDataArrive, "DAYDATA")

    def Min30DataArrive(self, message):
        self.min30_window.SetStockData(self.symbol, message.data, "30Min")

    def DayDataArrive(self, message):
        self.day_window.SetStockData(self.symbol, message.data, "Day")

    def _InitComponet(self):
        self.realtime_window = MyChildFrame(self.mainwindow, -1)
        self.realtime_window.SetStockData(self.symbol, None, "1Min")

        self.analysis_window = MyChildFrame(self.mainwindow, -1)
        self.min30_window = MyChildFrame(self.mainwindow, -1)
        self.day_window = MyChildFrame(self.mainwindow, -1)
        self.analysis_window.SetStockData(self.symbol, None, "5Min")
        self.min30_window.SetStockData(self.symbol, None, "30Min")
        self.day_window.SetStockData(self.symbol, None, "Day")

    def OnSymbolCtrlEnter(self, evt):
        sym = self.mainwindow.symbol_ctrl.GetValue()
        if sym in self.data_manager.symbol_dict:
            self.symbol = sym
            self.analysis_window.SetStockData(self.symbol, None, "5Min")
            self.min30_window.SetStockData(self.symbol, None, "30Min")
            self.day_window.SetStockData(self.symbol, None, "Day")
            self.realtime_window.SetStockData(self.symbol, None, "1Min")
            self.data_manager.UpdateSymbol(sym)
            #            self.realtime_window.SetTitle(sym)
            #            self.analysis_window.SetTitle(sym)
            self._lastclose = self.data_manager.GetLastClose(sym)

    def OnKeyDown(self, evt):
        keycode = evt.GetKeyCode()
        print keycode

    def OnAnalysisPaint(self, evt):

        dc = wx.PaintDC(self.analysis_window.main_panel)
        dc.Clear()
        draw_candle(dc, self.analysis_data)
        czsc = ChanlunCore()
        czsc.Draw(dc, self.analysis_data)
        print "refreshing analysis"

    def OnEraseBack(self, evt):
        pass

    def AnalysisDataArrive(self, message):
        # if self.analysis_window.IsShownOnScreen():
        self.analysis_data = message.data
        self.analysis_window.SetStockData(self.symbol, message.data, "5Min")
        # self.analysis_window.Refresh()
        # self.analysis_window.Refresh()

    def On5MinAnalysis(self, evt):

        self.analysis_window.Show(True)
        self.analysis_window.SetFocus()

    def On30MinAnalysis(self, evt):
        self.min30_window.Show(True)
        self.min30_window.SetFocus()

    def OnDayAnalysis(self, evt):
        self.day_window.Show(True)
        self.day_window.SetFocus()

    def OnNewRealtimeWindow(self, evt):
        self.realtime_window.Show(True)
        self.realtime_window.SetFocus()

    def OnRealtimePaint(self, evt):
        dc = wx.PaintDC(self.realtime_window.main_panel)
        # dc.DrawBitmap(self.Buffer, 0, 0)
        dc.Clear()
        draw_realtime(dc, self.realtime_data, self._lastclose)

    def RealtimeDataArrive(self, message):
        self.realtime_data = message.data
        self.realtime_window.SetStockData(self.symbol, message.data, "1Min")
예제 #12
0
def updatealllll():
    DataManager.getUpdatedData(db_file_path, in_table_name)
    return 'OK'
예제 #13
0
import numpy as np
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.naive_bayes import MultinomialNB
from sklearn.neighbors import KNeighborsClassifier
from sklearn.neural_network import MLPClassifier

from model import DataManager, Classifier, PlotGenerator

REPETITION = 50

probes, result = DataManager.load_data('data/diabetes.arff')
x = np.array(probes)
y = np.array(result)

bayes = Classifier(MultinomialNB(), REPETITION, x, y)
bayes.calculate_indicators()

logistic_regression = Classifier(LogisticRegression(), REPETITION, x, y)
logistic_regression.calculate_indicators()

kneighbours_classifier = Classifier(KNeighborsClassifier(10), REPETITION, x, y)
kneighbours_classifier.calculate_indicators()

mlp_classifier = Classifier(MLPClassifier(), REPETITION, x, y)
mlp_classifier.calculate_indicators()

classifiers_array = []
classifiers_array.append(bayes)
classifiers_array.append(logistic_regression)
classifiers_array.append(kneighbours_classifier)