示例#1
0
    def setUp(self):
        self.client = Client()

        today = datetime.today()
        timestamp = int(
            time.mktime(
                (today.year, today.month, today.day, 10, 30, 0, 0, 0, 0)))
        dt = datetime.fromtimestamp(timestamp)

        d = {
            'SH000001': {
                'amount': 84596203520.0,
                'close': 2856.9899999999998,
                'high': 2880.5599999999999,
                'low': 2851.9499999999998,
                'name': u'\u4e0a\u8bc1\u6307\u6570',
                'open': 2868.73,
                'preclose': 2875.8600000000001,
                'price': 2856.9899999999998,
                'symbol': u'SH000001',
                'time': str(dt),
                'timestamp': timestamp,
                'volume': 75147848.0
            }
        }
        self.client.put_reports(d)
示例#2
0
    def __init__(self, host='localhost', password=None):
        self.client = Client(host=host, password=password, socket_timeout=10)

        msg_task_bar_restart = win32gui.RegisterWindowMessage("TaskbarCreated")
        message_map = {
            msg_task_bar_restart: self._on_restart,
            win32con.WM_DESTROY: self._on_destroy,
            win32con.WM_COMMAND: self._on_command,
            self._WM_USER_STOCK_DATA: self._on_data_receive,
            win32con.WM_USER + 20: self._on_taskbar_notify
        }
        # Register the Window class.
        wc = win32gui.WNDCLASS()
        hinst = wc.hInstance = win32api.GetModuleHandle(None)
        wc.lpszClassName = "StockTaskBar"
        wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW
        wc.hCursor = win32api.LoadCursor(0, win32con.IDC_ARROW)
        wc.hbrBackground = win32con.COLOR_WINDOW
        wc.lpfnWndProc = message_map  # could also specify a wndproc.

        # Don't blow up if class already registered to make testing easier
        try:
            classAtom = win32gui.RegisterClass(wc)
        except win32gui.error, err_info:
            if err_info.winerror != winerror.ERROR_CLASS_ALREADY_EXISTS:
                raise
示例#3
0
        for sector in _SECTORS:
            options = OrderedDict()
            for name, value in config.items(sector):
                options[name] = value.split(' ')
            yield sector, options

        self.f.close()
        file.close


if __name__ == '__main__':
    from cStringIO import StringIO
    from datafeed.client import Client

    client = Client()

    # path = os.path.join(os.path.realpath(os.path.dirname(__file__)),
    #                     '../../var')

    # filename = os.path.join(path, "/dzh/sh/DAY.DAT")
    # io = DzhDay()
    # for symbol, ohlcs in io.read(filename, 'SH') :
    #     memfile = StringIO()
    #     np.save(memfile, ohlcs)
    #     client.put('DayHistory', symbol, memfile.getvalue())

    io = DzhDividend()
    for data in io.read():
        memfile = StringIO()
        np.save(memfile, data[1])