Kaynağa Gözat

1.指数,
2.盘前盘后

qlm 4 yıl önce
ebeveyn
işleme
d7a95bfe5f
13 değiştirilmiş dosya ile 540 ekleme ve 129 silme
  1. 1 1
      BondHistData.py
  2. 77 46
      BondStructure.py
  3. 1 1
      ForexHistData.py
  4. 1 1
      SotckHistData.py
  5. 16 1
      StockRestData.py
  6. 113 52
      StockStructure.py
  7. 1 1
      StockUsaHistData.py
  8. 234 0
      TempIndexHistData.py
  9. 18 2
      TempIndexRestData.py
  10. 16 1
      bondRestData.py
  11. 5 5
      getCst.py
  12. 6 4
      startGetHistData.py
  13. 51 14
      test.py

+ 1 - 1
BondHistData.py

@@ -20,7 +20,7 @@ class BondHistData:
     def toGet(self):
         try:
             db = dbOperation(db_config.db_zhaiquan)
-            stockPojoList = db.query_list("select id, code, name, list_date listDate from t_stock_base_info where 1=1")
+            stockPojoList = db.query_list("select id, code, name, list_date listDate from t_stock_base_info where 1=1 and is_rest_add = 0 ")
             getDataTime = time.strftime('%Y-%m-%d',time.localtime(time.time()))
             for stockPojo in stockPojoList:
                 if(stockPojo['listDate'] == '待上市'):

Dosya farkı çok büyük olduğundan ihmal edildi
+ 77 - 46
BondStructure.py


+ 1 - 1
ForexHistData.py

@@ -20,7 +20,7 @@ class ForexHistData:
         try:
             # csd使用范例
             db = dbOperation(db_config.db_waihui)
-            stockPojoList = db.query_list("select id, code, name, list_date listDate from t_stock_base_info where 1=1")
+            stockPojoList = db.query_list("select id, code, name, list_date listDate from t_stock_base_info where 1=1  and is_rest_add = 0  ")
             getDataTime = time.strftime('%Y-%m-%d',time.localtime(time.time()))
             for stockPojo in stockPojoList:
                 # print(str(stockPojo['code']))

+ 1 - 1
SotckHistData.py

@@ -20,7 +20,7 @@ class SotckHistData:
         try:
             # csd使用范例
             db = dbOperation(db_config.db_gupiao)
-            stockPojoList = db.query_list("select id, code, name, list_date listDate from t_stock_base_info where 1 = 1")
+            stockPojoList = db.query_list("select id, code, name, list_date listDate from t_stock_base_info where 1 = 1  and is_rest_add = 0 ")
             getDataTime = time.strftime('%Y-%m-%d',time.localtime(time.time()))
             for stockPojo in stockPojoList:
                 # print(str(stockPojo['code']))

+ 16 - 1
StockRestData.py

@@ -23,9 +23,24 @@ def csqCallback(quantdata):
                 file.write(str(quantdata.Data))
         except Exception as e:
             print(str(e))
+    elif current_time > time4:
+        try:
+            fileName = "/www/wwwroot/csqdata/stock/after/" + 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))
+    elif current_time < time1:
+        # 盘前数据
+        try:
+            fileName = "/www/wwwroot/csqdata/stock/InFront/" + 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 StockRestData:
-
+    # 股票数据抓取
     def toGet(self):
         try:
             db = dbOperation(db_config.db_gupiao)

Dosya farkı çok büyük olduğundan ihmal edildi
+ 113 - 52
StockStructure.py


+ 1 - 1
StockUsaHistData.py

@@ -21,7 +21,7 @@ class StockUsaHistData:
         try:
             # csd使用范例
             db = dbOperation(db_config.db_meigu)
-            stockPojoList = db.query_list("select id, code, name, list_date listDate from t_stock_base_info where 1=1")
+            stockPojoList = db.query_list("select id, code, name, list_date listDate from t_stock_base_info where 1=1 ")
             getDataTime = time.strftime('%Y-%m-%d',time.localtime(time.time()))
             for stockPojo in stockPojoList:
                 isAdd = False

Dosya farkı çok büyük olduğundan ihmal edildi
+ 234 - 0
TempIndexHistData.py


+ 18 - 2
TempIndexRestData.py

@@ -23,12 +23,28 @@ def csqCallback(quantdata):
                 file.write(str(quantdata.Data))
         except Exception as e:
             print(str(e))
+    elif current_time > time4:
+        try:
+            fileName = "/www/wwwroot/csqdata/tempindex/after/" + 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))
+    # elif current_time < time1:
+    #     # 盘前数据
+    #     try:
+    #         fileName = "/www/wwwroot/csqdata/bond/InFront/" + 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)
+            #  上证指数  深圳指数   创业板指数   沪深300  	中小板指  深证综指
+            data = c.csq("000001.SH,399001.SZ,399006.SZ,399300.SZ,399005.SZ,399106.SZ,159982.SZ,IXIC.GI,US30USD.FX,159919.SZ,159912.SZ,510050.SH,159922.SZ,HSI.HI","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)

+ 16 - 1
bondRestData.py

@@ -23,9 +23,24 @@ def csqCallback(quantdata):
                 file.write(str(quantdata.Data))
         except Exception as e:
             print(str(e))
+    elif current_time > time4:
+        try:
+            fileName = "/www/wwwroot/csqdata/bond/after/" + 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))
+    # elif current_time < time1:
+    #     # 盘前数据
+    #     try:
+    #         fileName = "/www/wwwroot/csqdata/bond/InFront/" + 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:
-
+    # 证券数据抓取
     def toGet(self):
         try:
             db = dbOperation(db_config.db_zhaiquan)

+ 5 - 5
getCst.py

@@ -55,7 +55,7 @@ def cstCallBack(quantdata):
             if "None" == str(result[2][j]):
                 continue
             stockRestPojo = StockRestPojo()
-            stockRestPojo.date = "20201123"
+            stockRestPojo.date = "20201221"
             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("202011230" + str(result[0][j]), "%Y%m%d%H%M%S"))
+                datTime = time.mktime(time.strptime("202012210" + str(result[0][j]), "%Y%m%d%H%M%S"))
                 stockRestPojo.realTime = str(int(datTime))
             else:
-                datTime = time.mktime(time.strptime("20201123" + str(result[0][j]), "%Y%m%d%H%M%S"))
+                datTime = time.mktime(time.strptime("20201221" + str(result[0][j]), "%Y%m%d%H%M%S"))
                 stockRestPojo.realTime = str(int(datTime))
 
             min_ = time.localtime(datTime).tm_min # 获取分钟
@@ -180,7 +180,7 @@ 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 and id > 216 order by id asc")
+    stockPojoList = db.query_list("select id, code, name, list_date listDate, seralid from t_stock_base_info where 1=1  order by id asc")
     # cst使用范例
     for stockPojo in stockPojoList:
         # sql = "SELECT count(1) count FROM data_rt_" + stockPojo['code'].replace(".", "_").lower() + " WHERE `date` = '20201123'"
@@ -188,7 +188,7 @@ try:
         # 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)
+        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', '144300', '150000','',cstCallBack)
     db.close()
     input("press any key to quit cst \r\n")
 #退出

+ 6 - 4
startGetHistData.py

@@ -63,10 +63,12 @@ try:
         exit()
     # asyncio.run(main())
 
-    # tempIndexHistData = TempIndexHistData()
-    # tempIndexHistData.toGet1()
-    # tempIndexHistData.toGet2()
-    # tempIndexHistData.toGet3()
+    tempIndexHistData = TempIndexHistData()
+    tempIndexHistData.toGet1()
+    tempIndexHistData.toGet2()
+    tempIndexHistData.toGet3()
+    #tempIndexHistData.toGet4()
+    tempIndexHistData.toGet5()
 
     # 获取股票历史数据
     sotckHistData = SotckHistData()

+ 51 - 14
test.py

@@ -1,19 +1,56 @@
 import requests
 import json
+from datetime import timedelta, datetime
+import time
 
-postdatas = {}
-postdatas['title'] = "标题1111"
-postdatas['cover'] = "封面img"
-postdatas['content'] = "内容"
-postdatas['source'] = "来源"
-postdatas['hot'] = "0"
-postdatas['publishTime'] = "2020-11-23"
+# 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)
+# 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)
 
+
+# url = 'http://192.168.0.6:8090/api/stock/addStock.do'
+# stock = {}
+# stock['stockName'] = "11"
+# stock['stockCode'] = "22"
+# stock['stockSpell'] = ''
+# stock['stockType'] = "33"
+# stock['stockGid'] = "44"
+# stock['stockPlate'] = "55"
+# stock['isLock'] = 0
+# stock['isShow'] = 0
+# stock['buyLimit'] = 1
+# stock['isLimitUpBuy'] = 0
+# stock['isStopTradingBuy'] = 0
+# stock['nowPrice'] = ""
+# stock['change'] = ""
+# stock['pctChange'] = ""
+# stock['stockOrBond'] = "0"
+# stock['issueNum'] = ""
+# headers = {'Content-Type': 'application/json'}
+# response = requests.post(url=url, headers=headers, data=json.dumps(stock))
+# print(response)
+
+# yearDatTime = time.mktime("2020" + "/01/01", "%Y/%m/%d")
+# print(yearDatTime)
+
+# getDataTime = time.strftime('%Y-%m-%d',time.localtime(time.time()))
+# print(getDataTime)
+
+data = "2020/01"
+if 0 == data.count("/"):
+    data = data + "/01/01"
+elif 1 == data.count("/"):
+    data = data + "/01"
+print(data)