Example #1
0
 def __buy0(self, code, quantity, new_stock_order_hwnd):
     """
     买入函数
     :param code: 股票代码,字符串
     :param quantity: 数量, 字符串
     """
     setEditText(self.__buy_sell_hwnds[0][0], code)
     time.sleep(0.2)
     if quantity != '0':
         setEditText(self.__buy_sell_hwnds[3][0], quantity)
         time.sleep(0.2)
     click(self.__buy_sell_hwnds[5][0])
     time.sleep(0.2)
Example #2
0
 def __buy0(self, code, quantity,new_stock_order_hwnd):
     """
     买入函数
     :param code: 股票代码,字符串
     :param quantity: 数量, 字符串
     """
     setEditText(self.__buy_sell_hwnds[0][0], code)
     time.sleep(0.2)
     if quantity != '0':
         setEditText(self.__buy_sell_hwnds[3][0], quantity)
         time.sleep(0.2)
     click(self.__buy_sell_hwnds[5][0])
     time.sleep(0.2)
Example #3
0
 def __buy(self, code, quantity):
     """买函数
     :param code: 代码, 字符串
     :param quantity: 数量, 字符串
     """
     click(self.__buy_sell_hwnds[2][0])
     time.sleep(0.2)
     setEditText(self.__buy_sell_hwnds[2][0], code)
     time.sleep(0.2)
     if quantity != '0':
         setEditText(self.__buy_sell_hwnds[7][0], quantity)
         time.sleep(0.2)
     click(self.__buy_sell_hwnds[8][0])
     time.sleep(1)
Example #4
0
    def __buy(self, code, quantity, actual_price, limit=None):
        """
        买入函数
        :param code: 股票代码,字符串
        :param quantity: 数量, 字符串
        """

        available_fund = self.getMoney()
        #if highest:
        #    actual_price=highest
        final_quantity = self._get_valid_buy_quantity(available_fund,
                                                      actual_price, quantity)
        if self.debug: print('final_buy_quantity=', final_quantity)
        if final_quantity:
            setEditText(self.__buy_sell_hwnds[0][0], code)
            time.sleep(0.2)
            setEditText(self.__buy_sell_hwnds[3][0], str(final_quantity))
            time.sleep(0.2)
            if limit:
                highest = limit[0]
                setEditText(self.__buy_sell_hwnds[1][0], str(highest))
                time.sleep(0.2)
            else:
                setEditText(self.__buy_sell_hwnds[1][0], str(actual_price))
            click(self.__buy_sell_hwnds[5][0])
            if self.debug: print('buy_quantity=', final_quantity)
            if self.debug: print(datetime.datetime.now())
            time.sleep(0.2)
Example #5
0
 def __buy(self, code, quantity):
     """买函数
     :param code: 代码, 字符串
     :param quantity: 数量, 字符串
     """
     click(self.__buy_sell_hwnds[2][0])
     time.sleep(0.2)
     setEditText(self.__buy_sell_hwnds[2][0], code)
     time.sleep(0.2)
     if quantity != '0':
         setEditText(self.__buy_sell_hwnds[7][0], quantity)
         time.sleep(0.2)
     click(self.__buy_sell_hwnds[8][0])
     time.sleep(1)
Example #6
0
 def __buy(self, code, quantity,actual_price,limit=None):
     """
     买入函数
     :param code: 股票代码,字符串
     :param quantity: 数量, 字符串
     """
     
     available_fund=self.getMoney()
     #if highest:
     #    actual_price=highest
     final_quantity=self._get_valid_buy_quantity(available_fund, actual_price, quantity)
     if self.debug: print('final_buy_quantity=',final_quantity)
     if final_quantity:
         setEditText(self.__buy_sell_hwnds[0][0], code)
         time.sleep(0.2)
         setEditText(self.__buy_sell_hwnds[3][0], str(final_quantity))
         time.sleep(0.2)
         if limit:
             highest=limit[0]
             setEditText(self.__buy_sell_hwnds[1][0], str(highest))
             time.sleep(0.2)
         else:
             highest=limit[0]
             setEditText(self.__buy_sell_hwnds[1][0], str(actual_price))
         click(self.__buy_sell_hwnds[5][0])
         if self.debug: print('buy_quantity=',final_quantity)
         if self.debug: print(datetime.datetime.now())
         time.sleep(0.2)
Example #7
0
 def __sell(self, code, quantity):
     """
     卖函数
     :param code: 股票代码, 字符串
     :param quantity: 数量, 字符串
     """
     click(self.__buy_sell_hwnds[11][0])
     time.sleep(0.2)
     setEditText(self.__buy_sell_hwnds[11][0], code)
     time.sleep(0.2)
     if quantity != '0':
         setEditText(self.__buy_sell_hwnds[16][0], quantity)
         time.sleep(0.2)
     click(self.__buy_sell_hwnds[17][0])
     time.sleep(1)
Example #8
0
 def __sell(self, code, quantity):
     """
     卖函数
     :param code: 股票代码, 字符串
     :param quantity: 数量, 字符串
     """
     click(self.__buy_sell_hwnds[11][0])
     time.sleep(0.2)
     setEditText(self.__buy_sell_hwnds[11][0], code)
     time.sleep(0.2)
     if quantity != '0':
         setEditText(self.__buy_sell_hwnds[16][0], quantity)
         time.sleep(0.2)
     click(self.__buy_sell_hwnds[17][0])
     time.sleep(1)
Example #9
0
 def getMoney(self):
     """获取可用资金
     """
     code = '999999'
     setEditText(self.__buy_sell_hwnds[24][0], code)  # 测试时获得资金情况
     time.sleep(0.2)
     if self.debug: print('money_hwnd=', self.__buy_sell_hwnds[12][0])
     money = getWindowText(self.__buy_sell_hwnds[12][0]).strip()
     #setEditText(self.__buy_sell_hwnds[24][0], '')  # 测试时获得资金情况
     time.sleep(0.2)
     #print('money_str=',money)
     try:
         money = float(money)
     except:
         money = 0.0
         sm.send_mail(sub='获取可用资金失败', content='检查验证是否软件异常')
     if self.debug: print('可用资金=', money)
     return money
Example #10
0
 def getMoney(self):
     """获取可用资金
     """
     code = '999999'
     setEditText(self.__buy_sell_hwnds[24][0], code)  # 测试时获得资金情况
     time.sleep(0.2)
     if self.debug: print('money_hwnd=',self.__buy_sell_hwnds[12][0])
     money = getWindowText(self.__buy_sell_hwnds[12][0]).strip()
     #setEditText(self.__buy_sell_hwnds[24][0], '')  # 测试时获得资金情况
     time.sleep(0.2)
     #print('money_str=',money)
     try:
         money=float(money)
     except:
         money=0.0
         sm.send_mail(sub='获取可用资金失败',content='检查验证是否软件异常' )
     if self.debug: print('可用资金=',money)
     return money
Example #11
0
 def getRealtimeQuotation(self, code='300431'):
     """获取可用资金
     """
     #code = '999999'
     setEditText(self.__buy_sell_hwnds[24][0], code)  # 测试时获得资金情况
     time.sleep(0.2)
     if self.debug: print('money_hwnd=', self.__buy_sell_hwnds[12][0])
     #money = getWindowText(self.__buy_sell_hwnds[12][0]).strip()
     #setEditText(self.__buy_sell_hwnds[24][0], '')  # 测试时获得资金情况
     buy1 = getWindowText(self.__buy_sell_hwnds[25][0]).strip()
     sell1 = getWindowText(self.__buy_sell_hwnds[1][0]).strip()
     print('buy1=', buy1)
     print('sell1=', sell1)
     time.sleep(0.2)
     #print('money_str=',money)
     try:
         money = float(money)
     except:
         money = 0.0
         sm.send_mail(sub='获取可用资金失败', content='检查验证是否软件异常')
     if self.debug: print('可用资金=', money)
     return money
Example #12
0
 def getRealtimeQuotation(self,code='300431'):
     """获取可用资金
     """
     #code = '999999'
     setEditText(self.__buy_sell_hwnds[24][0], code)  # 测试时获得资金情况
     time.sleep(0.2)
     if self.debug: print('money_hwnd=',self.__buy_sell_hwnds[12][0])
     #money = getWindowText(self.__buy_sell_hwnds[12][0]).strip()
     #setEditText(self.__buy_sell_hwnds[24][0], '')  # 测试时获得资金情况
     buy1 = getWindowText(self.__buy_sell_hwnds[25][0]).strip()
     sell1 = getWindowText(self.__buy_sell_hwnds[1][0]).strip()
     print('buy1=',buy1)
     print('sell1=',sell1)
     time.sleep(0.2)
     #print('money_str=',money)
     try:
         money=float(money)
     except:
         money=0.0
         sm.send_mail(sub='获取可用资金失败',content='检查验证是否软件异常' )
     if self.debug: print('可用资金=',money)
     return money
Example #13
0
 def __sell(self, code, quantity, actual_price, limit=None):
     """
     卖出函数
     :param code: 股票代码, 字符串
     :param quantity: 数量, 字符串
     """
     quantity = self._get_valid_sell_quantity(code, quantity)
     if quantity:
         setEditText(self.__buy_sell_hwnds[24][0], code)
         time.sleep(0.2)
         setEditText(self.__buy_sell_hwnds[27][0], str(quantity))
         time.sleep(0.2)
         if limit:
             lowest = limit[1]
             setEditText(self.__buy_sell_hwnds[25][0], str(lowest))
             time.sleep(0.2)
         else:
             setEditText(self.__buy_sell_hwnds[25][0], str(actual_price))
             time.sleep(0.2)
         click(self.__buy_sell_hwnds[29][0])
         if self.debug: print('sell_quantity=', quantity)
         if self.debug: print(datetime.datetime.now())
         time.sleep(0.2)
Example #14
0
 def __sell(self, code, quantity,actual_price,limit=None):
     """
     卖出函数
     :param code: 股票代码, 字符串
     :param quantity: 数量, 字符串
     """
     quantity=self._get_valid_sell_quantity(code, quantity)
     if quantity:
         setEditText(self.__buy_sell_hwnds[24][0], code)
         time.sleep(0.2)
         setEditText(self.__buy_sell_hwnds[27][0], str(quantity))
         time.sleep(0.2)
         if limit:
             lowest=limit[1]
             setEditText(self.__buy_sell_hwnds[25][0], str(lowest))
             time.sleep(0.2)
         else:
             setEditText(self.__buy_sell_hwnds[25][0], str(actual_price))
             time.sleep(0.2)
         click(self.__buy_sell_hwnds[29][0])
         if self.debug: print('sell_quantity=',quantity)
         if self.debug: print(datetime.datetime.now())
         time.sleep(0.2)