Browse Source

get history price 1.0

Daniel 3 years ago
parent
commit
e4ad98f12a
4 changed files with 9 additions and 6 deletions
  1. 1 1
      .idea/misc.xml
  2. 1 1
      .idea/stock.iml
  3. 3 0
      docker.start.txt
  4. 4 4
      get_history_price.py

+ 1 - 1
.idea/misc.xml

@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
-  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (jqdata)" project-jdk-type="Python SDK" />
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
 </project>

+ 1 - 1
.idea/stock.iml

@@ -2,7 +2,7 @@
 <module type="PYTHON_MODULE" version="4">
   <component name="NewModuleRootManager">
     <content url="file://$MODULE_DIR$" />
-    <orderEntry type="jdk" jdkName="Python 3.8 (jqdata)" jdkType="Python SDK" />
+    <orderEntry type="jdk" jdkName="Python 3.8" jdkType="Python SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="module" module-name="stocks_to_sql" />
     <orderEntry type="module" module-name="quantify01" />

+ 3 - 0
docker.start.txt

@@ -0,0 +1,3 @@
+docker run -itd --name mysql8 -p 3307:3306 -e MYSQL_ROOT_PASSWORD=r6kEwqWU9!v3 -v D:/MySQL/docker_mysql:/var/lib/mysql mysql:8.0.28-oracle
+
+docker run -itd --name mysql82 -p 3312:3306 -e MYSQL_ROOT_PASSWORD=r6kEwqWU9!v3 mysql:8.0.28-oracle

+ 4 - 4
get_history_price.py

@@ -3,11 +3,11 @@ from sqlalchemy import create_engine
 auth('18616891214', 'Ea?*7f68nD.dafcW34d!')
 
 # 获得代码列表
-stocks = list(get_all_securities(['stock'], date='2022-02-01').index)
-stocks = stocks[0:50]
+stocks = list(get_all_securities(['stock'], date='2022-03-08').index)
+# stocks = stocks[0:50]
 
 # 建立stocks 数据库
-engine = create_engine('mysql+pymysql://root:r6kEwqWU9!v3@localhost:3307/sit?charset=utf8')
+engine = create_engine('mysql+pymysql://root:r6kEwqWU9!v3@localhost:3307/stocks?charset=utf8')
 
 # 定义周期级别
 fre = '1d'
@@ -15,7 +15,7 @@ print('ready to get history')
 # 逐一取数据,写入sql
 for stock in stocks:
     print(stock)
-    df_stock = get_price(stock, start_date='2020-01-01 00:00:00', end_date='2022-02-01 00:00:00',
+    df_stock = get_price(stock, start_date='2010-01-01 00:00:00', end_date='2022-02-01 00:00:00',
                          frequency=fre, fields=['open', 'close', 'high', 'low', 'volume', 'money'], skip_paused=False,
                          fq='pre', count=None, panel=False)
     # 去除无数据日