# -*- coding: utf-8 -*- """ Created on Fri Aug 5 15:29:12 2022 @author: MINGL """ import pandas as pd import pyautogui import pywinauto from pywinauto import clipboard,keyboard from skimage import io import io as mio import pytesseract import datetime from tools import * warnings.filterwarnings('ignore') from config import ssid,password from pathlib import Path root_path = Path(__file__).parent.parent path = os.path.join(root_path,'broker_xiadan','东吴证券金融终端独立下单','xiadan.exe') global engine engine = create_engine( 'mysql+pymysql://cn_ainvest_db:cn_ainvest_sd3a1@rm-2zewagytttzk6f24xno.mysql.rds.aliyuncs.com:3306/', echo=False) class DongWuClientTrader: """ 基于同花顺委托下单程序的"长城证券客户端"自动交易程序 """ def __init__(self, account_name, exe_path=path): self.path = exe_path self.account_name = account_name # 确保logs目录存在 logs_dir = root_path / 'logs' logs_dir.mkdir(exist_ok=True) # 初始化日志系统 self._setup_logging() # 用户券商信息 sql = f"select * from ainvest_usercount where username='{account_name}'" df_count = download_data_from_db(sql, 'ai_strategy_update_iddb') self.securities_name = str(df_count['securities_username'].tolist()[0]) self.securities_password = str(df_count['securities_password'].tolist()[0]) self.communication_password = str(df_count['communication_password'].tolist()[0]) def _setup_logging(self): """设置日志系统""" import logging import os # 获取当前模块的logger self.logger = logging.getLogger(__name__) # 为当前账户添加文件处理器,记录到logs目录 logs_file = os.path.join(root_path, 'logs', f'{self.account_name}.log') # 检查是否已经有针对这个账户的处理器,避免重复添加 account_handler_exists = False 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: formatter = logging.Formatter('[%(asctime)s] [%(levelname)s] %(message)s', '%Y-%m-%d %H:%M:%S') file_handler = logging.FileHandler(logs_file, encoding='utf-8') file_handler.setFormatter(formatter) file_handler.setLevel(logging.DEBUG) self.logger.addHandler(file_handler) # 如果根logger没有处理器(单独运行时),添加控制台处理器 root_logger = logging.getLogger() if not root_logger.handlers: console_handler = logging.StreamHandler() console_handler.setFormatter(logging.Formatter('[%(asctime)s] [%(levelname)s] %(message)s', '%Y-%m-%d %H:%M:%S')) console_handler.setLevel(logging.INFO) self.logger.addHandler(console_handler) # 设置logger级别 self.logger.setLevel(logging.DEBUG) def exit(self): ''' 结束进程 Returns ------- None. ''' self._app.kill() def login(self): ''' 启动软件并登录 Returns ------- None. ''' account_name = self.account_name broker = '东吴证券' #软件启动判断,若有进行中进程,先关闭再重启 try: self._app = pywinauto.Application().connect( path=self.path, timeout=1 ) self.exit() self.logger.warning('There are running programs, and there are processes in retreat') except Exception: pass #启动软件进程,输入账号密码 self.logger.info('Start login') start_time = time.time() # 重置mac set_mac = SetMac() set_mac.run() # 尝试连接WiFi connect_wifi(ssid,password) get_ip_times = 0 writer = ExcelDataWriter() # 初始化ip_records 表格 used_ip = writer.get_unavailable_ips(broker, account_name) while get_ip_times<10: try: item = get_ip_data() #获取动态IP if item['ip'] in used_ip: get_ip_times += 1 self.logger.warning(f'代理IP重复,重新获取IP') else: self.logger.info(f'代理IP已经获取{item}') break except Exception as e: self.logger.error(f'获取IP失败,请检查网络连接{e}') time.sleep(5) # raise ConnectionError(f"获取IP失败,请检查网络连接。错误详情: {e}") #设置全局代理 proxy_ip = item['ip'] proxy_port = str(item['port']) set_proxy(proxy_ip,proxy_port) # exit_ip = get_proxy_ip(proxy_ip,proxy_port) time_with_change_proxy = time.time()-start_time self.logger.info('全局代理设置成功') insert_data= {'as_of_date':datetime.datetime.fromtimestamp(start_time).strftime('%Y-%m-%d %H:%M:%S.%f'), 'broker':broker, 'account': account_name, 'proxy_ip': proxy_ip, 'proxy_port':proxy_port, 'ip_location': item['prov']+':'+item['city'], #'exit_ip': exit_ip, 'ip_cross_check_result': '一致', 'ip_switch_time':time_with_change_proxy, #'ip_expire_time':item['expire'] 'ip_survival_time':'5min' } # 写入数据表 writer = ExcelDataWriter() # 初始化ip_records 表格 writer.write_data(insert_data) # 检查IP是否可用 # 开始登录 time.sleep(2) self._app = pywinauto.Application().start(self.path) while True: try: self._app.window(title_re='用户登录.*').wait("ready") break except RuntimeError: pass self._app.window(title_re='用户登录.*').Edit1.type_keys(self.securities_name) time.sleep(0.1) self._app.window(title_re='用户登录.*').Edit2.type_keys(self.securities_password) time.sleep(0.1) # # 验证码登录 # while True: # #获取id_code # id_code = self.verify_code(0x5DB) # time.sleep(0.2) # self._app.window(title_re='用户登录.*').Edit3.type_keys('{BACKSPACE}' * 6) # time.sleep(0.2) # self._app.window(title_re='用户登录.*').Edit3.type_keys(id_code) # time.sleep(0.2) # pywinauto.keyboard.send_keys("{ENTER}") # time.sleep(0.5) # try: # self._app.top_window().set_focus() # result_idcode = self._app.window(control_id=0x0, class_name='#32770',found_index = 0).window(control_id=0x3EC, class_name='Static').window_text() # self.log.softInfo(result_idcode) # if '验证码错误' in result_idcode or '连接委托主站失败' in result_idcode: # self.log.warn('Verification code error') # self._app.window(control_id=0x0, class_name='#32770',found_index = 0).window(control_id=0x2, class_name='Button').click() # time.sleep(0.5) # else: # break # except Exception as e: # self.log.info(f'登录失败:{e}') # break # # time.sleep(10) # 这里sleep(10)是? # while True: # try: # self._app.window(title_re='网上股票交易系统5.0.*').wait("ready") # break # except RuntimeError: # pass pywinauto.keyboard.send_keys("{ENTER}") tryrun(self._app.window(title_re='网上股票交易系统5.0.*').wait("ready")) #关闭弹窗 for i in range(3): self._turn_off_advertising() #设置主窗口及菜单窗口 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) # #使用的ip mac入库 # ip = get_ip() # 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 # ) # # 执行搜索 # mac = pattern.search(mac_info).group(1) # data = {'As_Of_Date': datetime.datetime.now(), 'Account_Name': account_name, 'Broker': broker, 'MAC': mac, # 'IP': ip} # aaa = pd.DataFrame([data]) # aaa.to_sql('trade_mac_ip', engine, schema='auth_center', index=False, if_exists='append') # self.log.info('IP:' + ip + ' MAC:' + mac) def _turn_off_advertising(self): ''' 关闭弹窗 Returns ------- None. ''' try: self._app.top_window().set_focus() time.sleep(0.5) pywinauto.keyboard.send_keys("{ESC}") pywinauto.keyboard.send_keys("{ENTER}") pywinauto.keyboard.send_keys("{ESC}") except Exception as e: pass def verify_code(self,control_id): ''' 获取登录验证码 Returns ------- id_code : TYPE DESCRIPTION. ''' time.sleep(0.5) self._app.top_window().Static.click() time.sleep(0.2) self._app.top_window().window(control_id=control_id, class_name='Static').capture_as_image().save( f'{root_path}/imgs/temp.png') time.sleep(0.2) im = io.imread(f'{root_path}/imgs/temp.png') id_code = pytesseract.image_to_string(im, lang='eng', config='--psm 6 --oem 3 -c tessedit_char_whitelist=0123456789').strip() id_code = id_code.replace(' ', '') return id_code def buy(self, stock_no, price, num): ''' 买入股票 Parameters ---------- stock_no : TYPE DESCRIPTION. price : TYPE DESCRIPTION. num : TYPE DESCRIPTION. Returns ------- None. ''' self.left_wnd.select(['买入[F1]']) self.__trade(stock_no, price, num) def sell(self, stock_no, price, num): ''' 卖出股票 Parameters ---------- stock_no : TYPE DESCRIPTION. price : TYPE DESCRIPTION. num : TYPE DESCRIPTION. Returns ------- None. ''' self.left_wnd.select(['卖出[F2]']) self.__trade(stock_no, price, num) def etf_buy(self, ticker, num): ''' etf认购 Parameters ---------- ticker : TYPE DESCRIPTION. num : TYPE DESCRIPTION. Returns ------- None. ''' self.left_wnd.select(['场内基金', '基金认购']) # 设置股票代码 self.main_wnd.window(control_id=0x408, class_name="Edit").click() self.main_wnd.window(control_id=0x408, class_name="Edit").set_text(str(ticker)) time.sleep(0.5) # 设置价格 self.main_wnd.window(control_id=0x40A, class_name="Edit").set_text(str(num)) time.sleep(0.5) # 点击确认 self.main_wnd.window(control_id=0x3EE, class_name="Button").click() time.sleep(1) # 获取弹窗返回的信息 # self._app.top_window().set_focus() one_text = self._app.window(control_id=0x0, class_name='#32770').window(control_id=0x410, class_name='Static').window_text() # 摘取合同信息 self.logger.info(one_text.replace('/n', ' ')) time.sleep(0.2) # 确认申购委托 self._app.window(control_id=0x0, class_name="#32770", found_index=0).window(control_id=0x6, class_name='Button').click() # 获取弹窗返回的信息 # self._app.top_window().set_focus() one_text = self._app.window(control_id=0x0, class_name='#32770').window(control_id=0x3EC, class_name='Static').window_text() self.logger.info(one_text.replace('/n', ' ')) time.sleep(0.2) self._app.window(control_id=0x0, class_name="#32770", found_index=0).window(control_id=0x2, class_name='Button').click() def get_cancel_entrust(self, ticker): ''' 按股票撤单 Parameters ---------- ticker : TYPE DESCRIPTION. Returns ------- None. ''' self.left_wnd.select(['撤单[F3]']) time.sleep(1) # 删除框内ticker self.main_wnd.window(control_id=0xD14, class_name='Edit').click() for i in range(7): pywinauto.keyboard.send_keys("{DELETE}") # 输入ticker self.main_wnd.window(control_id=0xD14, class_name='Edit').type_keys(ticker) time.sleep(0.2) # 选中ticker pywinauto.keyboard.send_keys("{ENTER}") time.sleep(0.1) # 点击撤单 self.main_wnd.window(control_id=0x44B, class_name='Button').click() time.sleep(0.1) # 确认撤单 pywinauto.keyboard.send_keys("{ENTER}") time.sleep(0.2) #获取弹窗信息 result = self._app.top_window().window(control_id=0x3EC, class_name='Static').window_text() self.logger.info(result) pywinauto.keyboard.send_keys("{ENTER}") time.sleep(0.2) pywinauto.keyboard.send_keys("{ESC}") def cancel_entrust(self): ''' 全撤 Returns ------- None. ''' # # 进入撤单页面 self.left_wnd.select(['撤单[F3]']) time.sleep(1) # 一键全撤 self.main_wnd.window(control_id=0x7531, class_name='Button').click() self._app.top_window().set_focus() self.main_wnd.window(control_id=0x44B, class_name='Button').click() time.sleep(1) pywinauto.keyboard.send_keys("{ENTER}") time.sleep(0.5) pywinauto.keyboard.send_keys("{ENTER}") def get_unsettled_trades(self): ''' 获取未成交单 Returns ------- one_df : TYPE DESCRIPTION. ''' self.left_wnd.select(['撤单[F3]']) self._copy_data() one_df =self._data_to_df() if len(one_df) == 0: pass else: one_df['证券代码'] = one_df['证券代码'].apply(lambda x: tranTicker(x.strip('=').strip('"'))) return one_df def get_balance(self): ''' 获取资金情况 Returns ------- record : TYPE DESCRIPTION. ''' self.left_wnd.select(['查询[F4]','资金股票']) self.main_wnd.window(control_id=0x3f7, class_name="Static").click() balance_dict_id = { "总资产": 0x3f7, "可用金额": 0x3f8, "股票市值": 0x3f6, } result = {} for key, control_id in balance_dict_id.items(): result[key] = float(self.main_wnd.window(control_id=control_id, class_name="Static").window_text()) record = pd.DataFrame.from_dict(result, orient='index').T record = record[['可用金额', '股票市值', '总资产']] record.rename(columns={'可用金额': 'cash', '股票市值': 'Position_amount', '总资产': 'Total_account'}, inplace=True) record['As_Of_Date'] = datetime.date.today() record['Account_Name'] = self.account_name return record def get_position(self): ''' 获取持仓情况 Returns ------- df_position : TYPE DESCRIPTION. ''' self.left_wnd.select(['查询[F4]','资金股票']) # 复制表格数据 time.sleep(1) self.main_wnd.window(control_id=0x417, class_name="CVirtualGridCtrl").click() self._copy_data() df_position = self._data_to_df() if len(df_position) == 0: self.logger.info('--------------------------------------无当日持仓--------------------------------------') return pd.DataFrame() df_position['证券代码'] = df_position['证券代码'].apply(lambda x: tranTicker(str(x).replace('="', '').replace('"', ''))) df_position = df_position[['证券代码','证券名称','股票余额','可用余额','冻结数量','成本价','市价','市值','盈亏','盈亏比例(%)']] df_position.rename(columns={"证券代码": "Ticker", "证券名称": "Ticker_name", "股票余额": "Number_transactions", "可用余额": "cash", "冻结数量": "frozen_quantity", "成本价": "cost_price", "市价": "market_price", "市值": "market_value", "盈亏": "profit_and_loss", "盈亏比例(%)": "profit_loss_ratio", }, inplace=True) df_position['As_Of_Date'] = datetime.date.today() df_position['Account_Name'] = self.account_name return df_position def get_order(self): ''' 获取委托情况 Returns ------- TYPE DESCRIPTION. ''' self.left_wnd.select(['查询[F4]', '当日委托']) time.sleep(1) self.main_wnd.window(control_id=0x417, class_name="CVirtualGridCtrl").click() self._copy_data() df = self._data_to_df() if len(df) == 0: self.logger.info('--------------------------------------无当日委托--------------------------------------') return pd.DataFrame() else: df = df[['委托时间', '证券代码', '证券名称', '操作', '委托价格', '委托数量', '成交数量', '成交均价', '股票成交金额']] df['Account_Name'] = self.account_name df['As_Of_Date'] = datetime.date.today() df.rename(columns={'委托时间': 'Entrust_time', '证券代码': 'Ticker', '证券名称': 'Ticker_name', '操作': 'Operate', '成交数量': 'Number_transactions', '成交均价': 'Average_price', '委托数量': 'Entrust_Number_transactions', '委托价格': 'Entrust_price', '股票成交金额': 'Trade_Money', }, inplace=True) df['Operate'] = df['Operate'].apply(lambda x: x if '认购' in x else ('卖' if '卖' in x else '买')) df['Ticker'] = df['Ticker'].apply(lambda x: tranTicker(str(x).replace('="', '').replace('"', ''))) return df def get_today_trades(self): ''' 获取当日成交 Returns ------- TYPE DESCRIPTION. ''' self.left_wnd.select(['查询[F4]','当日成交']) time.sleep(1) self.main_wnd.window(control_id=0x417, class_name="CVirtualGridCtrl").click() self._copy_data() df = self._data_to_df() if len(df) == 0: self.logger.info('--------------------------------------无当日成交--------------------------------------') return pd.DataFrame() else: df = df[['成交时间','证券代码','证券名称','操作','成交数量','成交均价']] df['Account_Name'] = self.account_name df['As_Of_Date'] = datetime.date.today() 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).replace('="', '').replace('"', ''))) return df def __trade(self, stock_no, price, amount): ''' 交易输入函数 Parameters ---------- stock_no : TYPE DESCRIPTION. price : TYPE DESCRIPTION. amount : TYPE DESCRIPTION. Returns ------- None. ''' time.sleep(0.2) # 设置股票代码 self.main_wnd.window(control_id=0x408, class_name="Edit").click() self.main_wnd.window(control_id=0x408, class_name="Edit").set_text(str(stock_no)) time.sleep(0.5) # 设置价格 self.main_wnd.window(control_id=0x409, class_name="Edit").set_text(str(price)) time.sleep(0.5) # 设置股数目 self.main_wnd.window(control_id=0x40A, class_name="Edit").set_text(str(amount)) time.sleep(0.5) # 点击卖出or买入 self.main_wnd.window(control_id=0x3EE, class_name="Button").click() time.sleep(1) #获取弹窗返回的信息 # self._app.top_window().set_focus() one_text = self._app.window(class_name='#32770', control_id=0x0,found_index = 0).window(control_id=0x410, class_name='Static').window_text() # one_text = self._app.top_window().window(control_id=0x410, class_name='Static').window_text() if '委托价格的小数部分应该为2位' in one_text: # 点击"否" self.logger.warning(one_text.replace('/n',' ')) self._app.top_window().window(control_id=0x7, class_name='Button').click() # 保留两位小数截断 price = str(price)[:-1] # 重新设置价格 self.main_wnd.window(control_id=0x409, class_name="Edit").set_text(str(price)) time.sleep(0.5) # 点击卖出or买入 self.main_wnd.window(control_id=0x3EE, class_name="Button").click() time.sleep(1) self._app.top_window().set_focus() one_text = self._app.top_window().window(control_id=0x410, class_name='Static').window_text() else: # 摘取合同信息 self.logger.info(one_text.replace('/n',' ')) time.sleep(0.2) # 确认买入 # self._app.top_window().set_focus() # pywinauto.keyboard.send_keys("{ENTER}") self._app.window(class_name='#32770', control_id=0x0,found_index = 0).window(control_id=0x6, class_name='Button').click() time.sleep(1) # 摘取合同信息2 # one_text2 = self._app.window(control_id=0x0, class_name="#32770", found_index=0).window(control_id=0x3EC, # class_name='Static').window_text() one_text2 = self._app.window(class_name='#32770', control_id=0x0,found_index = 0).window(control_id=0x3EC, class_name='Static').window_text() # self._app.top_window().set_focus() # one_text2 = self._app.top_window().window(control_id=0x3EC, class_name='Static').window_text() self.logger.info(one_text2.replace('/n', ' ')) time.sleep(0.5) # 确认合同 # self._app.top_window().set_focus() # pywinauto.keyboard.send_keys("{ENTER}") # self._app.top_window().window(control_id=0x2, class_name="Button").click() # self._app.window(control_id=0x0, class_name="#32770", found_index=0).window(control_id=0x2, # class_name='Button').click() self._app.window(class_name='#32770', control_id=0x0,found_index = 0).window(control_id=0x2, class_name='Button').click() time.sleep(0.5) def _copy_data(self): ''' 拷贝数据函数 Returns ------- None. ''' while True: keyboard.send_keys('^C') # 获取验证码 id_code = self.verify_code(0x965) time.sleep(0.2) self._app.top_window().Edit3.type_keys('{BACKSPACE}' * 6) time.sleep(0.2) self._app.top_window().Edit3.type_keys(id_code) time.sleep(0.2) pywinauto.keyboard.send_keys("{ENTER}") time.sleep(0.5) try: self._app.top_window().set_focus() result_idcode = self._app.top_window().window(control_id=0x966, class_name='Static').window_text() self.logger.info(result_idcode) if '验证码错误' in result_idcode: self.logger.warning('Verification code error') self._app.top_window().window(control_id=0x2, class_name="Button").click() time.sleep(0.5) else: break except Exception: break def _data_to_df(self): ''' 剪切板转dataframe Returns ------- TYPE DESCRIPTION. ''' data_table = clipboard.GetData() df_table = pd.read_csv(mio.StringIO(data_table), delimiter='\t', na_filter=False) table_dict = df_table.to_dict('records') if len(table_dict) == 0: return pd.DataFrame() else: data = [] for i in table_dict: data.append(pd.DataFrame.from_dict(i, orient='index').T) return pd.concat(data, ignore_index=True) def get_deliver_order(self): time.sleep(1) time.sleep(2) # self.__select_menu(['查询[F4]', '交割单']) self.left_wnd.select(['查询[F4]', '交割单']) time.sleep(2) # time_start = "2021-5-24" # time_end = "2021-5-27" # year = parser.parse(time_start).year # print(year) now = datetime.date.today() # last_week_start = now - timedelta(days=now.weekday() + 7) # last_week_end = now - timedelta(days=now.weekday() + 3) engine = create_engine( 'mysql+pymysql://ainvest_all_read:ainvest_all_read1@rm-2zewagytttzk6f24xno.mysql.rds.aliyuncs.com:3306/') workdates = pd.read_sql('select As_Of_Date from ai_strategy.trade_days', engine) date = str(now) workdates_dates = workdates['As_Of_Date'].tolist() dates = [str(i) for i in workdates_dates] # 根据交易日列表,判断昨日 day_index = dates.index(date) lastday = dates[(day_index - 10)] # result = datetime.datetime.strptime(lastday, '%Y-%m-%d').date() result = datetime.date(2023,6,14) now = datetime.date(2023,7,6) # 开始日期 self.main_wnd.window(control_id=0x3F1, class_name="SysDateTimePick32").click() pywinauto.keyboard.send_keys(str(result.year)) pyautogui.click(511, 330) pywinauto.keyboard.send_keys(str(result.month)) pyautogui.click(529, 330) pywinauto.keyboard.send_keys(str(result.day)) pyautogui.click() # 结束日期 pyautogui.click(587, 331) pywinauto.keyboard.send_keys(str(now.year)) pyautogui.click(613, 330) pywinauto.keyboard.send_keys(str(now.month)) pyautogui.click(631, 330) pywinauto.keyboard.send_keys(str(now.day)) # 确定 self.main_wnd.window(control_id=0x3EE, class_name="Button").click() time.sleep(0.2) pyautogui.press('f5') time.sleep(0.2) # table = self.__get_grid_data() self._copy_data() table = self._data_to_df() time.sleep(1) if len(table) == 0: df_empty = pd.DataFrame() return df_empty else: table['证券代码'] = table['证券代码'].apply(lambda x:x.replace('="','')) table['证券代码'] = table['证券代码'].apply(lambda x: x.replace('"', '')) table['合同编号'] = table['合同编号'].apply(lambda x: x.replace('="', '')) table['合同编号'] = table['合同编号'].apply(lambda x: x.replace('"', '')) table['股东帐户'] = table['股东帐户'].apply(lambda x: x.replace('="', '')) table['股东帐户'] = table['股东帐户'].apply(lambda x: x.replace('"', '')) df = table # df = df[(df['操作'] != '买入')&(df['操作'] != '卖出')] df = df[['成交日期', '成交时间', '证券代码', '证券名称', '操作', '成交数量', '成交编号', '成交均价', '成交金额','余额', '股票余额', '发生金额', '手续费', '印花税', '其他杂费', '合同编号', '市场名称', '股东帐户','过户费', '交易市场']] # df1 = df[:-1] # print(df.columns) # print(df1.columns) # del df['Unnamed: 20'] print(df) return df if __name__ == '__main__': # account_name = str('18817026786') # account_name = str('13466839727') account_name = str('13401019175') # account_name = str('18207551053') # account_name = str('15355324922') # account_name = str('18810394120') # account_name = str('15299080760') # account_name = str('18099200966') # account_name = str('15837720201') # account_name = str('13079977044') # account_name = str('18254288217') # account_name = str('13157750940') # account_name = str('13166000510') # account_name = str('13079905318') # account_name = str('13791973211') # account_name = str('13165027171') # account_name = str('15810381872') # account_name = str('15017576903') # account_name = str('13923760353') # account_name = str('13146277795') # account_name = str('15017576903') # account_name = str('13812913261') # account_name = str('15626660713') # account_name = str('13880392643') a = DongWuClientTrader(account_name) a.login() # a.etf_buy('561923', '1000') # 买入 # a.sell('600000', '7','100') # 卖出 # a.sell('600835', '12.15','900') # print(a.get_deliver_order()) # 获取当日实际持仓 # print(a.get_position()) # 获取资金情况 # print(a.get_balance()) # 获取当日成交 # print(a.get_today_trades())