AI 通过python脚本自动化导出交易软件某一天的分笔成交明细

AI 通过python脚本自动化导出交易软件某一天的分笔成交明细

一.背景需求

打开交易软件,我们想要导出非今日的日线股票成交分笔明细,其实,很麻烦的。你得在日线图上点击某一天的柱状图,然后双击,就会出现当日的成交明细,然后导出。如果你想到导出30天或者1年的数据呢?你难道盯着电脑一步一步的操作?不,我不允许你还不知道用python来处理这种事情,今天就教你们怎么把这些操作,用代码自动化执行,哪怕是交易软件里面的数据,我们也来爬。

二.人工操作视频

操作步骤-CSDN直播

三.实现步骤

我们现在了解我们的需求了,就是把上面这个视频操作用python自动化的执行,如果你会的话,就不用往下看了。现在我们分析,如何将上面的步骤自动化处理呢?

1.柱状图的检测并发送双击按键事件,弹出成交明细弹框

先将屏幕截图,然后通过像素分析得到柱状图的左上角的像素规律。然后,发送鼠标双击事件。下面是python代码和得到的结果图:

# 跌幅柱状图像素检测

def checkGreenPoint(image, x, y):

r, g, b = image.getpixel((x, y))

return (r == 84 and g == 255 and b == 255)

# 涨幅柱状图像素检测

def checkRedPoint(image, x, y):

r, g, b = image.getpixel((x, y))

return (r == 255 and g == 61 and b == 61)

# 截取屏幕截图

screenshot = ImageGrab.grab()

# 保存截图到文件,使用活动窗口标题作为文件名

screenshot.save('./screenshot.png')

# 获取图像的宽度和高度

# 打开图像

image = Image.open('./screenshot.png')

width, height = image.size

# 遍历图像的每个像素点

for y in range(height):

for x in range(width):

# 获取像素点的RGB值

r, g, b = image.getpixel((x, y))

# # 检测跌幅的点

## 跌幅柱状图 满足的条件

checkGreenPoint(image, x, y) and checkGreenPoint(image, x+1, y) and checkGreenPoint(image, x, y+1) \

and checkGreenPoint(image, x+1, y+1) and not checkGreenPoint(image, x-1, y) and not checkGreenPoint(image, x, y-1) \

and not checkGreenPoint(image, x-1, y-1) and not checkGreenPoint(image, x+1, y-1) and not checkGreenPoint(image, x-1, y+1)

# 检测涨幅的点

## 涨幅柱状图 满足的条件

if checkRedPoint(image, x, y) and checkRedPoint(image, x+1, y) and checkRedPoint(image, x, y+1) \

and checkRedPoint(image, x+2, y) and checkRedPoint(image, x+3, y) and checkRedPoint(image, x+4, y) \

and checkRedPoint(image, x+5, y) and checkRedPoint(image, x+6, y) and checkRedPoint(image, x+7, y) \

and not checkRedPoint(image, x+2, y+1) and not checkRedPoint(image, x+3, y+1) and not checkRedPoint(image, x+4, y+1) \

and not checkRedPoint(image, x+5, y+1) and not checkRedPoint(image, x+6, y+1) and not checkRedPoint(image, x+7, y+1) \

and not checkRedPoint(image, x+1, y+1) and not checkRedPoint(image, x-1, y) and not checkRedPoint(image, x, y-1) \

and not checkRedPoint(image, x-1, y-1) and not checkRedPoint(image, x+1, y-1) and not checkRedPoint(image, x-1, y+1):

2.弹出成交明细弹窗后,我们需要将弹窗里面的 “操作” 二字坐标捕捉到,然后,继续发送单击事件,进行下一步。刚开始用easyocr 识别中文错别字较多,没用,这里我们用paddleocr来进行中文识别。下面是python代码和结果:

def checkCon

相关文章

如何玩扑克 - 基本规则和技巧
英国上市公司官网365

如何玩扑克 - 基本规则和技巧

⌛ 07-06 💥 6087
什么探花软件比较真实靠谱?
英国上市公司官网365

什么探花软件比较真实靠谱?

⌛ 07-07 💥 5552
PCB 封装与 3D 系列 02:电容
365bet稳定备用网站

PCB 封装与 3D 系列 02:电容

⌛ 08-25 💥 5834