Пример #1
0
def getFundListFromCode(fund_code, f_save_dir):
	em = EM1234567(fund_code)
	try:
		xy = em.getHistoryPlotJson()
		np.savetxt('%s/%s.csv' % (f_save_dir, fund_code), np.array(xy), delimiter=',')
	except:
		print('Unable to find [%s].' % fund_code)
Пример #2
0
 def _getRealtimeInfo(c):
     try:
         em = EM1234567(c)
         if self.logPath == None:
             return em.getRealtimeInfo()
         else:
             return {**em.getRealtimeInfo(), **em.getHistoryRate()}
     except:
         return None
Пример #3
0
def getFundListFromXlsx(f_xlsx, f_save_dir):
	wb = openpyxl.load_workbook(f_xlsx)
	sh = wb['INFO']
	for i in range(1, sh.max_row+1):
		fund_code = sh.cell(row=i, column=1).value
		em = EM1234567(fund_code)
		try:
			xy = em.getHistoryPlotJson()
			np.savetxt('%s/%s.csv' % (f_save_dir, fund_code), np.array(xy), delimiter=',')
		except:
			print('Unable to find [%s].' % fund_code)
Пример #4
0
 def update(self):
     rates = []
     for c in self.codes:
         em = EM1234567(c)
         try:
             realtime = em.getRealtimeInfo()
             rates.append(self.__colorByRate(realtime['gszzl']))
         except:
             rates.append('--')
     tb = pt.PrettyTable()
     tb.add_column('CODE', self.codes)
     tb.add_column('NAME', self.names)
     tb.add_column('RATE', rates)
     self.__clear()
     print(tb)
Пример #5
0
def updateSheet(fname, isHistory):
    wb = openpyxl.load_workbook(fname)
    sh = wb['INFO']
    for i in range(1, sh.max_row):
        fund_code = sh.cell(row=i, column=1).value
        em = EM1234567(fund_code)
        try:
            realtime = em.getRealtimeInfo()
            print('Updating [%s] %s...' % (fund_code, realtime['name']))
            sh.cell(row=i, column=2).value = realtime['name']
            sh.cell(row=i, column=3).value = float(realtime['gszzl'])
            sh.cell(row=i, column=4).value = realtime['gztime']
            if isHistory == '1':
                history = em.getHistoryRate()
                sh.cell(row=i, column=5).value = history['1m']
                sh.cell(row=i, column=6).value = history['3m']
                sh.cell(row=i, column=7).value = history['6m']
                sh.cell(row=i, column=8).value = history['1y']
        except:
            print('Unable to find [%s].' % fund_code)
    wb.save(fname)
Пример #6
0
 def __init__(self, fund_code, src_dir):
     self.fund_code = fund_code
     self.em = EM1234567(fund_code)
     self.day_x_value = np.array(
         self.em.loadHistoryPlotFromLocal(src_dir)).astype(float)
Пример #7
0
 def __getDataFromEM1234567(self, code):
     em = EM1234567(code)
     return em.getHistoryPlotJson()