日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python官方论坛_python

發(fā)布時(shí)間:2024/5/15 python 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python官方论坛_python 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

不訴 2017-2-10 13:53

用python取sqlserver實(shí)時(shí)行情數(shù)據(jù),與產(chǎn)品組合匹配后,推送給influxdb 事件模塊代碼: # encoding: UTF-8 # 系統(tǒng)模塊 from Queue import Queue , Empty from threading import * ######################################################################## class EventManager : #---------------------------------------------------------------------- def __init__ ( self ): """初始化事件管理器""" # 事件對象列表 self .__eventQueue = Queue() # 事件管理器開關(guān) self .__active = False # 事件處理線程 self .__thread = Thread( target = self .__Run) # 這里的__handlers是一個(gè)字典,用來保存對應(yīng)的事件的響應(yīng)函數(shù) # 其中每個(gè)鍵對應(yīng)的值是一個(gè)列表,列表中保存了對該事件監(jiān)聽的響應(yīng)函數(shù),一對多 self .__handlers = {} #---------------------------------------------------------------------- def __Run ( self ): """引擎運(yùn)行""" while self .__active == True : try : # 獲取事件的阻塞時(shí)間設(shè)為1秒 event = self .__eventQueue.get( block = True , timeout = 1 ) self .__EventProcess(event) except Empty: pass #---------------------------------------------------------------------- def __EventProcess ( self , event): """處理事件""" # 檢查是否存在對該事件進(jìn)行監(jiān)聽的處理函數(shù) if event.type_ in self .__handlers: # 若存在,則按順序?qū)⑹录鬟f給處理函數(shù)執(zhí)行 for handler in self .__handlers : handler(event) #---------------------------------------------------------------------- def Start ( self ): """啟動(dòng)""" # 將事件管理器設(shè)為啟動(dòng) self .__active = True # 啟動(dòng)事件處理線程 self .__thread.start() #---------------------------------------------------------------------- def Stop ( self ): """停止""" # 將事件管理器設(shè)為停止 self .__active = False # 等待事件處理線程退出 self .__thread.join() #---------------------------------------------------------------------- def AddEventListener ( self , type_ , handler): """綁定事件和監(jiān)聽器處理函數(shù)""" # 嘗試獲取該事件類型對應(yīng)的處理函數(shù)列表,若無則創(chuàng)建 try : handlerList = self .__handlers except KeyError : handlerList = = handlerList # 若要注冊的處理器不在該事件的處理器列表中,則注冊該事件 if handler not in handlerList: handlerList.append(handler) #---------------------------------------------------------------------- def RemoveEventListener ( self , type_ , handler): """移除監(jiān)聽器的處理函數(shù)""" #讀者自己試著實(shí)現(xiàn) #---------------------------------------------------------------------- def SendEvent ( self , event): """發(fā)送事件,向事件隊(duì)列中存入事件""" self .__eventQueue.put(event) ######################################################################## """事件對象""" class Event : def __init__ ( self , type_= None ): self .type_ = type_ # 事件類型 self .list = 主程序代碼 #!/usr/bin/python # -*- coding: UTF-8 -*- import pymssql import time import datetime #import numpy import decimal #import threading from influxdb import InfluxDBClient #from datetime import datetime #from threading import * from EventManager import * dbhost = '192.168.1.101' dbuser = 'jiyang.wang' dbuser_password = 'Amc_0001' dbhost1 = '10.200.66.125' user = 'root' password = 'root' TradingDB = 'TradingDB' TShengYunDB = 'TShengYunDB' HBTG = 'HBTG' indbname = 'DailyPositionDB' host = 'localhost' port = 8086 StatArb2_Target_500 = dObPV8hL27H26 = dObPV10hL24H23 = GE_PE = Sig_1 = H8 = PVI = V2 = VM1 = E2 = tick_IF = * num client = InfluxDBClient(host , port , user , password , indbname) #事件名稱 行情 EVENT_Tick = 'tick' #事件源 公眾號 class PublicAccounts : def __init__ ( self , eventManager): self .__eventManager = eventManager def Get_Tick ( self ): #事件對象,新行情進(jìn)來 var = 1 event = Event( type_ =EVENT_Tick) con = pymssql.connect(dbhost , dbuser , dbuser_password , TShengYunDB , charset = 'utf8' ) while var == 1 : current_timestamp = datetime.datetime.now() current_timestamp = current_timestamp - datetime.timedelta( minutes = 2 ) current_timestamp = current_timestamp.strftime( "%H:%M:%S" ) # current_timestamp = '14:55:00' if current_timestamp '15:00:00' : break if (current_timestamp '11:30:00' and current_timestamp '13:00:00' ) or current_timestamp '09:30:00' : time.sleep( 3 ) continue sql1 = '''select AA. * from HB_lnk.HBTG.dbo.Tick_SH AA join(select max (id) as id from HB_lnk.HBTG.dbo.Tick_SH A where %s group by tkr ) BB on AA.id=BB.id union all select AA. * from HB_lnk.HBTG.dbo.Tick_SZ AA join( select max (id) as id from HB_lnk.HBTG.dbo.Tick_SZ A where %s group by tkr ) BB on AA.id=BB.id''' try : cur1 = con.cursor() cur1.execute(sql1 , (current_timestamp , current_timestamp)) global tick tick = cur1.fetchall() except Exception , err: print "error: %s" % str (err) event.list = tick print ( "Tick is coming!" ) #發(fā)送事件 #sql1 = '''select AA.* from HB_lnk.HBTG.dbo.Tick_SH AA join(select max(id) as id from HB_lnk.HBTG.dbo.Tick_SH A where %s group by tkr ) BB on AA.id=BB.id union all select AA.* from HB_lnk.HBTG.dbo.Tick_SZ AA join( select max(id) as id from HB_lnk.HBTG.dbo.Tick_SZ A where %s group by tkr ) BB on AA.id=BB.id''' #cur1 = con.cursor() #cur1.execute(sql1, (current_timestamp, current_timestamp)) #global tick_IF #tick_IF = cur1.fetchall() #event.list_IF = tick_IF #print("Tick is coming!") self .__eventManager.SendEvent(event) time.sleep( 3 ) #print u'公眾號發(fā)送新文章\n' #監(jiān)聽器 訂閱者 class Listener : def __init__ ( self , username): self .__username = username #監(jiān)聽器的處理函數(shù) 讀文章 def StatArb2_Target_500 ( self , event): self .__username current_tick = event.list a = len (StatArb2_Target_500) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == StatArb2_Target_500 : b = round (StatArb2_Target_500 , 4 ) c = current_tick d = StatArb2_Target_500 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) # portfolio = (StatArb2_Target_500 , StatArb2_Target_500 , StatArb2_Target_500 , current_tick ) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "StatArb2_Target_500 working working!" ) # dObPV8hL27H26 def dObPV8hL27H26 ( self , event): self .__username current_tick = event.list a = len (dObPV8hL27H26) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == dObPV8hL27H26 : b = round (dObPV8hL27H26 , 4 ) c = current_tick d = dObPV8hL27H26 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "dObPV8hL27H26 working working!" ) #dObPV9hL23H22 def dObPV9hL23H22 ( self , event): self .__username current_tick = event.list a = len (dObPV9hL23H22) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == dObPV9hL23H22 : b = round (dObPV9hL23H22 , 4 ) c = current_tick d = dObPV9hL23H22 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "dObPV9hL23H22 working working!" ) # dObPV10hL24H23 def dObPV10hL24H23 ( self , event): self .__username current_tick = event.list a = len (dObPV10hL24H23) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == dObPV10hL24H23 : b = round (dObPV10hL24H23 , 4 ) c = current_tick d = dObPV10hL24H23 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "dObPV10hL24H23 working working!" ) # PVIL10H9 def PVIL10H9 ( self , event): self .__username current_tick = event.list a = len (PVIL10H9) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == PVIL10H9 : b = round (PVIL10H9 , 4 ) c = current_tick d = PVIL10H9 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "PVIL10H9 working working!" ) # GE_PE def GE_PE ( self , event): self .__username current_tick = event.list a = len (GE_PE) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == GE_PE : b = round (GE_PE , 4 ) c = current_tick d = GE_PE portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "GE_PE working working!" ) # cumR1L2ToL5 def cumR1L2ToL5 ( self , event): self .__username current_tick = event.list a = len (cumR1L2ToL5) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == cumR1L2ToL5 : b = round (cumR1L2ToL5 , 4 ) c = current_tick d = cumR1L2ToL5 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "cumR1L2ToL5 working working!" ) # Sig_1 def Sig_1 ( self , event): self .__username current_tick = event.list a = len (Sig_1) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == Sig_1 : b = round (Sig_1 , 4 ) c = current_tick d = Sig_1 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "Sig_1 working working!" ) # Sig_2 def Sig_2 ( self , event): self .__username current_tick = event.list a = len (Sig_2) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == Sig_2 : b = round (Sig_2 , 4 ) c = current_tick d = Sig_2 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "Sig_2 working working!" ) # H8 def H8 ( self , event): self .__username current_tick = event.list a = len (H8) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == H8 : b = round (H8 , 4 ) c = current_tick d = H8 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "H8 working working!" ) # H10 def H10 ( self , event): self .__username current_tick = event.list a = len (H10) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == H10 : b = round (H10 , 4 ) c = current_tick d = H10 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "H10 working working!" ) # PVI def PVI ( self , event): self .__username current_tick = event.list a = len (PVI) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == PVI : b = round (PVI , 4 ) c = current_tick d = PVI portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "PVI working working!" ) # V1 def V1 ( self , event): self .__username current_tick = event.list a = len (V1) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == V1 : b = round (V1 , 4 ) c = current_tick d = V1 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "V1 working working!" ) # V2 def V2 ( self , event): self .__username current_tick = event.list a = len (V2) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == V2 : b = round (V2 , 4 ) c = current_tick d = V2 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "V2 working working!" ) # D1 def D1 ( self , event): self .__username current_tick = event.list a = len (D1) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == D1 : b = round (D1 , 4 ) c = current_tick d = D1 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "D1 working working!" ) # VM1 def VM1 ( self , event): self .__username current_tick = event.list a = len (VM1) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == VM1 : b = round (VM1 , 4 ) c = current_tick d = VM1 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "VM1 working working!" ) # E1 def E1 ( self , event): self .__username current_tick = event.list a = len (E1) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == E1 : b = round (E1 , 4 ) c = current_tick d = E1 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "E1 working working!" ) # E2 def E2 ( self , event): self .__username current_tick = event.list a = len (E2) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == E2 : b = round (E2 , 4 ) c = current_tick d = E2 portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "E2 working working!" ) # StatFM def StatFM ( self , event): self .__username current_tick = event.list a = len (StatFM) portfolio = * a for i in range (a): for j in range ( len (current_tick)): if current_tick == StatFM : b = round (StatFM , 4 ) c = current_tick d = StatFM portfolio = ((c / d) - 1 ) * decimal.Decimal(b) portfoliomove = sum (portfolio) json_body = client.write_points(json_body) print ( "StatFM working working!" ) """權(quán)重函數(shù)""" def Get_TargetWeight (): sql2 = 'select CONVERT (varchar(10), MAX (TradingDate),23) from JYDB.dbo.QT_TradingDayNew where IfTradingDay=1 and TradingDate( CONVERT (varchar(10), GETDATE(), 23)) and SecuMarket=83' con2 = pymssql.connect(dbhost , dbuser , dbuser_password , TShengYunDB , charset = 'utf8' ) cur2 = con2.cursor() cur2.execute(sql2) day = cur2.fetchone() tradingday = '' .join(day) ################################################################## sql3 = '''select B.SecuCode,A.model_target,b.ClosePrice from ShengYunDB.dbo.StatArb2_Target_500 A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.model_target0 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) #roww = cur3.fetchall() global StatArb2_Target_500 StatArb2_Target_500 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.dObPV8hL27H26,b.ClosePrice from ShengYunDB.dbo.StatArb2_Target_500 A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.dObPV8hL27H260 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global dObPV8hL27H26 dObPV8hL27H26 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.dObPV9hL23H22,b.ClosePrice from ShengYunDB.dbo.StatArb2_Target_500 A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.dObPV9hL23H220 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global dObPV9hL23H22 dObPV9hL23H22 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.dObPV10hL24H23,b.ClosePrice from ShengYunDB.dbo.StatArb2_Target_500 A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.dObPV10hL24H230 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global dObPV10hL24H23 dObPV10hL24H23 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.PVIL10H9,b.ClosePrice from ShengYunDB.dbo.StatArb2_Target_500 A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.PVIL10H90 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global PVIL10H9 PVIL10H9 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.GE_PE,b.ClosePrice from ShengYunDB.dbo.StatArb2_Target_500 A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.GE_PE0 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global GE_PE GE_PE = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.cumR1L2ToL5,b.ClosePrice from ShengYunDB.dbo.StatArb_TargetPortfolios A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.cumR1L2ToL50 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global cumR1L2ToL5 cumR1L2ToL5 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.Sig_1,b.ClosePrice from ShengYunDB.dbo.StatArb2_Target_500 A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.Sig_10 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global Sig_1 Sig_1 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.Sig_2,b.ClosePrice from ShengYunDB.dbo.StatArb2_Target_500 A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.Sig_20 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global Sig_2 Sig_2 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.H8_w,b.ClosePrice from ShengYunDB.dbo.StatFM_Info A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.H8_w0 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global H8 H8 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.H10_W,b.ClosePrice from ShengYunDB.dbo.StatFM_Info A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.H10_W0 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global H10 H10 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.PVI_W,b.ClosePrice from ShengYunDB.dbo.StatFM_Info A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.PVI_W0 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global PVI PVI = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.V1_W,b.ClosePrice from ShengYunDB.dbo.StatFM_Info A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.V1_W0 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global V1 V1 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.V2_W,b.ClosePrice from ShengYunDB.dbo.StatFM_Info A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.V2_W0 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global V2 V2 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.D1_W,b.ClosePrice from ShengYunDB.dbo.StatFM_Info A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.D1_W0 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global D1 D1 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.VM1_W,b.ClosePrice from ShengYunDB.dbo.StatFM_Info A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.VM1_W0 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global VM1 VM1 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.E1_W,b.ClosePrice from ShengYunDB.dbo.StatFM_Info A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.E1_W0 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global E1 E1 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.E2_W,b.ClosePrice from ShengYunDB.dbo.StatFM_Info A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.E2_W0 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global E2 E2 = cur3.fetchall() ################################################################## sql3 = '''select B.SecuCode,A.Total_W,b.ClosePrice from ShengYunDB.dbo.StatFM_Info A left join ShengYunDB.dbo.StockDailyTrading B on A.InnerCode=B.InnerCode where A.Total_W0 and A.TradingDay=%s and b.TradingDay=%s''' cur3 = con2.cursor() cur3.execute(sql3 , (tradingday , tradingday)) # roww = cur3.fetchall() global StatFM StatFM = cur3.fetchall() """主函數(shù)""" #-------------------------------------------------------------------- def main (): Get_TargetWeight() listner1 = Listener( "StatArb2_Target_500" ) #訂閱者1 listner2 = Listener( "dObPV8hL27H26" ) #訂閱者2 listner3 = Listener( "dObPV9hL23H22" ) # 訂閱者2 listner4 = Listener( "dObPV10hL24H23" ) # 訂閱者2 listner5 = Listener( "PVIL10H9" ) # 訂閱者2 listner6 = Listener( "GE_PE" ) # 訂閱者2 listner7 = Listener( "cumR1L2ToL5" ) # 訂閱者2 listner8 = Listener( "Sig_1" ) # 訂閱者2 listner9 = Listener( "Sig_2" ) # 訂閱者2 listner10 = Listener( "H8" ) # 訂閱者2 listner11 = Listener( "H10" ) # 訂閱者2 listner12 = Listener( "PVI" ) # 訂閱者2 listner13 = Listener( "V1" ) # 訂閱者2 listner14 = Listener( "V2" ) # 訂閱者2 listner15 = Listener( "D1" ) # 訂閱者2 listner16 = Listener( "VM1" ) # 訂閱者2 listner17 = Listener( "E1" ) # 訂閱者2 listner18 = Listener( "E2" ) # 訂閱者2 listner19 = Listener( "StatFM" ) # 訂閱者2 eventManager = EventManager() #綁定事件和監(jiān)聽器響應(yīng)函數(shù)(新文章) eventManager.AddEventListener(EVENT_Tick , listner1.StatArb2_Target_500) eventManager.AddEventListener(EVENT_Tick , listner2.dObPV8hL27H26) eventManager.AddEventListener(EVENT_Tick , listner3.dObPV9hL23H22) eventManager.AddEventListener(EVENT_Tick , listner4.dObPV10hL24H23) eventManager.AddEventListener(EVENT_Tick , listner5.PVIL10H9) eventManager.AddEventListener(EVENT_Tick , listner6.GE_PE) eventManager.AddEventListener(EVENT_Tick , listner7.cumR1L2ToL5) eventManager.AddEventListener(EVENT_Tick , listner8.Sig_1) eventManager.AddEventListener(EVENT_Tick , listner9.Sig_2) eventManager.AddEventListener(EVENT_Tick , listner10.H8) eventManager.AddEventListener(EVENT_Tick , listner11.H10) eventManager.AddEventListener(EVENT_Tick , listner12.PVI) eventManager.AddEventListener(EVENT_Tick , listner13.V1) eventManager.AddEventListener(EVENT_Tick , listner14.V2) eventManager.AddEventListener(EVENT_Tick , listner15.D1) eventManager.AddEventListener(EVENT_Tick , listner16.VM1) eventManager.AddEventListener(EVENT_Tick , listner17.E1) eventManager.AddEventListener(EVENT_Tick , listner18.E2) eventManager.AddEventListener(EVENT_Tick , listner19.StatFM) eventManager.Start() publicAcc = PublicAccounts(eventManager) #timer = Timer(2, publicAcc.Get_Tick) #timer.start() publicAcc.Get_Tick() if __name__ == '__main__' : main()

總結(jié)

以上是生活随笔為你收集整理的python官方论坛_python的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。