2 Star 0 Fork 16

wangqiyuan/traderStock-gui

forked from macroan/traderStock-gui 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
autoAnalysisStockMain.py 7.96 KB
一键复制 编辑 原始数据 按行查看 历史
macroan 提交于 2018-03-15 14:07 . no commit message
#coding=utf-8
import sys
import stock
import config
import successrate
import xuangu
from autoAnalysisStock import Ui_MainWindow
from PyQt5 import QtWidgets
from PyQt5.QtCore import QDateTime
from PyQt5.QtCore import QDate
from PyQt5.QtWidgets import QFileDialog
import setGlobalVar
import time
from trader import monitor
class mywindow(QtWidgets.QWidget, Ui_MainWindow):
def __init__(self):
super(mywindow, self).__init__()
self.setupUi(self)
def setupUi(self, MainWindow):
super(mywindow, self).setupUi(MainWindow)
self.startdate.setCalendarPopup(True)
self.enddate.setCalendarPopup(True)
self.enddate.setDateTime(QDateTime.currentDateTime());
self.compute_succ_type.activated['QString'].connect(self.OnActivated_compute_succ)
self.comput_btn.clicked.connect(self.comput_btn_click)
self.download_btn.clicked.connect(self.download_btn_click)
self.update_btn.clicked.connect(self.update_btn_click)
self.xuangu_type_1.activated['QString'].connect(self.OnActivated_xuangu_type_1)
self.xuangu_btn.clicked.connect(self.xuangu_btn_click)
self.xuangu_end_btn.clicked.connect(self.xuangu_end_btn_click)
self.testdown.clicked.connect(self.testdown_click)
self.testxuangu.clicked.connect(self.testxuangu_click)
self.testxuangu2.clicked.connect(self.testxuangu2_click)
now_day = time.strftime("%Y-%m-%d", time.localtime())
self.delete_date.setDate(QDate.fromString(now_day, 'yyyy-MM-dd'))
self.delete_btn.clicked.connect(self.delete_btn_click)
self.deletetable_btn.clicked.connect(self.deletetable_btn_click)
self.monitor_btn.clicked.connect(self.monitor_btn_click)
self.monitor_btn_2.clicked.connect(self.monitor_btn_click2)
self.monitor_stop_btn.clicked.connect(self.monitor_stop_btn_click)
self.select_file_btn.clicked.connect(self.select_file_btn_click)
self.init_ui()
#下载数据
def download_btn_click(self):
s = stock.Stock.getInstance()
srctype = self.download_type1.currentText()
opttype = self.download_type2.currentText()
srctype = config.STOCKDATA_SOURCE[srctype]
opttype = config.DOWNLOAD_DATA_OPT[opttype]
cycle = self.download_cycle.currentText()
#opttype 1基础数据 2最近的数据 3所有数据
s.download_stockdata(srctype, opttype, cycle)
#更新数据
def update_btn_click(self):
s = stock.Stock.getInstance()
srctype = config.STOCKDATA_SOURCE[self.download_type1.currentText()]
opttype = config.UPDATE_DATA_OPT[self.download_type2.currentText()]
cycle = self.update_cycle.currentText()
if opttype == 1:#最近数据
s.update_recently_stockdata(srctype, cycle)
def delete_btn_click(self):
s = stock.Stock.getInstance()
srctype = config.STOCKDATA_SOURCE[self.delete_type.currentText()]
date = self.delete_date.date().toString("yyyy-MM-dd")
cycle = self.delete_cycle.currentText()
s.delete_sockdata_by_date(date, srctype, cycle)
def deletetable_btn_click(self):
s = stock.Stock.getInstance()
s.delete_table()
def monitor_btn_click(self):
m = monitor.Monitor.getInstance()
pathname = self.path_edit.text()
zf_name = self.zf_cbx.currentText()
if pathname == '' or zf_name == '':
return
l = m.read_data(pathname, zf_name)
if l is not None:
m.monitor_stock(l)
def monitor_btn_click2(self):
m = monitor.Monitor.getInstance()
pathname = self.path_edit.text()
zf_name = self.zf_cbx.currentText()
if pathname == '' or zf_name == '':
return
l = m.read_data(pathname, zf_name)
if l is not None:
m.monitor_stock2(l)
def monitor_stop_btn_click(self):
m = monitor.Monitor.getInstance()
m.stop()
def select_file_btn_click(self):
file_name = QFileDialog.getOpenFileName(self, "open file dialog","E:\\traderStock-gui\output\选股","Csv files(*.csv)")
self.path_edit.setText(file_name[0])
def testxuangu_click(self):
s = stock.Stock.getInstance()
code = self.codeEdit_2.text()
df = s.get_df(code+'d_igd')
if df is None or df.shape[0] == 0:
return
l = []
import kdj
import macd
#kdj.kdj_lowtwo_gc(df, code)
#macd.macd_zeroup_beaboutto_first_gc(df, code)
#macd.macd_zeroup_first_gc(df, code)
macd.macd_zerodown_two_glodencross(df)
def testxuangu2_click(self):
xuangu.testxuangu()
def testdown_click(self):
#start = self.startdate.date()
#start = start.toString("yyyy-MM-dd");
#end = self.enddate.date()
#end = end.toString("yyyy-MM-dd");
#code = self.codeEdit.text()
s = stock.Stock.getInstance()
#df = s.get_alldata_yahoo('aa')
#print(df)
s.get_realtime_capital('000001')
#选股
def xuangu_btn_click(self):
self.xungu(1)
#尾盘选股
def xuangu_end_btn_click(self):
self.xungu(2)
def xungu(self, type):
type1 = self.xuangu_type_1.currentText()
type2 = self.xuangu_type_2.currentText()
cycle = self.xuangu_cycle.currentText()
if type1 != '' and type2 != '':
func = config.XUANGU_FUN[type1][type2]
xuangu.xuangu(cycle, type1, func, type2, type)
#选中股类 A股 美股
def OnActivated_xuangu_type_1(self, txt):
self.xuangu_type_2.clear()
config_item = config.XUANGU_FUN[txt]
for k, v in config_item.items():
self.xuangu_type_2.addItem(k)
#计算成功率
def comput_btn_click(self):
technique_data = self.compute_succ_type.currentText()
func_desc = self.comput_succ_fun.currentText()
cycle = self.succ_cycle.currentText()
if technique_data != '' and func_desc != '':
func_str = config.SUCCESS_FUN[technique_data][func_desc]
successrate.get_successrate(cycle, technique_data, func_str, func_desc)
#选中指标类型
def OnActivated_compute_succ(self, txt):
self.comput_succ_fun.clear()
config_item = config.SUCCESS_FUN[txt]
for k, v in config_item.items():
self.comput_succ_fun.addItem(k)
#初始化ui揭盲
def init_ui(self):
for k, v in config.STOCKDATA_SOURCE.items():
self.download_type1.addItem(k)
self.update_type1.addItem(k)
self.delete_type.addItem(k)
self.xuangu_src.addItem(k)
for k, v in config.DOWNLOAD_DATA_OPT.items():
self.download_type2.addItem(k)
for k, v in config.UPDATE_DATA_OPT.items():
self.update_type2.addItem(k)
for i in config.SUCCESS_TYPE:
self.compute_succ_type.addItem(i)
for k, v in config.SUCCESS_FUN[config.SUCCESS_TYPE[0]].items():
self.comput_succ_fun.addItem(k)
for i in config.XUANGU_TYPE:
self.xuangu_type_1.addItem(i)
for k, v in config.XUANGU_FUN[config.XUANGU_TYPE[0]].items():
self.xuangu_type_2.addItem(k)
for i in config.CYCLE:
self.succ_cycle.addItem(i)
self.xuangu_cycle.addItem(i)
self.download_cycle.addItem(i)
self.update_cycle.addItem(i)
self.delete_cycle.addItem(i)
for item in config.MONITOR_CONFIG:
self.zf_cbx.addItem(item)
#初始化数据
def init_app_data():
import public
public.set_orderid()
if __name__=="__main__":
app = QtWidgets.QApplication(sys.argv)
myshow = mywindow()
setGlobalVar.setWindow(myshow)
init_app_data()
myshow.show()
sys.exit(app.exec_())
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/wangqiyuan2/traderStock-gui.git
git@gitee.com:wangqiyuan2/traderStock-gui.git
wangqiyuan2
traderStock-gui
traderStock-gui
master

搜索帮助