150 lines
6.3 KiB
Python
150 lines
6.3 KiB
Python
# import pandas as pd
|
|
# import datetime
|
|
# from sqlalchemy import create_engine
|
|
# # 转换股票代码
|
|
# def tranTicker(tick):
|
|
# tick = str(tick)
|
|
#
|
|
# if len(tick) == 8:
|
|
# tick = tick.strip('SH').strip('SZ')
|
|
# if tick.startswith('6') or tick.startswith('11') or tick.startswith('10') or tick.startswith('51'):
|
|
# tick = 'SH' + tick
|
|
# elif tick.startswith('0') or tick.startswith('3') or tick.startswith('15') or tick.startswith(
|
|
# '16') or tick.startswith(
|
|
# '12'):
|
|
# tick = 'SZ' + tick
|
|
# else:
|
|
# pass
|
|
# elif len(tick) == 6:
|
|
# if tick.startswith('6') or tick.startswith('11') or tick.startswith('10') or tick.startswith('51'):
|
|
# tick = 'SH' + tick
|
|
# elif tick.startswith('0') or tick.startswith('15') or tick.startswith('12') or tick.startswith(
|
|
# '16') or tick.startswith('3'):
|
|
# tick = 'SZ' + tick
|
|
# else:
|
|
# pass
|
|
# else:
|
|
# num = 6 - len(tick)
|
|
# tick = 'SZ' + num * '0' + tick
|
|
#
|
|
# return tick
|
|
# engine_auto_update_web_strategy = create_engine(
|
|
# 'mysql+pymysql://ainvest:JRLeiYD423!@rm-2zewagytttzk6f24xno.mysql.rds.aliyuncs.com:3306/auto_update_web_strategy',
|
|
# encoding="utf-8", echo=False)
|
|
# # df = pd.read_excel(fr'C:\Users\EDY\Documents\20250403 历史成交查询.xls')
|
|
# df = pd.read_csv(fr'C:\Users\EDY\Documents\20250411 历史成交查询.xls', encoding='gbk', sep='\t',
|
|
# error_bad_lines=False).applymap(
|
|
# lambda x: x.replace('"', '').replace('=', '') if isinstance(x, str) else x)
|
|
# df.columns = [i.replace('"', '').replace('=', '') for i in list(df.columns)]
|
|
# df = df[['成交时间', '证券代码', '证券名称', '买卖标志', '成交数量', '成交价格']]
|
|
# print(df)
|
|
# df['As_Of_Date'] = datetime.date(2025,4,10)
|
|
# df.rename(columns={'成交时间': 'Trade_time', '证券代码': 'Ticker', '证券名称': 'Ticker_name', '买卖标志': 'Operate',
|
|
# '成交数量': 'Number_transactions',
|
|
# '成交价格': 'Average_price'}, inplace=True)
|
|
# df['Operate'] = df['Operate'].apply(lambda x: '卖' if '卖' in x else '买')
|
|
#
|
|
# df['Ticker'] = df['Ticker'].apply(lambda x: tranTicker(str(x)))
|
|
# df['Account_Name'] = '13834890033'
|
|
# print(df)
|
|
# df.to_sql('daily_transaction_record_detail', engine_auto_update_web_strategy,
|
|
# if_exists='append',
|
|
# index=False, chunksize=100)
|
|
|
|
|
|
|
|
|
|
# import pandas as pd
|
|
# import datetime
|
|
# from sqlalchemy import create_engine
|
|
# # 转换股票代码
|
|
# def tranTicker(tick):
|
|
# tick = str(tick)
|
|
#
|
|
# if len(tick) == 8:
|
|
# tick = tick.strip('SH').strip('SZ')
|
|
# if tick.startswith('6') or tick.startswith('11') or tick.startswith('10') or tick.startswith('51'):
|
|
# tick = 'SH' + tick
|
|
# elif tick.startswith('0') or tick.startswith('3') or tick.startswith('15') or tick.startswith(
|
|
# '16') or tick.startswith(
|
|
# '12'):
|
|
# tick = 'SZ' + tick
|
|
# else:
|
|
# pass
|
|
# elif len(tick) == 6:
|
|
# if tick.startswith('6') or tick.startswith('11') or tick.startswith('10') or tick.startswith('51'):
|
|
# tick = 'SH' + tick
|
|
# elif tick.startswith('0') or tick.startswith('15') or tick.startswith('12') or tick.startswith(
|
|
# '16') or tick.startswith('3'):
|
|
# tick = 'SZ' + tick
|
|
# else:
|
|
# pass
|
|
# else:
|
|
# num = 6 - len(tick)
|
|
# tick = 'SZ' + num * '0' + tick
|
|
#
|
|
# return tick
|
|
# engine_auto_update_web_strategy = create_engine(
|
|
# 'mysql+pymysql://ainvest:JRLeiYD423!@rm-2zewagytttzk6f24xno.mysql.rds.aliyuncs.com:3306/auto_update_web_strategy',
|
|
# encoding="utf-8", echo=False)
|
|
# df = pd.read_csv(fr'C:\Users\EDY\Documents\table.xls',encoding='gbk',sep = '\t').applymap(
|
|
# lambda x: x.replace('"', '').replace('=', '') if isinstance(x, str) else x)
|
|
# print(df)
|
|
# # df = df[['成交时间', '证券代码', '证券名称', '方向', '成交数量', '成交价格']]
|
|
# df = df[['成交时间', '证券代码', '证券名称', '操作', '成交数量', '成交价格']]
|
|
# df['As_Of_Date'] = datetime.date(2025,4,2)
|
|
# df.rename(columns={'成交时间': 'Trade_time', '证券代码': 'Ticker', '证券名称': 'Ticker_name', '操作': 'Operate',
|
|
# '成交数量': 'Number_transactions',
|
|
# '成交价格': 'Average_price'}, inplace=True)
|
|
# df['Operate'] = df['Operate'].apply(lambda x: '卖' if '卖' in x else '买')
|
|
#
|
|
# df['Ticker'] = df['Ticker'].apply(lambda x: tranTicker(str(x)))
|
|
# df['Account_Name'] = '15935144173'
|
|
# print(df)
|
|
# df.to_sql('daily_transaction_record_detail', engine_auto_update_web_strategy,
|
|
# if_exists='append',
|
|
# index=False, chunksize=100)
|
|
#
|
|
# from tools import *
|
|
#
|
|
# mac_info = subprocess.check_output('GETMAC /v /FO list', stderr=subprocess.STDOUT)
|
|
# mac_info = mac_info.decode('gbk')
|
|
# # 想要匹配的连接名
|
|
# target_connection_name = "WLAN 2"
|
|
#
|
|
# # 构建正则表达式模式
|
|
# pattern = re.compile(
|
|
# r"连接名:\s+" + re.escape(target_connection_name) + r".*?物理地址:\s+([0-9A-Fa-f-]+)",
|
|
# re.DOTALL
|
|
# )
|
|
# # 执行搜索
|
|
# match = pattern.search(mac_info).group(1)
|
|
# print(match)
|
|
# mac_info = subprocess.check_output('GETMAC /v /FO list', stderr=subprocess.STDOUT)
|
|
# mac_info = mac_info.decode('gbk')
|
|
# search = re.search(r'WLAN 2\s+物理地址: (.+)\s+传输名称', mac_info)
|
|
# mac = (search.group(1).strip()) if search else ('', '')
|
|
# print(search)
|
|
project_name = 'auto_trade_20230130'
|
|
import pyautogui
|
|
import pywinauto
|
|
from PIL import ImageGrab
|
|
from pywinauto import clipboard
|
|
from pywinauto import keyboard
|
|
from skimage import io
|
|
import time
|
|
import io as mio
|
|
import pytesseract
|
|
import warnings
|
|
import datetime
|
|
from tools import *
|
|
from connect_wifi import connect_wifi
|
|
from iptest import get_proxy_ip,set_global_proxy,get_ip_data
|
|
scripts_path = os.path.dirname(os.path.realpath(__file__))
|
|
root_path = scripts_path[:scripts_path.find(project_name)+len(project_name)]
|
|
im = io.imread(f'{root_path}/imgs/temp123.png')
|
|
# print(')))))',im)
|
|
id_code = pytesseract.image_to_string(im, lang='chi_sim',config='--psm 7').strip()
|
|
|
|
id_code = id_code.replace(' ', '')
|
|
print(id_code) |