Пример #1
0
 def to_csv(self, symbol, date):
     file_name = '%s%s.log' % (symbol, date.strftime('%Y%m%d'))
     path = PathMgr.get_data_path('quantopian_daily_min/%s' % file_name)
     content = read_file_to_string(path)
     lines = content.split('\n')
     filtered_lines = filter(lambda x: len(x) > 100, lines)
     lines = map(lambda x: string_fetch(x, 'PRINT ', ''), filtered_lines)
     close_list_str = ','.join(lines)
     # print close_list_str
     prices_list = map(float, close_list_str.split(','))
     datetimes = TradeTime.generate_datetimes(date, date)
     new_lines = map(lambda x, y: '%s,%s' % (x, y), datetimes, prices_list)
     new_content = '\n'.join(new_lines)
     write_path = PathMgr.get_data_path('quantopian_daily_min/%s%s.csv' %
                                        (symbol, date.strftime('%Y%m%d')))
     write_to_file(write_path, new_content)
Пример #2
0
def realtimedata_to_csv():
    records = \
    EquityRealTimeDAO().get_min_time_and_price('SVXY',
        datetime.datetime(2018, 05, 29, 0, 0, 0),
        datetime.datetime(2018, 05, 30, 0, 0, 0),
        )
    lines = map(lambda x: '%s,%s' % (x[0], x[1]), records[1:])
    content = '\n'.join(lines)
    write_path = PathMgr.get_data_path(
        'quantopian_daily_min/realtime_%s%s.csv' % ('SVXY', '20180529'))
    write_to_file(write_path, content)
Пример #3
0
 def load_log(self, symbol, date):
     file_name = '%s%s.log' % (symbol, date.strftime('%Y%m%d'))
     path = PathMgr.get_data_path('quantopian_daily_min/%s' % file_name)
     content = read_file_to_string(path)
     lines = content.split('\n')
     filtered_lines = filter(lambda x: len(x) > 100, lines)
     lines = map(lambda x: string_fetch(x, 'PRINT ', ''), filtered_lines)
     close_list_str = ','.join(lines)
     prices_list = map(float, close_list_str.split(','))
     datetimes = TradeTime.generate_datetimes(date, date)
     equities = map(lambda x, y: Equity(symbol, x, y, y, y, y), datetimes,
                    prices_list)
     EquityMinDAO().insert(equities)
Пример #4
0
 def load_csv(self, symbol):
     path = PathMgr.get_data_path('1mincsv/%s.txt' % symbol)
     content = read_file_to_string(path)
     lines = content.split('\n')
     return map(lambda x: self.try_parse_line(x, symbol), lines)
Пример #5
0
 def load_log(self, code):
     path = PathMgr.get_data_path('joinquant_min/%s_2018.log'%code)
     content = read_file_to_string(path)
     lines = content.split('\n')
     filtered_lines = filter(lambda x: 'INFO' not in x and x != '', lines)
     return map(lambda x: self.parse_line(x, code), filtered_lines)