z 4 年 前
コミット
74093c0d4f
49 ファイル変更1018 行追加896 行削除
  1. 1 1
      .vscode/launch.json
  2. 75 0
      BondStructure.py
  3. 124 0
      ForexHistData.py
  4. 7 7
      structure/StockStructure.py
  5. 4 2
      hist/FundHistData.py
  6. 69 0
      FundStructure.py
  7. 54 0
      LimitUpNewsData.py
  8. 2 1
      hist/StockHkHistData.py
  9. 3 2
      structure/StockHkStructure.py
  10. 10 12
      StockRestData.py
  11. 80 0
      StockStructure.py
  12. 2 1
      hist/StockUsaHistData.py
  13. 66 0
      StockUsaStructure.py
  14. 348 0
      TempIndexHistData.py
  15. 35 0
      TempIndexRestData.py
  16. BIN
      __pycache__/BondHistData.cpython-38.pyc
  17. BIN
      __pycache__/BondRestData.cpython-38.pyc
  18. BIN
      __pycache__/BondStructure.cpython-38.pyc
  19. BIN
      __pycache__/ForexHistData.cpython-38.pyc
  20. BIN
      __pycache__/ForexStructure.cpython-38.pyc
  21. BIN
      __pycache__/FundHistData.cpython-38.pyc
  22. BIN
      __pycache__/FundStructure.cpython-38.pyc
  23. BIN
      __pycache__/SotckHistData.cpython-38.pyc
  24. BIN
      __pycache__/StockHkHistData.cpython-38.pyc
  25. BIN
      __pycache__/StockHkStructure.cpython-38.pyc
  26. BIN
      __pycache__/StockRestData.cpython-38.pyc
  27. BIN
      __pycache__/StockStructure.cpython-38.pyc
  28. BIN
      __pycache__/StockUsaHistData.cpython-38.pyc
  29. BIN
      __pycache__/StockUsaStructure.cpython-38.pyc
  30. BIN
      __pycache__/TempIndexHistData.cpython-38.pyc
  31. BIN
      __pycache__/TempIndexRestData.cpython-38.pyc
  32. BIN
      __pycache__/db_config.cpython-38.pyc
  33. 8 11
      bondRestData.py
  34. 10 5
      db_config.py
  35. 10 10
      getCst.py
  36. 0 120
      getLimitUpNewsData.py
  37. 0 112
      getStockList_jijinData.py
  38. 0 109
      getStockList_meiguData.py
  39. 0 109
      getStockList_waihuiData.py
  40. 0 143
      getStockList_zhaiquanData.py
  41. 0 0
      hist/__init__.py
  42. 0 0
      rest/__init__.py
  43. 44 25
      startGetHistData.py
  44. 20 2
      startGetRestData.py
  45. 30 21
      startGetStructure.py
  46. 0 0
      structure/__init__.py
  47. 16 47
      test.py
  48. 0 95
      test1.py
  49. 0 61
      test2.py

+ 1 - 1
.vscode/launch.json

@@ -8,7 +8,7 @@
             "name": "Python: 当前文件",
             "type": "python",
             "stopOnEntry": false,
-            "pythonPath": "${command:python.interpreterPath}",
+            "python": "${command:python.interpreterPath}",
             "request": "launch",
             "program": "${file}",
             "console": "integratedTerminal"

ファイルの差分が大きいため隠しています
+ 75 - 0
BondStructure.py


ファイルの差分が大きいため隠しています
+ 124 - 0
ForexHistData.py


+ 7 - 7
structure/StockStructure.py

@@ -4,29 +4,29 @@ __author__ = 'weijie'
 
 from EmQuantAPI import *
 from datetime import timedelta, datetime
+# import time as _time
 import time
 import traceback
 from StockPojo import StockPojo
+from StockHistPojo import StockHistPojo
 from dbOperation import dbOperation
 import db_config
 import pandas as pd
 import json
 import array
 
-class StockStructure:
-
+# 初始化外汇表 112002 全部外汇
+class ForexStructure:
     def toGet(self):
         try:
             getDataTime = time.strftime('%Y-%m-%d',time.localtime(time.time()))
-            #获取A股所有数据 并且入库
-            data = c.sector("001004", getDataTime) # 001004 全部A股板块
+            data = c.sector("112002", getDataTime)
             if data.ErrorCode != 0:
                 print("request sector Error, ", data.ErrorMsg)
             else:
                 print("sector输出结果======分隔线======")
-                # print(data.Data)
                 stockPojoList = []
-                db = dbOperation(db_config.db_gupiao)
+                db = dbOperation(db_config.db_waihui)
                 for inx, code in enumerate(data.Data):
                     if(inx % 2 != 1):
                         stockPojo = StockPojo()
@@ -63,4 +63,4 @@ class StockStructure:
             print("error >>>",ee)
             traceback.print_exc()
         else:
-            print("demo end")
+            print("外汇表初始化完成")

+ 4 - 2
hist/FundHistData.py

@@ -13,12 +13,14 @@ import json
 import array
 import db_config
 from dbOperation import dbOperation
+
+# 基金
 class FundHistData:
     def toGet(self):
         try:
             # csd使用范例
             db = dbOperation(db_config.db_jijin)
-            stockPojoList = db.query_list("select id, code, name, list_date listDate from t_stock_base_info where is_hist_add = 0 limit 1")
+            stockPojoList = db.query_list("select id, code, name, list_date listDate from t_stock_base_info where is_hist_add = 0 and code not like '%OF' limit 1")
             getDataTime = time.strftime('%Y-%m-%d',time.localtime(time.time()))
             for stockPojo in stockPojoList:
                 # print(str(stockPojo['code']))
@@ -121,4 +123,4 @@ class FundHistData:
             print("error >>>",ee)
             traceback.print_exc()
         else:
-            print("demo end")
+            print("获取历史基金结束")

ファイルの差分が大きいため隠しています
+ 69 - 0
FundStructure.py


+ 54 - 0
LimitUpNewsData.py

@@ -0,0 +1,54 @@
+# -*- coding:utf-8 -*-
+
+__author__ = 'weijie'
+
+from EmQuantAPI import *
+from datetime import timedelta, datetime
+from time import sleep
+import traceback
+import requests
+import re
+from dbOperationStock import dbOperationStock
+import db_config
+import json
+
+def cnqCallback(quantdata):
+    url = 'http://taifooksec.com/api/news/batchAddNews.do'
+    newsList = []
+    for code in quantdata.Data:
+        for k in range(0, len(quantdata.Data[code])):
+            se = requests.session()
+            url = "http://app.jg.eastmoney.com/NewsData/GetNewsText.do?cid=Admin&cid=Admin&id=" + quantdata.Data[code][k][5]
+            dfNews = se.post(url).text.replace("'", '"').replace('/ ', '/')
+            dfNew = eval(dfNews)
+            content = str(dfNew['text']).replace("<a","<span").replace("/a>","/span>")
+            pattern = 'https://z1.*?\.jpg'
+            p2 = re.findall(pattern, str(content))
+            imgUrl = "http://taifooksec.com/public/default.png"
+            if(0 != len(p2)) :
+                imgUrl = p2[0]
+            news = {}
+            news['title'] = str(dfNew['Title'])
+            news['cover'] = str(imgUrl)
+            news['content'] = str(content)
+            news['source'] = str(dfNew['medianame'])
+            news['hot'] = "0"
+            news['publishTime'] = str(dfNew['Date'])
+            newsList.append(news)
+    headers = {'Content-Type': 'application/json'}
+    response = requests.post(url=url, headers=headers, data=json.dumps(newsList))
+
+class LimitUpNewsData:
+
+    def toGet(self):
+        try:
+            data = c.cnq("S888005002API,S888005003API,S888005004API,S888005005API,S888005010API,S888005008API,S888005009API","sectornews","",cnqCallback)
+            if data.ErrorCode != 0:
+                print("request cnq Error, ", data.ErrorMsg)
+            else:
+                print("cnq输出结果======分隔线======")
+        except Exception as ee:
+            print("error >>>",ee)
+            traceback.print_exc()
+        else:
+            print("demo end")

+ 2 - 1
hist/StockHkHistData.py

@@ -14,6 +14,7 @@ import json
 import array
 import db_config
 
+# 港股
 class StockHkHistData:
 
     def toGet(self):
@@ -127,4 +128,4 @@ class StockHkHistData:
             print("error >>>",ee)
             traceback.print_exc()
         else:
-            print("demo end")
+            print("获取历史港股结束")

+ 3 - 2
structure/StockHkStructure.py

@@ -15,12 +15,13 @@ import json
 import array
 
 
+# 港股
 class StockHkStructure:
 
     def toGet(self):
         try:
             getDataTime = time.strftime('%Y-%m-%d',time.localtime(time.time()))
-            #获取全部基金 并且入库
+            # 401001 港股
             data = c.sector("401001", getDataTime)
             if data.ErrorCode != 0:
                 print("request sector Error, ", data.ErrorMsg)
@@ -65,4 +66,4 @@ class StockHkStructure:
             print("error >>>",ee)
             traceback.print_exc()
         else:
-            print("demo end")
+            print("港股表初始化完成")

ファイルの差分が大きいため隠しています
+ 10 - 12
StockRestData.py


ファイルの差分が大きいため隠しています
+ 80 - 0
StockStructure.py


+ 2 - 1
hist/StockUsaHistData.py

@@ -14,6 +14,7 @@ import json
 import array
 import db_config
 
+# 美股
 class StockUsaHistData:
 
     def toGet(self):
@@ -125,4 +126,4 @@ class StockUsaHistData:
             print("error >>>",ee)
             traceback.print_exc()
         else:
-            print("demo end")
+            print("获取历史美股结束")

ファイルの差分が大きいため隠しています
+ 66 - 0
StockUsaStructure.py


ファイルの差分が大きいため隠しています
+ 348 - 0
TempIndexHistData.py


+ 35 - 0
TempIndexRestData.py

@@ -0,0 +1,35 @@
+__author__ = 'weijie'
+
+from EmQuantAPI import *
+from datetime import timedelta, datetime
+import time
+import traceback
+import json
+from StockRestPojo import StockRestPojo
+from dbOperation import dbOperation
+from threading import Thread
+import db_config
+
+def csqCallback(quantdata):
+    current_time = datetime.strftime(datetime.now(),"%H:%M:%S") 
+    time1 = "09:15:00"
+    time2 = "11:30:00"
+    time3 = "12:59: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/tempindex/" + 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 TempIndexRestData:
+
+    def toGet(self):
+        try:
+            data = c.csq("000001.SH,399001.SZ,399006.SZ","Date,Time,Now,High,Low,Open,PreClose,Roundlot,Volume,Amount,Change,PctChange,Speed",'Pushtype=2',csqCallback)
+            print(data)
+        except Exception as ee:
+            print("error >>>",ee)
+            traceback.print_exc()

BIN
__pycache__/BondHistData.cpython-38.pyc


BIN
__pycache__/BondRestData.cpython-38.pyc


BIN
__pycache__/BondStructure.cpython-38.pyc


BIN
__pycache__/ForexHistData.cpython-38.pyc


BIN
__pycache__/ForexStructure.cpython-38.pyc


BIN
__pycache__/FundHistData.cpython-38.pyc


BIN
__pycache__/FundStructure.cpython-38.pyc


BIN
__pycache__/SotckHistData.cpython-38.pyc


BIN
__pycache__/StockHkHistData.cpython-38.pyc


BIN
__pycache__/StockHkStructure.cpython-38.pyc


BIN
__pycache__/StockRestData.cpython-38.pyc


BIN
__pycache__/StockStructure.cpython-38.pyc


BIN
__pycache__/StockUsaHistData.cpython-38.pyc


BIN
__pycache__/StockUsaStructure.cpython-38.pyc


BIN
__pycache__/TempIndexHistData.cpython-38.pyc


BIN
__pycache__/TempIndexRestData.cpython-38.pyc


BIN
__pycache__/db_config.cpython-38.pyc


+ 8 - 11
bondRestData.py

@@ -14,7 +14,7 @@ def csqCallback(quantdata):
     current_time = datetime.strftime(datetime.now(),"%H:%M:%S") 
     time1 = "09:15:00"
     time2 = "11:30:00"
-    time3 = "13:00:00"
+    time3 = "12:59:00"
     time4 = "15:00:00"
     if (current_time > time1 and current_time < time2) or (current_time > time3 and current_time < time4):
         try:
@@ -24,7 +24,6 @@ def csqCallback(quantdata):
         except Exception as e:
             print(str(e))
     
-
 class BondRestData:
 
     def toGet(self):
@@ -33,18 +32,16 @@ class BondRestData:
             stockPojoList = db.query_list("select id, code, name, list_date listDate, seralid from t_stock_base_info where is_rest_add = 0 order by id asc")
             # 拼接证券代码
             codesStr = ""
-            i = 1
+            i = 0
             for stockPojo in stockPojoList:
-                if 0 != i%500 :
-                    codesStr = codesStr + stockPojo['code'] + ','
+                i = i + 1
+                codesStr = codesStr + stockPojo['code'] + ','
                 if 0 == i%500 or str(i) == str(len(stockPojoList)):
-                    if(codesStr != ""):
-                        #实时行情订阅使用范例
-                        codesStr = codesStr[:-1]
-                        data = c.csq(codesStr, 'Date,Time,Now,High,Low,Open,PreClose,Roundlot,Change,PctChange,Volume,Amount,BuyPrice1,BuyPrice2,BuyPrice3,BuyPrice4,BuyPrice5,BuyVolume1,BuyVolume2,BuyVolume3,BuyVolume4,BuyVolume5,SellPrice1,SellPrice2,SellPrice3,SellPrice4,SellPrice5,SellVolume1,SellVolume2,SellVolume3,SellVolume4,SellVolume5','Pushtype=2',csqCallback)
-                        print(data)
+                    #实时行情订阅使用范例
+                    codesStr = codesStr[:-1]
+                    data = c.csq(codesStr, 'Date,Time,Now,High,Low,Open,PreClose,Roundlot,Change,PctChange,Volume,Amount,BuyPrice1,BuyPrice2,BuyPrice3,BuyPrice4,BuyPrice5,BuyVolume1,BuyVolume2,BuyVolume3,BuyVolume4,BuyVolume5,SellPrice1,SellPrice2,SellPrice3,SellPrice4,SellPrice5,SellVolume1,SellVolume2,SellVolume3,SellVolume4,SellVolume5','Pushtype=2',csqCallback)
+                    print(data)
                     codesStr = ""
-                i = i + 1
             db.close()
         except Exception as ee:
             print("error >>>",ee)

+ 10 - 5
db_config.py

@@ -1,12 +1,17 @@
-host = 'bj-cdb-1j873yci.sql.tencentcdb.com' # 连接名称,默认127.0.0.1 
+host = 'bj-cdb-1j873yci.sql.tencentcdb.com' # 连接名称,默认127.0.0.1
 port = 61196 # 端口,默认为3306
 user = 'root' # 用户名
 passwd='TestBicon@123' # 密码
 
-hoststock = '47.96.39.5' # 连接名称,默认127.0.0.1 
-portstock = 3306 # 端口,默认为3306
+# host = 'hk-cdb-mw8z8p47.sql.tencentcdb.com' # 连接名称,默认127.0.0.1
+# port = 63791 # 端口,默认为3306
+# user = 'root' # 用户名
+# passwd='TestBicon@123' # 密码
+
+hoststock = 'bj-cdb-1j873yci.sql.tencentcdb.com' # 连接名称,默认127.0.0.1
+portstock = 61196 # 端口,默认为3306
 userstock = 'root' # 用户名
-passwdstock ='root' # 密码
+passwdstock ='TestBicon@123' # 密码
 
 charset = 'utf8' # 字符编码
 
@@ -21,4 +26,4 @@ db_waihui = 'stock_data_waihui' #外汇
 db_zhaiquan = 'stock_data_zhaiquan' #债券
 
 
-db_stock = 'stock2chen' # 股票
+db_stock = 'stock' # 股票

+ 10 - 10
getCst.py

@@ -55,7 +55,7 @@ def cstCallBack(quantdata):
             if "None" == str(result[2][j]):
                 continue
             stockRestPojo = StockRestPojo()
-            stockRestPojo.date = "20201106"
+            stockRestPojo.date = "20201123"
             stockRestPojo.time = str(result[0][j])
             stockRestPojo.now = str(result[1][j])
             stockRestPojo.high = str(result[2][j])
@@ -103,10 +103,10 @@ def cstCallBack(quantdata):
 
             datTime = ""
             if len(str(result[0][j])) != 6:
-                datTime = time.mktime(time.strptime("202011060" + str(result[0][j]), "%Y%m%d%H%M%S"))
+                datTime = time.mktime(time.strptime("202011230" + str(result[0][j]), "%Y%m%d%H%M%S"))
                 stockRestPojo.realTime = str(int(datTime))
             else:
-                datTime = time.mktime(time.strptime("20201106" + str(result[0][j]), "%Y%m%d%H%M%S"))
+                datTime = time.mktime(time.strptime("20201123" + str(result[0][j]), "%Y%m%d%H%M%S"))
                 stockRestPojo.realTime = str(int(datTime))
 
             min_ = time.localtime(datTime).tm_min # 获取分钟
@@ -180,15 +180,15 @@ try:
         print("login in fail")
         exit()
     db = dbOperation(db_config.db_gupiao)
-    stockPojoList = db.query_list("select id, code, name, list_date listDate, seralid from t_stock_base_info where 1 = 1 order by id asc")
+    stockPojoList = db.query_list("select id, code, name, list_date listDate, seralid from t_stock_base_info where 1 = 1 and id > 216 order by id asc")
     # cst使用范例
     for stockPojo in stockPojoList:
-        sql = "SELECT count(1) count FROM data_rt_" + stockPojo['code'].replace(".", "_").lower() + " WHERE `date` = '20201106'"
-        count = db.query_one(sql)
-        if int(count['count']) <= 4000:
-            sql1 = "delete from data_rt_" + stockPojo['code'].replace(".", "_").lower() + " where date = '20201106'"
-            db.dele(sql1)
-            data = c.cst(stockPojo['code'], 'Time,Now,High,Low,Open,PreClose,Volume,Amount,HighLimit,LowLimit,BuyPrice1,BuyPrice2,BuyPrice3,BuyPrice4,BuyPrice5,BuyVolume1,BuyVolume2,BuyVolume3,BuyVolume4,BuyVolume5,SellPrice1,SellPrice2,SellPrice3,SellPrice4,SellPrice5,SellVolume1,SellVolume2,SellVolume3,SellVolume4,SellVolume5,ClosedTime,ClosedVolume,ClosedAmount', '093001', '150000','',cstCallBack)
+        # sql = "SELECT count(1) count FROM data_rt_" + stockPojo['code'].replace(".", "_").lower() + " WHERE `date` = '20201123'"
+        # count = db.query_one(sql)
+        # if int(count['count']) <= 4000:
+            # sql1 = "delete from data_rt_" + stockPojo['code'].replace(".", "_").lower() + " where date = '20201123'"
+            # db.dele(sql1)
+        data = c.cst(stockPojo['code'], 'Time,Now,High,Low,Open,PreClose,Volume,Amount,HighLimit,LowLimit,BuyPrice1,BuyPrice2,BuyPrice3,BuyPrice4,BuyPrice5,BuyVolume1,BuyVolume2,BuyVolume3,BuyVolume4,BuyVolume5,SellPrice1,SellPrice2,SellPrice3,SellPrice4,SellPrice5,SellVolume1,SellVolume2,SellVolume3,SellVolume4,SellVolume5,ClosedTime,ClosedVolume,ClosedAmount', '093001', '150000','',cstCallBack)
     db.close()
     input("press any key to quit cst \r\n")
 #退出

+ 0 - 120
getLimitUpNewsData.py

@@ -1,120 +0,0 @@
-# -*- coding:utf-8 -*-
-
-__author__ = 'weijie'
-
-from EmQuantAPI import *
-from datetime import timedelta, datetime
-import time as _time
-import traceback
-import requests
-import re
-from dbOperationStock import dbOperationStock
-import db_config
-
-print("开始了")
-def mainCallback(quantdata):
-    print ("mainCallback",str(quantdata))
-    #登录掉线或者 登陆数达到上线(即登录被踢下线) 这时所有的服务都会停止
-    if str(quantdata.ErrorCode) == "10001011" or str(quantdata.ErrorCode) == "10001009":
-        print ("Your account is disconnect. You can force login automatically here if you need.")
-    #行情登录验证失败(每次连接行情服务器时需要登录验证)或者行情流量验证失败时,会取消所有订阅,用户需根据具体情况处理
-    elif str(quantdata.ErrorCode) == "10001021" or str(quantdata.ErrorCode) == "10001022":
-        print ("Your all csq subscribe have stopped.")
-    #行情服务器断线自动重连连续6次失败(1分钟左右)不过重连尝试还会继续进行直到成功为止,遇到这种情况需要确认两边的网络状况
-    elif str(quantdata.ErrorCode) == "10002009":
-        print ("Your all csq subscribe have stopped, reconnect 6 times fail.")
-        # 行情订阅遇到一些错误(这些错误会导致重连,错误原因通过日志输出,统一转换成EQERR_QUOTE_RECONNECT在这里通知),正自动重连并重新订阅,可以做个监控
-    elif str(quantdata.ErrorCode) == "10002012":
-        print ("csq subscribe break on some error, reconnect and request automatically.")
-        # 资讯服务器断线自动重连连续6次失败(1分钟左右)不过重连尝试还会继续进行直到成功为止,遇到这种情况需要确认两边的网络状况
-    elif str(quantdata.ErrorCode) == "10002014":
-        print ("Your all cnq subscribe have stopped, reconnect 6 times fail.")
-    # 资讯订阅遇到一些错误(这些错误会导致重连,错误原因通过日志输出,统一转换成EQERR_INFO_RECONNECT在这里通知),正自动重连并重新订阅,可以做个监控
-    elif str(quantdata.ErrorCode) == "10002013":
-        print ("cnq subscribe break on some error, reconnect and request automatically.")
-    # 资讯登录验证失败(每次连接资讯服务器时需要登录验证)或者资讯流量验证失败时,会取消所有订阅,用户需根据具体情况处理
-    elif str(quantdata.ErrorCode) == "10001024" or str(quantdata.ErrorCode) == "10001025":
-        print("Your all cnq subscribe have stopped.")
-    else:
-        pass
-
-def cnqCallback(quantdata):
-    db = dbOperationStock(db_config.db_stock)
-    for code in data.Data:
-        # total = len(data.Data[code])
-        for k in range(0, len(data.Data[code])):
-            # print(data.Data[code][k])
-            # print(data.Data[code][k][7])
-            se = requests.session()
-            url = "http://app.jg.eastmoney.com/NewsData/GetNewsText.do?cid=Admin&cid=Admin&id=" + data.Data[code][k][5]
-            dfNews = se.post(url).text.replace("'", '"').replace('/ ', '/')
-            dfNew = eval(dfNews)
-            # print(dfNew)
-            content = str(dfNew['text']).replace("<a","<span").replace("/a>","/span>")
-            pattern = 'https://z1.*?\.jpg'
-            p2 = re.findall(pattern, str(content))
-            # print(p2)
-            imgUrl = "http://47.96.39.5:8080/public/default.png"
-            if(0 != len(p2)) :
-                imgUrl = p2[0]
-            sql = "insert into `news` (`title`, `cover`, `content`, `source`, `hot`, `publish_time`, `create_time`, `update_time`) values('" + str(dfNew['Title']) + "', '" + str(imgUrl) + "', '" + str(content) +"', '" + str(dfNew['medianame']) + "',0,'" + str(dfNew['Date']) + "',now(),now());"
-            # print(sql)
-            db.insert(sql)
-    db.close()
-
-
-try:
-    #调用登录函数(激活后使用,不需要用户名密码)
-    loginResult = c.start("ForceLogin=1", '', mainCallback)
-    if(loginResult.ErrorCode != 0):
-        print("login in fail")
-        exit()
-    # 资讯查询使用范例
-    data = c.cfn("S888005002API", "sectornews", eCfnMode_EndCount, "starttime=20201106010000,endtime=20201107,count=10")
-    print("cfn输出结果======分隔线======")
-    if (not isinstance(data, c.EmQuantData)):
-        print (data)
-    else:
-        if (data.ErrorCode != 0):
-            print("request cfn Error, ", data.ErrorMsg)
-        else:
-            db = dbOperationStock(db_config.db_stock)
-            for code in data.Data:
-                # total = len(data.Data[code])
-                for k in range(0, len(data.Data[code])):
-                    # print(data.Data[code][k])
-                    # print(data.Data[code][k][7])
-                    se = requests.session()
-                    url = "http://app.jg.eastmoney.com/NewsData/GetNewsText.do?cid=Admin&cid=Admin&id=" + data.Data[code][k][5]
-                    dfNews = se.post(url).text.replace("'", '"').replace('/ ', '/')
-                    dfNew = eval(dfNews)
-                    # print(dfNew)
-                    content = str(dfNew['text']).replace("<a","<span").replace("/a>","/span>")
-                    pattern = 'https://z1.*?\.jpg'
-                    p2 = re.findall(pattern, str(content))
-                    # print(p2)
-                    imgUrl = "http://47.96.39.5:8080/public/default.png"
-                    if(0 != len(p2)) :
-                        imgUrl = p2[0]
-                    sql = "insert into `news` (`title`, `cover`, `content`, `source`, `hot`, `publish_time`, `create_time`, `update_time`) values('" + str(dfNew['Title']) + "', '" + str(imgUrl) + "', '" + str(content) +"', '" + str(dfNew['medianame']) + "',0,'" + str(dfNew['Date']) + "',now(),now());"
-                    # print(sql)
-                    db.insert(sql)
-            db.close()
-
-    # # 资讯订阅使用范例 S888005009API 昨日涨停
-    data = c.cnq("S888005002API","sectornews","",cnqCallback)
-    if data.ErrorCode != 0:
-        print("request cnq Error, ", data.ErrorMsg)
-    else:
-        print("cnq输出结果======分隔线======")
-        text = input("press any key to cancel cnq \r\n")
-        # 取消订阅
-        data = c.cnqcancel(data.SerialID)
-
-#退出
-    data = logoutResult = c.stop()
-except Exception as ee:
-    print("error >>>",ee)
-    traceback.print_exc()
-else:
-    print("demo end")

ファイルの差分が大きいため隠しています
+ 0 - 112
getStockList_jijinData.py


ファイルの差分が大きいため隠しています
+ 0 - 109
getStockList_meiguData.py


ファイルの差分が大きいため隠しています
+ 0 - 109
getStockList_waihuiData.py


ファイルの差分が大きいため隠しています
+ 0 - 143
getStockList_zhaiquanData.py


+ 0 - 0
hist/__init__.py


+ 0 - 0
rest/__init__.py


+ 44 - 25
startGetHistData.py

@@ -3,9 +3,12 @@ import asyncio
 from EmQuantAPI import *
 import traceback
 from SotckHistData import SotckHistData
-# from StockHkHistData import StockHkHistData
-# from StockUsaHistData import StockUsaHistData
+from StockHkHistData import StockHkHistData
+from StockUsaHistData import StockUsaHistData
 from BondHistData import BondHistData
+from FundHistData import FundHistData
+from ForexHistData import ForexHistData
+from TempIndexHistData import TempIndexHistData
 
 def mainCallback(quantdata):
     print ("mainCallback",str(quantdata))
@@ -34,9 +37,9 @@ def mainCallback(quantdata):
         pass
 
 # 获取股票历史数据
-async def getStockHist():
-    sotckHistData = SotckHistData()
-    sotckHistData.toGet()
+# async def getStockHist():
+#     sotckHistData = SotckHistData()
+#     sotckHistData.toGet()
     
 # # 获取港股历史数据
 # async def getStockHkHist():
@@ -48,37 +51,53 @@ async def getStockHist():
 #     stockUsaHistData = StockUsaHistData()
 #     stockUsaHistData.toGet()
 
-# 获取债券历史数据
-async def getBondHist():
-    bondHistData = BondHistData()
-    bondHistData.toGet()
-
-# 获取指数历史数据
-async def getIndexHist():
-    print(2)
-
-async def main():
-    await asyncio.gather(
-        getStockHist(),
-        # getStockHkHist(),
-        # getStockUsaHist(),
-        getBondHist(),
-    )
 
 # 每天执行一次  运行时间在每天停盘之后到第二天开盘之前就行
 try:
     #调用登录函数(激活后使用,不需要用户名密码)
-    loginResult = c.start("LoginMode=SXDL,PhoneNumber=15387568630", '', mainCallback)
+    # loginResult = c.start("LoginMode=SXDL,PhoneNumber=15387568630", '', mainCallback)
+    loginResult = c.start("ForceLogin=1", '', mainCallback)
     if(loginResult.ErrorCode != 0):
         print("login in fail")
         exit()
-    asyncio.run(main())
+    # asyncio.run(main())
+
+    tempIndexHistData = TempIndexHistData()
+    tempIndexHistData.toGet1()
+    tempIndexHistData.toGet2()
+    tempIndexHistData.toGet3()
+
+    # # 获取股票历史数据
+    # sotckHistData = SotckHistData()
+    # sotckHistData.toGet()
+
+    # # 获取债券历史数据
+    # bondHistData = BondHistData()
+    # bondHistData.toGet()
 
+    # # 获取美股历史数据
+    # stockUsaHistData = StockUsaHistData()
+    # stockUsaHistData.toGet()
+
+    # # 获取港股历史数据
+    # stockHkHistData = StockHkHistData()
+    # stockHkHistData.toGet()
+
+    # # 获取基金历史数据 
+    # fundHistData = FundHistData()
+    # fundHistData.toGet()
+
+    # # 获取外汇历史数据
+    # forexHistData = ForexHistData()
+    # forexHistData.toGet()
+
+    # 获取指数历史数据
+    print("缺少指数")
+    
 except Exception as ee:
     print("error >>>",ee)
     #退出
     data = logoutResult = c.stop()
     traceback.print_exc()
 else:
-    print("demo end")
-    
+    print("demo end")

+ 20 - 2
startGetRestData.py

@@ -5,6 +5,8 @@ from EmQuantAPI import *
 import traceback
 from StockRestData import StockRestData
 from BondRestData import BondRestData
+from TempIndexRestData import TempIndexRestData
+from LimitUpNewsData import LimitUpNewsData
 
 def async_call(fn):
     def wrapper(*args, **kwargs):
@@ -49,18 +51,34 @@ async def getBondRest():
     print("开始债券")
     bondRestData.toGet()
 
+# 获取指数实时数据
+async def getIndexRest():
+    tempIndexRestData = TempIndexRestData()
+    print("开始指数")
+    tempIndexRestData.toGet()
+
+# 获取订阅新闻
+async def getLimitUpNewsData():
+    limitUpNewsData = LimitUpNewsData()
+    print("开始新闻")
+    limitUpNewsData.toGet()
+
 # 运行了就不会停了
 try:
     #调用登录函数(激活后使用,不需要用户名密码)
-    loginResult = c.start("LoginMode=SXDL,PhoneNumber=15387568630", '', mainCallback)
+    # loginResult = c.start("LoginMode=SXDL,PhoneNumber=15387568630", '', mainCallback)
+    loginResult = c.start("ForceLogin=1", '', mainCallback)
     if(loginResult.ErrorCode != 0):
         print("login in fail")
         exit()
     # data = c.csqcancel(0)
+    # data = c.csqcancel(-1)
     loop = asyncio.events.get_event_loop()
     tasks= [
         getStockRest(),
-        getBondRest()
+        getBondRest(),
+        getIndexRest(),
+        getLimitUpNewsData()
     ]
     loop.run_until_complete((asyncio.wait(tasks)))
     loop.close()

+ 30 - 21
startGetStructure.py

@@ -5,7 +5,10 @@ from EmQuantAPI import *
 import traceback
 from StockStructure import StockStructure
 from StockHkStructure import StockHkStructure
-
+from StockUsaStructure import StockUsaStructure
+from BondStructure import BondStructure
+from ForexStructure import ForexStructure
+from FundStructure import FundStructure
 
 def mainCallback(quantdata):
     print ("mainCallback",str(quantdata))
@@ -32,32 +35,39 @@ def mainCallback(quantdata):
         print("Your all cnq subscribe have stopped.")
     else:
         pass
-
-# 获取股票列表并生成数据库表
-async def getStockStructure():
+# 获取需要数据的数据结构
+try:
+    #调用登录函数(激活后使用,不需要用户名密码)
+    loginResult = c.start("ForceLogin=1", '', mainCallback)
+    if(loginResult.ErrorCode != 0):
+        print("login in fail")
+        exit()
+    # asyncio.run(main())
+    print("开始初始化=======股票表")
     stockStructure = StockStructure()
     stockStructure.toGet()
 
-# 获取港股列表并生成数据库表
-async def getStockHkStructure():
+    print("开始初始化=======债券表")
+    bondStructure = BondStructure()
+    bondStructure.toGet()  
+
+    print("开始初始化=======港股")
     stockHkStructure = StockHkStructure()
     stockHkStructure.toGet()  
+
+    print("开始初始化=======美股")
+    stockUsaStructure = StockUsaStructure()
+    stockUsaStructure.toGet()  
     
+    print("开始初始化=======外汇")
+    forexStructure = ForexStructure()
+    forexStructure.toGet()
 
-async def main():
-    await asyncio.gather(
-        getStockStructure(),
-        getStockHkStructure(),
-    )
+    print("开始初始化=======基金")
+    fundStructure = FundStructure()
+    fundStructure.toGet()
 
-# 获取需要数据的数据结构
-try:
-    #调用登录函数(激活后使用,不需要用户名密码)
-    loginResult = c.start("ForceLogin=1", '', mainCallback)
-    if(loginResult.ErrorCode != 0):
-        print("login in fail")
-        exit()
-    asyncio.run(main())
+    print("缺少指数")
 
 except Exception as ee:
     print("error >>>",ee)
@@ -65,5 +75,4 @@ except Exception as ee:
     data = logoutResult = c.stop()
     traceback.print_exc()
 else:
-    print("demo end")
-    
+    print("数据库表初始化完成")

+ 0 - 0
structure/__init__.py


+ 16 - 47
test.py

@@ -1,50 +1,19 @@
-# -*- coding:utf-8 -*-
-
-__author__ = 'weijie'
-
-from EmQuantAPI import *
-import datetime
-import time
-import traceback
+import requests
 import json
-from StockRestPojo import StockRestPojo
-from dbOperation import dbOperation
-
-# print("开始了")
-# datTime = datetime.datetime.strptime("2020-1-23", "%Y-%m-%d")
-# print(datTime)
-
-
-
-
-
-# year = time.localtime(datTime1).tm_year # 获取年份
-# print(str(year) + "-01-01")
-# datTime = time.mktime(time.strptime(str(year) + "-01-01", "%Y-%m-%d"))
-# print(int(datTime))
-
-# month = time.localtime(datTime1).tm_mon # 获取月份
-# print(str(month))
-# year = time.localtime(datTime1).tm_year # 获取年份
-# if 10 > month:
-#     print(str(year) + "-0" + str(month) + "-01")
-#     datTime = time.mktime(time.strptime(str(year) + "-0" + str(month) + "-01", "%Y-%m-%d"))
-#     print(int(datTime))
-# else:
-#     print(str(year) + "-" + str(month) + "-01")
-#     datTime = time.mktime(time.strptime(str(year) + "-" + str(month) + "-01", "%Y-%m-%d"))
-#     print(int(datTime))
-
-in_date = '1994-04-12'
-# datTime1 = time.mktime(time.strptime(in_date, "%Y-%m-%d"))
-# wday = time.localtime(datTime1).tm_wday # 获取周
-
-dt = datetime.datetime.strptime(in_date, "%Y-%m-%d")
-out_date = (dt + datetime.timedelta(days=-wday)).strftime("%Y-%m-%d")
-datTime = time.mktime(time.strptime(out_date, "%Y-%m-%d"))
 
-# #获取日
-# datTime = time.mktime(time.strptime(in_date, "%Y-%m-%d"))
-# print(int(datTime))
+postdatas = {}
+postdatas['title'] = "标题1111"
+postdatas['cover'] = "封面img"
+postdatas['content'] = "内容"
+postdatas['source'] = "来源"
+postdatas['hot'] = "0"
+postdatas['publishTime'] = "2020-11-23"
+
+lista = []
+lista.append(postdatas)
+url = 'http://192.168.0.12:8080/api/news/batchAddNews.do'
+print(json.dumps(lista))
+headers = {'Content-Type': 'application/json'}
+response = requests.post(url=url, headers=headers, data=json.dumps(lista))
+print(response.text)
 
-# print n_days.strftime('%Y-%m-%d')

+ 0 - 95
test1.py

@@ -1,95 +0,0 @@
-# -*- coding:utf-8 -*-
-
-__author__ = 'weijie'
-
-from EmQuantAPI import *
-import datetime
-import time
-import traceback
-import json
-from StockRestPojo import StockRestPojo
-from dbOperation import dbOperation
-
-# print("开始了")
-# datTime = datetime.datetime.strptime("2020-1-23", "%Y-%m-%d")
-# print(datTime)
-
-date = "20201023"
-time1 = "155959"
-
-datTime = time.mktime(time.strptime(date + time1, "%Y%m%d%H%M%S"))
-print(date + time1 +"=="+ str(datTime))
-
-month = time.localtime(datTime).tm_mon # 获取月份
-year = time.localtime(datTime).tm_year # 获取年份
-day = time.localtime(datTime).tm_mday #获取日
-hour = time.localtime(datTime).tm_hour #获取小时
-min_ = time.localtime(datTime).tm_min # 获取分钟
-sec_ = time.localtime(datTime).tm_sec # 获取秒数
-
-print(min_)
-# 设置1分钟
-if sec_ != 0:
-    min_ = min_ + 1
-    if min_ == 60:
-        min_ = 0
-        hour = hour + 1
-        sec_ = 0
-
-if min_ >= 10:
-    dateOne = str(year) + str(month) + str(day) + str(hour) + str(min_) + "00"
-else :
-    dateOne = str(year) + str(month) + str(day) + str(hour) + "0" + str(min_) + "00"
-datTime1 = time.mktime(time.strptime(str(dateOne), "%Y%m%d%H%M%S"))
-print(str(dateOne) + "==" + str(int(datTime1)))
-
-# 设置5分钟
-dateFive = ""
-tempHour = hour
-tremMin = min_
-if(min_ > 55):
-    tempHour = tempHour + 1
-    tremMin = "00"
-elif (min_%5 != 0):
-    tremMin = tremMin + (5 - tremMin%5)
-if tremMin >= 10:
-    dateFive = str(year) + str(month) + str(day) + str(tempHour) + str(tremMin) + "00"
-else :
-    dateFive = str(year) + str(month) + str(day) + str(tempHour) + "0" + str(tremMin) + "00"
-datTime1 = time.mktime(time.strptime(str(dateFive), "%Y%m%d%H%M%S"))
-print(str(dateFive) + "==" + str(int(datTime1)))
-
-# 设置15分钟
-dateFifteen = ""
-tempHour = hour
-tremMin = min_
-if(min_ > 45):
-    tempHour = tempHour + 1
-    tremMin = "00"
-elif (min_%15 != 0):
-    tremMin = tremMin + (15 - tremMin%15)
-dateFifteen = str(year) + str(month) + str(day) + str(tempHour) + str(tremMin) + "00"
-datTime1 = time.mktime(time.strptime(str(dateFifteen), "%Y%m%d%H%M%S"))
-print(str(dateFifteen) + "==" + str(int(datTime1)))
-
-# 设置30分钟
-dateThirty = ""
-tempHour = hour
-tremMin = min_
-if(min_ > 30):
-    tempHour = tempHour + 1
-    tremMin = "00"
-elif (min_%30 != 0):
-    tremMin = tremMin + (30 - tremMin%30)
-dateThirty = str(year) + str(month) + str(day) + str(tempHour) + str(tremMin) + "00"
-datTime1 = time.mktime(time.strptime(str(dateThirty), "%Y%m%d%H%M%S"))
-print(str(dateThirty) + "==" + str(int(datTime1)))
-
-
-# 设置小时
-if sec_ != 0 ^ min_ != 0:
-    dateSixty = str(year) + str(month) + str(day) + str(hour + 1) + "0000"
-else :
-    dateSixty = str(year) + str(month) + str(day) + str(hour) + "0000"
-datTime1 = time.mktime(time.strptime(str(dateSixty), "%Y%m%d%H%M%S"))
-print(str(dateSixty) + "==" + str(int(datTime1)))

+ 0 - 61
test2.py

@@ -1,61 +0,0 @@
-# -*- coding:utf-8 -*-
-
-__author__ = 'weijie'
-
-from EmQuantAPI import *
-import datetime
-import time
-import traceback
-import json
-from StockRestPojo import StockRestPojo
-from dbOperation import dbOperation
-
-# print("开始了")
-# datTime = datetime.datetime.strptime("2020-1-23", "%Y-%m-%d")
-# print(datTime)
-
-date = "20201023"
-time1 = "155959"
-
-datTime = time.mktime(time.strptime(date + time1, "%Y%m%d%H%M%S"))
-print(date + time1 +"=="+ str(datTime))
-
-hour = time.localtime(datTime).tm_hour #获取小时
-min_ = time.localtime(datTime).tm_min # 获取分钟
-sec_ = time.localtime(datTime).tm_sec # 获取秒数
-
-
-# 1分钟数据
-if sec_ != 0:
-    tempDatTime = datTime + 60 - sec_
-    print(tempDatTime)
-else:
-    print(datTime)
-
-# 5分钟数据
-if sec_ != 0 ^ min_%5 != 0:
-    tempDatTime = datTime + (5 * 60) - sec_ - (min_%5 * 60)
-    print(tempDatTime)
-else:
-    print(datTime)
-
-# 15分钟数据
-if sec_ != 0 ^ min_%15 != 0:
-    tempDatTime = datTime + (15 * 60) - sec_ - (min_%15 * 60)
-    print(tempDatTime)
-else:
-    print(datTime)
-
-# 30分钟数据
-if sec_ != 0 ^ min_%30 != 0:
-    tempDatTime = datTime + (30 * 60) - sec_ - (min_%30 * 60)
-    print(tempDatTime)
-else:
-    print(datTime)
-
-# 60分钟数据
-if sec_ != 0 ^ min_%60 != 0:
-    tempDatTime = datTime + (60 * 60) - sec_ - (min_%60 * 60)
-    print(tempDatTime)
-else:
-    print(datTime)