提交 0182ef7d 编写于 作者: D dave

修改目录结构

上级 263fe61b
[codestyle]
indentation = True
[main]
version = '0.1.0'
[encoding]
text_encoding = utf-8
[main]
version = '0.1.0'
[vcs]
use_version_control = False
version_control_system =
[main]
version = '0.1.0'
[workspace]
save_data_on_exit = True
restore_data_on_startup = True
save_history = True
save_non_project_files = False
[main]
version = '0.1.0'
recent_files = [u'C:\\Users\\Administrator\\.spyder\\temp.py', u'F:\\git\\stock\\auto_stock\\auto.py', u'F:\\git\\stock\\auto_stock\\server.py', u'F:\\git\\stock\\auto_stock\\main.py', u'F:\\git\\stock\\auto_stock\\gui.py', u'F:\\git\\stock\\auto_stock\\auto\\main.py', u'F:\\git\\stock\\auto_stock\\common\\DBMange.py', u'F:\\git\\stock\\auto_stock\\common\\Software.py', u'F:\\git\\stock\\auto_stock\\common\\VK_CODE.py']
#目录结构
... auto 自动化交易
... crawler 爬虫目录
.... data 获取股票数据
.... lib 自动化类
\ No newline at end of file
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 18 13:05:36 2018
@author: daveqing
@qq : 1029329095
"""
from lib import Winauto
#软件启动
class Auto(object):
#软件初始化
def __init__(self):
self.Winauto = Winauto();
#判断软件是否启动成功
def IsWindow(self):
if self.Winauto.IsWindow():
return 1
else:
return 0
#软件启动
def startApp(self,filePath,var):
self.Winauto.appStart(filePath,var)
#购买
def buy(self,stock,price,num):
self.Winauto.Buy(stock,price,num)
#出售
def sell(self,stock,price,num):
self.Winauto.Sell(stock,price,num)
#查看所有资产
def getAllInfo(self):
return self.Winauto.getAllAsset();
#窗口置顶
def topWindow(self):
self.Winauto.topWindow()
#查询目前持仓
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 18 13:05:36 2018
@author: daveqing
@qq : 1029329095
"""
from lib import Winauto
#软件启动
class Auto(object):
#软件初始化
def __init__(self):
self.Winauto = Winauto();
#判断软件是否启动成功
def IsWindow(self):
if self.Winauto.IsWindow():
return 1
else:
return 0
#软件启动
def startApp(self,filePath,var):
self.Winauto.appStart(filePath,var)
#购买
def buy(self,stock,price,num):
self.Winauto.Buy(stock,price,num)
#出售
def sell(self,stock,price,num):
self.Winauto.Sell(stock,price,num)
#查看所有资产
def getAllInfo(self):
return self.Winauto.getAllAsset();
#窗口置顶
def topWindow(self):
self.Winauto.topWindow()
#查询目前持仓
\ No newline at end of file
# -*- mode: python -*-
block_cipher = None
a = Analysis(['auto.py'],
pathex=['E:\\dev\\python\\python-dem\\python-dem\\stock'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='auto',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='auto')
# -*- mode: python -*-
block_cipher = None
a = Analysis(['auto.py'],
pathex=['E:\\dev\\python\\python-dem\\python-dem\\stock'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='auto',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='auto')
# -*- coding: utf-8 -*-
import sys
sys.path.append('../')
from common import Software
from common import DBMange
import time
class Winauto(object):
def __init__(self):
self.flush = Software(u'同花顺(v8.60.83) - A股技术分析')
self.flush.topWindow()
self.db = DBMange()
def seeK(self,stock):
self.flush.keyStr(stock)
self.flush.Key_event('enter')
def getData(self,stype):
if stype==1:
sql = "SELECT hy_zystock FROM hy \
WHERE newtime = '%s' " % ('2018-08-13')
if stype==2:
sql = "SELECT stkCode FROM stocklhrank \
WHERE newtime = '%s' " % ('2018-08-13')
data = self.db.select(sql)
stock = []
for row in data:
fname = row[0]
# 打印结果
stock.append(fname)
return stock
auto = Winauto()
stockList =auto.getData(1)
for i in range(len(stockList)):
auto.seeK(stockList[i][0:6])
#print stockList[i][0:6]
time.sleep(5)
# -*- coding: utf-8 -*-
import sys
sys.path.append('../')
from common import Software
from common import DBMange
import time
class Winauto(object):
def __init__(self):
self.flush = Software(u'同花顺(v8.60.83) - A股技术分析')
self.flush.topWindow()
self.db = DBMange()
def seeK(self,stock):
self.flush.keyStr(stock)
self.flush.Key_event('enter')
def getData(self,stype):
if stype==1:
sql = "SELECT hy_zystock FROM hy \
WHERE newtime = '%s' " % ('2018-08-13')
if stype==2:
sql = "SELECT stkCode FROM stocklhrank \
WHERE newtime = '%s' " % ('2018-08-13')
data = self.db.select(sql)
stock = []
for row in data:
fname = row[0]
# 打印结果
stock.append(fname)
return stock
auto = Winauto()
stockList =auto.getData(1)
for i in range(len(stockList)):
auto.seeK(stockList[i][0:6])
#print stockList[i][0:6]
time.sleep(5)
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import pymysql
import time
class DBMange(object):
def __init__(self):
self.db = pymysql.connect("localhost","root","root","stock",charset="utf8")
self.cursor = self.db.cursor()
def select(self,sql):
self.cursor.execute(sql)
# 获取所有记录列表
self.results = self.cursor.fetchall()
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import pymysql
import time
class DBMange(object):
def __init__(self):
self.db = pymysql.connect("localhost","root","root","stock",charset="utf8")
self.cursor = self.db.cursor()
def select(self,sql):
self.cursor.execute(sql)
# 获取所有记录列表
self.results = self.cursor.fetchall()
return self.results
\ No newline at end of file
# -*- coding: utf-8 -*-
from VK_CODE import VK_CODE
#from pywinauto import application
#import win32clipboard as wc
from pykeyboard import PyKeyboard
import win32gui, win32api, win32con
import time
class Software(object):
def __init__(self,keyword):
self.k = PyKeyboard() #get pykeyboard
self.software=keyword
self.hWndChildList=0
self.para_hld=win32gui.FindWindow(None,self.software)
if self.IsWindow():
self.hWndChildList=self.demo_child_windows(self.para_hld) #get hld
attr=self.show_window_attr(self.para_hld)
win32api.SetCursorPos([attr['post'][0],attr['post'][1]]) #Mover to post(x,y)
'''
判定窗口是否激活
'''
def IsWindow(self):
if self.para_hld>0:
return 1;
else:
return 0;
'''
窗口置顶
'''
def topWindow(self):
self.Key_event('ctrl')
win32gui.SetForegroundWindow(self.para_hld) #show window
'''
输入键盘事件
'''
def keyStr(self,st):
self.k.type_string(st)
'''
输入键盘事件
'''
def Key_event(self,key):
win32api.keybd_event(VK_CODE[key],0,0,0) #
win32api.keybd_event(VK_CODE[key],0,win32con.KEYEVENTF_KEYUP,0) #
'''
ldList:
'post:?§|left, top, right, bottom
'''
def GetHld(self,post):
for hld in self.hWndChildList:
left, top, right, bottom =win32gui.GetWindowRect(hld) #get hld post left top right bottom
#if (post[0]==left) & (post[1]==top) & (post[2]==right) & (post[3]==right):
if (post[0]==left) & (post[1]==top): #get hld by (x,y) left top
return hld
return 0
'''
通过字符找到窗口
'''
def GetHldWord(self,word):
for hld in self.hWndChildList:
title = win32gui.GetWindowText(hld)
title=title.decode('gbk')
if title==word:
return hld
return 0
'''
获取窗口下的所有子窗口
'''
def demo_child_windows(self,parent):
if not parent:
return
hWndChildList = []
win32gui.EnumChildWindows(parent, lambda hWnd, param: param.append(hWnd), hWndChildList)
return hWndChildList
#get all hld attr
def show_window_attr(self,hWnd):
if not hWnd:
return
title = win32gui.GetWindowText(hWnd)
clsname = win32gui.GetClassName(hWnd)
left, top, right, bottom =win32gui.GetWindowRect(hWnd) #
attr = {'hWnd':hWnd,'title': title, 'clsname':clsname, 'post':[left,top,right,bottom]}
return attr
# -*- coding: utf-8 -*-
from VK_CODE import VK_CODE
#from pywinauto import application
#import win32clipboard as wc
from pykeyboard import PyKeyboard
import win32gui, win32api, win32con
import time
class Software(object):
def __init__(self,keyword):
self.k = PyKeyboard() #get pykeyboard
self.software=keyword
self.hWndChildList=0
self.para_hld=win32gui.FindWindow(None,self.software)
if self.IsWindow():
self.hWndChildList=self.demo_child_windows(self.para_hld) #get hld
attr=self.show_window_attr(self.para_hld)
win32api.SetCursorPos([attr['post'][0],attr['post'][1]]) #Mover to post(x,y)
'''
判定窗口是否激活
'''
def IsWindow(self):
if self.para_hld>0:
return 1;
else:
return 0;
'''
窗口置顶
'''
def topWindow(self):
self.Key_event('ctrl')
win32gui.SetForegroundWindow(self.para_hld) #show window
'''
输入键盘事件
'''
def keyStr(self,st):
self.k.type_string(st)
'''
输入键盘事件
'''
def Key_event(self,key):
win32api.keybd_event(VK_CODE[key],0,0,0) #
win32api.keybd_event(VK_CODE[key],0,win32con.KEYEVENTF_KEYUP,0) #
'''
ldList:
'post:?§|left, top, right, bottom
'''
def GetHld(self,post):
for hld in self.hWndChildList:
left, top, right, bottom =win32gui.GetWindowRect(hld) #get hld post left top right bottom
#if (post[0]==left) & (post[1]==top) & (post[2]==right) & (post[3]==right):
if (post[0]==left) & (post[1]==top): #get hld by (x,y) left top
return hld
return 0
'''
通过字符找到窗口
'''
def GetHldWord(self,word):
for hld in self.hWndChildList:
title = win32gui.GetWindowText(hld)
title=title.decode('gbk')
if title==word:
return hld
return 0
'''
获取窗口下的所有子窗口
'''
def demo_child_windows(self,parent):
if not parent:
return
hWndChildList = []
win32gui.EnumChildWindows(parent, lambda hWnd, param: param.append(hWnd), hWndChildList)
return hWndChildList
#get all hld attr
def show_window_attr(self,hWnd):
if not hWnd:
return
title = win32gui.GetWindowText(hWnd)
clsname = win32gui.GetClassName(hWnd)
left, top, right, bottom =win32gui.GetWindowRect(hWnd) #
attr = {'hWnd':hWnd,'title': title, 'clsname':clsname, 'post':[left,top,right,bottom]}
return attr
# -*- mode: python -*-
block_cipher = None
a = Analysis(['VK_CODE.py'],
pathex=['E:\\dev\\python\\python-dem\\python-dem\\stock\\lib'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='VK_CODE',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='VK_CODE')
# -*- mode: python -*-
block_cipher = None
a = Analysis(['VK_CODE.py'],
pathex=['E:\\dev\\python\\python-dem\\python-dem\\stock\\lib'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='VK_CODE',
debug=False,
strip=False,
upx=True,
console