z 4 éve
szülő
commit
42875965c1
6 módosított fájl, 28 hozzáadás és 16 törlés
  1. 12 6
      StockRestData.py
  2. BIN
      __pycache__/db_config.cpython-38.pyc
  3. 12 6
      bondRestData.py
  4. 2 2
      db_config.py
  5. 1 1
      startGetHistData.py
  6. 1 1
      startGetRestData.py

+ 12 - 6
StockRestData.py

@@ -11,12 +11,18 @@ from threading import Thread
 import db_config
 
 def csqCallback(quantdata):
-    try:
-        fileName = "/www/wwwroot/csqdata/stock/" + str(round(time.time() * 1000000)) + ".txt"
-        with open(fileName, 'w', encoding="utf-8") as file:
-            file.write(quantdata.Data)
-    except Exception as e:
-        print(str(e))
+    current_time = datetime.strftime(datetime.now(),"%H:%M:%S") 
+    time1 = "09:15:00"
+    time2 = "11:30:00"
+    time3 = "13:00:00"
+    time4 = "15:00:00"
+    if (current_time > time1 and current_time < time2) or (current_time > time3 and current_time < time4):
+        try:
+            fileName = "/www/wwwroot/csqdata/stock/" + str(round(time.time() * 1000000)) + ".txt"
+            with open(fileName, 'w', encoding="utf-8") as file:
+                file.write(quantdata.Data)
+        except Exception as e:
+            print(str(e))
 
 class StockRestData:
 

BIN
__pycache__/db_config.cpython-38.pyc


+ 12 - 6
bondRestData.py

@@ -11,12 +11,18 @@ from threading import Thread
 import db_config
 
 def csqCallback(quantdata):
-    try:
-        fileName = "/www/wwwroot/csqdata/bond/" + str(round(time.time() * 1000000)) + ".txt"
-        with open(fileName, 'w', encoding="utf-8") as file:
-            file.write(str(quantdata.Data))
-    except Exception as e:
-        print(str(e))
+    current_time = datetime.strftime(datetime.now(),"%H:%M:%S") 
+    time1 = "09:15:00"
+    time2 = "11:30:00"
+    time3 = "13:00:00"
+    time4 = "15:00:00"
+    if (current_time > time1 and current_time < time2) or (current_time > time3 and current_time < time4):
+        try:
+            fileName = "/www/wwwroot/csqdata/bond/" + str(round(time.time() * 1000000)) + ".txt"
+            with open(fileName, 'w', encoding="utf-8") as file:
+                file.write(str(quantdata.Data))
+        except Exception as e:
+            print(str(e))
     
 
 class BondRestData:

+ 2 - 2
db_config.py

@@ -1,5 +1,5 @@
-host = 'hk-cdb-mw8z8p47.sql.tencentcdb.com' # 连接名称,默认127.0.0.1 
-port = 63791 # 端口,默认为3306
+host = 'bj-cdb-1j873yci.sql.tencentcdb.com' # 连接名称,默认127.0.0.1 
+port = 61196 # 端口,默认为3306
 user = 'root' # 用户名
 passwd='TestBicon@123' # 密码
 

+ 1 - 1
startGetHistData.py

@@ -68,7 +68,7 @@ async def main():
 # 每天执行一次  运行时间在每天停盘之后到第二天开盘之前就行
 try:
     #调用登录函数(激活后使用,不需要用户名密码)
-    loginResult = c.start("ForceLogin=1", '', mainCallback)
+    loginResult = c.start("LoginMode=SXDL,PhoneNumber=15387568630", '', mainCallback)
     if(loginResult.ErrorCode != 0):
         print("login in fail")
         exit()

+ 1 - 1
startGetRestData.py

@@ -52,7 +52,7 @@ async def getBondRest():
 # 运行了就不会停了
 try:
     #调用登录函数(激活后使用,不需要用户名密码)
-    loginResult = c.start("ForceLogin=1", '', mainCallback)
+    loginResult = c.start("LoginMode=SXDL,PhoneNumber=15387568630", '', mainCallback)
     if(loginResult.ErrorCode != 0):
         print("login in fail")
         exit()