mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-12-01 03:18:18 +08:00
data tool(continue)
This commit is contained in:
parent
ad4133ae80
commit
e7bc50b6ca
@ -205,7 +205,7 @@ class Ui_MainWindow(object):
|
||||
self.groupBox_7.setGeometry(QtCore.QRect(10, 20, 511, 91))
|
||||
self.groupBox_7.setObjectName("groupBox_7")
|
||||
self.layoutWidget5 = QtWidgets.QWidget(self.groupBox_7)
|
||||
self.layoutWidget5.setGeometry(QtCore.QRect(20, 30, 208, 18))
|
||||
self.layoutWidget5.setGeometry(QtCore.QRect(20, 30, 141, 18))
|
||||
self.layoutWidget5.setObjectName("layoutWidget5")
|
||||
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.layoutWidget5)
|
||||
self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0)
|
||||
@ -216,10 +216,6 @@ class Ui_MainWindow(object):
|
||||
self.import_fund_checkBox = QtWidgets.QCheckBox(self.layoutWidget5)
|
||||
self.import_fund_checkBox.setObjectName("import_fund_checkBox")
|
||||
self.horizontalLayout_3.addWidget(self.import_fund_checkBox)
|
||||
self.import_bond_checkBox = QtWidgets.QCheckBox(self.layoutWidget5)
|
||||
self.import_bond_checkBox.setEnabled(False)
|
||||
self.import_bond_checkBox.setObjectName("import_bond_checkBox")
|
||||
self.horizontalLayout_3.addWidget(self.import_bond_checkBox)
|
||||
self.import_future_checkBox = QtWidgets.QCheckBox(self.layoutWidget5)
|
||||
self.import_future_checkBox.setEnabled(False)
|
||||
self.import_future_checkBox.setObjectName("import_future_checkBox")
|
||||
@ -248,7 +244,7 @@ class Ui_MainWindow(object):
|
||||
self.import_min_time_checkBox.setObjectName("import_min_time_checkBox")
|
||||
self.horizontalLayout_2.addWidget(self.import_min_time_checkBox)
|
||||
self.import_weight_checkBox = QtWidgets.QCheckBox(self.groupBox_7)
|
||||
self.import_weight_checkBox.setGeometry(QtCore.QRect(250, 30, 151, 16))
|
||||
self.import_weight_checkBox.setGeometry(QtCore.QRect(200, 30, 151, 16))
|
||||
self.import_weight_checkBox.setObjectName("import_weight_checkBox")
|
||||
self.import_status_label = QtWidgets.QLabel(self.tab)
|
||||
self.import_status_label.setGeometry(QtCore.QRect(650, 30, 361, 21))
|
||||
@ -307,7 +303,6 @@ class Ui_MainWindow(object):
|
||||
self.groupBox_7.setTitle(_translate("MainWindow", "导入设置"))
|
||||
self.import_stock_checkBox.setText(_translate("MainWindow", "股票"))
|
||||
self.import_fund_checkBox.setText(_translate("MainWindow", "基金"))
|
||||
self.import_bond_checkBox.setText(_translate("MainWindow", "债券"))
|
||||
self.import_future_checkBox.setText(_translate("MainWindow", "期货"))
|
||||
self.import_day_checkBox.setText(_translate("MainWindow", "日线"))
|
||||
self.import_min_checkBox.setText(_translate("MainWindow", "1分钟线"))
|
||||
|
@ -490,7 +490,7 @@ p, li { white-space: pre-wrap; }
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>208</width>
|
||||
<width>141</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -509,16 +509,6 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="import_bond_checkBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>债券</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="import_future_checkBox">
|
||||
<property name="enabled">
|
||||
@ -587,7 +577,7 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QCheckBox" name="import_weight_checkBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>250</x>
|
||||
<x>200</x>
|
||||
<y>30</y>
|
||||
<width>151</width>
|
||||
<height>16</height>
|
||||
|
@ -45,7 +45,7 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.reset_progress_bar()
|
||||
|
||||
#读取保存的配置文件信息,如果不存在,则使用默认配置
|
||||
this_dir = os.getcwd()
|
||||
this_dir = os.path.dirname(__file__)
|
||||
import_config = ConfigParser()
|
||||
if os.path.exists(this_dir + '/importdata.ini'):
|
||||
import_config.read(this_dir + '/importdata.ini')
|
||||
@ -53,7 +53,6 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
||||
#初始化导入行情数据类型配置
|
||||
self.import_stock_checkBox.setChecked(import_config.getboolean('quotation', 'stock', fallback=True))
|
||||
self.import_fund_checkBox.setChecked(import_config.getboolean('quotation', 'fund', fallback=True))
|
||||
self.import_bond_checkBox.setChecked(import_config.getboolean('quotation', 'bond', fallback=False))
|
||||
self.import_future_checkBox.setChecked(import_config.getboolean('quotation', 'future', fallback=False))
|
||||
|
||||
#初始化导入K线类型配置
|
||||
@ -111,7 +110,6 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
||||
import_config = ConfigParser()
|
||||
import_config['quotation'] = {'stock': self.import_stock_checkBox.isChecked(),
|
||||
'fund': self.import_fund_checkBox.isChecked(),
|
||||
'bond': self.import_bond_checkBox.isChecked(),
|
||||
'future': self.import_future_checkBox.isChecked()}
|
||||
import_config['ktype'] = {'day': self.import_day_checkBox.isChecked(),
|
||||
'min': self.import_min_checkBox.isChecked(),
|
||||
@ -134,7 +132,7 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
||||
return import_config
|
||||
|
||||
def saveConfig(self):
|
||||
filename = os.getcwd() + '/importdata.ini'
|
||||
filename = os.path.dirname(__file__) + '/importdata.ini'
|
||||
with open(filename, 'w') as f:
|
||||
self.getCurrentConfig().write(f)
|
||||
|
||||
|
@ -309,19 +309,25 @@ if __name__ == '__main__':
|
||||
api.connect(tdx_server, tdx_port)
|
||||
|
||||
print("导入股票代码表")
|
||||
import_stock_name(connect, api, 'SH', quotations)
|
||||
import_stock_name(connect, api, 'SZ', quotations)
|
||||
#import_stock_name(connect, api, 'SH', quotations)
|
||||
#import_stock_name(connect, api, 'SZ', quotations)
|
||||
|
||||
add_count = 0
|
||||
|
||||
print("\n导入上证日线数据")
|
||||
add_count = import_data(connect, 'SH', 'DAY', ['bond'], api, dest_dir, progress=ProgressBar)
|
||||
#add_count = import_data(connect, 'SH', 'DAY', ['bond'], api, dest_dir, progress=ProgressBar)
|
||||
print("\n导入数量:", add_count)
|
||||
|
||||
print("\n导入深证日线数据")
|
||||
#add_count = import_data(connect, 'SZ', 'DAY', ['stock'], api, dest_dir, progress=ProgressBar)
|
||||
print("\n导入数量:", add_count)
|
||||
|
||||
for i in range(10):
|
||||
x = api.get_history_transaction_data(TDXParams.MARKET_SZ, '000001', (9-i)*2000, 2000, 20181112)
|
||||
#x = api.get_transaction_data(TDXParams.MARKET_SZ, '000001', (9-i)*800, 800)
|
||||
if x is not None and len(x) > 0:
|
||||
print(i, len(x), x[0], x[-1])
|
||||
|
||||
|
||||
api.disconnect()
|
||||
|
||||
|
@ -32,7 +32,7 @@ def create_database(connect):
|
||||
"""创建SQLITE3数据库表"""
|
||||
try:
|
||||
cur = connect.cursor()
|
||||
filename = os.getcwd() + '/sqlite_createdb.sql'
|
||||
filename = os.path.dirname(__file__) + '/sqlite_createdb.sql'
|
||||
with open(filename, 'r', encoding='utf8') as sqlfile:
|
||||
cur.executescript(sqlfile.read())
|
||||
connect.commit()
|
||||
|
Loading…
Reference in New Issue
Block a user