xinxin
This commit is contained in:
parent
f711286bff
commit
39e4e7d1f0
@ -108,7 +108,7 @@ class ChangJiangClientTrader:
|
||||
# 获取动态IP
|
||||
new_mac = set_mac.get_macinfos()
|
||||
broker = '长江证券'
|
||||
proxy_ip,proxy_port = get_proxy_ip(broker,new_mac,account_name)
|
||||
proxy_ip,proxy_port = get_proxy_ip(broker,new_mac,self.account_name)
|
||||
|
||||
#设置全局代理
|
||||
set_proxy(proxy_ip,proxy_port)
|
||||
|
@ -63,6 +63,7 @@ class DongWuClientTrader:
|
||||
for handler in self.logger.handlers:
|
||||
if hasattr(handler, 'baseFilename') and handler.baseFilename == os.path.abspath(logs_file):
|
||||
account_handler_exists = True
|
||||
|
||||
break
|
||||
|
||||
if not account_handler_exists:
|
||||
@ -725,6 +726,7 @@ class DongWuClientTrader:
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
setup_logging()
|
||||
# account_name = str('18817026786')
|
||||
|
||||
# account_name = str('13466839727')
|
||||
|
@ -92,7 +92,7 @@ class GJClientTrader:
|
||||
new_mac = set_mac.get_macinfos()
|
||||
broker = '国金证券'
|
||||
account_name = self.account_name
|
||||
proxy_ip,proxy_port = get_proxy_ip(broker,new_mac,account_name)
|
||||
proxy_ip,proxy_port = get_proxy_ip(broker,new_mac,self.account_name)
|
||||
|
||||
# 设置全局代理
|
||||
set_proxy(proxy_ip,proxy_port)
|
||||
|
@ -19,8 +19,8 @@ import datetime
|
||||
from tools import *
|
||||
from config import ssid,password
|
||||
warnings.filterwarnings('ignore')
|
||||
scripts_path = os.path.dirname(os.path.realpath(__file__))
|
||||
root_path = scripts_path[:scripts_path.find(project_name)+len(project_name)]
|
||||
from pathlib import Path
|
||||
root_path = Path(__file__).parent.parent
|
||||
|
||||
path = r'C:\国盛证券同花顺新一代\xiadan.exe'
|
||||
engine = create_engine(
|
||||
|
@ -19,8 +19,8 @@ import datetime
|
||||
from tools import *
|
||||
|
||||
warnings.filterwarnings('ignore')
|
||||
scripts_path = os.path.dirname(os.path.realpath(__file__))
|
||||
root_path = scripts_path[:scripts_path.find(project_name)+len(project_name)]
|
||||
from pathlib import Path
|
||||
root_path = Path(__file__).parent.parent
|
||||
|
||||
path = r'C:\goldsun\TdxW.exe'
|
||||
engine = create_engine(
|
||||
|
@ -126,6 +126,7 @@ class HTClientTrader:
|
||||
|
||||
# 关闭弹窗
|
||||
self._close_prompt_windows()
|
||||
time.sleep(7)
|
||||
#设置主窗口及菜单窗口
|
||||
self.main_wnd = self._app.window(title='网上股票交易系统5.0')
|
||||
self.left_wnd = self.main_wnd.window(class_name='AfxWnd140s', control_id=0xC8,found_index=0).window(class_name='SysTreeView32',control_id=0x81)
|
||||
|
33
tools.py
33
tools.py
@ -192,6 +192,36 @@ def connect_wifi(ssid: str = 'MaxEntropy', password: str = 'cskj12345678') -> bo
|
||||
print(f"清理wifi连接的临时文件失败: {str(e)}")
|
||||
|
||||
|
||||
def setup_logging():
|
||||
"""统一配置日志系统"""
|
||||
root_logger = logging.getLogger()
|
||||
root_logger.setLevel(logging.DEBUG)
|
||||
|
||||
# 移除所有现有处理器(避免重复)
|
||||
for handler in root_logger.handlers[:]:
|
||||
root_logger.removeHandler(handler)
|
||||
|
||||
# 控制台处理器
|
||||
console_handler = logging.StreamHandler()
|
||||
console_handler.setLevel(logging.INFO) # 控制台只显示INFO及以上级别
|
||||
|
||||
# 文件处理器
|
||||
file_handler = logging.FileHandler('Auto_Trade_Log.log', encoding='utf-8')
|
||||
file_handler.setLevel(logging.DEBUG) # 文件记录所有DEBUG及以上级别
|
||||
|
||||
# 格式化
|
||||
formatter = logging.Formatter(
|
||||
'%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
console_handler.setFormatter(formatter)
|
||||
file_handler.setFormatter(formatter)
|
||||
|
||||
root_logger.addHandler(console_handler)
|
||||
root_logger.addHandler(file_handler)
|
||||
|
||||
|
||||
|
||||
|
||||
# 设置代理
|
||||
# 设置代理
|
||||
def set_proxy(proxy_ip: str, proxy_port: str):
|
||||
@ -348,6 +378,7 @@ def set_proxy(proxy_ip: str, proxy_port: str):
|
||||
|
||||
def get_proxy_ip(broker,new_mac,account_name) -> tuple:
|
||||
|
||||
start_time = time.time()
|
||||
get_ip_times = 0
|
||||
while get_ip_times<10:
|
||||
try:
|
||||
@ -366,7 +397,7 @@ def get_proxy_ip(broker,new_mac,account_name) -> tuple:
|
||||
'Mac': new_mac,
|
||||
'IP': proxy_ip,
|
||||
'Port': proxy_port,
|
||||
'Location': item['prov'] + ':' + item['city']}])
|
||||
'Location': item['prov'] + ':' + item['city']}],)
|
||||
|
||||
# 尝试写入数据库:
|
||||
while True:
|
||||
|
Loading…
x
Reference in New Issue
Block a user