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):

3b5c56c469ac421a9034884248037e6c.png

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

def che
  • 12
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

风亲云叹

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值