コード例 #1
0
 def get_trade_detail_data(self, stock_code, trade_date):
     # trade_date format: '20191118'
     root_path = '/root/download/'
     code = self.coder.net_ease_code(stock_code)
     url = read_url("URL_tick_data", CONF_FILE).format(
         trade_date[:4], trade_date, code)
     df = pd.read_excel(url)
     filename = absolute_path(root_path, f"{stock_code}_{trade_date}.csv")
     if not df.empty:
         df.to_csv(filename, encoding='gb18030')
コード例 #2
0
 def get_trade_detail_data(self, stock_code, trade_date):
     # trade_date format: '20191118'
     DOWNLOAD_PATH = '/home/friederich/Downloads/stock_data/'
     code = self.net_ease_code(stock_code)
     url = read_url("URL_tick_data", CONF_FILE).format(
         trade_date[:4], trade_date, code)
     df = pd.read_excel(url)
     filename = absolute_path(DOWNLOAD_PATH, f"{stock_code}_{trade_date}.csv")
     if not df.empty:
         df.to_csv(filename, encoding='gb18030')
コード例 #3
0
def unit_test_utils():
    print("test read_json")
    print(dev_global.env.CONF_FILE)
    print(utils.read_json('URL', dev_global.env.CONF_FILE))
    print("test read_url")
    print(utils.read_url('Sina', dev_global.env.CONF_FILE))
    print("test record_base")
    print(dev_global.env.LOG_FILE)
    utils.INFO('test')
    utils.ERROR('test')
    utils.WARN('test')
    print("Not tested: class Resource.")
    print("Not tested: str2number.")
コード例 #4
0
 def update_income(self, stock_code):
     # get url
     url = read_url("URL_income", CONF_FILE)
     url = url.format(stock_code[2:])
     # get data
     df = self.get_income(stock_code, url)
     if not df.empty:
         dataline = dataLine('income_statement')
         try:
             insert_sql_list = dataline.insert_sql(stock_code, df)
             for sql in insert_sql_list:
                 self.mysql.engine.execute(sql)
         except Exception as e:
             print(e)
コード例 #5
0
 def url_netease(self, stock_code, start_date, end_date):
     url = read_url('URL_163_MONEY', CONF_FILE)
     query_code = self.coder.net_ease_code(stock_code)
     netease_url = url.format(query_code, start_date, end_date)
     return netease_url
コード例 #6
0
 def __init__(self, header):
     super(EventTradeDataManager, self).__init__(header)
     self.url = read_url('URL_163_MONEY', CONF_FILE)
     self.j2sql.load_table('template_stock')