Ejemplo n.º 1
0
	def OnMktBondd( self, event ):
		tradetime = timecheck.getweekday(todaydate,'1600')
		cursor.execute("""SELECT distinct(tradeDate) FROM mkt_mktbondd group by tradeDate order by tradeDate desc
					""")
		tradetimesql = cursor.fetchone()
		if tradetime != tradetimesql[0]:
			inputtradetime = timecheck.chgtimefor(tradetime)
			mkt.mktbondd(inputtradetime)
			'''app = wx.App()
			frame = dialogover.MyDialogover(parent=None)
			frame.Show()
			app.MainLoop()'''
			
		cursor.execute("""select ticker,secShortName,preClosePrice,openPrice,highestPrice,lowestPrice,
				closePrice,turnoverVol,turnoverValue,dealAmount,accrInterest,YTM,tradeDate
					from mkt_mktbondd where tradeDate = %s
					order by ticker asc
					limit 50
			""",(tradetime))

		datacode = cursor.fetchall()
		data1 = [[] for i in range(50)]
		k=0
		for datalist in datacode:
			for j in range(0,13):
				data1[k].append(datalist[j])
			k=k+1
		colLabels1 =[u"债券交易代码",u"债券简称",u"昨日收盘价",u"今日开盘价",u"最高价",u"最低价",u"今日收盘价",
			u"成交量",u"成交金额",u"成交笔数",u"应计利息",u"到期收益率",u"交易日期"]	

		colnum = len(data1[0])
		dataSortBigger1 = [[]for i in range(colnum)]
		dataSortSmaller1 = [[]for i in range(colnum)]
		#print dataSortBigger1[0]
		self.allsort(colnum,dataSortBigger1,dataSortSmaller1,data1,colLabels1)
Ejemplo n.º 2
0
	def OnBShare( self, event ):
		tradetime = timecheck.getweekday(todaydate,'1530')
		tradetime = checktddata.check_mktequd(tradetime)
		cursor.execute( """SELECT mkt_mktequd.ticker,secShortName,openPrice,highestPrice,lowestPrice,preClosePrice,closePrice,turnoverVol,turnoverValue,dealAmount,
							turnoverRate,negMarketValue,marketValue,PE,PE1,PB,tradeDate
				 FROM mkt_mktequd,type_bshare
				 WHERE tradeDate = %s
				 AND mkt_mktequd.ticker = type_bshare.tickerint
				 order by ticker asc
		""",(tradetime))

		datacode = cursor.fetchall()
		count = cursor.rowcount
		data1 = [[] for i in range(count)]
		k=0
		for datalist in datacode:
			for j in range(0,17):
				data1[k].append(datalist[j])
			k=k+1
		colLabels1 =[u"股票代码",u"股票名称",u"今日开盘价",u"最高价",u"最低价",u"昨日收盘价",u"今日收盘价",u"成交量",u"成交金额",u"成交笔数",
			u"日换手率",u"流通市值",u"总市值",u"滚动市盈率",u"市盈率",u"市净率",u"交易日期",u"所属行业",u"概念板块"]
		#colLabels1 = colLabels	
		colnum = len(data1[0])
		dataSortBigger1 = [[]for i in range(colnum)]
		dataSortSmaller1 = [[]for i in range(colnum)]
		#print dataSortBigger1[0]
		self.allsort(colnum,dataSortBigger1,dataSortSmaller1,data1,colLabels1)
Ejemplo n.º 3
0
def typeinfo(countind,caltb_name,datatb_name,type_name):
	
	#countind = 49
	type_info = [[] for i in range(countind)]
	for i in range(0,countind):
		if type_name == 'industry':
			type_info[i].extend(gettypei(typedata.industry[i],datatb_name))
		elif type_name == 'area':
			type_info[i].extend(gettypei(typedata.area[i],datatb_name))
		elif type_name == 'concept':
			type_info[i].extend(gettypei(typedata.concept[i],datatb_name))
		
	#print type_info
	#print type(type_info[0][0])
	#print type_info[0][0]
	typeindustryinfo = []
	avg_ch_pt = []
	avg_weight_ch_pt = []
	turnoverVol_all = []
	max_chpt_name = []
	count_chpt_per = []
	avg_market_per = []
	avg_turnoverRate = []
	avg_pe = []
	for i in range(0,countind):
		typeindustryinfo.append(type_info[i][0])
		avg_ch_pt.append(type_info[i][1])
		avg_weight_ch_pt.append(type_info[i][2])
		turnoverVol_all.append(type_info[i][3])
		max_chpt_name.append(type_info[i][4])
		count_chpt_per.append(type_info[i][5])
		avg_market_per.append(type_info[i][6])
		avg_turnoverRate.append(type_info[i][7])
		avg_pe.append(type_info[i][8])
		#print typeindustryinfo
	
	type_infodata = {'typeinfo':typeindustryinfo,
	'avg_ch_pt':avg_ch_pt,'avg_weight_ch_pt':avg_weight_ch_pt,'turnoverVol_all':turnoverVol_all,
	'max_chpt_name':max_chpt_name,'count_chpt_per':count_chpt_per,
	'avg_market_per':avg_market_per,'avg_turnoverRate':avg_turnoverRate,'avg_pe':avg_pe

	}
	frame = pd.DataFrame(type_infodata,columns=['typeinfo',
	'avg_ch_pt','avg_weight_ch_pt','turnoverVol_all',
	'max_chpt_name','count_chpt_per',
	'avg_market_per','avg_turnoverRate','avg_pe'])
	tradetime = timecheck.getweekday(todaydate,'1530')
	frame.insert(8,'tradetime',tradetime)
	#print frame
	frame.to_sql('%s' % (caltb_name),engine,if_exists='append')
	#print typeindustryinfo,avg_pe
	return type_info
#typeinfo(46,'cal_industryinfo','sec_typeindustry','industry')
#typeinfo(32,'cal_areainfo','sec_typearea','area')
#typeinfo(156,'cal_conceptinfo','sec_typeconcept','concept')
Ejemplo n.º 4
0
	def OnMktFutd( self, event ):
		
		tradetime = timecheck.getweekday(todaydate,'1800')
		cursor.execute("""SELECT distinct(tradeDate) FROM mkt_mktfutd group by tradeDate order by tradeDate desc
					""")
		tradetimesql = cursor.fetchone()
		if tradetime != tradetimesql[0]:
			#app = wx.App()
			#frame1 = dialoging.MyDialoging(parent=None)
			#frame1.Show()
			#app.MainLoop()
			inputtradetime = timecheck.chgtimefor(tradetime)
			mkt.mktfutd(inputtradetime)
			'''app = wx.App()
			#frame1.Close()
			frame = dialogover.MyDialogover(parent=None)
			frame.Show()
			app.MainLoop()'''
			
		cursor.execute("""select ticker,secShortName,openPrice,highestPrice,lowestPrice,preClosePrice,preSettlePrice,
				closePrice,settlePrice,turnoverVol,turnoverValue,openInt,CHG,CHGPct,tradeDate
					from mkt_mktfutd where tradeDate = %s
					order by ticker asc
					limit 474
			""",(tradetime))

		datacode = cursor.fetchall()
		count = cursor.rowcount
		#global data1
		data1 = [[] for i in range(count)]
		k=0
		for datalist in datacode:
			for j in range(0,15):
				data1[k].append(datalist[j])
			k=k+1
		#global colLabels1
		colLabels1 =[u"合约代码",u"合约简称",u"今日开盘价",u"最高价",u"最低价",u"昨日收盘价",u"昨日结算价",u"今日收盘价",
			u"今日结算价",u"成交量",u"成交金额",u"持仓量",u"涨跌",u"涨跌幅",u"交易日期"]	
		
		colnum = len(data1[0])
		dataSortBigger1 = [[]for i in range(colnum)]
		dataSortSmaller1 = [[]for i in range(colnum)]
		#print dataSortBigger1[0]
		self.allsort(colnum,dataSortBigger1,dataSortSmaller1,data1,colLabels1)
Ejemplo n.º 5
0
	def OnMktIndex( self, event ):
		
		tradetime = timecheck.getweekday(todaydate,'0930')
		#cursor.execute("""SELECT distinct(tradeDate) FROM mkt_mktindex group by tradeDate order by tradeDate desc
		#			""")
		#tradetimesql = cursor.fetchone()
		#if tradetime != tradetimesql[0]:
		#timeArray = time.strptime(tradetime,'%Y-%m-%d')
		#inputtradetime = time.strftime('%Y%m%d',timeArray)
		mkt.mktindex(todaydate)
		'''app = wx.App()
			frame = dialogover.MyDialogover(parent=None)
			frame.Show()
			app.MainLoop()'''
			
		cursor.execute("""select code,name,preclose,open,high,
						low,close,volume,amount,`change`,tradeDate,tradeTimehm
					from mkt_mktindex where tradeDate = %s
					order by code asc
					limit 23
			""",(tradetime))

		datacode = cursor.fetchall()
		count = cursor.rowcount
		#print count
		#global data1
		data1 = [[] for i in range(count)]
		k=0
		for datalist in datacode:
			for j in range(0,12):
				data1[k].append(datalist[j])
			k=k+1
		#global colLabels1
		colLabels1 =[u"指数代码",u"指数名称",u"昨收盘点位",u"今开盘点位",u"最高点位",u"最低点位",u"今收盘点位",
			u"成交量",u"成交金额(亿元)",u"涨跌幅",u"交易日期",u"交易时间"]	

		colnum = len(data1[0])
		dataSortBigger1 = [[]for i in range(colnum)]
		dataSortSmaller1 = [[]for i in range(colnum)]
		self.allsort(colnum,dataSortBigger1,dataSortSmaller1,data1,colLabels1)
Ejemplo n.º 6
0
	def OnMktIdxd( self, event ):
		tradetime = timecheck.getweekday(todaydate,'1600')
		cursor.execute("""SELECT distinct(tradeDate) FROM mkt_mktidxd group by tradeDate order by tradeDate desc
					""")
		tradetimesql = cursor.fetchone()
		if tradetime != tradetimesql[0]:
			inputtradetime = timecheck.chgtimefor(tradetime)
			mkt.mktidxd(inputtradetime)
			'''app = wx.App()
			frame = dialogover.MyDialogover(parent=None)
			frame.Show()
			app.MainLoop()'''
			
		cursor.execute("""select ticker,secShortName,porgFullName,preCloseIndex,openIndex,lowestIndex,
						highestIndex,closeIndex,turnoverVol,turnoverValue,CHG,CHGPct,tradeDate
					from mkt_mktidxd where tradeDate = %s
					order by ticker asc
					limit 847
			""",(tradetime))

		datacode = cursor.fetchall()
		count = cursor.rowcount
		#print count
		#global data1
		data1 = [[] for i in range(count)]
		k=0
		for datalist in datacode:
			for j in range(0,13):
				data1[k].append(datalist[j])
			k=k+1
		#global colLabels1
		colLabels1 =[u"指数代码",u"证券简称",u"发布机构全称",u"昨收盘指数",u"今开盘指数",u"最低价指数",u"最高价指数",u"今收盘指数",
			u"成交量",u"成交金额",u"涨跌",u"涨跌幅",u"交易日期"]	

		colnum = len(data1[0])
		dataSortBigger1 = [[]for i in range(colnum)]
		dataSortSmaller1 = [[]for i in range(colnum)]
		self.allsort(colnum,dataSortBigger1,dataSortSmaller1,data1,colLabels1)
Ejemplo n.º 7
0
	def OnMktFund( self, event ):
		tradetime = timecheck.getweekday(todaydate,'1600')
		cursor.execute("""SELECT distinct(tradeDate) FROM mkt_mktfundd group by tradeDate order by tradeDate desc
					""")
		tradetimesql = cursor.fetchone()
		if tradetime != tradetimesql[0]:
			inputtradetime = timecheck.chgtimefor(tradetime)
			mkt.mktfundd(inputtradetime)
			'''app = wx.App()
			frame = dialogover.MyDialogover(parent=None)
			frame.Show()
			app.MainLoop()'''
			
		cursor.execute("""select ticker,secShortName,preClosePrice,openPrice,highestPrice,lowestPrice,
				closePrice,turnoverVol,turnoverValue,CHG,CHGPct,circulationShares,accumAdjFactor,tradeDate
					from mkt_mktfundd where tradeDate = %s
					order by ticker asc
					limit 606
			""",(tradetime))

		datacode = cursor.fetchall()
		count = cursor.rowcount
		data1 = [[] for i in range(count)]
		k=0
		for datalist in datacode:
			for j in range(0,14):
				data1[k].append(datalist[j])
			k=k+1
		colLabels1 =[u"基金交易代码",u"证券简称",u"昨日收盘价",u"今日开盘价",u"最高价",u"最低价",u"今日收盘价",
			u"成交量",u"成交金额",u"涨跌",u"涨跌幅",u"流通份额",u"累积复权因子",u"交易日期"]	
		
		colnum = len(data1[0])
		dataSortBigger1 = [[]for i in range(colnum)]
		dataSortSmaller1 = [[]for i in range(colnum)]
		#print dataSortBigger1[0]
		self.allsort(colnum,dataSortBigger1,dataSortSmaller1,data1,colLabels1)
Ejemplo n.º 8
0
	def __init__( self, parent ):
		
		#定义获取数据
		tradetime = timecheck.getweekday(todaydate,'1530')
		#cursor.execute("""SELECT distinct(tradeDate) FROM mkt_mktequd group by tradeDate order by tradeDate desc
		#				""")
		cursor.execute("""SELECT distinct(tradeDate) FROM mkt_mktequd where tradeDate=%s
						""",(tradetime))
		#tradetimesql = cursor.fetchone()
		#print tradetime
		#print tradetimesql[0]
		#if tradetime != tradetimesql[0] :
		counttoday = 0
		i = 0
		counttoday += cursor.rowcount
		print counttoday
		while (counttoday == 0 and i < 2):
			'''
			app = wx.App()
			frame1 = dialoging.MyDialoging(parent=None)
			frame1.Show()
			app.MainLoop()'''
			#print tradetime
			inputtradetime = timecheck.chgtimefor(tradetime)
			#print inputtradetime
			mkt.mktequd(inputtradetime)
			cursor.execute("""SELECT distinct(tradeDate) FROM mkt_mktequd where tradeDate=%s
						""",(tradetime))
			counttoday += cursor.rowcount
			print counttoday
			if counttoday == 0 :
				tradetime = timecheck.getyesday(tradetime)
				cursor.execute("""SELECT distinct(tradeDate) FROM mkt_mktequd where tradeDate=%s
						""",(tradetime))
				if cursor.rowcount > 0:
					break
			print tradetime
			i += 1
		
		'''app = wx.App()
		#frame1.Close()
		frame = dialogover.MyDialogover(parent=None)
		frame.Show()
		app.MainLoop()'''


		cursor.execute("""select ticker,secShortName,openPrice,highestPrice,lowestPrice,preClosePrice,closePrice,turnoverVol,turnoverValue,dealAmount,
							turnoverRate,negMarketValue,marketValue,PE,PE1,PB,tradeDate
				from mkt_mktequd where tradeDate = %s
				order by ticker asc
				limit 50
		""",(tradetime))

		datacode = cursor.fetchall()
		count = cursor.rowcount
		global data
		data = [[] for i in range(count)]
		k=0
		for datalist in datacode:
			for j in range(0,17):
				data[k].append(datalist[j])
			k=k+1
		#将ticker的显示数前面补0
		for i in range(0,count):
			data[i][0]= "%06d" % data[i][0]

		global colLabels
		colLabels =[u"股票代码",u"股票名称",u"今日开盘价",u"最高价",u"最低价",u"昨日收盘价",u"今日收盘价",u"成交量",u"成交金额",u"成交笔数",
			u"日换手率",u"流通市值",u"总市值",u"滚动市盈率",u"市盈率",u"市净率",u"交易日期",u"所属行业",u"概念板块"]
			
		#print len(colLabels)
		global colnum,dataSortBigger,dataSortSmaller
		colnum = len(data[0])
		#print colnum
		dataSortBigger = [[]for i in range(colnum)]
		dataSortSmaller = [[]for i in range(colnum)]
		
		for i in range(0,colnum):
			sortMin(data,i,dataSortBigger[i])
			sortMax(data,i,dataSortSmaller[i])
		#print dataSortBigger

		wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"沪深股票日行情", pos = wx.DefaultPosition, size = wx.Size( 716,508 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
		#id = frame.GetId()
		self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
		
		self.m_menubar1 = wx.MenuBar( 0 )
		self.m_menuupdb = wx.Menu()
		self.m_menuupdb.AppendSeparator()
		
		self.m_menuItemdb = wx.MenuItem( self.m_menuupdb, wx.ID_ANY, u"选择更新数据库", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menuupdb.AppendItem( self.m_menuItemdb )
		
		self.m_menuupdb.AppendSeparator()
		
		self.m_menubar1.Append( self.m_menuupdb, u"更新数据库" ) 
		
		self.m_menuanal = wx.Menu()
		self.m_menuanal.AppendSeparator()
		
		self.m_menuItemanal1 = wx.MenuItem( self.m_menuanal, wx.ID_ANY, u"报价分析", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menuanal.AppendItem( self.m_menuItemanal1 )
		
		self.m_menuItemanal2 = wx.MenuItem( self.m_menuanal, wx.ID_ANY, u"即时分析", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menuanal.AppendItem( self.m_menuItemanal2 )
		
		self.m_menuItemanal3 = wx.MenuItem( self.m_menuanal, wx.ID_ANY, u"技术分析", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menuanal.AppendItem( self.m_menuItemanal3 )
		
		self.m_menuItemanal4 = wx.MenuItem( self.m_menuanal, wx.ID_ANY, u"报表分析", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menuanal.AppendItem( self.m_menuItemanal4 )
		
		self.m_menuanal.AppendSeparator()
		
		self.m_menubar1.Append( self.m_menuanal, u"分析" ) 
		
		self.m_menuday = wx.Menu()
		self.m_menuday.AppendSeparator()
		self.m_menu11 = wx.Menu()
		self.m_menuItem79 = wx.MenuItem( self.m_menu11, wx.ID_ANY, u"全部沪深股", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu11.AppendItem( self.m_menuItem79 )
		
		self.m_menuItem4711 = wx.MenuItem( self.m_menu11, wx.ID_ANY, u"A股", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu11.AppendItem( self.m_menuItem4711 )
		
		self.m_menuItem481 = wx.MenuItem( self.m_menu11, wx.ID_ANY, u"中小板", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu11.AppendItem( self.m_menuItem481 )
		
		self.m_menuItem491 = wx.MenuItem( self.m_menu11, wx.ID_ANY, u"创业板", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu11.AppendItem( self.m_menuItem491 )
		
		self.m_menuItem501 = wx.MenuItem( self.m_menu11, wx.ID_ANY, u"B股", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu11.AppendItem( self.m_menuItem501 )
		
		self.m_menuItem511 = wx.MenuItem( self.m_menu11, wx.ID_ANY, u"三板", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu11.AppendItem( self.m_menuItem511 )
		
		self.m_menuday.AppendSubMenu( self.m_menu11, u"沪深股" )
		
		self.m_menu51 = wx.Menu()
		self.m_menuItem86 = wx.MenuItem( self.m_menu51, wx.ID_ANY, u"全部基金", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu51.AppendItem( self.m_menuItem86 )

		self.m_menuItem461 = wx.MenuItem( self.m_menu51, wx.ID_ANY, u"LOF", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu51.AppendItem( self.m_menuItem461 )
		
		self.m_menuItem531 = wx.MenuItem( self.m_menu51, wx.ID_ANY, u"ETF", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu51.AppendItem( self.m_menuItem531 )
		
		self.m_menuItem541 = wx.MenuItem( self.m_menu51, wx.ID_ANY, u"上证基金", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu51.AppendItem( self.m_menuItem541 )
		
		self.m_menuItem551 = wx.MenuItem( self.m_menu51, wx.ID_ANY, u"深证基金", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu51.AppendItem( self.m_menuItem551 )
		
		
		self.m_menuday.AppendSubMenu( self.m_menu51, u"基金" )
		
		self.m_menu251 = wx.Menu()
		self.m_menuItem87 = wx.MenuItem( self.m_menu251, wx.ID_ANY, u"全部债券", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu251.AppendItem( self.m_menuItem87 )
		
		self.m_menuItem92 = wx.MenuItem( self.m_menu251, wx.ID_ANY, u"银行间债券", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu251.AppendItem( self.m_menuItem92 )
		
		self.m_menuItem93 = wx.MenuItem( self.m_menu251, wx.ID_ANY, u"上证债券", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu251.AppendItem( self.m_menuItem93 )
		
		self.m_menuItem94 = wx.MenuItem( self.m_menu251, wx.ID_ANY, u"深证债券", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu251.AppendItem( self.m_menuItem94 )
		
		
		self.m_menuday.AppendSubMenu( self.m_menu251, u"债券" )
		
		self.m_menu261 = wx.Menu()
		self.m_menuItem88 = wx.MenuItem( self.m_menu261, wx.ID_ANY, u"全部期货", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu261.AppendItem( self.m_menuItem88 )

		self.m_menuItem95 = wx.MenuItem( self.m_menu261, wx.ID_ANY, u"中金所", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu261.AppendItem( self.m_menuItem95 )
		
		self.m_menuItem96 = wx.MenuItem( self.m_menu261, wx.ID_ANY, u"上海期货", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu261.AppendItem( self.m_menuItem96 )
		
		self.m_menuItem97 = wx.MenuItem( self.m_menu261, wx.ID_ANY, u"大连商品", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu261.AppendItem( self.m_menuItem97 )
		
		self.m_menuItem98 = wx.MenuItem( self.m_menu261, wx.ID_ANY, u"郑州商品", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu261.AppendItem( self.m_menuItem98 )
		
		
		self.m_menuday.AppendSubMenu( self.m_menu261, u"期货" )
		
		self.m_menu241 = wx.Menu()
		self.m_menuItem89 = wx.MenuItem( self.m_menu241, wx.ID_ANY, u"全部期权", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu241.AppendItem( self.m_menuItem89 )
		
		self.m_menuItem99 = wx.MenuItem( self.m_menu241, wx.ID_ANY, u"上证期权", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu241.AppendItem( self.m_menuItem99 )
		
		self.m_menuItem100 = wx.MenuItem( self.m_menu241, wx.ID_ANY, u"期权标的", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu241.AppendItem( self.m_menuItem100 )
		
		
		self.m_menuday.AppendSubMenu( self.m_menu241, u"期权" )
		
		self.m_menu221 = wx.Menu()
		self.m_menuday.AppendSubMenu( self.m_menu221, u"港股" )
		
		self.m_menuday.AppendSeparator()
		
		self.m_menubar1.Append( self.m_menuday, u"日行情显示" ) 
		
		self.m_menureal = wx.Menu()
		self.m_menureal.AppendSeparator()
		
		self.m_menuItem110 = wx.MenuItem( self.m_menureal, wx.ID_ANY, u"大盘指数实时行情", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menureal.AppendItem( self.m_menuItem110 )
		
		self.m_menu1 = wx.Menu()
		self.m_menuItem791 = wx.MenuItem( self.m_menu1, wx.ID_ANY, u"全部沪深股", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu1.AppendItem( self.m_menuItem791 )
		
		self.m_menuItem471 = wx.MenuItem( self.m_menu1, wx.ID_ANY, u"A股", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu1.AppendItem( self.m_menuItem471 )
		
		self.m_menuItem48 = wx.MenuItem( self.m_menu1, wx.ID_ANY, u"中小板", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu1.AppendItem( self.m_menuItem48 )
		
		self.m_menuItem49 = wx.MenuItem( self.m_menu1, wx.ID_ANY, u"创业板", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu1.AppendItem( self.m_menuItem49 )
		
		self.m_menuItem50 = wx.MenuItem( self.m_menu1, wx.ID_ANY, u"B股", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu1.AppendItem( self.m_menuItem50 )
		
		self.m_menuItem51 = wx.MenuItem( self.m_menu1, wx.ID_ANY, u"三板", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu1.AppendItem( self.m_menuItem51 )
		
		
		self.m_menureal.AppendSubMenu( self.m_menu1, u"沪深股" )
		
		self.m_menu5 = wx.Menu()

		self.m_menuItem861 = wx.MenuItem( self.m_menu5, wx.ID_ANY, u"全部基金", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu5.AppendItem( self.m_menuItem861 )

		self.m_menuItem46 = wx.MenuItem( self.m_menu5, wx.ID_ANY, u"LOF", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu5.AppendItem( self.m_menuItem46 )
		
		self.m_menuItem53 = wx.MenuItem( self.m_menu5, wx.ID_ANY, u"ETF", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu5.AppendItem( self.m_menuItem53 )
		
		self.m_menuItem54 = wx.MenuItem( self.m_menu5, wx.ID_ANY, u"上证基金", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu5.AppendItem( self.m_menuItem54 )
		
		self.m_menuItem55 = wx.MenuItem( self.m_menu5, wx.ID_ANY, u"深证基金", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu5.AppendItem( self.m_menuItem55 )
		
		
		self.m_menureal.AppendSubMenu( self.m_menu5, u"基金" )
		
		self.m_menu25 = wx.Menu()
		self.m_menuItem871 = wx.MenuItem( self.m_menu25, wx.ID_ANY, u"全部债券", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu25.AppendItem( self.m_menuItem871 )
		
		self.m_menuItem921 = wx.MenuItem( self.m_menu25, wx.ID_ANY, u"银行间债券", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu25.AppendItem( self.m_menuItem921 )
		
		self.m_menuItem931 = wx.MenuItem( self.m_menu25, wx.ID_ANY, u"上证债券", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu25.AppendItem( self.m_menuItem931 )
		
		self.m_menuItem941 = wx.MenuItem( self.m_menu25, wx.ID_ANY, u"深证债券", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu25.AppendItem( self.m_menuItem941 )
		
		self.m_menureal.AppendSubMenu( self.m_menu25, u"债券" )
		
		self.m_menu26 = wx.Menu()
		self.m_menuItem881 = wx.MenuItem( self.m_menu26, wx.ID_ANY, u"全部期货", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu26.AppendItem( self.m_menuItem881 )
		
		self.m_menuItem951 = wx.MenuItem( self.m_menu26, wx.ID_ANY, u"中金所", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu26.AppendItem( self.m_menuItem951 )
		
		self.m_menuItem961 = wx.MenuItem( self.m_menu26, wx.ID_ANY, u"上海期货", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu26.AppendItem( self.m_menuItem961 )
		
		self.m_menuItem971 = wx.MenuItem( self.m_menu26, wx.ID_ANY, u"大连商品", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu26.AppendItem( self.m_menuItem971 )
		
		self.m_menuItem981 = wx.MenuItem( self.m_menu26, wx.ID_ANY, u"郑州商品", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu26.AppendItem( self.m_menuItem981 )
		
		self.m_menureal.AppendSubMenu( self.m_menu26, u"期货" )
		
		self.m_menu24 = wx.Menu()
		self.m_menuItem891 = wx.MenuItem( self.m_menu24, wx.ID_ANY, u"全部期权", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu24.AppendItem( self.m_menuItem891 )
		
		self.m_menuItem991 = wx.MenuItem( self.m_menu24, wx.ID_ANY, u"上证期权", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu24.AppendItem( self.m_menuItem991 )
		
		self.m_menuItem1001 = wx.MenuItem( self.m_menu24, wx.ID_ANY, u"期权标的", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu24.AppendItem( self.m_menuItem1001 )
		
		self.m_menureal.AppendSubMenu( self.m_menu24, u"期权" )
		
		self.m_menu22 = wx.Menu()
		self.m_menureal.AppendSubMenu( self.m_menu22, u"港股" )
		
		self.m_menureal.AppendSeparator()
		
		self.m_menubar1.Append( self.m_menureal, u"实时行情显示" ) 
		
		self.m_menuboard = wx.Menu()
		self.m_menuboard.AppendSeparator()
		
		self.m_menu211 = wx.Menu()
		self.m_menuItem106 = wx.MenuItem( self.m_menu211, wx.ID_ANY, u"全部行业板块", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu211.AppendItem( self.m_menuItem106 )
		
		self.m_menuboard.AppendSubMenu( self.m_menu211, u"行业板块" )
		
		self.m_menu171 = wx.Menu()
		self.m_menuItem107 = wx.MenuItem( self.m_menu171, wx.ID_ANY, u"全部地区板块", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu171.AppendItem( self.m_menuItem107 )
		
		self.m_menuboard.AppendSubMenu( self.m_menu171, u"地区板块" )
		
		self.m_menu161 = wx.Menu()
		self.m_menuItem108 = wx.MenuItem( self.m_menu161, wx.ID_ANY, u"全部指数", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu161.AppendItem( self.m_menuItem108 )
		'''
		self.m_menuItem110 = wx.MenuItem( self.m_menu161, wx.ID_ANY, u"大盘指数", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu161.AppendItem( self.m_menuItem110 )
		'''

		self.m_menuboard.AppendSubMenu( self.m_menu161, u"指数板块" )
		
		self.m_menu81 = wx.Menu()
		self.m_menuItem109 = wx.MenuItem( self.m_menu81, wx.ID_ANY, u"全部概念板块", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu81.AppendItem( self.m_menuItem109 )
		
		self.m_menuboard.AppendSubMenu( self.m_menu81, u"概念板块" )
		
		self.m_menuboard.AppendSeparator()
		
		self.m_menubar1.Append( self.m_menuboard, u"板块" ) 
		
		self.m_menutools = wx.Menu()
		self.m_menutools.AppendSeparator()
		self.child1 = self.m_menutools.Append(-1,u'公式管理器','there are lots of formulas')
		self.child2 = self.m_menutools.Append(-1,u'模板管理器','there are lots of templates')
		self.m_menutools.AppendSeparator()
		self.m_menubar1.Append(self.m_menutools, u'工具')
		
		'''self.menu4 = wx.Menu()
		self.child3 = wx.MenuItem(self.menu4,1,u'&个股数据\tF10')
        self.menu4.AppendItem(child3)
        self.menu4.AppendSeparator()
        self.child4 = wx.Menu()
        self.child4_1=self.child4.Append(-1,u'更新所有')
        self.child4_2=self.child4.Append(-1,u'更新SZ板块')
        self.child4_3=self.child4.Append(-1,u'更新SH板块')
        #注意区别的是,这里用appendmenu而不是appenditem
        self.menu4.AppendMenu(-1,u'更新个股资料',self.child4)
		self.m_menubar1.Append(self.menu4,u'微系统')
		self.SetMenuBar( self.m_menubar1 )
		'''
		self.m_menu18 = wx.Menu()
		self.m_menu18.AppendSeparator()
		
		self.m_menuItem942 = wx.MenuItem( self.m_menu18, wx.ID_ANY, u"个股数据\tF10", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu18.AppendItem( self.m_menuItem942 )
		
		self.m_menu17 = wx.Menu()
		self.m_menuItem952 = wx.MenuItem( self.m_menu17, wx.ID_ANY, u"更新所有", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu17.AppendItem( self.m_menuItem952 )
		
		self.m_menuItem962 = wx.MenuItem( self.m_menu17, wx.ID_ANY, u"更新SZ板块", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu17.AppendItem( self.m_menuItem962 )
		
		self.m_menuItem972 = wx.MenuItem( self.m_menu17, wx.ID_ANY, u"更新SH板块", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu17.AppendItem( self.m_menuItem972 )
		
		self.m_menu18.AppendSubMenu( self.m_menu17, u"更新个股资料" )
		
		self.m_menubar1.Append( self.m_menu18, u"微系统" ) 

		self.SetMenuBar( self.m_menubar1 )

		bSizer6 = wx.BoxSizer( wx.VERTICAL )
		
		self.m_panel2 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
		bSizer1 = wx.BoxSizer( wx.VERTICAL )
		
		self.m_staticline33 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
		bSizer1.Add( self.m_staticline33, 0, wx.EXPAND |wx.ALL, 5 )
		
		
		fgSizer14 = wx.FlexGridSizer( 1, 1, 0, 0 )
		fgSizer14.SetFlexibleDirection( wx.BOTH )
		fgSizer14.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
		
		########################		
		#创建网格表
		self.grid = wx.grid.Grid(self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0)
		
		self.table = TestTable(data,colLabels)
		self.grid.SetTable(self.table, True)

		self.grid.EnableEditing( False )
		self.grid.EnableGridLines( True )
		self.grid.EnableDragGridSize( True )
		#self.grid.SetColSize( 8, 100 )
		#self.grid.AutoSizeColumns()
		#self.grid.AutoSizeRows()
		self.grid.SetDefaultCellAlignment( wx.ALIGN_LEFT, wx.ALIGN_TOP )
		fgSizer14.Add( self.grid, 1, wx.ALL|wx.EXPAND, 5 )
		bSizer1.Add( fgSizer14, 1, wx.EXPAND, 5 )
		#########################

		
		self.m_staticline17 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
		bSizer1.Add( self.m_staticline17, 0, wx.EXPAND |wx.ALL, 5 )
		
		self.m_panel2.SetSizer( bSizer1 )
		self.m_panel2.Layout()
		bSizer1.Fit( self.m_panel2 )
		bSizer6.Add( self.m_panel2, 1, wx.EXPAND |wx.ALL, 5 )
		
		self.SetSizer( bSizer6 )
		self.Layout()
		
		self.Centre( wx.BOTH )
		
		# Connect Events
		self.Bind( wx.EVT_MENU, self.OnUpdata, id = self.m_menuItemdb.GetId() )
		self.Bind( wx.EVT_MENU, self.Onbaojia, id = self.m_menuItemanal1.GetId() )
		self.Bind( wx.EVT_MENU, self.Onjishi, id = self.m_menuItemanal2.GetId() )
		self.Bind( wx.EVT_MENU, self.Onjishu, id = self.m_menuItemanal3.GetId() )
		self.Bind( wx.EVT_MENU, self.Onbaobiao, id = self.m_menuItemanal4.GetId() )
		self.Bind( wx.EVT_MENU, self.OnMktEqud, id = self.m_menuItem79.GetId() )
		self.Bind( wx.EVT_MENU, self.OnAshare, id = self.m_menuItem4711.GetId() )
		self.Bind( wx.EVT_MENU, self.OnSME, id = self.m_menuItem481.GetId() )
		self.Bind( wx.EVT_MENU, self.OnGEM, id = self.m_menuItem491.GetId() )
		self.Bind( wx.EVT_MENU, self.OnBShare, id = self.m_menuItem501.GetId() )
		self.Bind( wx.EVT_MENU, self.On3Board, id = self.m_menuItem511.GetId() )
		
		self.Bind( wx.EVT_MENU, self.OnMktFund, id = self.m_menuItem86.GetId() )
		self.Bind( wx.EVT_MENU, self.OnMktBondd, id = self.m_menuItem87.GetId() )
		self.Bind( wx.EVT_MENU, self.OnMktFutd, id = self.m_menuItem88.GetId() )
		self.Bind( wx.EVT_MENU, self.OnMktOptd, id = self.m_menuItem89.GetId() )
		self.Bind( wx.EVT_MENU, self.OnMktIndex, id = self.m_menuItem110.GetId() )
		self.Bind( wx.EVT_MENU, self.OnMktIdxd, id = self.m_menuItem108.GetId() )
		self.Bind( wx.EVT_MENU, self.OnTypeIndustry, id = self.m_menuItem106.GetId() )
		self.Bind( wx.EVT_MENU, self.OnTyeArea, id = self.m_menuItem107.GetId() )
		self.Bind( wx.EVT_MENU, self.OnTypeConcept, id = self.m_menuItem109.GetId() )
		self.Bind(wx.EVT_MENU,self.OnChild1,self.child1)
		self.Bind(wx.EVT_MENU,self.OnChild2,self.child2)
		self.Bind( wx.EVT_MENU, self.OnChild3, id = self.m_menuItem942.GetId() )
		self.Bind( wx.EVT_MENU, self.OnChild4_1, id = self.m_menuItem952.GetId() )
		self.grid.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK,lambda evt,dataSortBigger=dataSortBigger,colLabels=colLabels:self.OnLeftClick(evt,dataSortBigger,colLabels))
		self.grid.Bind(wx.grid.EVT_GRID_LABEL_RIGHT_CLICK,lambda evt,dataSortSmaller=dataSortSmaller,colLabels=colLabels:self.OnRightClick(evt,dataSortSmaller,colLabels))
Ejemplo n.º 9
0
def mktindex(update):
    #dfindex = ts.get_index()
    inputtradetime = timecheck.getweekday(update, '0930')

    def inserttable(dfindex, hm):
        dfindex.insert(0, 'uploadtime', nowtime)
        dfindex.insert(1, 'tradeDate', inputtradetime)
        dfindex.insert(2, 'tradeTimehm', hm)

        def insertidindex():
            sql = """ALTER TABLE mkt_mktindex 
					ADD mktindex_id int(20) not null auto_increment ,
					ADD primary key (mktindex_id)"""
            cursor.execute(sql)

        countindex = cursor.execute(
            'show columns from mkt_mktindex like \'mktindex_id\'')
        if countindex == 0:
            insertidindex()
        else:
            dfindex.to_sql('mkt_mktindex', engine, if_exists='append')

    #timeArray = time.strptime(tradetime,'%Y%m%d')
    #inputtradetime = time.strftime('%Y-%m-%d',timeArray)
    def notrealdata():
        cursor.execute(
            """SELECT distinct(tradeDate) FROM mkt_mktindex group by tradeDate order by tradeDate desc
						""")
        tradetimesql = cursor.fetchone()
        count = cursor.rowcount
        if count == 0:
            dfindex = ts.get_index()
            inserttable(dfindex, '15:00')
        elif inputtradetime != tradetimesql[0]:
            dfindex = ts.get_index()
            #dfindex.insert(2,'tradeTimehm','15:00')
            inserttable(dfindex, '15:00')

        #print "notreal"
    def notrealdatanoon():
        cursor.execute(
            """SELECT distinct(tradeTimehm) FROM mkt_mktindex where tradeDate=%s order by tradeTimehm desc
						""", (inputtradetime))
        tradetimesql = cursor.fetchone()
        count = cursor.rowcount
        print count
        print tradetimesql[0]
        if count == 0:
            dfindex = ts.get_index()
            inserttable(dfindex, '11:30')
        elif (tradetimesql[0] != '11:30'):
            dfindex = ts.get_index()
            inserttable(dfindex, '11:30')

    def notrealdatanight():
        cursor.execute(
            """SELECT distinct(tradeTimehm) FROM mkt_mktindex where tradeDate=%s order by tradeTimehm desc
						""", (inputtradetime))
        tradetimesql = cursor.fetchone()
        print tradetimesql[0]
        count = cursor.rowcount
        if count == 0:
            dfindex = ts.get_index()
            inserttable(dfindex, '15:00')
        if (tradetimesql[0] != '15:00'):
            dfindex = ts.get_index()
            #dfindex.insert(2,'tradeTimehm','15:00')
            inserttable(dfindex, '15:00')

    def realdata():
        dfindex = ts.get_index()
        #dfindex.insert(2,'tradeTimehm',nowhm)
        inserttable(dfindex, nowhm)
        #print "real"

    if inputtradetime == todaydate:
        start_hm_a = '0830'
        end_hm_a = '1130'
        start_hm_p = '1300'
        end_hm_p = '1500'
        #中午休市时间
        if (timecheck.compare_hourmin(now_hm, end_hm_a, start_hm_p)):
            notrealdatanoon()
        #开市时间
        elif (timecheck.compare_hourmin(now_hm, start_hm_a, end_hm_a)
              or timecheck.compare_hourmin(now_hm, start_hm_p, end_hm_p)):
            realdata()
        #晚上停市时间
        #if(int(now_hm) > int(end_hm_p)):
        else:
            notrealdatanight()
    else:
        notrealdata()
Ejemplo n.º 10
0
def typeinfo(countind, caltb_name, datatb_name, type_name):

    #countind = 49
    type_info = [[] for i in range(countind)]
    for i in range(0, countind):
        if type_name == 'industry':
            type_info[i].extend(gettypei(typedata.industry[i], datatb_name))
        elif type_name == 'area':
            type_info[i].extend(gettypei(typedata.area[i], datatb_name))
        elif type_name == 'concept':
            type_info[i].extend(gettypei(typedata.concept[i], datatb_name))

    #print type_info
    #print type(type_info[0][0])
    #print type_info[0][0]
    typeindustryinfo = []
    avg_ch_pt = []
    avg_weight_ch_pt = []
    turnoverVol_all = []
    max_chpt_name = []
    count_chpt_per = []
    avg_market_per = []
    avg_turnoverRate = []
    avg_pe = []
    for i in range(0, countind):
        typeindustryinfo.append(type_info[i][0])
        avg_ch_pt.append(type_info[i][1])
        avg_weight_ch_pt.append(type_info[i][2])
        turnoverVol_all.append(type_info[i][3])
        max_chpt_name.append(type_info[i][4])
        count_chpt_per.append(type_info[i][5])
        avg_market_per.append(type_info[i][6])
        avg_turnoverRate.append(type_info[i][7])
        avg_pe.append(type_info[i][8])
        #print typeindustryinfo

    type_infodata = {
        'typeinfo': typeindustryinfo,
        'avg_ch_pt': avg_ch_pt,
        'avg_weight_ch_pt': avg_weight_ch_pt,
        'turnoverVol_all': turnoverVol_all,
        'max_chpt_name': max_chpt_name,
        'count_chpt_per': count_chpt_per,
        'avg_market_per': avg_market_per,
        'avg_turnoverRate': avg_turnoverRate,
        'avg_pe': avg_pe
    }
    frame = pd.DataFrame(type_infodata,
                         columns=[
                             'typeinfo', 'avg_ch_pt', 'avg_weight_ch_pt',
                             'turnoverVol_all', 'max_chpt_name',
                             'count_chpt_per', 'avg_market_per',
                             'avg_turnoverRate', 'avg_pe'
                         ])
    tradetime = timecheck.getweekday(todaydate, '1530')
    frame.insert(8, 'tradetime', tradetime)
    #print frame
    frame.to_sql('%s' % (caltb_name), engine, if_exists='append')
    #print typeindustryinfo,avg_pe
    return type_info


#typeinfo(46,'cal_industryinfo','sec_typeindustry','industry')
#typeinfo(32,'cal_areainfo','sec_typearea','area')
#typeinfo(156,'cal_conceptinfo','sec_typeconcept','concept')
Ejemplo n.º 11
0
#!usr/bin/python
#-*- coding: UTF-8 -*-
import timecheck
import checktddata
import MySQLdb
db = MySQLdb.connect("127.0.0.1","root","root","db_mkt",charset='utf8' )
cursor = db.cursor()

tradetime = timecheck.getweekday(todaydate,'1530')
tradetime = checktddata.check_mktequd(tradetime)